Skip to content

Commit 99fd1ec

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: #3937 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 19ed33d commit 99fd1ec

17 files changed

+61
-18
lines changed

deps/v8/src/ast-numbering.cc

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

555555
if (scope->HasIllegalRedeclaration()) {
556-
scope->VisitIllegalRedeclaration(this);
556+
Visit(scope->GetIllegalRedeclaration());
557557
DisableOptimization(kFunctionWithIllegalRedeclaration);
558558
return Finish(node);
559559
}

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

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

587587
// Visit illegal re-declaration and bail out if it exists.
588588
if (scope->HasIllegalRedeclaration()) {
589-
AstEffectContext for_effect(this);
590-
scope->VisitIllegalRedeclaration(this);
589+
VisitForEffect(scope->GetIllegalRedeclaration());
591590
return;
592591
}
593592

deps/v8/src/compiler/linkage.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
218218
switch (function) {
219219
case Runtime::kAllocateInTargetSpace:
220220
case Runtime::kDateField:
221-
case Runtime::kFinalizeClassDefinition: // TODO(conradw): Is it safe?
222221
case Runtime::kDefineClassMethod: // TODO(jarin): Is it safe?
223222
case Runtime::kDefineGetterPropertyUnchecked: // TODO(jarin): Is it safe?
224223
case Runtime::kDefineSetterPropertyUnchecked: // TODO(jarin): Is it safe?
224+
case Runtime::kFinalizeClassDefinition: // TODO(conradw): Is it safe?
225225
case Runtime::kForInDone:
226226
case Runtime::kForInStep:
227227
case Runtime::kGetOriginalConstructor:
@@ -244,6 +244,7 @@ int Linkage::FrameStateInputCount(Runtime::FunctionId function) {
244244
case Runtime::kInlineGetCallerJSFunction:
245245
case Runtime::kInlineGetPrototype:
246246
case Runtime::kInlineRegExpExec:
247+
case Runtime::kInlineSubString:
247248
case Runtime::kInlineToObject:
248249
return 1;
249250
case Runtime::kInlineDeoptimizeNow:

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

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

343343
} else {
344344
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

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

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

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

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

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

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

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

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

361361
} else {
362362
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

deps/v8/src/full-codegen/mips64/full-codegen-mips64.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/full-codegen/ppc/full-codegen-ppc.cc

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

354354
} else {
355355
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

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

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

343343
} else {
344344
PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);

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

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

343343
} else {
344344
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/scopes.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ void Scope::SetIllegalRedeclaration(Expression* expression) {
550550
}
551551

552552

553-
void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
553+
Expression* Scope::GetIllegalRedeclaration() {
554554
DCHECK(HasIllegalRedeclaration());
555-
illegal_redecl_->Accept(visitor);
555+
return illegal_redecl_;
556556
}
557557

558558

deps/v8/src/scopes.h

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

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

196196
// Check if the scope has (at least) one illegal redeclaration.
197197
bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }
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)