| OLD | NEW |
| 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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 compare_switch.EndCase(); | 1328 compare_switch.EndCase(); |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 compare_switch.EndSwitch(); | 1331 compare_switch.EndSwitch(); |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 | 1334 |
| 1335 void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { | 1335 void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 1336 LoopBuilder while_loop(this); | 1336 LoopBuilder while_loop(this); |
| 1337 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1337 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
| 1338 VisitIterationBody(stmt, &while_loop); | 1338 VisitIterationBody(stmt, &while_loop, stmt->StackCheckId()); |
| 1339 while_loop.EndBody(); | 1339 while_loop.EndBody(); |
| 1340 VisitForTest(stmt->cond()); | 1340 VisitForTest(stmt->cond()); |
| 1341 Node* condition = environment()->Pop(); | 1341 Node* condition = environment()->Pop(); |
| 1342 while_loop.BreakUnless(condition); | 1342 while_loop.BreakUnless(condition); |
| 1343 while_loop.EndLoop(); | 1343 while_loop.EndLoop(); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 | 1346 |
| 1347 void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 1347 void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| 1348 LoopBuilder while_loop(this); | 1348 LoopBuilder while_loop(this); |
| 1349 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1349 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
| 1350 VisitForTest(stmt->cond()); | 1350 VisitForTest(stmt->cond()); |
| 1351 Node* condition = environment()->Pop(); | 1351 Node* condition = environment()->Pop(); |
| 1352 while_loop.BreakUnless(condition); | 1352 while_loop.BreakUnless(condition); |
| 1353 VisitIterationBody(stmt, &while_loop); | 1353 VisitIterationBody(stmt, &while_loop, stmt->StackCheckId()); |
| 1354 while_loop.EndBody(); | 1354 while_loop.EndBody(); |
| 1355 while_loop.EndLoop(); | 1355 while_loop.EndLoop(); |
| 1356 } | 1356 } |
| 1357 | 1357 |
| 1358 | 1358 |
| 1359 void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { | 1359 void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { |
| 1360 LoopBuilder for_loop(this); | 1360 LoopBuilder for_loop(this); |
| 1361 VisitIfNotNull(stmt->init()); | 1361 VisitIfNotNull(stmt->init()); |
| 1362 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1362 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
| 1363 if (stmt->cond() != nullptr) { | 1363 if (stmt->cond() != nullptr) { |
| 1364 VisitForTest(stmt->cond()); | 1364 VisitForTest(stmt->cond()); |
| 1365 Node* condition = environment()->Pop(); | 1365 Node* condition = environment()->Pop(); |
| 1366 for_loop.BreakUnless(condition); | 1366 for_loop.BreakUnless(condition); |
| 1367 } else { | 1367 } else { |
| 1368 for_loop.BreakUnless(jsgraph()->TrueConstant()); | 1368 for_loop.BreakUnless(jsgraph()->TrueConstant()); |
| 1369 } | 1369 } |
| 1370 VisitIterationBody(stmt, &for_loop); | 1370 VisitIterationBody(stmt, &for_loop, stmt->StackCheckId()); |
| 1371 for_loop.EndBody(); | 1371 for_loop.EndBody(); |
| 1372 VisitIfNotNull(stmt->next()); | 1372 VisitIfNotNull(stmt->next()); |
| 1373 for_loop.EndLoop(); | 1373 for_loop.EndLoop(); |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 | 1376 |
| 1377 void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { | 1377 void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { |
| 1378 VisitForValue(stmt->subject()); | 1378 VisitForValue(stmt->subject()); |
| 1379 Node* object = environment()->Pop(); | 1379 Node* object = environment()->Pop(); |
| 1380 BlockBuilder for_block(this); | 1380 BlockBuilder for_block(this); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 test_value.Else(); | 1437 test_value.Else(); |
| 1438 { | 1438 { |
| 1439 environment()->Push(value); | 1439 environment()->Push(value); |
| 1440 PrepareEagerCheckpoint(stmt->FilterId()); | 1440 PrepareEagerCheckpoint(stmt->FilterId()); |
| 1441 value = environment()->Pop(); | 1441 value = environment()->Pop(); |
| 1442 // Bind value and do loop body. | 1442 // Bind value and do loop body. |
| 1443 VectorSlotPair feedback = | 1443 VectorSlotPair feedback = |
| 1444 CreateVectorSlotPair(stmt->EachFeedbackSlot()); | 1444 CreateVectorSlotPair(stmt->EachFeedbackSlot()); |
| 1445 VisitForInAssignment(stmt->each(), value, feedback, | 1445 VisitForInAssignment(stmt->each(), value, feedback, |
| 1446 stmt->AssignmentId()); | 1446 stmt->AssignmentId()); |
| 1447 VisitIterationBody(stmt, &for_loop); | 1447 VisitIterationBody(stmt, &for_loop, stmt->StackCheckId()); |
| 1448 } | 1448 } |
| 1449 test_value.End(); | 1449 test_value.End(); |
| 1450 for_loop.EndBody(); | 1450 for_loop.EndBody(); |
| 1451 | 1451 |
| 1452 // Increment counter and continue. | 1452 // Increment counter and continue. |
| 1453 index = environment()->Peek(0); | 1453 index = environment()->Peek(0); |
| 1454 index = NewNode(javascript()->ForInStep(), index); | 1454 index = NewNode(javascript()->ForInStep(), index); |
| 1455 environment()->Poke(0, index); | 1455 environment()->Poke(0, index); |
| 1456 } | 1456 } |
| 1457 for_loop.EndLoop(); | 1457 for_loop.EndLoop(); |
| 1458 environment()->Drop(5); | 1458 environment()->Drop(5); |
| 1459 } | 1459 } |
| 1460 for_block.EndBlock(); | 1460 for_block.EndBlock(); |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 | 1463 |
| 1464 void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { | 1464 void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { |
| 1465 LoopBuilder for_loop(this); | 1465 LoopBuilder for_loop(this); |
| 1466 VisitForEffect(stmt->assign_iterator()); | 1466 VisitForEffect(stmt->assign_iterator()); |
| 1467 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1467 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
| 1468 VisitForEffect(stmt->next_result()); | 1468 VisitForEffect(stmt->next_result()); |
| 1469 VisitForTest(stmt->result_done()); | 1469 VisitForTest(stmt->result_done()); |
| 1470 Node* condition = environment()->Pop(); | 1470 Node* condition = environment()->Pop(); |
| 1471 for_loop.BreakWhen(condition); | 1471 for_loop.BreakWhen(condition); |
| 1472 VisitForEffect(stmt->assign_each()); | 1472 VisitForEffect(stmt->assign_each()); |
| 1473 VisitIterationBody(stmt, &for_loop); | 1473 VisitIterationBody(stmt, &for_loop, stmt->StackCheckId()); |
| 1474 for_loop.EndBody(); | 1474 for_loop.EndBody(); |
| 1475 for_loop.EndLoop(); | 1475 for_loop.EndLoop(); |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 | 1478 |
| 1479 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1479 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 1480 TryCatchBuilder try_control(this); | 1480 TryCatchBuilder try_control(this); |
| 1481 | 1481 |
| 1482 // Evaluate the try-block inside a control scope. This simulates a handler | 1482 // Evaluate the try-block inside a control scope. This simulates a handler |
| 1483 // that is intercepting 'throw' control commands. | 1483 // that is intercepting 'throw' control commands. |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2959 Visit(stmt); | 2959 Visit(stmt); |
| 2960 } | 2960 } |
| 2961 | 2961 |
| 2962 | 2962 |
| 2963 void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) { | 2963 void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) { |
| 2964 ContextScope scope(this, s, context); | 2964 ContextScope scope(this, s, context); |
| 2965 DCHECK(s->declarations()->is_empty()); | 2965 DCHECK(s->declarations()->is_empty()); |
| 2966 Visit(stmt); | 2966 Visit(stmt); |
| 2967 } | 2967 } |
| 2968 | 2968 |
| 2969 | |
| 2970 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, | 2969 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, |
| 2971 LoopBuilder* loop) { | 2970 LoopBuilder* loop, |
| 2971 BailoutId stack_check_id) { |
| 2972 ControlScopeForIteration scope(this, stmt, loop); | 2972 ControlScopeForIteration scope(this, stmt, loop); |
| 2973 if (FLAG_turbo_loop_stackcheck || !info()->shared_info()->asm_function()) { | 2973 if (FLAG_turbo_loop_stackcheck || !info()->shared_info()->asm_function()) { |
| 2974 Node* node = NewNode(javascript()->StackCheck()); | 2974 Node* node = NewNode(javascript()->StackCheck()); |
| 2975 PrepareFrameState(node, stmt->StackCheckId()); | 2975 PrepareFrameState(node, stack_check_id); |
| 2976 } | 2976 } |
| 2977 Visit(stmt->body()); | 2977 Visit(stmt->body()); |
| 2978 } | 2978 } |
| 2979 | 2979 |
| 2980 | 2980 |
| 2981 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { | 2981 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { |
| 2982 Node* value; | 2982 Node* value; |
| 2983 if (expr->expression()->IsVariableProxy()) { | 2983 if (expr->expression()->IsVariableProxy()) { |
| 2984 // Delete of an unqualified identifier is only allowed in classic mode but | 2984 // Delete of an unqualified identifier is only allowed in classic mode but |
| 2985 // deleting "this" is allowed in all language modes. | 2985 // deleting "this" is allowed in all language modes. |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4369 // Phi does not exist yet, introduce one. | 4369 // Phi does not exist yet, introduce one. |
| 4370 value = NewPhi(inputs, value, control); | 4370 value = NewPhi(inputs, value, control); |
| 4371 value->ReplaceInput(inputs - 1, other); | 4371 value->ReplaceInput(inputs - 1, other); |
| 4372 } | 4372 } |
| 4373 return value; | 4373 return value; |
| 4374 } | 4374 } |
| 4375 | 4375 |
| 4376 } // namespace compiler | 4376 } // namespace compiler |
| 4377 } // namespace internal | 4377 } // namespace internal |
| 4378 } // namespace v8 | 4378 } // namespace v8 |
| OLD | NEW |