Skip to content

Commit

Permalink
deps: backport 819b40a from V8 upstream
Browse files Browse the repository at this point in the history
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: #3934
PR-URL: #3937
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
targos committed Nov 25, 2015
1 parent b061e3a commit ab25589
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 18 deletions.
2 changes: 1 addition & 1 deletion deps/v8/src/ast-numbering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
Scope* scope = node->scope();

if (scope->HasIllegalRedeclaration()) {
scope->VisitIllegalRedeclaration(this);
Visit(scope->GetIllegalRedeclaration());
DisableOptimization(kFunctionWithIllegalRedeclaration);
return Finish(node);
}
Expand Down
3 changes: 1 addition & 2 deletions deps/v8/src/compiler/ast-graph-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,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;
}

Expand Down
3 changes: 2 additions & 1 deletion deps/v8/src/compiler/linkage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
switch (function) {
case Runtime::kAllocateInTargetSpace:
case Runtime::kDateField:
case Runtime::kFinalizeClassDefinition: // TODO(conradw): Is it safe?
case Runtime::kDefineClassMethod: // TODO(jarin): Is it safe?
case Runtime::kDefineGetterPropertyUnchecked: // TODO(jarin): Is it safe?
case Runtime::kDefineSetterPropertyUnchecked: // TODO(jarin): Is it safe?
case Runtime::kFinalizeClassDefinition: // TODO(conradw): Is it safe?
case Runtime::kForInDone:
case Runtime::kForInStep:
case Runtime::kGetOriginalConstructor:
Expand All @@ -244,6 +244,7 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
case Runtime::kInlineGetCallerJSFunction:
case Runtime::kInlineGetPrototype:
case Runtime::kInlineRegExpExec:
case Runtime::kInlineSubString:
case Runtime::kInlineToObject:
return 1;
case Runtime::kInlineDeoptimizeNow:
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/arm/full-codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/arm64/full-codegen-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/ia32/full-codegen-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/mips/full-codegen-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/mips64/full-codegen-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/ppc/full-codegen-ppc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/x64/full-codegen-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen/x87/full-codegen-x87.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void FullCodeGenerator::Generate() {
// redeclaration.
if (scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ Declarations");
scope()->VisitIllegalRedeclaration(this);
VisitForEffect(scope()->GetIllegalRedeclaration());

} else {
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Expand Down
9 changes: 7 additions & 2 deletions deps/v8/src/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/scopes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,9 @@ void Scope::SetIllegalRedeclaration(Expression* expression) {
}


void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
Expression* Scope::GetIllegalRedeclaration() {
DCHECK(HasIllegalRedeclaration());
illegal_redecl_->Accept(visitor);
return illegal_redecl_;
}


Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/scopes.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,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; }
Expand Down
11 changes: 11 additions & 0 deletions deps/v8/test/message/regress/regress-4266.js
Original file line number Diff line number Diff line change
@@ -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;
}
})();
10 changes: 10 additions & 0 deletions deps/v8/test/message/regress/regress-4266.out
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions deps/v8/test/mjsunit/regress/regress-4266.js
Original file line number Diff line number Diff line change
@@ -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());

0 comments on commit ab25589

Please sign in to comment.