Skip to content

Commit 5f431b7

Browse files
targosrvagg
authored andcommitted
deps: backport 819b40a from V8 upstream
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. [email protected] 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: #3938 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent ec5c8d7 commit 5f431b7

17 files changed

+60
-17
lines changed

deps/v8/src/arm/full-codegen-arm.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void FullCodeGenerator::Generate() {
340340
// redeclaration.
341341
if (scope()->HasIllegalRedeclaration()) {
342342
Comment cmnt(masm_, "[ Declarations");
343-
scope()->VisitIllegalRedeclaration(this);
343+
VisitForEffect(scope()->GetIllegalRedeclaration());
344344

345345
} else {
346346
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/arm64/full-codegen-arm64.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ void FullCodeGenerator::Generate() {
345345
// redeclaration.
346346
if (scope()->HasIllegalRedeclaration()) {
347347
Comment cmnt(masm_, "[ Declarations");
348-
scope()->VisitIllegalRedeclaration(this);
348+
VisitForEffect(scope()->GetIllegalRedeclaration());
349349

350350
} else {
351351
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/ast-numbering.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
530530
Scope* scope = node->scope();
531531

532532
if (scope->HasIllegalRedeclaration()) {
533-
scope->VisitIllegalRedeclaration(this);
533+
Visit(scope->GetIllegalRedeclaration());
534534
DisableOptimization(kFunctionWithIllegalRedeclaration);
535535
return Finish(node);
536536
}

deps/v8/src/compiler/ast-graph-builder.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ void AstGraphBuilder::CreateGraphBody(bool stack_check) {
579579

580580
// Visit illegal re-declaration and bail out if it exists.
581581
if (scope->HasIllegalRedeclaration()) {
582-
AstEffectContext for_effect(this);
583-
scope->VisitIllegalRedeclaration(this);
582+
VisitForEffect(scope->GetIllegalRedeclaration());
584583
return;
585584
}
586585

deps/v8/src/compiler/linkage.cc

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
194194
case Runtime::kInlineGetCallerJSFunction:
195195
case Runtime::kInlineGetPrototype:
196196
case Runtime::kInlineRegExpExec:
197+
case Runtime::kInlineSubString:
197198
return 1;
198199
case Runtime::kInlineDeoptimizeNow:
199200
case Runtime::kInlineThrowNotDateError:

deps/v8/src/ia32/full-codegen-ia32.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void FullCodeGenerator::Generate() {
342342
// redeclaration.
343343
if (scope()->HasIllegalRedeclaration()) {
344344
Comment cmnt(masm_, "[ Declarations");
345-
scope()->VisitIllegalRedeclaration(this);
345+
VisitForEffect(scope()->GetIllegalRedeclaration());
346346

347347
} else {
348348
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/isolate.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -1279,9 +1279,14 @@ void Isolate::ComputeLocation(MessageLocation* target) {
12791279
Object* script = fun->shared()->script();
12801280
if (script->IsScript() &&
12811281
!(Script::cast(script)->source()->IsUndefined())) {
1282-
int pos = frame->LookupCode()->SourcePosition(frame->pc());
1283-
// Compute the location from the function and the reloc info.
12841282
Handle<Script> casted_script(Script::cast(script));
1283+
// Compute the location from the function and the relocation info of the
1284+
// baseline code. For optimized code this will use the deoptimization
1285+
// information to get canonical location information.
1286+
List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
1287+
it.frame()->Summarize(&frames);
1288+
FrameSummary& summary = frames.last();
1289+
int pos = summary.code()->SourcePosition(summary.pc());
12851290
*target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
12861291
}
12871292
}

deps/v8/src/mips/full-codegen-mips.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void FullCodeGenerator::Generate() {
358358
// redeclaration.
359359
if (scope()->HasIllegalRedeclaration()) {
360360
Comment cmnt(masm_, "[ Declarations");
361-
scope()->VisitIllegalRedeclaration(this);
361+
VisitForEffect(scope()->GetIllegalRedeclaration());
362362

363363
} else {
364364
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/mips64/full-codegen-mips64.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void FullCodeGenerator::Generate() {
353353
// redeclaration.
354354
if (scope()->HasIllegalRedeclaration()) {
355355
Comment cmnt(masm_, "[ Declarations");
356-
scope()->VisitIllegalRedeclaration(this);
356+
VisitForEffect(scope()->GetIllegalRedeclaration());
357357

358358
} else {
359359
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/ppc/full-codegen-ppc.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void FullCodeGenerator::Generate() {
351351
// redeclaration.
352352
if (scope()->HasIllegalRedeclaration()) {
353353
Comment cmnt(masm_, "[ Declarations");
354-
scope()->VisitIllegalRedeclaration(this);
354+
VisitForEffect(scope()->GetIllegalRedeclaration());
355355

356356
} else {
357357
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/scopes.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,9 @@ void Scope::SetIllegalRedeclaration(Expression* expression) {
565565
}
566566

567567

568-
void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
568+
Expression* Scope::GetIllegalRedeclaration() {
569569
DCHECK(HasIllegalRedeclaration());
570-
illegal_redecl_->Accept(visitor);
570+
return illegal_redecl_;
571571
}
572572

573573

deps/v8/src/scopes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ class Scope: public ZoneObject {
191191
// the additional requests will be silently ignored.
192192
void SetIllegalRedeclaration(Expression* expression);
193193

194-
// Visit the illegal redeclaration expression. Do not call if the
194+
// Retrieve the illegal redeclaration expression. Do not call if the
195195
// scope doesn't have an illegal redeclaration node.
196-
void VisitIllegalRedeclaration(AstVisitor* visitor);
196+
Expression* GetIllegalRedeclaration();
197197

198198
// Check if the scope has (at least) one illegal redeclaration.
199199
bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }

deps/v8/src/x64/full-codegen-x64.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void FullCodeGenerator::Generate() {
340340
// redeclaration.
341341
if (scope()->HasIllegalRedeclaration()) {
342342
Comment cmnt(masm_, "[ Declarations");
343-
scope()->VisitIllegalRedeclaration(this);
343+
VisitForEffect(scope()->GetIllegalRedeclaration());
344344

345345
} else {
346346
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/x87/full-codegen-x87.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void FullCodeGenerator::Generate() {
339339
// redeclaration.
340340
if (scope()->HasIllegalRedeclaration()) {
341341
Comment cmnt(masm_, "[ Declarations");
342-
scope()->VisitIllegalRedeclaration(this);
342+
VisitForEffect(scope()->GetIllegalRedeclaration());
343343

344344
} else {
345345
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2015 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
(function() {
6+
try {
7+
[].foo();
8+
} catch (e) {
9+
throw e;
10+
}
11+
})();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2015 the V8 project authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
*%(basename)s:9: TypeError: [].foo is not a function
6+
throw e;
7+
^
8+
TypeError: [].foo is not a function
9+
at *%(basename)s:7:8
10+
at *%(basename)s:11:3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2015 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --turbo-filter=test --allow-natives-syntax
6+
7+
function test() {
8+
try {
9+
[].foo();
10+
} catch (e) {
11+
return e.message;
12+
}
13+
}
14+
15+
assertEquals("[].foo is not a function", test());
16+
%OptimizeFunctionOnNextCall(test);
17+
assertEquals("[].foo is not a function", test());

0 commit comments

Comments
 (0)