Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1015683002: [turbofan] Fix C++ evaluation order in AstGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-467531.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 // The result value semantics depend on how the block was entered: 1300 // The result value semantics depend on how the block was entered:
1301 // - ReturnStatement: It represents the return value being returned. 1301 // - ReturnStatement: It represents the return value being returned.
1302 // - ThrowStatement: It represents the exception being thrown. 1302 // - ThrowStatement: It represents the exception being thrown.
1303 // - BreakStatement/ContinueStatement: Filled with the hole. 1303 // - BreakStatement/ContinueStatement: Filled with the hole.
1304 // - Falling through into finally-block: Filled with the hole. 1304 // - Falling through into finally-block: Filled with the hole.
1305 Node* result = try_control.GetResultValueNode(); 1305 Node* result = try_control.GetResultValueNode();
1306 Node* token = try_control.GetDispatchTokenNode(); 1306 Node* token = try_control.GetDispatchTokenNode();
1307 1307
1308 // The result value, dispatch token and message is expected on the operand 1308 // The result value, dispatch token and message is expected on the operand
1309 // stack (this is in sync with FullCodeGenerator::EnterFinallyBlock). 1309 // stack (this is in sync with FullCodeGenerator::EnterFinallyBlock).
1310 Node* message = BuildLoadExternal(message_object, kMachAnyTagged);
1310 environment()->Push(token); // TODO(mstarzinger): Cook token! 1311 environment()->Push(token); // TODO(mstarzinger): Cook token!
1311 environment()->Push(result); 1312 environment()->Push(result);
1312 environment()->Push(BuildLoadExternal(message_object, kMachAnyTagged)); 1313 environment()->Push(message);
1313 1314
1314 // Evaluate the finally-block. 1315 // Evaluate the finally-block.
1315 Visit(stmt->finally_block()); 1316 Visit(stmt->finally_block());
1316 try_control.EndFinally(); 1317 try_control.EndFinally();
1317 1318
1318 // The result value, dispatch token and message is restored from the operand 1319 // The result value, dispatch token and message is restored from the operand
1319 // stack (this is in sync with FullCodeGenerator::ExitFinallyBlock). 1320 // stack (this is in sync with FullCodeGenerator::ExitFinallyBlock).
1320 BuildStoreExternal(message_object, kMachAnyTagged, environment()->Pop()); 1321 message = environment()->Pop();
1321 result = environment()->Pop(); 1322 result = environment()->Pop();
1322 token = environment()->Pop(); // TODO(mstarzinger): Uncook token! 1323 token = environment()->Pop(); // TODO(mstarzinger): Uncook token!
1324 BuildStoreExternal(message_object, kMachAnyTagged, message);
1323 1325
1324 // Dynamic dispatch after the finally-block. 1326 // Dynamic dispatch after the finally-block.
1325 commands->ApplyDeferredCommands(token, result); 1327 commands->ApplyDeferredCommands(token, result);
1326 1328
1327 // TODO(mstarzinger): Remove bailout once everything works. 1329 // TODO(mstarzinger): Remove bailout once everything works.
1328 if (!FLAG_turbo_exceptions) SetStackOverflow(); 1330 if (!FLAG_turbo_exceptions) SetStackOverflow();
1329 } 1331 }
1330 1332
1331 1333
1332 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { 1334 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 // its right. All the code from above initializes the static component of the 1645 // its right. All the code from above initializes the static component of the
1644 // object literal, and arranges for the map of the result to reflect the 1646 // object literal, and arranges for the map of the result to reflect the
1645 // static order in which the keys appear. For the dynamic properties, we 1647 // static order in which the keys appear. For the dynamic properties, we
1646 // compile them into a series of "SetOwnProperty" runtime calls. This will 1648 // compile them into a series of "SetOwnProperty" runtime calls. This will
1647 // preserve insertion order. 1649 // preserve insertion order.
1648 for (; property_index < expr->properties()->length(); property_index++) { 1650 for (; property_index < expr->properties()->length(); property_index++) {
1649 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1651 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1650 1652
1651 environment()->Push(literal); // Duplicate receiver. 1653 environment()->Push(literal); // Duplicate receiver.
1652 VisitForValue(property->key()); 1654 VisitForValue(property->key());
1653 environment()->Push(BuildToName(environment()->Pop(), 1655 Node* name = BuildToName(environment()->Pop(),
1654 expr->GetIdForProperty(property_index))); 1656 expr->GetIdForProperty(property_index));
1657 environment()->Push(name);
1655 // TODO(mstarzinger): For ObjectLiteral::Property::PROTOTYPE the key should 1658 // TODO(mstarzinger): For ObjectLiteral::Property::PROTOTYPE the key should
1656 // not be on the operand stack while the value is being evaluated. Come up 1659 // not be on the operand stack while the value is being evaluated. Come up
1657 // with a repro for this and fix it. Also find a nice way to do so. :) 1660 // with a repro for this and fix it. Also find a nice way to do so. :)
1658 VisitForValue(property->value()); 1661 VisitForValue(property->value());
1659 Node* value = environment()->Pop(); 1662 Node* value = environment()->Pop();
1660 Node* key = environment()->Pop(); 1663 Node* key = environment()->Pop();
1661 Node* receiver = environment()->Pop(); 1664 Node* receiver = environment()->Pop();
1662 BuildSetHomeObject(value, receiver, property->value()); 1665 BuildSetHomeObject(value, receiver, property->value());
1663 1666
1664 switch (property->kind()) { 1667 switch (property->kind()) {
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() && 2471 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() &&
2469 !info()->scope()->calls_sloppy_eval()) { 2472 !info()->scope()->calls_sloppy_eval()) {
2470 return receiver; 2473 return receiver;
2471 } 2474 }
2472 2475
2473 IfBuilder receiver_check(this); 2476 IfBuilder receiver_check(this);
2474 Node* undefined = jsgraph()->UndefinedConstant(); 2477 Node* undefined = jsgraph()->UndefinedConstant();
2475 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined); 2478 Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined);
2476 receiver_check.If(check); 2479 receiver_check.If(check);
2477 receiver_check.Then(); 2480 receiver_check.Then();
2478 environment()->Push(BuildLoadGlobalProxy()); 2481 Node* proxy = BuildLoadGlobalProxy();
2482 environment()->Push(proxy);
2479 receiver_check.Else(); 2483 receiver_check.Else();
2480 environment()->Push(receiver); 2484 environment()->Push(receiver);
2481 receiver_check.End(); 2485 receiver_check.End();
2482 return environment()->Pop(); 2486 return environment()->Pop();
2483 } 2487 }
2484 2488
2485 2489
2486 Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) { 2490 Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) {
2487 // Allocate a new local context. 2491 // Allocate a new local context.
2488 const Operator* op = javascript()->CreateFunctionContext(); 2492 const Operator* op = javascript()->CreateFunctionContext();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 2571
2568 2572
2569 Node* AstGraphBuilder::BuildHoleCheckThrow(Node* value, Variable* variable, 2573 Node* AstGraphBuilder::BuildHoleCheckThrow(Node* value, Variable* variable,
2570 Node* not_hole, 2574 Node* not_hole,
2571 BailoutId bailout_id) { 2575 BailoutId bailout_id) {
2572 IfBuilder hole_check(this); 2576 IfBuilder hole_check(this);
2573 Node* the_hole = jsgraph()->TheHoleConstant(); 2577 Node* the_hole = jsgraph()->TheHoleConstant();
2574 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); 2578 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
2575 hole_check.If(check); 2579 hole_check.If(check);
2576 hole_check.Then(); 2580 hole_check.Then();
2577 environment()->Push(BuildThrowReferenceError(variable, bailout_id)); 2581 Node* error = BuildThrowReferenceError(variable, bailout_id);
2582 environment()->Push(error);
2578 hole_check.Else(); 2583 hole_check.Else();
2579 environment()->Push(not_hole); 2584 environment()->Push(not_hole);
2580 hole_check.End(); 2585 hole_check.End();
2581 return environment()->Pop(); 2586 return environment()->Pop();
2582 } 2587 }
2583 2588
2584 2589
2585 Node* AstGraphBuilder::BuildThrowIfStaticPrototype(Node* name, 2590 Node* AstGraphBuilder::BuildThrowIfStaticPrototype(Node* name,
2586 BailoutId bailout_id) { 2591 BailoutId bailout_id) {
2587 IfBuilder prototype_check(this); 2592 IfBuilder prototype_check(this);
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 // Phi does not exist yet, introduce one. 3353 // Phi does not exist yet, introduce one.
3349 value = NewPhi(inputs, value, control); 3354 value = NewPhi(inputs, value, control);
3350 value->ReplaceInput(inputs - 1, other); 3355 value->ReplaceInput(inputs - 1, other);
3351 } 3356 }
3352 return value; 3357 return value;
3353 } 3358 }
3354 3359
3355 } // namespace compiler 3360 } // namespace compiler
3356 } // namespace internal 3361 } // namespace internal
3357 } // namespace v8 3362 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-467531.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698