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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 compare_switch.EndCase(); | 1342 compare_switch.EndCase(); |
1343 } | 1343 } |
1344 | 1344 |
1345 compare_switch.EndSwitch(); | 1345 compare_switch.EndSwitch(); |
1346 } | 1346 } |
1347 | 1347 |
1348 | 1348 |
1349 void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { | 1349 void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
1350 LoopBuilder while_loop(this); | 1350 LoopBuilder while_loop(this); |
1351 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1351 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
1352 VisitIterationBody(stmt, &while_loop); | 1352 VisitIterationBody(stmt, &while_loop, stmt->StackCheckId()); |
1353 while_loop.EndBody(); | 1353 while_loop.EndBody(); |
1354 VisitForTest(stmt->cond()); | 1354 VisitForTest(stmt->cond()); |
1355 Node* condition = environment()->Pop(); | 1355 Node* condition = environment()->Pop(); |
1356 while_loop.BreakUnless(condition); | 1356 while_loop.BreakUnless(condition); |
1357 while_loop.EndLoop(); | 1357 while_loop.EndLoop(); |
1358 } | 1358 } |
1359 | 1359 |
1360 | 1360 |
1361 void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 1361 void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
1362 LoopBuilder while_loop(this); | 1362 LoopBuilder while_loop(this); |
1363 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1363 while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
1364 VisitForTest(stmt->cond()); | 1364 VisitForTest(stmt->cond()); |
1365 Node* condition = environment()->Pop(); | 1365 Node* condition = environment()->Pop(); |
1366 while_loop.BreakUnless(condition); | 1366 while_loop.BreakUnless(condition); |
1367 VisitIterationBody(stmt, &while_loop); | 1367 VisitIterationBody(stmt, &while_loop, stmt->StackCheckId()); |
1368 while_loop.EndBody(); | 1368 while_loop.EndBody(); |
1369 while_loop.EndLoop(); | 1369 while_loop.EndLoop(); |
1370 } | 1370 } |
1371 | 1371 |
1372 | 1372 |
1373 void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { | 1373 void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { |
1374 LoopBuilder for_loop(this); | 1374 LoopBuilder for_loop(this); |
1375 VisitIfNotNull(stmt->init()); | 1375 VisitIfNotNull(stmt->init()); |
1376 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1376 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
1377 if (stmt->cond() != nullptr) { | 1377 if (stmt->cond() != nullptr) { |
1378 VisitForTest(stmt->cond()); | 1378 VisitForTest(stmt->cond()); |
1379 Node* condition = environment()->Pop(); | 1379 Node* condition = environment()->Pop(); |
1380 for_loop.BreakUnless(condition); | 1380 for_loop.BreakUnless(condition); |
1381 } else { | 1381 } else { |
1382 for_loop.BreakUnless(jsgraph()->TrueConstant()); | 1382 for_loop.BreakUnless(jsgraph()->TrueConstant()); |
1383 } | 1383 } |
1384 VisitIterationBody(stmt, &for_loop); | 1384 VisitIterationBody(stmt, &for_loop, stmt->StackCheckId()); |
1385 for_loop.EndBody(); | 1385 for_loop.EndBody(); |
1386 VisitIfNotNull(stmt->next()); | 1386 VisitIfNotNull(stmt->next()); |
1387 for_loop.EndLoop(); | 1387 for_loop.EndLoop(); |
1388 } | 1388 } |
1389 | 1389 |
1390 | 1390 |
1391 void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { | 1391 void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { |
1392 VisitForValue(stmt->subject()); | 1392 VisitForValue(stmt->subject()); |
1393 Node* object = environment()->Pop(); | 1393 Node* object = environment()->Pop(); |
1394 BlockBuilder for_block(this); | 1394 BlockBuilder for_block(this); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 test_value.Else(); | 1451 test_value.Else(); |
1452 { | 1452 { |
1453 environment()->Push(value); | 1453 environment()->Push(value); |
1454 PrepareEagerCheckpoint(stmt->FilterId()); | 1454 PrepareEagerCheckpoint(stmt->FilterId()); |
1455 value = environment()->Pop(); | 1455 value = environment()->Pop(); |
1456 // Bind value and do loop body. | 1456 // Bind value and do loop body. |
1457 VectorSlotPair feedback = | 1457 VectorSlotPair feedback = |
1458 CreateVectorSlotPair(stmt->EachFeedbackSlot()); | 1458 CreateVectorSlotPair(stmt->EachFeedbackSlot()); |
1459 VisitForInAssignment(stmt->each(), value, feedback, | 1459 VisitForInAssignment(stmt->each(), value, feedback, |
1460 stmt->AssignmentId()); | 1460 stmt->AssignmentId()); |
1461 VisitIterationBody(stmt, &for_loop); | 1461 VisitIterationBody(stmt, &for_loop, stmt->StackCheckId()); |
1462 } | 1462 } |
1463 test_value.End(); | 1463 test_value.End(); |
1464 for_loop.EndBody(); | 1464 for_loop.EndBody(); |
1465 | 1465 |
1466 // Increment counter and continue. | 1466 // Increment counter and continue. |
1467 index = environment()->Peek(0); | 1467 index = environment()->Peek(0); |
1468 index = NewNode(javascript()->ForInStep(), index); | 1468 index = NewNode(javascript()->ForInStep(), index); |
1469 environment()->Poke(0, index); | 1469 environment()->Poke(0, index); |
1470 } | 1470 } |
1471 for_loop.EndLoop(); | 1471 for_loop.EndLoop(); |
1472 environment()->Drop(5); | 1472 environment()->Drop(5); |
1473 } | 1473 } |
1474 for_block.EndBlock(); | 1474 for_block.EndBlock(); |
1475 } | 1475 } |
1476 | 1476 |
1477 | 1477 |
1478 void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { | 1478 void AstGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { |
1479 LoopBuilder for_loop(this); | 1479 LoopBuilder for_loop(this); |
1480 VisitForEffect(stmt->assign_iterator()); | 1480 VisitForEffect(stmt->assign_iterator()); |
1481 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); | 1481 for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), CheckOsrEntry(stmt)); |
1482 VisitForEffect(stmt->next_result()); | 1482 VisitForEffect(stmt->next_result()); |
1483 VisitForTest(stmt->result_done()); | 1483 VisitForTest(stmt->result_done()); |
1484 Node* condition = environment()->Pop(); | 1484 Node* condition = environment()->Pop(); |
1485 for_loop.BreakWhen(condition); | 1485 for_loop.BreakWhen(condition); |
1486 VisitForEffect(stmt->assign_each()); | 1486 VisitForEffect(stmt->assign_each()); |
1487 VisitIterationBody(stmt, &for_loop); | 1487 VisitIterationBody(stmt, &for_loop, stmt->StackCheckId()); |
1488 for_loop.EndBody(); | 1488 for_loop.EndBody(); |
1489 for_loop.EndLoop(); | 1489 for_loop.EndLoop(); |
1490 } | 1490 } |
1491 | 1491 |
1492 | 1492 |
1493 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1493 void AstGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { |
1494 TryCatchBuilder try_control(this); | 1494 TryCatchBuilder try_control(this); |
1495 | 1495 |
1496 // Evaluate the try-block inside a control scope. This simulates a handler | 1496 // Evaluate the try-block inside a control scope. This simulates a handler |
1497 // that is intercepting 'throw' control commands. | 1497 // that is intercepting 'throw' control commands. |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2976 Visit(stmt); | 2976 Visit(stmt); |
2977 } | 2977 } |
2978 | 2978 |
2979 | 2979 |
2980 void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) { | 2980 void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) { |
2981 ContextScope scope(this, s, context); | 2981 ContextScope scope(this, s, context); |
2982 DCHECK(s->declarations()->is_empty()); | 2982 DCHECK(s->declarations()->is_empty()); |
2983 Visit(stmt); | 2983 Visit(stmt); |
2984 } | 2984 } |
2985 | 2985 |
2986 | |
2987 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, | 2986 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, |
2988 LoopBuilder* loop) { | 2987 LoopBuilder* loop, |
| 2988 BailoutId stack_check_id) { |
2989 ControlScopeForIteration scope(this, stmt, loop); | 2989 ControlScopeForIteration scope(this, stmt, loop); |
2990 if (FLAG_turbo_loop_stackcheck || !info()->shared_info()->asm_function()) { | 2990 if (FLAG_turbo_loop_stackcheck || !info()->shared_info()->asm_function()) { |
2991 Node* node = NewNode(javascript()->StackCheck()); | 2991 Node* node = NewNode(javascript()->StackCheck()); |
2992 PrepareFrameState(node, stmt->StackCheckId()); | 2992 PrepareFrameState(node, stack_check_id); |
2993 } | 2993 } |
2994 Visit(stmt->body()); | 2994 Visit(stmt->body()); |
2995 } | 2995 } |
2996 | 2996 |
2997 | 2997 |
2998 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { | 2998 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { |
2999 Node* value; | 2999 Node* value; |
3000 if (expr->expression()->IsVariableProxy()) { | 3000 if (expr->expression()->IsVariableProxy()) { |
3001 // Delete of an unqualified identifier is only allowed in classic mode but | 3001 // Delete of an unqualified identifier is only allowed in classic mode but |
3002 // deleting "this" is allowed in all language modes. | 3002 // deleting "this" is allowed in all language modes. |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4386 // Phi does not exist yet, introduce one. | 4386 // Phi does not exist yet, introduce one. |
4387 value = NewPhi(inputs, value, control); | 4387 value = NewPhi(inputs, value, control); |
4388 value->ReplaceInput(inputs - 1, other); | 4388 value->ReplaceInput(inputs - 1, other); |
4389 } | 4389 } |
4390 return value; | 4390 return value; |
4391 } | 4391 } |
4392 | 4392 |
4393 } // namespace compiler | 4393 } // namespace compiler |
4394 } // namespace internal | 4394 } // namespace internal |
4395 } // namespace v8 | 4395 } // namespace v8 |
OLD | NEW |