| 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/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
| 6 #include "src/compiler/scheduler.h" | 6 #include "src/compiler/scheduler.h" |
| 7 #include "src/compiler/structured-machine-assembler.h" | 7 #include "src/compiler/structured-machine-assembler.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 void StructuredMachineAssembler::Merge(EnvironmentVector* environments, | 206 void StructuredMachineAssembler::Merge(EnvironmentVector* environments, |
| 207 int truncate_at) { | 207 int truncate_at) { |
| 208 DCHECK(current_environment_ == NULL || current_environment_->is_dead_); | 208 DCHECK(current_environment_ == NULL || current_environment_->is_dead_); |
| 209 Environment* next = new (zone()) Environment(zone(), NULL, false); | 209 Environment* next = new (zone()) Environment(zone(), NULL, false); |
| 210 current_environment_ = next; | 210 current_environment_ = next; |
| 211 size_t n_vars = number_of_variables_; | 211 size_t n_vars = number_of_variables_; |
| 212 NodeVector& vars = next->variables_; | 212 NodeVector& vars = next->variables_; |
| 213 vars.reserve(n_vars); | 213 vars.reserve(n_vars); |
| 214 Node** scratch = NULL; | 214 Node** scratch = NULL; |
| 215 size_t n_envs = environments->size(); | 215 size_t n_envs = environments->size(); |
| 216 Environment** live_environments = reinterpret_cast<Environment**>( | 216 Environment** live_environments = zone()->NewArray<Environment*>(n_envs); |
| 217 alloca(sizeof(environments->at(0)) * n_envs)); | |
| 218 size_t n_live = 0; | 217 size_t n_live = 0; |
| 219 for (size_t i = 0; i < n_envs; i++) { | 218 for (size_t i = 0; i < n_envs; i++) { |
| 220 if (environments->at(i)->is_dead_) continue; | 219 if (environments->at(i)->is_dead_) continue; |
| 221 live_environments[n_live++] = environments->at(i); | 220 live_environments[n_live++] = environments->at(i); |
| 222 } | 221 } |
| 223 n_envs = n_live; | 222 n_envs = n_live; |
| 224 if (n_live == 0) next->is_dead_ = true; | 223 if (n_live == 0) next->is_dead_ = true; |
| 225 if (!next->is_dead_) { | 224 if (!next->is_dead_) { |
| 226 next->block_ = schedule()->NewBasicBlock(); | 225 next->block_ = schedule()->NewBasicBlock(); |
| 227 } | 226 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 243 if (val == resolved) continue; | 242 if (val == resolved) continue; |
| 244 if (i != 0) break; | 243 if (i != 0) break; |
| 245 resolved = val; | 244 resolved = val; |
| 246 } | 245 } |
| 247 // Have to generate a phi. | 246 // Have to generate a phi. |
| 248 if (i < n_envs) { | 247 if (i < n_envs) { |
| 249 // All values thus far uninitialized, variable used out of scope. | 248 // All values thus far uninitialized, variable used out of scope. |
| 250 CHECK(resolved != NULL); | 249 CHECK(resolved != NULL); |
| 251 // Init scratch buffer. | 250 // Init scratch buffer. |
| 252 if (scratch == NULL) { | 251 if (scratch == NULL) { |
| 253 scratch = static_cast<Node**>(alloca(n_envs * sizeof(resolved))); | 252 scratch = zone()->NewArray<Node*>(n_envs); |
| 254 } | 253 } |
| 255 for (size_t k = 0; k < i; k++) { | 254 for (size_t k = 0; k < i; k++) { |
| 256 scratch[k] = resolved; | 255 scratch[k] = resolved; |
| 257 } | 256 } |
| 258 for (; i < n_envs; i++) { | 257 for (; i < n_envs; i++) { |
| 259 scratch[i] = live_environments[i]->variables_[j]; | 258 scratch[i] = live_environments[i]->variables_[j]; |
| 260 } | 259 } |
| 261 resolved = graph()->NewNode(common()->Phi(static_cast<int>(n_envs)), | 260 resolved = graph()->NewNode(common()->Phi(static_cast<int>(n_envs)), |
| 262 static_cast<int>(n_envs), scratch); | 261 static_cast<int>(n_envs), scratch); |
| 263 if (next->block_ != NULL) { | 262 if (next->block_ != NULL) { |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 654 } |
| 656 pending_header_merges_.clear(); | 655 pending_header_merges_.clear(); |
| 657 pending_exit_merges_.clear(); | 656 pending_exit_merges_.clear(); |
| 658 header_environment_ = NULL; | 657 header_environment_ = NULL; |
| 659 DCHECK(IsDone()); | 658 DCHECK(IsDone()); |
| 660 } | 659 } |
| 661 | 660 |
| 662 } // namespace compiler | 661 } // namespace compiler |
| 663 } // namespace internal | 662 } // namespace internal |
| 664 } // namespace v8 | 663 } // namespace v8 |
| OLD | NEW |