OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 namespace v8 { | 31 namespace v8 { |
32 namespace internal { | 32 namespace internal { |
33 | 33 |
34 // True iff. we are compiling for OSR and the statement is the entry. | 34 // True iff. we are compiling for OSR and the statement is the entry. |
35 bool HOsrBuilder::HasOsrEntryAt(IterationStatement* statement) { | 35 bool HOsrBuilder::HasOsrEntryAt(IterationStatement* statement) { |
36 return statement->OsrEntryId() == builder_->current_info()->osr_ast_id(); | 36 return statement->OsrEntryId() == builder_->current_info()->osr_ast_id(); |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 // Build a new loop header block and set it as the current block. | 40 HBasicBlock* HOsrBuilder::BuildOsrLoopEntry( |
Michael Starzinger
2013/09/27 13:26:22
nit: Should fit into one line.
mvstanton
2013/09/27 13:31:43
Done.
| |
41 HBasicBlock *HOsrBuilder::BuildLoopEntry() { | |
42 HBasicBlock* loop_entry = builder_->CreateLoopHeaderBlock(); | |
43 builder_->current_block()->Goto(loop_entry); | |
44 builder_->set_current_block(loop_entry); | |
45 return loop_entry; | |
46 } | |
47 | |
48 | |
49 HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry( | |
50 IterationStatement* statement) { | 41 IterationStatement* statement) { |
51 // Check if there is an OSR here first. | 42 ASSERT(HasOsrEntryAt(statement)); |
52 if (!HasOsrEntryAt(statement)) return BuildLoopEntry(); | |
53 | 43 |
54 Zone* zone = builder_->zone(); | 44 Zone* zone = builder_->zone(); |
55 HGraph* graph = builder_->graph(); | 45 HGraph* graph = builder_->graph(); |
56 | 46 |
57 // only one OSR point per compile is allowed. | 47 // only one OSR point per compile is allowed. |
58 ASSERT(graph->osr() == NULL); | 48 ASSERT(graph->osr() == NULL); |
59 | 49 |
60 // remember this builder as the one OSR builder in the graph. | 50 // remember this builder as the one OSR builder in the graph. |
61 graph->set_osr(this); | 51 graph->set_osr(this); |
62 | 52 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 | 96 |
107 builder_->Add<HSimulate>(osr_entry_id); | 97 builder_->Add<HSimulate>(osr_entry_id); |
108 builder_->Add<HOsrEntry>(osr_entry_id); | 98 builder_->Add<HOsrEntry>(osr_entry_id); |
109 HContext* context = builder_->Add<HContext>(); | 99 HContext* context = builder_->Add<HContext>(); |
110 environment->BindContext(context); | 100 environment->BindContext(context); |
111 builder_->current_block()->Goto(loop_predecessor); | 101 builder_->current_block()->Goto(loop_predecessor); |
112 loop_predecessor->SetJoinId(statement->EntryId()); | 102 loop_predecessor->SetJoinId(statement->EntryId()); |
113 builder_->set_current_block(loop_predecessor); | 103 builder_->set_current_block(loop_predecessor); |
114 | 104 |
115 // Create the final loop entry | 105 // Create the final loop entry |
116 osr_loop_entry_ = BuildLoopEntry(); | 106 osr_loop_entry_ = builder_->BuildLoopEntry(); |
117 return osr_loop_entry_; | 107 return osr_loop_entry_; |
118 } | 108 } |
119 | 109 |
120 | 110 |
121 void HOsrBuilder::FinishGraph() { | 111 void HOsrBuilder::FinishGraph() { |
122 // do nothing for now. | 112 // do nothing for now. |
123 } | 113 } |
124 | 114 |
125 | 115 |
126 void HOsrBuilder::FinishOsrValues() { | 116 void HOsrBuilder::FinishOsrValues() { |
127 const ZoneList<HPhi*>* phis = osr_loop_entry_->phis(); | 117 const ZoneList<HPhi*>* phis = osr_loop_entry_->phis(); |
128 for (int j = 0; j < phis->length(); j++) { | 118 for (int j = 0; j < phis->length(); j++) { |
129 HPhi* phi = phis->at(j); | 119 HPhi* phi = phis->at(j); |
130 if (phi->HasMergedIndex()) { | 120 if (phi->HasMergedIndex()) { |
131 osr_values_->at(phi->merged_index())->set_incoming_value(phi); | 121 osr_values_->at(phi->merged_index())->set_incoming_value(phi); |
132 } | 122 } |
133 } | 123 } |
134 } | 124 } |
135 | 125 |
136 } } // namespace v8::internal | 126 } } // namespace v8::internal |
OLD | NEW |