OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 int pop_count = environment->pop_count(); | 145 int pop_count = environment->pop_count(); |
146 | 146 |
147 HSimulate* instr = | 147 HSimulate* instr = |
148 new(zone()) HSimulate(ast_id, pop_count, zone(), removable); | 148 new(zone()) HSimulate(ast_id, pop_count, zone(), removable); |
149 // Order of pushed values: newest (top of stack) first. This allows | 149 // Order of pushed values: newest (top of stack) first. This allows |
150 // HSimulate::MergeInto() to easily append additional pushed values | 150 // HSimulate::MergeInto() to easily append additional pushed values |
151 // that are older (from further down the stack). | 151 // that are older (from further down the stack). |
152 for (int i = 0; i < push_count; ++i) { | 152 for (int i = 0; i < push_count; ++i) { |
153 instr->AddPushedValue(environment->ExpressionStackAt(i)); | 153 instr->AddPushedValue(environment->ExpressionStackAt(i)); |
154 } | 154 } |
155 for (int i = 0; i < environment->assigned_variables()->length(); ++i) { | 155 for (GrowableBitVector::Iterator it(environment->assigned_variables(), |
156 int index = environment->assigned_variables()->at(i); | 156 zone()); |
| 157 !it.Done(); |
| 158 it.Advance()) { |
| 159 int index = it.Current(); |
157 instr->AddAssignedValue(index, environment->Lookup(index)); | 160 instr->AddAssignedValue(index, environment->Lookup(index)); |
158 } | 161 } |
159 environment->ClearHistory(); | 162 environment->ClearHistory(); |
160 return instr; | 163 return instr; |
161 } | 164 } |
162 | 165 |
163 | 166 |
164 void HBasicBlock::Finish(HControlInstruction* end) { | 167 void HBasicBlock::Finish(HControlInstruction* end) { |
165 ASSERT(!IsFinished()); | 168 ASSERT(!IsFinished()); |
166 AddInstruction(end); | 169 AddInstruction(end); |
(...skipping 9396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9563 #undef CHECK_BAILOUT | 9566 #undef CHECK_BAILOUT |
9564 #undef CHECK_ALIVE | 9567 #undef CHECK_ALIVE |
9565 | 9568 |
9566 | 9569 |
9567 HEnvironment::HEnvironment(HEnvironment* outer, | 9570 HEnvironment::HEnvironment(HEnvironment* outer, |
9568 Scope* scope, | 9571 Scope* scope, |
9569 Handle<JSFunction> closure, | 9572 Handle<JSFunction> closure, |
9570 Zone* zone) | 9573 Zone* zone) |
9571 : closure_(closure), | 9574 : closure_(closure), |
9572 values_(0, zone), | 9575 values_(0, zone), |
9573 assigned_variables_(4, zone), | |
9574 frame_type_(JS_FUNCTION), | 9576 frame_type_(JS_FUNCTION), |
9575 parameter_count_(0), | 9577 parameter_count_(0), |
9576 specials_count_(1), | 9578 specials_count_(1), |
9577 local_count_(0), | 9579 local_count_(0), |
9578 outer_(outer), | 9580 outer_(outer), |
9579 entry_(NULL), | 9581 entry_(NULL), |
9580 pop_count_(0), | 9582 pop_count_(0), |
9581 push_count_(0), | 9583 push_count_(0), |
9582 ast_id_(BailoutId::None()), | 9584 ast_id_(BailoutId::None()), |
9583 zone_(zone) { | 9585 zone_(zone) { |
9584 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); | 9586 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); |
9585 } | 9587 } |
9586 | 9588 |
9587 | 9589 |
9588 HEnvironment::HEnvironment(Zone* zone) | 9590 HEnvironment::HEnvironment(Zone* zone) |
9589 : values_(0, zone), | 9591 : values_(0, zone), |
9590 assigned_variables_(0, zone), | |
9591 frame_type_(STUB), | 9592 frame_type_(STUB), |
9592 parameter_count_(0), | 9593 parameter_count_(0), |
9593 specials_count_(0), | 9594 specials_count_(0), |
9594 local_count_(0), | 9595 local_count_(0), |
9595 outer_(NULL), | 9596 outer_(NULL), |
9596 entry_(NULL), | 9597 entry_(NULL), |
9597 pop_count_(0), | 9598 pop_count_(0), |
9598 push_count_(0), | 9599 push_count_(0), |
9599 ast_id_(BailoutId::None()), | 9600 ast_id_(BailoutId::None()), |
9600 zone_(zone) { | 9601 zone_(zone) { |
9601 Initialize(0, 0, 0); | 9602 Initialize(0, 0, 0); |
9602 } | 9603 } |
9603 | 9604 |
9604 | 9605 |
9605 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) | 9606 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) |
9606 : values_(0, zone), | 9607 : values_(0, zone), |
9607 assigned_variables_(0, zone), | |
9608 frame_type_(JS_FUNCTION), | 9608 frame_type_(JS_FUNCTION), |
9609 parameter_count_(0), | 9609 parameter_count_(0), |
9610 specials_count_(1), | 9610 specials_count_(1), |
9611 local_count_(0), | 9611 local_count_(0), |
9612 outer_(NULL), | 9612 outer_(NULL), |
9613 entry_(NULL), | 9613 entry_(NULL), |
9614 pop_count_(0), | 9614 pop_count_(0), |
9615 push_count_(0), | 9615 push_count_(0), |
9616 ast_id_(other->ast_id()), | 9616 ast_id_(other->ast_id()), |
9617 zone_(zone) { | 9617 zone_(zone) { |
9618 Initialize(other); | 9618 Initialize(other); |
9619 } | 9619 } |
9620 | 9620 |
9621 | 9621 |
9622 HEnvironment::HEnvironment(HEnvironment* outer, | 9622 HEnvironment::HEnvironment(HEnvironment* outer, |
9623 Handle<JSFunction> closure, | 9623 Handle<JSFunction> closure, |
9624 FrameType frame_type, | 9624 FrameType frame_type, |
9625 int arguments, | 9625 int arguments, |
9626 Zone* zone) | 9626 Zone* zone) |
9627 : closure_(closure), | 9627 : closure_(closure), |
9628 values_(arguments, zone), | 9628 values_(arguments, zone), |
9629 assigned_variables_(0, zone), | |
9630 frame_type_(frame_type), | 9629 frame_type_(frame_type), |
9631 parameter_count_(arguments), | 9630 parameter_count_(arguments), |
9632 local_count_(0), | 9631 local_count_(0), |
9633 outer_(outer), | 9632 outer_(outer), |
9634 entry_(NULL), | 9633 entry_(NULL), |
9635 pop_count_(0), | 9634 pop_count_(0), |
9636 push_count_(0), | 9635 push_count_(0), |
9637 ast_id_(BailoutId::None()), | 9636 ast_id_(BailoutId::None()), |
9638 zone_(zone) { | 9637 zone_(zone) { |
9639 } | 9638 } |
9640 | 9639 |
9641 | 9640 |
9642 void HEnvironment::Initialize(int parameter_count, | 9641 void HEnvironment::Initialize(int parameter_count, |
9643 int local_count, | 9642 int local_count, |
9644 int stack_height) { | 9643 int stack_height) { |
9645 parameter_count_ = parameter_count; | 9644 parameter_count_ = parameter_count; |
9646 local_count_ = local_count; | 9645 local_count_ = local_count; |
9647 | 9646 |
9648 // Avoid reallocating the temporaries' backing store on the first Push. | 9647 // Avoid reallocating the temporaries' backing store on the first Push. |
9649 int total = parameter_count + specials_count_ + local_count + stack_height; | 9648 int total = parameter_count + specials_count_ + local_count + stack_height; |
9650 values_.Initialize(total + 4, zone()); | 9649 values_.Initialize(total + 4, zone()); |
9651 for (int i = 0; i < total; ++i) values_.Add(NULL, zone()); | 9650 for (int i = 0; i < total; ++i) values_.Add(NULL, zone()); |
9652 } | 9651 } |
9653 | 9652 |
9654 | 9653 |
9655 void HEnvironment::Initialize(const HEnvironment* other) { | 9654 void HEnvironment::Initialize(const HEnvironment* other) { |
9656 closure_ = other->closure(); | 9655 closure_ = other->closure(); |
9657 values_.AddAll(other->values_, zone()); | 9656 values_.AddAll(other->values_, zone()); |
9658 assigned_variables_.AddAll(other->assigned_variables_, zone()); | 9657 assigned_variables_.Union(other->assigned_variables_, zone()); |
9659 frame_type_ = other->frame_type_; | 9658 frame_type_ = other->frame_type_; |
9660 parameter_count_ = other->parameter_count_; | 9659 parameter_count_ = other->parameter_count_; |
9661 local_count_ = other->local_count_; | 9660 local_count_ = other->local_count_; |
9662 if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy. | 9661 if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy. |
9663 entry_ = other->entry_; | 9662 entry_ = other->entry_; |
9664 pop_count_ = other->pop_count_; | 9663 pop_count_ = other->pop_count_; |
9665 push_count_ = other->push_count_; | 9664 push_count_ = other->push_count_; |
9666 ast_id_ = other->ast_id_; | 9665 ast_id_ = other->ast_id_; |
9667 } | 9666 } |
9668 | 9667 |
(...skipping 23 matching lines...) Expand all Loading... |
9692 phi->AddInput(other->values_[i]); | 9691 phi->AddInput(other->values_[i]); |
9693 this->values_[i] = phi; | 9692 this->values_[i] = phi; |
9694 block->AddPhi(phi); | 9693 block->AddPhi(phi); |
9695 } | 9694 } |
9696 } | 9695 } |
9697 } | 9696 } |
9698 | 9697 |
9699 | 9698 |
9700 void HEnvironment::Bind(int index, HValue* value) { | 9699 void HEnvironment::Bind(int index, HValue* value) { |
9701 ASSERT(value != NULL); | 9700 ASSERT(value != NULL); |
9702 if (!assigned_variables_.Contains(index)) { | 9701 assigned_variables_.Add(index, zone()); |
9703 assigned_variables_.Add(index, zone()); | |
9704 } | |
9705 values_[index] = value; | 9702 values_[index] = value; |
9706 } | 9703 } |
9707 | 9704 |
9708 | 9705 |
9709 bool HEnvironment::HasExpressionAt(int index) const { | 9706 bool HEnvironment::HasExpressionAt(int index) const { |
9710 return index >= parameter_count_ + specials_count_ + local_count_; | 9707 return index >= parameter_count_ + specials_count_ + local_count_; |
9711 } | 9708 } |
9712 | 9709 |
9713 | 9710 |
9714 bool HEnvironment::ExpressionStackIsEmpty() const { | 9711 bool HEnvironment::ExpressionStackIsEmpty() const { |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10201 } | 10198 } |
10202 } | 10199 } |
10203 | 10200 |
10204 #ifdef DEBUG | 10201 #ifdef DEBUG |
10205 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10202 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10206 if (allocator_ != NULL) allocator_->Verify(); | 10203 if (allocator_ != NULL) allocator_->Verify(); |
10207 #endif | 10204 #endif |
10208 } | 10205 } |
10209 | 10206 |
10210 } } // namespace v8::internal | 10207 } } // namespace v8::internal |
OLD | NEW |