Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 | 28 |
| 29 #include "hydrogen-environment-liveness.h" | 29 #include "hydrogen-environment-liveness.h" |
| 30 | 30 |
| 31 | 31 |
| 32 namespace v8 { | 32 namespace v8 { |
| 33 namespace internal { | 33 namespace internal { |
| 34 | 34 |
| 35 | 35 |
| 36 EnvironmentSlotLivenessAnalyzer::EnvironmentSlotLivenessAnalyzer( | 36 EnvironmentSlotLivenessAnalyzer::EnvironmentSlotLivenessAnalyzer( |
| 37 HGraph* graph) | 37 HGraph* graph, |
| 38 Zone* phase_zone) | |
|
danno
2013/06/24 12:11:21
This should take an CompilationInfo rather than a
Benedikt Meurer
2013/06/24 12:18:28
Separate CL, see https://codereview.chromium.org/1
| |
| 38 : graph_(graph), | 39 : graph_(graph), |
| 39 zone_(graph->isolate()), | 40 phase_zone_(phase_zone), |
| 40 zone_scope_(&zone_, DELETE_ON_EXIT), | 41 phase_zone_scope_(phase_zone_, DELETE_ON_EXIT), |
| 41 block_count_(graph->blocks()->length()), | 42 block_count_(graph->blocks()->length()), |
| 42 maximum_environment_size_(graph->maximum_environment_size()), | 43 maximum_environment_size_(graph->maximum_environment_size()), |
| 43 collect_markers_(true), | 44 collect_markers_(true), |
| 44 last_simulate_(NULL) { | 45 last_simulate_(NULL) { |
| 45 if (maximum_environment_size_ == 0) return; | 46 if (maximum_environment_size_ == 0) return; |
| 46 | 47 |
| 47 live_at_block_start_ = | 48 live_at_block_start_ = |
| 48 new(zone()) ZoneList<BitVector*>(block_count_, zone()); | 49 new(phase_zone) ZoneList<BitVector*>(block_count_, phase_zone); |
| 49 first_simulate_ = new(zone()) ZoneList<HSimulate*>(block_count_, zone()); | 50 first_simulate_ = new(phase_zone) ZoneList<HSimulate*>(block_count_, |
| 51 phase_zone); | |
| 50 first_simulate_invalid_for_index_ = | 52 first_simulate_invalid_for_index_ = |
| 51 new(zone()) ZoneList<BitVector*>(block_count_, zone()); | 53 new(phase_zone) ZoneList<BitVector*>(block_count_, phase_zone); |
| 52 markers_ = new(zone()) | 54 markers_ = new(phase_zone) |
| 53 ZoneList<HEnvironmentMarker*>(maximum_environment_size_, zone()); | 55 ZoneList<HEnvironmentMarker*>(maximum_environment_size_, phase_zone); |
| 54 went_live_since_last_simulate_ = | 56 went_live_since_last_simulate_ = |
| 55 new(zone()) BitVector(maximum_environment_size_, zone()); | 57 new(phase_zone) BitVector(maximum_environment_size_, phase_zone); |
| 56 | 58 |
| 57 for (int i = 0; i < block_count_; ++i) { | 59 for (int i = 0; i < block_count_; ++i) { |
| 58 live_at_block_start_->Add( | 60 live_at_block_start_->Add( |
| 59 new(zone()) BitVector(maximum_environment_size_, zone()), zone()); | 61 new(phase_zone) BitVector(maximum_environment_size_, phase_zone), |
| 60 first_simulate_->Add(NULL, zone()); | 62 phase_zone); |
| 63 first_simulate_->Add(NULL, phase_zone); | |
| 61 first_simulate_invalid_for_index_->Add( | 64 first_simulate_invalid_for_index_->Add( |
| 62 new(zone()) BitVector(maximum_environment_size_, zone()), zone()); | 65 new(phase_zone) BitVector(maximum_environment_size_, phase_zone), |
| 66 phase_zone); | |
| 63 } | 67 } |
| 64 } | 68 } |
| 65 | 69 |
| 66 | 70 |
| 67 void EnvironmentSlotLivenessAnalyzer::ZapEnvironmentSlot(int index, | 71 void EnvironmentSlotLivenessAnalyzer::ZapEnvironmentSlot(int index, |
| 68 HSimulate* simulate) { | 72 HSimulate* simulate) { |
| 69 int operand_index = simulate->ToOperandIndex(index); | 73 int operand_index = simulate->ToOperandIndex(index); |
| 70 if (operand_index == -1) { | 74 if (operand_index == -1) { |
| 71 simulate->AddAssignedValue(index, graph_->GetConstantUndefined()); | 75 simulate->AddAssignedValue(index, graph_->GetConstantUndefined()); |
| 72 } else { | 76 } else { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 144 } |
| 141 if (marker->kind() == HEnvironmentMarker::LOOKUP) { | 145 if (marker->kind() == HEnvironmentMarker::LOOKUP) { |
| 142 live->Add(index); | 146 live->Add(index); |
| 143 } else { | 147 } else { |
| 144 ASSERT(marker->kind() == HEnvironmentMarker::BIND); | 148 ASSERT(marker->kind() == HEnvironmentMarker::BIND); |
| 145 live->Remove(index); | 149 live->Remove(index); |
| 146 went_live_since_last_simulate_->Add(index); | 150 went_live_since_last_simulate_->Add(index); |
| 147 } | 151 } |
| 148 if (collect_markers_) { | 152 if (collect_markers_) { |
| 149 // Populate |markers_| list during the first pass. | 153 // Populate |markers_| list during the first pass. |
| 150 markers_->Add(marker, &zone_); | 154 markers_->Add(marker, phase_zone()); |
| 151 } | 155 } |
| 152 break; | 156 break; |
| 153 } | 157 } |
| 154 case HValue::kLeaveInlined: | 158 case HValue::kLeaveInlined: |
| 155 // No environment values are live at the end of an inlined section. | 159 // No environment values are live at the end of an inlined section. |
| 156 live->Clear(); | 160 live->Clear(); |
| 157 last_simulate_ = NULL; | 161 last_simulate_ = NULL; |
| 158 | 162 |
| 159 // The following ASSERTs guard the assumption used in case | 163 // The following ASSERTs guard the assumption used in case |
| 160 // kEnterInlined below: | 164 // kEnterInlined below: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 case HValue::kSimulate: | 197 case HValue::kSimulate: |
| 194 last_simulate_ = HSimulate::cast(instr); | 198 last_simulate_ = HSimulate::cast(instr); |
| 195 went_live_since_last_simulate_->Clear(); | 199 went_live_since_last_simulate_->Clear(); |
| 196 break; | 200 break; |
| 197 default: | 201 default: |
| 198 break; | 202 break; |
| 199 } | 203 } |
| 200 } | 204 } |
| 201 | 205 |
| 202 | 206 |
| 203 void EnvironmentSlotLivenessAnalyzer::AnalyzeAndTrim() { | 207 void EnvironmentSlotLivenessAnalyzer::Run() { |
| 204 HPhase phase("H_EnvironmentLivenessAnalysis", graph_); | 208 HPhase phase("H_EnvironmentLivenessAnalysis", graph_); |
| 205 if (maximum_environment_size_ == 0) return; | 209 if (maximum_environment_size_ == 0) return; |
| 206 | 210 |
| 207 // Main iteration. Compute liveness of environment slots, and store it | 211 // Main iteration. Compute liveness of environment slots, and store it |
| 208 // for each block until it doesn't change any more. For efficiency, visit | 212 // for each block until it doesn't change any more. For efficiency, visit |
| 209 // blocks in reverse order and walk backwards through each block. We | 213 // blocks in reverse order and walk backwards through each block. We |
| 210 // need several iterations to propagate liveness through nested loops. | 214 // need several iterations to propagate liveness through nested loops. |
| 211 BitVector* live = new(zone()) BitVector(maximum_environment_size_, zone()); | 215 BitVector* live = new(phase_zone()) BitVector(maximum_environment_size_, |
| 212 BitVector* worklist = new(zone()) BitVector(block_count_, zone()); | 216 phase_zone()); |
| 217 BitVector* worklist = new(phase_zone()) BitVector(block_count_, phase_zone()); | |
| 213 for (int i = 0; i < block_count_; ++i) { | 218 for (int i = 0; i < block_count_; ++i) { |
| 214 worklist->Add(i); | 219 worklist->Add(i); |
| 215 } | 220 } |
| 216 while (!worklist->IsEmpty()) { | 221 while (!worklist->IsEmpty()) { |
| 217 for (int block_id = block_count_ - 1; block_id >= 0; --block_id) { | 222 for (int block_id = block_count_ - 1; block_id >= 0; --block_id) { |
| 218 if (!worklist->Contains(block_id)) { | 223 if (!worklist->Contains(block_id)) { |
| 219 continue; | 224 continue; |
| 220 } | 225 } |
| 221 worklist->Remove(block_id); | 226 worklist->Remove(block_id); |
| 222 last_simulate_ = NULL; | 227 last_simulate_ = NULL; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 ZapEnvironmentSlotsInSuccessors(block, live); | 263 ZapEnvironmentSlotsInSuccessors(block, live); |
| 259 } | 264 } |
| 260 | 265 |
| 261 // Finally, remove the HEnvironment{Bind,Lookup} markers. | 266 // Finally, remove the HEnvironment{Bind,Lookup} markers. |
| 262 for (int i = 0; i < markers_->length(); ++i) { | 267 for (int i = 0; i < markers_->length(); ++i) { |
| 263 markers_->at(i)->DeleteAndReplaceWith(NULL); | 268 markers_->at(i)->DeleteAndReplaceWith(NULL); |
| 264 } | 269 } |
| 265 } | 270 } |
| 266 | 271 |
| 267 } } // namespace v8::internal | 272 } } // namespace v8::internal |
| OLD | NEW |