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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 BitVector* live_in_successor = live_at_block_start_[successor_id]; | 77 BitVector* live_in_successor = live_at_block_start_[successor_id]; |
78 if (live_in_successor->Equals(*live)) continue; | 78 if (live_in_successor->Equals(*live)) continue; |
79 for (int i = 0; i < live->length(); ++i) { | 79 for (int i = 0; i < live->length(); ++i) { |
80 if (!live->Contains(i)) continue; | 80 if (!live->Contains(i)) continue; |
81 if (live_in_successor->Contains(i)) continue; | 81 if (live_in_successor->Contains(i)) continue; |
82 if (first_simulate_invalid_for_index_.at(successor_id)->Contains(i)) { | 82 if (first_simulate_invalid_for_index_.at(successor_id)->Contains(i)) { |
83 continue; | 83 continue; |
84 } | 84 } |
85 HSimulate* simulate = first_simulate_.at(successor_id); | 85 HSimulate* simulate = first_simulate_.at(successor_id); |
86 if (simulate == NULL) continue; | 86 if (simulate == NULL) continue; |
87 ASSERT(simulate->closure().is_identical_to( | 87 ASSERT(VerifyClosures(simulate->closure(), |
88 block->last_environment()->closure())); | 88 block->last_environment()->closure())); |
Hannes Payer (out of office)
2014/03/28 08:32:19
+4 spaces indent
| |
89 ZapEnvironmentSlot(i, simulate); | 89 ZapEnvironmentSlot(i, simulate); |
90 } | 90 } |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 void HEnvironmentLivenessAnalysisPhase::ZapEnvironmentSlotsForInstruction( | 95 void HEnvironmentLivenessAnalysisPhase::ZapEnvironmentSlotsForInstruction( |
96 HEnvironmentMarker* marker) { | 96 HEnvironmentMarker* marker) { |
97 if (!marker->CheckFlag(HValue::kEndsLiveRange)) return; | 97 if (!marker->CheckFlag(HValue::kEndsLiveRange)) return; |
98 HSimulate* simulate = marker->next_simulate(); | 98 HSimulate* simulate = marker->next_simulate(); |
99 if (simulate != NULL) { | 99 if (simulate != NULL) { |
100 ASSERT(simulate->closure().is_identical_to(marker->closure())); | 100 ASSERT(VerifyClosures(simulate->closure(), marker->closure())); |
101 ZapEnvironmentSlot(marker->index(), simulate); | 101 ZapEnvironmentSlot(marker->index(), simulate); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 void HEnvironmentLivenessAnalysisPhase::UpdateLivenessAtBlockEnd( | 106 void HEnvironmentLivenessAnalysisPhase::UpdateLivenessAtBlockEnd( |
107 HBasicBlock* block, | 107 HBasicBlock* block, |
108 BitVector* live) { | 108 BitVector* live) { |
109 // Liveness at the end of each block: union of liveness in successors. | 109 // Liveness at the end of each block: union of liveness in successors. |
110 live->Clear(); | 110 live->Clear(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 worklist.Add(block->inlined_entry_block()->block_id()); | 220 worklist.Add(block->inlined_entry_block()->block_id()); |
221 } | 221 } |
222 } | 222 } |
223 } | 223 } |
224 // Only collect bind/lookup instructions during the first pass. | 224 // Only collect bind/lookup instructions during the first pass. |
225 collect_markers_ = false; | 225 collect_markers_ = false; |
226 } | 226 } |
227 | 227 |
228 // Analysis finished. Zap dead environment slots. | 228 // Analysis finished. Zap dead environment slots. |
229 for (int i = 0; i < markers_.length(); ++i) { | 229 for (int i = 0; i < markers_.length(); ++i) { |
230 // Acquire relocation lock to dereference for assertion. | |
Hannes Payer (out of office)
2014/03/28 08:32:19
remove this comments
| |
230 ZapEnvironmentSlotsForInstruction(markers_[i]); | 231 ZapEnvironmentSlotsForInstruction(markers_[i]); |
231 } | 232 } |
232 for (int block_id = block_count_ - 1; block_id >= 0; --block_id) { | 233 for (int block_id = block_count_ - 1; block_id >= 0; --block_id) { |
233 HBasicBlock* block = graph()->blocks()->at(block_id); | 234 HBasicBlock* block = graph()->blocks()->at(block_id); |
234 UpdateLivenessAtBlockEnd(block, &live); | 235 UpdateLivenessAtBlockEnd(block, &live); |
235 ZapEnvironmentSlotsInSuccessors(block, &live); | 236 ZapEnvironmentSlotsInSuccessors(block, &live); |
236 } | 237 } |
237 | 238 |
238 // Finally, remove the HEnvironment{Bind,Lookup} markers. | 239 // Finally, remove the HEnvironment{Bind,Lookup} markers. |
239 for (int i = 0; i < markers_.length(); ++i) { | 240 for (int i = 0; i < markers_.length(); ++i) { |
240 markers_[i]->DeleteAndReplaceWith(NULL); | 241 markers_[i]->DeleteAndReplaceWith(NULL); |
241 } | 242 } |
242 } | 243 } |
243 | 244 |
245 | |
246 #ifdef DEBUG | |
247 bool HEnvironmentLivenessAnalysisPhase::VerifyClosures( | |
248 Handle<JSFunction> a, Handle<JSFunction> b) { | |
249 Heap::RelocationLock for_heap_access(isolate()->heap()); | |
250 AllowHandleDereference for_verification; | |
251 return a.is_identical_to(b); | |
252 } | |
253 #endif | |
254 | |
244 } } // namespace v8::internal | 255 } } // namespace v8::internal |
OLD | NEW |