deps: backport 819b40a from V8 upstream
authorMichaël Zasso <mic.besace@gmail.com>
Fri, 20 Nov 2015 11:08:27 +0000 (12:08 +0100)
committerJames M Snell <jasnell@gmail.com>
Wed, 23 Dec 2015 16:38:33 +0000 (08:38 -0800)
Original commit message:

    Use baseline code to compute message locations.

    This switches Isolate::ComputeLocation to use baseline code when
    computing message locations. This unifies locations between optimized
    and non-optimized code by always going through the FrameSummary for
    location computation.

    R=bmeurer@chromium.org
    TEST=message/regress/regress-4266
    BUG=v8:4266
    LOG=n

    Review URL: https://codereview.chromium.org/1331603002

    Cr-Commit-Position: refs/heads/master@{#30635}

Fixes: https://github.com/nodejs/node/issues/3934
PR-URL: https://github.com/nodejs/node/pull/3938
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
17 files changed:
deps/v8/src/arm/full-codegen-arm.cc
deps/v8/src/arm64/full-codegen-arm64.cc
deps/v8/src/ast-numbering.cc
deps/v8/src/compiler/ast-graph-builder.cc
deps/v8/src/compiler/linkage.cc
deps/v8/src/ia32/full-codegen-ia32.cc
deps/v8/src/isolate.cc
deps/v8/src/mips/full-codegen-mips.cc
deps/v8/src/mips64/full-codegen-mips64.cc
deps/v8/src/ppc/full-codegen-ppc.cc
deps/v8/src/scopes.cc
deps/v8/src/scopes.h
deps/v8/src/x64/full-codegen-x64.cc
deps/v8/src/x87/full-codegen-x87.cc
deps/v8/test/message/regress/regress-4266.js [new file with mode: 0644]
deps/v8/test/message/regress/regress-4266.out [new file with mode: 0644]
deps/v8/test/mjsunit/regress/regress-4266.js [new file with mode: 0644]

index e4b7cf34ee461dcfd8574f4e5c0e3d2a467867d8..f22bd20ebf85f26946c0527a744db2e5d470d022 100644 (file)
@@ -340,7 +340,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index 324bfb8160158e3de1875abbd8da9ffb6d89c41c..d4984701c93322932bf778c3684f97955981252f 100644 (file)
@@ -345,7 +345,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index 151cc8abc10b232b3047600dcff0f08f8bfb1320..93bdb690856f57eefec6660d10910e1b45e72883 100644 (file)
@@ -530,7 +530,7 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
   Scope* scope = node->scope();
 
   if (scope->HasIllegalRedeclaration()) {
-    scope->VisitIllegalRedeclaration(this);
+    Visit(scope->GetIllegalRedeclaration());
     DisableOptimization(kFunctionWithIllegalRedeclaration);
     return Finish(node);
   }
index 341aedc09910e393ea375c32184e62d981dee77a..4ee0f5dcc50eae74e1c706b6246ad6169cefbe91 100644 (file)
@@ -579,8 +579,7 @@ void AstGraphBuilder::CreateGraphBody(bool stack_check) {
 
   // Visit illegal re-declaration and bail out if it exists.
   if (scope->HasIllegalRedeclaration()) {
-    AstEffectContext for_effect(this);
-    scope->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope->GetIllegalRedeclaration());
     return;
   }
 
index 6ef014246d95f74dba60a5d0bb079b6a9defdfd8..c7835dd73e5707d6eadc92eb76897c68d1bb806d 100644 (file)
@@ -194,6 +194,7 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
     case Runtime::kInlineGetCallerJSFunction:
     case Runtime::kInlineGetPrototype:
     case Runtime::kInlineRegExpExec:
+    case Runtime::kInlineSubString:
       return 1;
     case Runtime::kInlineDeoptimizeNow:
     case Runtime::kInlineThrowNotDateError:
index 535f2c2c63e7b68d50307d7465f4bda6cae68708..b074a96f8c0b9c51aa62d879983d24129b6c79bf 100644 (file)
@@ -342,7 +342,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index 2c83faac4fba24b6974e580b6aa8a3f58e82e2ce..186a4935823ae6188668dcb58eccb619c887d451 100644 (file)
@@ -1279,9 +1279,14 @@ void Isolate::ComputeLocation(MessageLocation* target) {
     Object* script = fun->shared()->script();
     if (script->IsScript() &&
         !(Script::cast(script)->source()->IsUndefined())) {
-      int pos = frame->LookupCode()->SourcePosition(frame->pc());
-      // Compute the location from the function and the reloc info.
       Handle<Script> casted_script(Script::cast(script));
+      // Compute the location from the function and the relocation info of the
+      // baseline code. For optimized code this will use the deoptimization
+      // information to get canonical location information.
+      List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+      it.frame()->Summarize(&frames);
+      FrameSummary& summary = frames.last();
+      int pos = summary.code()->SourcePosition(summary.pc());
       *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
     }
   }
index 841ee4b99586bfae8736407212c72db69e2e0622..0aecb59ee125c4602b999b34f63f3edb77eb1813 100644 (file)
@@ -358,7 +358,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index 569dc51afc66fd6305cb28db59a9299700238c60..a6ee6b93460bf6faadb644d7d54e750ea6e730c3 100644 (file)
@@ -353,7 +353,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index ec94a242b4a1473d8661918c071eda09c877dbcc..5383cb36866be61414b6b9a8e0ffa8860246d8ae 100644 (file)
@@ -351,7 +351,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index f9eef9ab21d990c191df5aee894803c8682700e1..fa5338d2c10f882f2d4944ba6b5104e994d173c6 100644 (file)
@@ -565,9 +565,9 @@ void Scope::SetIllegalRedeclaration(Expression* expression) {
 }
 
 
-void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
+Expression* Scope::GetIllegalRedeclaration() {
   DCHECK(HasIllegalRedeclaration());
-  illegal_redecl_->Accept(visitor);
+  return illegal_redecl_;
 }
 
 
index 40863800e492da1c8983ed4015e0cc3b2339b0a1..0ca330d33022fdbbced57dcb471caa1459f3574e 100644 (file)
@@ -191,9 +191,9 @@ class Scope: public ZoneObject {
   // the additional requests will be silently ignored.
   void SetIllegalRedeclaration(Expression* expression);
 
-  // Visit the illegal redeclaration expression. Do not call if the
+  // Retrieve the illegal redeclaration expression. Do not call if the
   // scope doesn't have an illegal redeclaration node.
-  void VisitIllegalRedeclaration(AstVisitor* visitor);
+  Expression* GetIllegalRedeclaration();
 
   // Check if the scope has (at least) one illegal redeclaration.
   bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }
index ef8c15087fe292930e5322509eccd9be17b7b4cd..7198f38666509187e5717bb013a215e7d0012d05 100644 (file)
@@ -340,7 +340,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
index 7b1a35dcd72d1dae92c8d8f5827dcebcd9957c52..0eb3a82df8707ab5ccbd852fe332d5b1acec9e00 100644 (file)
@@ -339,7 +339,7 @@ void FullCodeGenerator::Generate() {
   // redeclaration.
   if (scope()->HasIllegalRedeclaration()) {
     Comment cmnt(masm_, "[ Declarations");
-    scope()->VisitIllegalRedeclaration(this);
+    VisitForEffect(scope()->GetIllegalRedeclaration());
 
   } else {
     PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
diff --git a/deps/v8/test/message/regress/regress-4266.js b/deps/v8/test/message/regress/regress-4266.js
new file mode 100644 (file)
index 0000000..552176b
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+  try {
+    [].foo();
+  } catch (e) {
+    throw e;
+  }
+})();
diff --git a/deps/v8/test/message/regress/regress-4266.out b/deps/v8/test/message/regress/regress-4266.out
new file mode 100644 (file)
index 0000000..d31541d
--- /dev/null
@@ -0,0 +1,10 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+*%(basename)s:9: TypeError: [].foo is not a function
+    throw e;
+    ^
+TypeError: [].foo is not a function
+    at *%(basename)s:7:8
+    at *%(basename)s:11:3
diff --git a/deps/v8/test/mjsunit/regress/regress-4266.js b/deps/v8/test/mjsunit/regress/regress-4266.js
new file mode 100644 (file)
index 0000000..f886250
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --turbo-filter=test --allow-natives-syntax
+
+function test() {
+  try {
+    [].foo();
+  } catch (e) {
+    return e.message;
+  }
+}
+
+assertEquals("[].foo is not a function", test());
+%OptimizeFunctionOnNextCall(test);
+assertEquals("[].foo is not a function", test());