| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 HConstant* HGraph::GetConstantTrue() { | 475 HConstant* HGraph::GetConstantTrue() { |
| 476 return GetConstant(&constant_true_, Heap::true_value()); | 476 return GetConstant(&constant_true_, Heap::true_value()); |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 HConstant* HGraph::GetConstantFalse() { | 480 HConstant* HGraph::GetConstantFalse() { |
| 481 return GetConstant(&constant_false_, Heap::false_value()); | 481 return GetConstant(&constant_false_, Heap::false_value()); |
| 482 } | 482 } |
| 483 | 483 |
| 484 | 484 |
| 485 void HSubgraph::AppendJoin(HSubgraph* then_graph, | 485 void HSubgraph::AppendJoin(HBasicBlock* first, |
| 486 HSubgraph* else_graph, | 486 HBasicBlock* second, |
| 487 AstNode* node) { | 487 int join_id) { |
| 488 if (then_graph->exit_block() != NULL && | 488 if (first == NULL) { |
| 489 else_graph->exit_block() != NULL) { | 489 exit_block_ = second; |
| 490 // We need to merge, create new merge block. | 490 } else if (second == NULL) { |
| 491 exit_block_ = first; |
| 492 } else { |
| 491 HBasicBlock* join_block = graph_->CreateBasicBlock(); | 493 HBasicBlock* join_block = graph_->CreateBasicBlock(); |
| 492 then_graph->exit_block()->Goto(join_block); | 494 first->Goto(join_block); |
| 493 else_graph->exit_block()->Goto(join_block); | 495 second->Goto(join_block); |
| 494 join_block->SetJoinId(node->id()); | 496 join_block->SetJoinId(join_id); |
| 495 exit_block_ = join_block; | 497 exit_block_ = join_block; |
| 496 } else if (then_graph->exit_block() != NULL) { | |
| 497 exit_block_ = then_graph->exit_block_; | |
| 498 } else if (else_graph->exit_block() != NULL) { | |
| 499 exit_block_ = else_graph->exit_block_; | |
| 500 } else { | |
| 501 exit_block_ = NULL; | |
| 502 } | 498 } |
| 503 } | 499 } |
| 504 | 500 |
| 505 | 501 |
| 506 void HSubgraph::ResolveContinue(IterationStatement* statement, | 502 void HSubgraph::ResolveContinue(IterationStatement* statement, |
| 507 HBasicBlock* continue_block) { | 503 HBasicBlock* continue_block) { |
| 508 if (continue_block != NULL) { | 504 if (continue_block != NULL) { |
| 509 continue_block->SetJoinId(statement->ContinueId()); | 505 continue_block->SetJoinId(statement->ContinueId()); |
| 510 } | 506 } |
| 511 exit_block_ = | 507 exit_block_ = |
| 512 JoinBlocks(exit_block(), continue_block, statement->ContinueId()); | 508 JoinBlocks(exit_block(), continue_block, statement->ContinueId()); |
| 513 } | 509 } |
| 514 | 510 |
| 515 | 511 |
| 516 HBasicBlock* HSubgraph::JoinBlocks(HBasicBlock* a, HBasicBlock* b, int id) { | 512 HBasicBlock* HSubgraph::JoinBlocks(HBasicBlock* a, HBasicBlock* b, int id) { |
| 517 if (a == NULL) return b; | 513 if (a == NULL) return b; |
| 518 if (b == NULL) return a; | 514 if (b == NULL) return a; |
| 519 HBasicBlock* target = graph_->CreateBasicBlock(); | 515 HBasicBlock* target = graph_->CreateBasicBlock(); |
| 520 a->Goto(target); | 516 a->Goto(target); |
| 521 b->Goto(target); | 517 b->Goto(target); |
| 522 target->SetJoinId(id); | 518 target->SetJoinId(id); |
| 523 return target; | 519 return target; |
| 524 } | 520 } |
| 525 | 521 |
| 526 | 522 |
| 527 void HSubgraph::AppendEndless(HSubgraph* body, | 523 void HSubgraph::AppendEndless(IterationStatement* statement, |
| 528 IterationStatement* statement, | 524 HBasicBlock* body_entry, |
| 525 HBasicBlock* body_exit, |
| 529 HBasicBlock* break_block) { | 526 HBasicBlock* break_block) { |
| 530 if (exit_block() != NULL) { | 527 if (exit_block() != NULL) { |
| 531 exit_block()->Goto(body->entry_block(), false); | 528 exit_block()->Goto(body_entry, false); |
| 532 } | 529 } |
| 533 if (body->exit_block() != NULL) { | 530 if (body_exit != NULL) { |
| 534 body->exit_block()->Goto(body->entry_block(), true); | 531 body_exit->Goto(body_entry, true); |
| 535 } | 532 } |
| 536 if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); | 533 if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); |
| 537 exit_block_ = break_block; | 534 exit_block_ = break_block; |
| 538 body->entry_block()->PostProcessLoopHeader(statement); | 535 body_entry->PostProcessLoopHeader(statement); |
| 539 } | 536 } |
| 540 | 537 |
| 541 | 538 |
| 542 void HSubgraph::AppendDoWhile(HSubgraph* body, | 539 void HSubgraph::AppendDoWhile(IterationStatement* statement, |
| 543 IterationStatement* statement, | 540 HBasicBlock* body_entry, |
| 544 HSubgraph* go_back, | 541 HBasicBlock* go_back, |
| 545 HSubgraph* exit, | 542 HBasicBlock* exit_block, |
| 546 HBasicBlock* break_block) { | 543 HBasicBlock* break_block) { |
| 547 if (exit_block() != NULL) { | 544 if (this->exit_block() != NULL) { |
| 548 exit_block()->Goto(body->entry_block(), false); | 545 this->exit_block()->Goto(body_entry, false); |
| 549 } | 546 } |
| 550 if (go_back->exit_block() != NULL) { | 547 if (go_back != NULL) { |
| 551 go_back->exit_block()->Goto(body->entry_block(), true); | 548 go_back->Goto(body_entry, true); |
| 552 } | 549 } |
| 553 if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); | 550 if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); |
| 554 exit_block_ = | 551 exit_block_ = |
| 555 JoinBlocks(exit->exit_block(), break_block, statement->ExitId()); | 552 JoinBlocks(exit_block, break_block, statement->ExitId()); |
| 556 body->entry_block()->PostProcessLoopHeader(statement); | 553 body_entry->PostProcessLoopHeader(statement); |
| 557 } | 554 } |
| 558 | 555 |
| 559 | 556 |
| 560 void HSubgraph::AppendWhile(HSubgraph* condition, | 557 void HSubgraph::AppendWhile(IterationStatement* statement, |
| 561 HSubgraph* body, | 558 HBasicBlock* condition_entry, |
| 562 IterationStatement* statement, | 559 HBasicBlock* exit_block, |
| 563 HSubgraph* continue_subgraph, | 560 HBasicBlock* body_exit, |
| 564 HSubgraph* exit, | 561 HBasicBlock* break_block, |
| 565 HBasicBlock* break_block) { | 562 HBasicBlock* loop_entry, |
| 566 if (exit_block() != NULL) { | 563 HBasicBlock* loop_exit) { |
| 567 exit_block()->Goto(condition->entry_block(), false); | 564 if (this->exit_block() != NULL) { |
| 565 this->exit_block()->Goto(condition_entry, false); |
| 568 } | 566 } |
| 569 | 567 |
| 570 if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); | 568 if (break_block != NULL) break_block->SetJoinId(statement->ExitId()); |
| 571 exit_block_ = | 569 exit_block_ = |
| 572 JoinBlocks(exit->exit_block(), break_block, statement->ExitId()); | 570 JoinBlocks(exit_block, break_block, statement->ExitId()); |
| 573 | 571 |
| 574 if (continue_subgraph != NULL) { | 572 if (loop_entry != NULL) { |
| 575 if (body->exit_block() != NULL) { | 573 if (body_exit != NULL) { |
| 576 body->exit_block()->Goto(continue_subgraph->entry_block(), true); | 574 body_exit->Goto(loop_entry, true); |
| 577 } | 575 } |
| 578 continue_subgraph->entry_block()->SetJoinId(statement->EntryId()); | 576 loop_entry->SetJoinId(statement->EntryId()); |
| 579 exit_block_ = JoinBlocks(exit_block_, | 577 exit_block_ = JoinBlocks(exit_block_, loop_exit, statement->ExitId()); |
| 580 continue_subgraph->exit_block(), | |
| 581 statement->ExitId()); | |
| 582 } else { | 578 } else { |
| 583 if (body->exit_block() != NULL) { | 579 if (body_exit != NULL) { |
| 584 body->exit_block()->Goto(condition->entry_block(), true); | 580 body_exit->Goto(condition_entry, true); |
| 585 } | 581 } |
| 586 } | 582 } |
| 587 condition->entry_block()->PostProcessLoopHeader(statement); | 583 condition_entry->PostProcessLoopHeader(statement); |
| 588 } | 584 } |
| 589 | 585 |
| 590 | 586 |
| 591 void HSubgraph::Append(HSubgraph* next, | 587 void HSubgraph::Append(BreakableStatement* stmt, |
| 592 BreakableStatement* stmt, | 588 HBasicBlock* entry_block, |
| 589 HBasicBlock* exit_block, |
| 593 HBasicBlock* break_block) { | 590 HBasicBlock* break_block) { |
| 594 exit_block_->Goto(next->entry_block()); | 591 exit_block_->Goto(entry_block); |
| 595 exit_block_ = next->exit_block_; | 592 exit_block_ = exit_block; |
| 596 | 593 |
| 597 if (stmt != NULL) { | 594 if (stmt != NULL) { |
| 598 next->entry_block()->SetJoinId(stmt->EntryId()); | 595 entry_block->SetJoinId(stmt->EntryId()); |
| 599 if (break_block != NULL) break_block->SetJoinId(stmt->EntryId()); | 596 if (break_block != NULL) break_block->SetJoinId(stmt->EntryId()); |
| 600 exit_block_ = JoinBlocks(exit_block(), break_block, stmt->ExitId()); | 597 exit_block_ = JoinBlocks(exit_block, break_block, stmt->ExitId()); |
| 601 } | 598 } |
| 602 } | 599 } |
| 603 | 600 |
| 604 | 601 |
| 605 void HSubgraph::FinishExit(HControlInstruction* instruction) { | 602 void HSubgraph::FinishExit(HControlInstruction* instruction) { |
| 606 ASSERT(exit_block() != NULL); | 603 ASSERT(exit_block() != NULL); |
| 607 exit_block_->Finish(instruction); | 604 exit_block_->Finish(instruction); |
| 608 exit_block_->ClearEnvironment(); | 605 exit_block_->ClearEnvironment(); |
| 609 exit_block_ = NULL; | 606 exit_block_ = NULL; |
| 610 } | 607 } |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 Scope* scope = info->scope(); | 2160 Scope* scope = info->scope(); |
| 2164 SetupScope(scope); | 2161 SetupScope(scope); |
| 2165 VisitDeclarations(scope->declarations()); | 2162 VisitDeclarations(scope->declarations()); |
| 2166 | 2163 |
| 2167 AddInstruction(new HStackCheck()); | 2164 AddInstruction(new HStackCheck()); |
| 2168 | 2165 |
| 2169 ZoneList<Statement*>* stmts = info->function()->body(); | 2166 ZoneList<Statement*>* stmts = info->function()->body(); |
| 2170 HSubgraph* body = CreateGotoSubgraph(environment()); | 2167 HSubgraph* body = CreateGotoSubgraph(environment()); |
| 2171 AddToSubgraph(body, stmts); | 2168 AddToSubgraph(body, stmts); |
| 2172 if (HasStackOverflow()) return NULL; | 2169 if (HasStackOverflow()) return NULL; |
| 2173 current_subgraph_->Append(body, NULL, NULL); | 2170 current_subgraph_->Append(NULL, |
| 2171 body->entry_block(), |
| 2172 body->exit_block(), |
| 2173 NULL); |
| 2174 body->entry_block()->SetJoinId(info->function()->id()); | 2174 body->entry_block()->SetJoinId(info->function()->id()); |
| 2175 | 2175 |
| 2176 if (graph()->exit_block() != NULL) { | 2176 if (graph()->exit_block() != NULL) { |
| 2177 graph_->FinishExit(new HReturn(graph_->GetConstantUndefined())); | 2177 graph_->FinishExit(new HReturn(graph_->GetConstantUndefined())); |
| 2178 } | 2178 } |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 graph_->OrderBlocks(); | 2181 graph_->OrderBlocks(); |
| 2182 graph_->AssignDominators(); | 2182 graph_->AssignDominators(); |
| 2183 graph_->EliminateRedundantPhis(); | 2183 graph_->EliminateRedundantPhis(); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 } | 2370 } |
| 2371 | 2371 |
| 2372 | 2372 |
| 2373 void HGraphBuilder::VisitBlock(Block* stmt) { | 2373 void HGraphBuilder::VisitBlock(Block* stmt) { |
| 2374 if (stmt->labels() != NULL) { | 2374 if (stmt->labels() != NULL) { |
| 2375 HSubgraph* block_graph = CreateGotoSubgraph(environment()); | 2375 HSubgraph* block_graph = CreateGotoSubgraph(environment()); |
| 2376 BreakAndContinueInfo break_info(stmt); | 2376 BreakAndContinueInfo break_info(stmt); |
| 2377 { BreakAndContinueScope push(&break_info, this); | 2377 { BreakAndContinueScope push(&break_info, this); |
| 2378 ADD_TO_SUBGRAPH(block_graph, stmt->statements()); | 2378 ADD_TO_SUBGRAPH(block_graph, stmt->statements()); |
| 2379 } | 2379 } |
| 2380 subgraph()->Append(block_graph, stmt, break_info.break_block()); | 2380 subgraph()->Append(stmt, |
| 2381 block_graph->entry_block(), |
| 2382 block_graph->exit_block(), |
| 2383 break_info.break_block()); |
| 2381 } else { | 2384 } else { |
| 2382 VisitStatements(stmt->statements()); | 2385 VisitStatements(stmt->statements()); |
| 2383 } | 2386 } |
| 2384 } | 2387 } |
| 2385 | 2388 |
| 2386 | 2389 |
| 2387 void HGraphBuilder::VisitExpressionStatement(ExpressionStatement* stmt) { | 2390 void HGraphBuilder::VisitExpressionStatement(ExpressionStatement* stmt) { |
| 2388 VisitForEffect(stmt->expression()); | 2391 VisitForEffect(stmt->expression()); |
| 2389 } | 2392 } |
| 2390 | 2393 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2406 VISIT_FOR_CONTROL(stmt->condition(), | 2409 VISIT_FOR_CONTROL(stmt->condition(), |
| 2407 then_graph->entry_block(), | 2410 then_graph->entry_block(), |
| 2408 else_graph->entry_block()); | 2411 else_graph->entry_block()); |
| 2409 | 2412 |
| 2410 then_graph->entry_block()->SetJoinId(stmt->ThenId()); | 2413 then_graph->entry_block()->SetJoinId(stmt->ThenId()); |
| 2411 ADD_TO_SUBGRAPH(then_graph, stmt->then_statement()); | 2414 ADD_TO_SUBGRAPH(then_graph, stmt->then_statement()); |
| 2412 | 2415 |
| 2413 else_graph->entry_block()->SetJoinId(stmt->ElseId()); | 2416 else_graph->entry_block()->SetJoinId(stmt->ElseId()); |
| 2414 ADD_TO_SUBGRAPH(else_graph, stmt->else_statement()); | 2417 ADD_TO_SUBGRAPH(else_graph, stmt->else_statement()); |
| 2415 | 2418 |
| 2416 current_subgraph_->AppendJoin(then_graph, else_graph, stmt); | 2419 current_subgraph_->AppendJoin(then_graph->exit_block(), |
| 2420 else_graph->exit_block(), |
| 2421 stmt->id()); |
| 2417 } | 2422 } |
| 2418 } | 2423 } |
| 2419 | 2424 |
| 2420 | 2425 |
| 2421 HBasicBlock* HGraphBuilder::BreakAndContinueScope::Get( | 2426 HBasicBlock* HGraphBuilder::BreakAndContinueScope::Get( |
| 2422 BreakableStatement* stmt, | 2427 BreakableStatement* stmt, |
| 2423 BreakType type) { | 2428 BreakType type) { |
| 2424 BreakAndContinueScope* current = this; | 2429 BreakAndContinueScope* current = this; |
| 2425 while (current != NULL && current->info()->target() != stmt) { | 2430 while (current != NULL && current->info()->target() != stmt) { |
| 2426 current = current->next(); | 2431 current = current->next(); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2715 subgraph()->PreProcessOsrEntry(stmt); | 2720 subgraph()->PreProcessOsrEntry(stmt); |
| 2716 | 2721 |
| 2717 HSubgraph* body_graph = CreateLoopHeaderSubgraph(environment()); | 2722 HSubgraph* body_graph = CreateLoopHeaderSubgraph(environment()); |
| 2718 BreakAndContinueInfo break_info(stmt); | 2723 BreakAndContinueInfo break_info(stmt); |
| 2719 { BreakAndContinueScope push(&break_info, this); | 2724 { BreakAndContinueScope push(&break_info, this); |
| 2720 ADD_TO_SUBGRAPH(body_graph, stmt->body()); | 2725 ADD_TO_SUBGRAPH(body_graph, stmt->body()); |
| 2721 } | 2726 } |
| 2722 body_graph->ResolveContinue(stmt, break_info.continue_block()); | 2727 body_graph->ResolveContinue(stmt, break_info.continue_block()); |
| 2723 | 2728 |
| 2724 if (body_graph->exit_block() == NULL || stmt->cond()->ToBooleanIsTrue()) { | 2729 if (body_graph->exit_block() == NULL || stmt->cond()->ToBooleanIsTrue()) { |
| 2725 subgraph()->AppendEndless(body_graph, stmt, break_info.break_block()); | 2730 subgraph()->AppendEndless(stmt, |
| 2731 body_graph->entry_block(), |
| 2732 body_graph->exit_block(), |
| 2733 break_info.break_block()); |
| 2726 } else { | 2734 } else { |
| 2727 HSubgraph* go_back = CreateEmptySubgraph(); | 2735 HSubgraph* go_back = CreateEmptySubgraph(); |
| 2728 HSubgraph* exit = CreateEmptySubgraph(); | 2736 HSubgraph* exit = CreateEmptySubgraph(); |
| 2729 { | 2737 { |
| 2730 SubgraphScope scope(this, body_graph); | 2738 SubgraphScope scope(this, body_graph); |
| 2731 VISIT_FOR_CONTROL(stmt->cond(), | 2739 VISIT_FOR_CONTROL(stmt->cond(), |
| 2732 go_back->entry_block(), | 2740 go_back->entry_block(), |
| 2733 exit->entry_block()); | 2741 exit->entry_block()); |
| 2734 go_back->entry_block()->SetJoinId(stmt->BackEdgeId()); | 2742 go_back->entry_block()->SetJoinId(stmt->BackEdgeId()); |
| 2735 exit->entry_block()->SetJoinId(stmt->ExitId()); | 2743 exit->entry_block()->SetJoinId(stmt->ExitId()); |
| 2736 } | 2744 } |
| 2737 subgraph()->AppendDoWhile(body_graph, stmt, go_back, exit, | 2745 subgraph()->AppendDoWhile(stmt, |
| 2746 body_graph->entry_block(), |
| 2747 go_back->exit_block(), |
| 2748 exit->exit_block(), |
| 2738 break_info.break_block()); | 2749 break_info.break_block()); |
| 2739 } | 2750 } |
| 2740 } | 2751 } |
| 2741 | 2752 |
| 2742 | 2753 |
| 2743 bool HGraphBuilder::ShouldPeel(HSubgraph* cond, HSubgraph* body) { | |
| 2744 return FLAG_use_peeling; | |
| 2745 } | |
| 2746 | |
| 2747 | |
| 2748 void HGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 2754 void HGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| 2749 ASSERT(current_block() != NULL); | 2755 ASSERT(current_block() != NULL); |
| 2750 subgraph()->PreProcessOsrEntry(stmt); | 2756 subgraph()->PreProcessOsrEntry(stmt); |
| 2751 | 2757 |
| 2752 HSubgraph* cond_graph = NULL; | 2758 HSubgraph* cond_graph = NULL; |
| 2753 HSubgraph* body_graph = NULL; | 2759 HSubgraph* body_graph = NULL; |
| 2754 HSubgraph* exit_graph = NULL; | 2760 HSubgraph* exit_graph = NULL; |
| 2755 | 2761 |
| 2756 // If the condition is constant true, do not generate a condition subgraph. | 2762 // If the condition is constant true, do not generate a condition subgraph. |
| 2757 if (stmt->cond()->ToBooleanIsTrue()) { | 2763 if (stmt->cond()->ToBooleanIsTrue()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2770 } | 2776 } |
| 2771 } | 2777 } |
| 2772 | 2778 |
| 2773 BreakAndContinueInfo break_info(stmt); | 2779 BreakAndContinueInfo break_info(stmt); |
| 2774 { BreakAndContinueScope push(&break_info, this); | 2780 { BreakAndContinueScope push(&break_info, this); |
| 2775 ADD_TO_SUBGRAPH(body_graph, stmt->body()); | 2781 ADD_TO_SUBGRAPH(body_graph, stmt->body()); |
| 2776 } | 2782 } |
| 2777 body_graph->ResolveContinue(stmt, break_info.continue_block()); | 2783 body_graph->ResolveContinue(stmt, break_info.continue_block()); |
| 2778 | 2784 |
| 2779 if (cond_graph != NULL) { | 2785 if (cond_graph != NULL) { |
| 2780 AppendPeeledWhile(stmt, cond_graph, body_graph, exit_graph, | 2786 AppendPeeledWhile(stmt, |
| 2787 cond_graph->entry_block(), |
| 2788 exit_graph->exit_block(), |
| 2789 body_graph->exit_block(), |
| 2781 break_info.break_block()); | 2790 break_info.break_block()); |
| 2782 } else { | 2791 } else { |
| 2783 // TODO(fschneider): Implement peeling for endless loops as well. | 2792 // TODO(fschneider): Implement peeling for endless loops as well. |
| 2784 subgraph()->AppendEndless(body_graph, stmt, break_info.break_block()); | 2793 subgraph()->AppendEndless(stmt, |
| 2794 body_graph->entry_block(), |
| 2795 body_graph->exit_block(), |
| 2796 break_info.break_block()); |
| 2785 } | 2797 } |
| 2786 } | 2798 } |
| 2787 | 2799 |
| 2788 | 2800 |
| 2789 void HGraphBuilder::AppendPeeledWhile(IterationStatement* stmt, | 2801 void HGraphBuilder::AppendPeeledWhile(IterationStatement* stmt, |
| 2790 HSubgraph* cond_graph, | 2802 HBasicBlock* condition_entry, |
| 2791 HSubgraph* body_graph, | 2803 HBasicBlock* exit_block, |
| 2792 HSubgraph* exit_graph, | 2804 HBasicBlock* body_exit, |
| 2793 HBasicBlock* break_block) { | 2805 HBasicBlock* break_block) { |
| 2794 HSubgraph* loop = NULL; | 2806 HBasicBlock* loop_entry = NULL; |
| 2795 if (body_graph->exit_block() != NULL && stmt != peeled_statement_ && | 2807 HBasicBlock* loop_exit = NULL; |
| 2796 ShouldPeel(cond_graph, body_graph)) { | 2808 if (FLAG_use_peeling && body_exit != NULL && stmt != peeled_statement_) { |
| 2797 // Save the last peeled iteration statement to prevent infinite recursion. | 2809 // Save the last peeled iteration statement to prevent infinite recursion. |
| 2798 IterationStatement* outer_peeled_statement = peeled_statement_; | 2810 IterationStatement* outer_peeled_statement = peeled_statement_; |
| 2799 peeled_statement_ = stmt; | 2811 peeled_statement_ = stmt; |
| 2800 loop = CreateGotoSubgraph(body_graph->exit_block()->last_environment()); | 2812 HSubgraph* loop = CreateGotoSubgraph(body_exit->last_environment()); |
| 2801 ADD_TO_SUBGRAPH(loop, stmt); | 2813 ADD_TO_SUBGRAPH(loop, stmt); |
| 2802 peeled_statement_ = outer_peeled_statement; | 2814 peeled_statement_ = outer_peeled_statement; |
| 2815 loop_entry = loop->entry_block(); |
| 2816 loop_exit = loop->exit_block(); |
| 2803 } | 2817 } |
| 2804 subgraph()->AppendWhile(cond_graph, body_graph, stmt, loop, exit_graph, | 2818 subgraph()->AppendWhile(stmt, |
| 2805 break_block); | 2819 condition_entry, |
| 2820 exit_block, |
| 2821 body_exit, |
| 2822 break_block, |
| 2823 loop_entry, |
| 2824 loop_exit); |
| 2806 } | 2825 } |
| 2807 | 2826 |
| 2808 | 2827 |
| 2809 void HGraphBuilder::VisitForStatement(ForStatement* stmt) { | 2828 void HGraphBuilder::VisitForStatement(ForStatement* stmt) { |
| 2810 // Only visit the init statement in the peeled part of the loop. | 2829 // Only visit the init statement in the peeled part of the loop. |
| 2811 if (stmt->init() != NULL && peeled_statement_ != stmt) { | 2830 if (stmt->init() != NULL && peeled_statement_ != stmt) { |
| 2812 Visit(stmt->init()); | 2831 Visit(stmt->init()); |
| 2813 CHECK_BAILOUT; | 2832 CHECK_BAILOUT; |
| 2814 } | 2833 } |
| 2815 ASSERT(current_block() != NULL); | 2834 ASSERT(current_block() != NULL); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2838 ADD_TO_SUBGRAPH(body_graph, stmt->body()); | 2857 ADD_TO_SUBGRAPH(body_graph, stmt->body()); |
| 2839 } | 2858 } |
| 2840 | 2859 |
| 2841 HSubgraph* next_graph = NULL; | 2860 HSubgraph* next_graph = NULL; |
| 2842 body_graph->ResolveContinue(stmt, break_info.continue_block()); | 2861 body_graph->ResolveContinue(stmt, break_info.continue_block()); |
| 2843 | 2862 |
| 2844 if (stmt->next() != NULL && body_graph->exit_block() != NULL) { | 2863 if (stmt->next() != NULL && body_graph->exit_block() != NULL) { |
| 2845 next_graph = | 2864 next_graph = |
| 2846 CreateGotoSubgraph(body_graph->exit_block()->last_environment()); | 2865 CreateGotoSubgraph(body_graph->exit_block()->last_environment()); |
| 2847 ADD_TO_SUBGRAPH(next_graph, stmt->next()); | 2866 ADD_TO_SUBGRAPH(next_graph, stmt->next()); |
| 2848 body_graph->Append(next_graph, NULL, NULL); | 2867 body_graph->Append(NULL, |
| 2868 next_graph->entry_block(), |
| 2869 next_graph->exit_block(), |
| 2870 NULL); |
| 2849 next_graph->entry_block()->SetJoinId(stmt->ContinueId()); | 2871 next_graph->entry_block()->SetJoinId(stmt->ContinueId()); |
| 2850 } | 2872 } |
| 2851 | 2873 |
| 2852 if (cond_graph != NULL) { | 2874 if (cond_graph != NULL) { |
| 2853 AppendPeeledWhile(stmt, cond_graph, body_graph, exit_graph, | 2875 AppendPeeledWhile(stmt, |
| 2876 cond_graph->entry_block(), |
| 2877 exit_graph->exit_block(), |
| 2878 body_graph->exit_block(), |
| 2854 break_info.break_block()); | 2879 break_info.break_block()); |
| 2855 } else { | 2880 } else { |
| 2856 subgraph()->AppendEndless(body_graph, stmt, break_info.break_block()); | 2881 subgraph()->AppendEndless(stmt, |
| 2882 body_graph->entry_block(), |
| 2883 body_graph->exit_block(), |
| 2884 break_info.break_block()); |
| 2857 } | 2885 } |
| 2858 } | 2886 } |
| 2859 | 2887 |
| 2860 | 2888 |
| 2861 void HGraphBuilder::VisitForInStatement(ForInStatement* stmt) { | 2889 void HGraphBuilder::VisitForInStatement(ForInStatement* stmt) { |
| 2862 BAILOUT("ForInStatement"); | 2890 BAILOUT("ForInStatement"); |
| 2863 } | 2891 } |
| 2864 | 2892 |
| 2865 | 2893 |
| 2866 void HGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { | 2894 void HGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 VISIT_FOR_CONTROL(expr->condition(), | 2928 VISIT_FOR_CONTROL(expr->condition(), |
| 2901 then_graph->entry_block(), | 2929 then_graph->entry_block(), |
| 2902 else_graph->entry_block()); | 2930 else_graph->entry_block()); |
| 2903 | 2931 |
| 2904 then_graph->entry_block()->SetJoinId(expr->ThenId()); | 2932 then_graph->entry_block()->SetJoinId(expr->ThenId()); |
| 2905 ADD_TO_SUBGRAPH(then_graph, expr->then_expression()); | 2933 ADD_TO_SUBGRAPH(then_graph, expr->then_expression()); |
| 2906 | 2934 |
| 2907 else_graph->entry_block()->SetJoinId(expr->ElseId()); | 2935 else_graph->entry_block()->SetJoinId(expr->ElseId()); |
| 2908 ADD_TO_SUBGRAPH(else_graph, expr->else_expression()); | 2936 ADD_TO_SUBGRAPH(else_graph, expr->else_expression()); |
| 2909 | 2937 |
| 2910 current_subgraph_->AppendJoin(then_graph, else_graph, expr); | 2938 current_subgraph_->AppendJoin(then_graph->exit_block(), |
| 2939 else_graph->exit_block(), |
| 2940 expr->id()); |
| 2911 ast_context()->ReturnValue(Pop()); | 2941 ast_context()->ReturnValue(Pop()); |
| 2912 } | 2942 } |
| 2913 | 2943 |
| 2914 | 2944 |
| 2915 void HGraphBuilder::LookupGlobalPropertyCell(Variable* var, | 2945 void HGraphBuilder::LookupGlobalPropertyCell(Variable* var, |
| 2916 LookupResult* lookup, | 2946 LookupResult* lookup, |
| 2917 bool is_store) { | 2947 bool is_store) { |
| 2918 if (var->is_this()) { | 2948 if (var->is_this()) { |
| 2919 BAILOUT("global this reference"); | 2949 BAILOUT("global this reference"); |
| 2920 } | 2950 } |
| (...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4688 false_graph->entry_block(), | 4718 false_graph->entry_block(), |
| 4689 true_graph->entry_block()); | 4719 true_graph->entry_block()); |
| 4690 true_graph->entry_block()->SetJoinId(expr->expression()->id()); | 4720 true_graph->entry_block()->SetJoinId(expr->expression()->id()); |
| 4691 true_graph->exit_block()->last_environment()->Push( | 4721 true_graph->exit_block()->last_environment()->Push( |
| 4692 graph_->GetConstantTrue()); | 4722 graph_->GetConstantTrue()); |
| 4693 | 4723 |
| 4694 false_graph->entry_block()->SetJoinId(expr->expression()->id()); | 4724 false_graph->entry_block()->SetJoinId(expr->expression()->id()); |
| 4695 false_graph->exit_block()->last_environment()->Push( | 4725 false_graph->exit_block()->last_environment()->Push( |
| 4696 graph_->GetConstantFalse()); | 4726 graph_->GetConstantFalse()); |
| 4697 | 4727 |
| 4698 current_subgraph_->AppendJoin(true_graph, false_graph, expr); | 4728 current_subgraph_->AppendJoin(true_graph->exit_block(), |
| 4729 false_graph->exit_block(), |
| 4730 expr->id()); |
| 4699 ast_context()->ReturnValue(Pop()); | 4731 ast_context()->ReturnValue(Pop()); |
| 4700 } else { | 4732 } else { |
| 4701 ASSERT(ast_context()->IsEffect()); | 4733 ASSERT(ast_context()->IsEffect()); |
| 4702 VISIT_FOR_EFFECT(expr->expression()); | 4734 VISIT_FOR_EFFECT(expr->expression()); |
| 4703 } | 4735 } |
| 4704 | 4736 |
| 4705 } else if (op == Token::BIT_NOT || op == Token::SUB) { | 4737 } else if (op == Token::BIT_NOT || op == Token::SUB) { |
| 4706 VISIT_FOR_VALUE(expr->expression()); | 4738 VISIT_FOR_VALUE(expr->expression()); |
| 4707 HValue* value = Pop(); | 4739 HValue* value = Pop(); |
| 4708 HInstruction* instr = NULL; | 4740 HInstruction* instr = NULL; |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6089 } | 6121 } |
| 6090 } | 6122 } |
| 6091 | 6123 |
| 6092 #ifdef DEBUG | 6124 #ifdef DEBUG |
| 6093 if (graph_ != NULL) graph_->Verify(); | 6125 if (graph_ != NULL) graph_->Verify(); |
| 6094 if (allocator_ != NULL) allocator_->Verify(); | 6126 if (allocator_ != NULL) allocator_->Verify(); |
| 6095 #endif | 6127 #endif |
| 6096 } | 6128 } |
| 6097 | 6129 |
| 6098 } } // namespace v8::internal | 6130 } } // namespace v8::internal |
| OLD | NEW |