| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if (environment->is_dead_) return; | 299 if (environment->is_dead_) return; |
| 300 BasicBlock* true_block = TrampolineFor(true_val->block_); | 300 BasicBlock* true_block = TrampolineFor(true_val->block_); |
| 301 BasicBlock* false_block = TrampolineFor(false_val->block_); | 301 BasicBlock* false_block = TrampolineFor(false_val->block_); |
| 302 schedule()->AddBranch(environment->block_, branch, true_block, false_block); | 302 schedule()->AddBranch(environment->block_, branch, true_block, false_block); |
| 303 } | 303 } |
| 304 | 304 |
| 305 | 305 |
| 306 StructuredMachineAssembler::Environment::Environment(Zone* zone, | 306 StructuredMachineAssembler::Environment::Environment(Zone* zone, |
| 307 BasicBlock* block, | 307 BasicBlock* block, |
| 308 bool is_dead) | 308 bool is_dead) |
| 309 : block_(block), | 309 : block_(block), variables_(zone), is_dead_(is_dead) {} |
| 310 variables_(NodeVector::allocator_type(zone)), | |
| 311 is_dead_(is_dead) {} | |
| 312 | 310 |
| 313 | 311 |
| 314 StructuredMachineAssembler::IfBuilder::IfBuilder( | 312 StructuredMachineAssembler::IfBuilder::IfBuilder( |
| 315 StructuredMachineAssembler* smasm) | 313 StructuredMachineAssembler* smasm) |
| 316 : smasm_(smasm), | 314 : smasm_(smasm), |
| 317 if_clauses_(IfClauses::allocator_type(smasm_->zone())), | 315 if_clauses_(smasm_->zone()), |
| 318 pending_exit_merges_(EnvironmentVector::allocator_type(smasm_->zone())) { | 316 pending_exit_merges_(smasm_->zone()) { |
| 319 DCHECK(smasm_->current_environment_ != NULL); | 317 DCHECK(smasm_->current_environment_ != NULL); |
| 320 PushNewIfClause(); | 318 PushNewIfClause(); |
| 321 DCHECK(!IsDone()); | 319 DCHECK(!IsDone()); |
| 322 } | 320 } |
| 323 | 321 |
| 324 | 322 |
| 325 StructuredMachineAssembler::IfBuilder& | 323 StructuredMachineAssembler::IfBuilder& |
| 326 StructuredMachineAssembler::IfBuilder::If() { | 324 StructuredMachineAssembler::IfBuilder::If() { |
| 327 DCHECK(smasm_->current_environment_ != NULL); | 325 DCHECK(smasm_->current_environment_ != NULL); |
| 328 IfClause* clause = CurrentClause(); | 326 IfClause* clause = CurrentClause(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 static_cast<int>(smasm_->current_environment_->variables_.size()); | 385 static_cast<int>(smasm_->current_environment_->variables_.size()); |
| 388 IfClause* clause = new (smasm_->zone()) IfClause(smasm_->zone(), curr_size); | 386 IfClause* clause = new (smasm_->zone()) IfClause(smasm_->zone(), curr_size); |
| 389 if_clauses_.push_back(clause); | 387 if_clauses_.push_back(clause); |
| 390 } | 388 } |
| 391 | 389 |
| 392 | 390 |
| 393 StructuredMachineAssembler::IfBuilder::IfClause::IfClause( | 391 StructuredMachineAssembler::IfBuilder::IfClause::IfClause( |
| 394 Zone* zone, int initial_environment_size) | 392 Zone* zone, int initial_environment_size) |
| 395 : unresolved_list_tail_(NULL), | 393 : unresolved_list_tail_(NULL), |
| 396 initial_environment_size_(initial_environment_size), | 394 initial_environment_size_(initial_environment_size), |
| 397 expression_states_(ExpressionStates::allocator_type(zone)), | 395 expression_states_(zone), |
| 398 pending_then_merges_(PendingMergeStack::allocator_type(zone)), | 396 pending_then_merges_(zone), |
| 399 pending_else_merges_(PendingMergeStack::allocator_type(zone)), | 397 pending_else_merges_(zone), |
| 400 then_environment_(NULL), | 398 then_environment_(NULL), |
| 401 else_environment_(NULL) { | 399 else_environment_(NULL) { |
| 402 PushNewExpressionState(); | 400 PushNewExpressionState(); |
| 403 } | 401 } |
| 404 | 402 |
| 405 | 403 |
| 406 StructuredMachineAssembler::IfBuilder::PendingMergeStackRange | 404 StructuredMachineAssembler::IfBuilder::PendingMergeStackRange |
| 407 StructuredMachineAssembler::IfBuilder::IfClause::ComputeRelevantMerges( | 405 StructuredMachineAssembler::IfBuilder::IfClause::ComputeRelevantMerges( |
| 408 CombineType combine_type) { | 406 CombineType combine_type) { |
| 409 DCHECK(!expression_states_.empty()); | 407 DCHECK(!expression_states_.empty()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 432 PendingMergeStackRange data = ComputeRelevantMerges(combine_type); | 430 PendingMergeStackRange data = ComputeRelevantMerges(combine_type); |
| 433 DCHECK_EQ(data.merge_stack_->back(), unresolved_list_tail_); | 431 DCHECK_EQ(data.merge_stack_->back(), unresolved_list_tail_); |
| 434 DCHECK(data.size_ > 0); | 432 DCHECK(data.size_ > 0); |
| 435 // TODO(dcarney): assert no new variables created during expression building. | 433 // TODO(dcarney): assert no new variables created during expression building. |
| 436 int truncate_at = initial_environment_size_; | 434 int truncate_at = initial_environment_size_; |
| 437 if (data.size_ == 1) { | 435 if (data.size_ == 1) { |
| 438 // Just copy environment in common case. | 436 // Just copy environment in common case. |
| 439 smasm->current_environment_ = | 437 smasm->current_environment_ = |
| 440 smasm->Copy(unresolved_list_tail_->environment_, truncate_at); | 438 smasm->Copy(unresolved_list_tail_->environment_, truncate_at); |
| 441 } else { | 439 } else { |
| 442 EnvironmentVector environments( | 440 EnvironmentVector environments(smasm->zone()); |
| 443 EnvironmentVector::allocator_type(smasm->zone())); | |
| 444 environments.reserve(data.size_); | 441 environments.reserve(data.size_); |
| 445 CopyEnvironments(data, &environments); | 442 CopyEnvironments(data, &environments); |
| 446 DCHECK(static_cast<int>(environments.size()) == data.size_); | 443 DCHECK(static_cast<int>(environments.size()) == data.size_); |
| 447 smasm->Merge(&environments, truncate_at); | 444 smasm->Merge(&environments, truncate_at); |
| 448 } | 445 } |
| 449 Environment* then_environment = then_environment_; | 446 Environment* then_environment = then_environment_; |
| 450 Environment* else_environment = NULL; | 447 Environment* else_environment = NULL; |
| 451 if (resolution_type == kExpressionDone) { | 448 if (resolution_type == kExpressionDone) { |
| 452 DCHECK(expression_states_.size() == 1); | 449 DCHECK(expression_states_.size() == 1); |
| 453 // Set the current then_ or else_environment_ to the new merged environment. | 450 // Set the current then_ or else_environment_ to the new merged environment. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 pending_exit_merges_.clear(); | 600 pending_exit_merges_.clear(); |
| 604 if_clauses_.clear(); | 601 if_clauses_.clear(); |
| 605 DCHECK(IsDone()); | 602 DCHECK(IsDone()); |
| 606 } | 603 } |
| 607 | 604 |
| 608 | 605 |
| 609 StructuredMachineAssembler::LoopBuilder::LoopBuilder( | 606 StructuredMachineAssembler::LoopBuilder::LoopBuilder( |
| 610 StructuredMachineAssembler* smasm) | 607 StructuredMachineAssembler* smasm) |
| 611 : smasm_(smasm), | 608 : smasm_(smasm), |
| 612 header_environment_(NULL), | 609 header_environment_(NULL), |
| 613 pending_header_merges_(EnvironmentVector::allocator_type(smasm_->zone())), | 610 pending_header_merges_(smasm_->zone()), |
| 614 pending_exit_merges_(EnvironmentVector::allocator_type(smasm_->zone())) { | 611 pending_exit_merges_(smasm_->zone()) { |
| 615 DCHECK(smasm_->current_environment_ != NULL); | 612 DCHECK(smasm_->current_environment_ != NULL); |
| 616 // Create header environment. | 613 // Create header environment. |
| 617 header_environment_ = smasm_->CopyForLoopHeader(smasm_->current_environment_); | 614 header_environment_ = smasm_->CopyForLoopHeader(smasm_->current_environment_); |
| 618 smasm_->AddGoto(smasm_->current_environment_, header_environment_); | 615 smasm_->AddGoto(smasm_->current_environment_, header_environment_); |
| 619 // Create body environment. | 616 // Create body environment. |
| 620 Environment* body = smasm_->Copy(header_environment_); | 617 Environment* body = smasm_->Copy(header_environment_); |
| 621 smasm_->AddGoto(header_environment_, body); | 618 smasm_->AddGoto(header_environment_, body); |
| 622 smasm_->current_environment_ = body; | 619 smasm_->current_environment_ = body; |
| 623 DCHECK(!IsDone()); | 620 DCHECK(!IsDone()); |
| 624 } | 621 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 655 } | 652 } |
| 656 pending_header_merges_.clear(); | 653 pending_header_merges_.clear(); |
| 657 pending_exit_merges_.clear(); | 654 pending_exit_merges_.clear(); |
| 658 header_environment_ = NULL; | 655 header_environment_ = NULL; |
| 659 DCHECK(IsDone()); | 656 DCHECK(IsDone()); |
| 660 } | 657 } |
| 661 | 658 |
| 662 } // namespace compiler | 659 } // namespace compiler |
| 663 } // namespace internal | 660 } // namespace internal |
| 664 } // namespace v8 | 661 } // namespace v8 |
| OLD | NEW |