Upgrade V8 to version 4.9.385.28

https://chromium.googlesource.com/v8/v8/+/4.9.385.28

FPIIM-449

Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc
index 7f3dafc..77ba2f2 100644
--- a/test/cctest/test-func-name-inference.cc
+++ b/test/cctest/test-func-name-inference.cc
@@ -29,11 +29,12 @@
 #include "src/v8.h"
 
 #include "src/api.h"
-#include "src/debug.h"
+#include "src/debug/debug.h"
 #include "src/string-search.h"
 #include "test/cctest/cctest.h"
 
 
+using ::v8::base::SmartArrayPointer;
 using ::v8::internal::CStrVector;
 using ::v8::internal::Factory;
 using ::v8::internal::Handle;
@@ -43,13 +44,12 @@
 using ::v8::internal::Object;
 using ::v8::internal::Runtime;
 using ::v8::internal::Script;
-using ::v8::internal::SmartArrayPointer;
 using ::v8::internal::SharedFunctionInfo;
 using ::v8::internal::String;
 using ::v8::internal::Vector;
 
 
-static void CheckFunctionName(v8::Handle<v8::Script> script,
+static void CheckFunctionName(v8::Local<v8::Script> script,
                               const char* func_pos_src,
                               const char* ref_inferred_name) {
   Isolate* isolate = CcTest::i_isolate();
@@ -80,22 +80,25 @@
   CHECK_NE(0, func_pos);
 
   // Obtain SharedFunctionInfo for the function.
-  isolate->debug()->PrepareForBreakPoints();
-  Object* shared_func_info_ptr =
-      isolate->debug()->FindSharedFunctionInfoInScript(i_script, func_pos);
-  CHECK(shared_func_info_ptr != CcTest::heap()->undefined_value());
-  Handle<SharedFunctionInfo> shared_func_info(
-      SharedFunctionInfo::cast(shared_func_info_ptr));
+  Handle<SharedFunctionInfo> shared_func_info =
+      Handle<SharedFunctionInfo>::cast(
+          isolate->debug()->FindSharedFunctionInfoInScript(i_script, func_pos));
 
   // Verify inferred function name.
   SmartArrayPointer<char> inferred_name =
       shared_func_info->inferred_name()->ToCString();
-  CHECK_EQ(ref_inferred_name, inferred_name.get());
+  i::PrintF("expected: %s, found: %s\n", ref_inferred_name,
+            inferred_name.get());
+  CHECK_EQ(0, strcmp(ref_inferred_name, inferred_name.get()));
 }
 
 
-static v8::Handle<v8::Script> Compile(v8::Isolate* isolate, const char* src) {
-  return v8::Script::Compile(v8::String::NewFromUtf8(isolate, src));
+static v8::Local<v8::Script> Compile(v8::Isolate* isolate, const char* src) {
+  return v8::Script::Compile(
+             isolate->GetCurrentContext(),
+             v8::String::NewFromUtf8(isolate, src, v8::NewStringType::kNormal)
+                 .ToLocalChecked())
+      .ToLocalChecked();
 }
 
 
@@ -103,10 +106,9 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "fun1 = function() { return 1; }\n"
-      "fun2 = function() { return 2; }\n");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "fun1 = function() { return 1; }\n"
+                                         "fun2 = function() { return 2; }\n");
   CheckFunctionName(script, "return 1", "fun1");
   CheckFunctionName(script, "return 2", "fun2");
 }
@@ -116,10 +118,10 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "var fun1 = function() { return 1; }\n"
-      "var fun2 = function() { return 2; }\n");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "var fun1 = function() { return 1; }\n"
+              "var fun2 = function() { return 2; }\n");
   CheckFunctionName(script, "return 1", "fun1");
   CheckFunctionName(script, "return 2", "fun2");
 }
@@ -129,12 +131,12 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function outer() {\n"
-      "  var fun1 = function() { return 1; }\n"
-      "  var fun2 = function() { return 2; }\n"
-      "}");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function outer() {\n"
+              "  var fun1 = function() { return 1; }\n"
+              "  var fun2 = function() { return 2; }\n"
+              "}");
   CheckFunctionName(script, "return 1", "fun1");
   CheckFunctionName(script, "return 2", "fun2");
 }
@@ -144,12 +146,12 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function MyClass() {\n"
-      "  this.method1 = function() { return 1; }\n"
-      "  this.method2 = function() { return 2; }\n"
-      "}");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function MyClass() {\n"
+              "  this.method1 = function() { return 1; }\n"
+              "  this.method2 = function() { return 2; }\n"
+              "}");
   CheckFunctionName(script, "return 1", "MyClass.method1");
   CheckFunctionName(script, "return 2", "MyClass.method2");
 }
@@ -159,14 +161,14 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function createMyObj() {\n"
-      "  var obj = {};\n"
-      "  obj.method1 = function() { return 1; }\n"
-      "  obj.method2 = function() { return 2; }\n"
-      "  return obj;\n"
-      "}");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function createMyObj() {\n"
+              "  var obj = {};\n"
+              "  obj.method1 = function() { return 1; }\n"
+              "  obj.method2 = function() { return 2; }\n"
+              "  return obj;\n"
+              "}");
   CheckFunctionName(script, "return 1", "obj.method1");
   CheckFunctionName(script, "return 2", "obj.method2");
 }
@@ -176,14 +178,14 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function MyClass() {}\n"
-      "MyClass.static1 = function() { return 1; }\n"
-      "MyClass.static2 = function() { return 2; }\n"
-      "MyClass.MyInnerClass = {}\n"
-      "MyClass.MyInnerClass.static3 = function() { return 3; }\n"
-      "MyClass.MyInnerClass.static4 = function() { return 4; }");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function MyClass() {}\n"
+              "MyClass.static1 = function() { return 1; }\n"
+              "MyClass.static2 = function() { return 2; }\n"
+              "MyClass.MyInnerClass = {}\n"
+              "MyClass.MyInnerClass.static3 = function() { return 3; }\n"
+              "MyClass.MyInnerClass.static4 = function() { return 4; }");
   CheckFunctionName(script, "return 1", "MyClass.static1");
   CheckFunctionName(script, "return 2", "MyClass.static2");
   CheckFunctionName(script, "return 3", "MyClass.MyInnerClass.static3");
@@ -195,7 +197,7 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
+  v8::Local<v8::Script> script = Compile(
       CcTest::isolate(),
       "function MyClass() {}\n"
       "MyClass.prototype.method1 = function() { return 1; }\n"
@@ -214,22 +216,60 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function MyClass() {}\n"
-      "MyClass.prototype = {\n"
-      "  method1: function() { return 1; },\n"
-      "  method2: function() { return 2; } }");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function MyClass() {}\n"
+              "MyClass.prototype = {\n"
+              "  method1: function() { return 1; },\n"
+              "  method2: function() { return 2; } }");
   CheckFunctionName(script, "return 1", "MyClass.method1");
   CheckFunctionName(script, "return 2", "MyClass.method2");
 }
 
 
+TEST(UpperCaseClass) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "'use strict';\n"
+                                         "class MyClass {\n"
+                                         "  constructor() {\n"
+                                         "    this.value = 1;\n"
+                                         "  }\n"
+                                         "  method() {\n"
+                                         "    this.value = 2;\n"
+                                         "  }\n"
+                                         "}");
+  CheckFunctionName(script, "this.value = 1", "MyClass");
+  CheckFunctionName(script, "this.value = 2", "MyClass.method");
+}
+
+
+TEST(LowerCaseClass) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "'use strict';\n"
+                                         "class myclass {\n"
+                                         "  constructor() {\n"
+                                         "    this.value = 1;\n"
+                                         "  }\n"
+                                         "  method() {\n"
+                                         "    this.value = 2;\n"
+                                         "  }\n"
+                                         "}");
+  CheckFunctionName(script, "this.value = 1", "myclass");
+  CheckFunctionName(script, "this.value = 2", "myclass.method");
+}
+
+
 TEST(AsParameter) {
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
+  v8::Local<v8::Script> script = Compile(
       CcTest::isolate(),
       "function f1(a) { return a(); }\n"
       "function f2(a, b) { return a() + b(); }\n"
@@ -246,11 +286,10 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "fun1 = 0 ?\n"
-      "    function() { return 1; } :\n"
-      "    function() { return 2; }");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "fun1 = 0 ?\n"
+                                         "    function() { return 1; } :\n"
+                                         "    function() { return 2; }");
   CheckFunctionName(script, "return 1", "fun1");
   CheckFunctionName(script, "return 2", "fun1");
 }
@@ -260,12 +299,12 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function MyClass() {}\n"
-      "MyClass.prototype = {\n"
-      "  method1: 0 ? function() { return 1; } :\n"
-      "               function() { return 2; } }");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function MyClass() {}\n"
+              "MyClass.prototype = {\n"
+              "  method1: 0 ? function() { return 1; } :\n"
+              "               function() { return 2; } }");
   CheckFunctionName(script, "return 1", "MyClass.method1");
   CheckFunctionName(script, "return 2", "MyClass.method1");
 }
@@ -275,18 +314,17 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "(function() {\n"
-      "  (function() {\n"
-      "      var a = 1;\n"
-      "      return;\n"
-      "  })();\n"
-      "  var b = function() {\n"
-      "      var c = 1;\n"
-      "      return;\n"
-      "  };\n"
-      "})();");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "(function() {\n"
+                                         "  (function() {\n"
+                                         "      var a = 1;\n"
+                                         "      return;\n"
+                                         "  })();\n"
+                                         "  var b = function() {\n"
+                                         "      var c = 1;\n"
+                                         "      return;\n"
+                                         "  };\n"
+                                         "})();");
   CheckFunctionName(script, "return", "");
 }
 
@@ -295,15 +333,14 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "(function() {\n"
-      "  (function() {\n"
-      "      var a = 1;\n"
-      "      return;\n"
-      "  })();\n"
-      "  var c = 1;\n"
-      "})();");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "(function() {\n"
+                                         "  (function() {\n"
+                                         "      var a = 1;\n"
+                                         "      return;\n"
+                                         "  })();\n"
+                                         "  var c = 1;\n"
+                                         "})();");
   CheckFunctionName(script, "return", "");
 }
 
@@ -312,15 +349,14 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "var foo = function() {\n"
-      "  (function named() {\n"
-      "      var a = 1;\n"
-      "  })();\n"
-      "  var c = 1;\n"
-      "  return;\n"
-      "};");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "var foo = function() {\n"
+                                         "  (function named() {\n"
+                                         "      var a = 1;\n"
+                                         "  })();\n"
+                                         "  var c = 1;\n"
+                                         "  return;\n"
+                                         "};");
   CheckFunctionName(script, "return", "foo");
 }
 
@@ -330,12 +366,12 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function a() {\n"
-      "var result = function(p,a,c,k,e,d)"
-      "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n"
-      "}");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function a() {\n"
+              "var result = function(p,a,c,k,e,d)"
+              "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n"
+              "}");
   CheckFunctionName(script, "return p", "");
 }
 
@@ -344,12 +380,12 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "var fun1 = fun2 = function () { return 1; }\n"
-      "var bar1 = bar2 = bar3 = function () { return 2; }\n"
-      "foo1 = foo2 = function () { return 3; }\n"
-      "baz1 = baz2 = baz3 = function () { return 4; }");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "var fun1 = fun2 = function () { return 1; }\n"
+              "var bar1 = bar2 = bar3 = function () { return 2; }\n"
+              "foo1 = foo2 = function () { return 3; }\n"
+              "baz1 = baz2 = baz3 = function () { return 4; }");
   CheckFunctionName(script, "return 1", "fun2");
   CheckFunctionName(script, "return 2", "bar3");
   CheckFunctionName(script, "return 3", "foo2");
@@ -361,7 +397,7 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
+  v8::Local<v8::Script> script = Compile(
       CcTest::isolate(),
       "function Foo() {}\n"
       "var foo = new Foo(function() { return 1; })\n"
@@ -376,14 +412,14 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function createMyObj() {\n"
-      "  var obj = {};\n"
-      "  obj[\"method1\"] = function() { return 1; }\n"
-      "  obj[\"method2\"] = function() { return 2; }\n"
-      "  return obj;\n"
-      "}");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function createMyObj() {\n"
+              "  var obj = {};\n"
+              "  obj[\"method1\"] = function() { return 1; }\n"
+              "  obj[\"method2\"] = function() { return 2; }\n"
+              "  return obj;\n"
+              "}");
   CheckFunctionName(script, "return 1", "obj.method1");
   CheckFunctionName(script, "return 2", "obj.method2");
 }
@@ -393,16 +429,16 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "function createMyObj() {\n"
-      "  var obj = {};\n"
-      "  var methodName = \"method1\";\n"
-      "  obj[methodName] = function() { return 1; }\n"
-      "  methodName = \"method2\";\n"
-      "  obj[methodName] = function() { return 2; }\n"
-      "  return obj;\n"
-      "}");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "function createMyObj() {\n"
+              "  var obj = {};\n"
+              "  var methodName = \"method1\";\n"
+              "  obj[methodName] = function() { return 1; }\n"
+              "  methodName = \"method2\";\n"
+              "  obj[methodName] = function() { return 2; }\n"
+              "  return obj;\n"
+              "}");
   // Can't infer function names statically.
   CheckFunctionName(script, "return 1", "obj.(anonymous function)");
   CheckFunctionName(script, "return 2", "obj.(anonymous function)");
@@ -413,7 +449,7 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
+  v8::Local<v8::Script> script = Compile(
       CcTest::isolate(),
       "function createMyObj() {\n"
       "  var obj = {};\n"
@@ -429,14 +465,13 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "var Foo = function() {\n"
-      "  return 1;\n"
-      "}();\n"
-      "var Baz = Bar = function() {\n"
-      "  return 2;\n"
-      "}");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "var Foo = function() {\n"
+                                         "  return 1;\n"
+                                         "}();\n"
+                                         "var Baz = Bar = function() {\n"
+                                         "  return 2;\n"
+                                         "}");
   // The inferred name is empty, because this is an assignment of a result.
   CheckFunctionName(script, "return 1", "");
   // See MultipleAssignments test.
@@ -448,17 +483,16 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "(function Enclosing() {\n"
-      "  var Foo;\n"
-      "  Foo = function() {\n"
-      "    return 1;\n"
-      "  }();\n"
-      "  var Baz = Bar = function() {\n"
-      "    return 2;\n"
-      "  }\n"
-      "})();");
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "(function Enclosing() {\n"
+                                         "  var Foo;\n"
+                                         "  Foo = function() {\n"
+                                         "    return 1;\n"
+                                         "  }();\n"
+                                         "  var Baz = Bar = function() {\n"
+                                         "    return 2;\n"
+                                         "  }\n"
+                                         "})();");
   // The inferred name is empty, because this is an assignment of a result.
   CheckFunctionName(script, "return 1", "");
   // See MultipleAssignments test.
@@ -472,15 +506,15 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "(function () {\n"
-      "    var EventSource = function () { };\n"
-      "    EventSource.prototype.addListener = function () {\n"
-      "        return 2012;\n"
-      "    };\n"
-      "    this.PublicEventSource = EventSource;\n"
-      "})();");
+  v8::Local<v8::Script> script =
+      Compile(CcTest::isolate(),
+              "(function () {\n"
+              "    var EventSource = function () { };\n"
+              "    EventSource.prototype.addListener = function () {\n"
+              "        return 2012;\n"
+              "    };\n"
+              "    this.PublicEventSource = EventSource;\n"
+              "})();");
   CheckFunctionName(script, "return 2012", "EventSource.addListener");
 }
 
@@ -489,20 +523,19 @@
   CcTest::InitializeVM();
   v8::HandleScope scope(CcTest::isolate());
 
-  v8::Handle<v8::Script> script = Compile(
-      CcTest::isolate(),
-      "(function() {\n"
-      "  function wrapCode() {\n"
-      "    return function () {\n"
-      "      return 2012;\n"
-      "    };\n"
-      "  };\n"
-      "  var foo = 10;\n"
-      "  function f() {\n"
-      "    return wrapCode();\n"
-      "  }\n"
-      "  this.ref = f;\n"
-      "})()");
-  script->Run();
+  v8::Local<v8::Script> script = Compile(CcTest::isolate(),
+                                         "(function() {\n"
+                                         "  function wrapCode() {\n"
+                                         "    return function () {\n"
+                                         "      return 2012;\n"
+                                         "    };\n"
+                                         "  };\n"
+                                         "  var foo = 10;\n"
+                                         "  function f() {\n"
+                                         "    return wrapCode();\n"
+                                         "  }\n"
+                                         "  this.ref = f;\n"
+                                         "})()");
+  script->Run(CcTest::isolate()->GetCurrentContext()).ToLocalChecked();
   CheckFunctionName(script, "return 2012", "");
 }