| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 end_ = end; | 161 end_ = end; |
| 162 for (HSuccessorIterator it(end); !it.Done(); it.Advance()) { | 162 for (HSuccessorIterator it(end); !it.Done(); it.Advance()) { |
| 163 it.Current()->RegisterPredecessor(this); | 163 it.Current()->RegisterPredecessor(this); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 void HBasicBlock::Goto(HBasicBlock* block, FunctionState* state) { | 168 void HBasicBlock::Goto(HBasicBlock* block, FunctionState* state) { |
| 169 bool drop_extra = state != NULL && | 169 bool drop_extra = state != NULL && |
| 170 state->inlining_kind() == DROP_EXTRA_ON_RETURN; | 170 state->inlining_kind() == DROP_EXTRA_ON_RETURN; |
| 171 bool arguments_pushed = state != NULL && state->arguments_pushed(); |
| 171 | 172 |
| 172 if (block->IsInlineReturnTarget()) { | 173 if (block->IsInlineReturnTarget()) { |
| 173 AddInstruction(new(zone()) HLeaveInlined()); | 174 AddInstruction(new(zone()) HLeaveInlined(arguments_pushed)); |
| 174 last_environment_ = last_environment()->DiscardInlined(drop_extra); | 175 last_environment_ = last_environment()->DiscardInlined(drop_extra); |
| 175 } | 176 } |
| 176 | 177 |
| 177 AddSimulate(BailoutId::None()); | 178 AddSimulate(BailoutId::None()); |
| 178 HGoto* instr = new(zone()) HGoto(block); | 179 HGoto* instr = new(zone()) HGoto(block); |
| 179 Finish(instr); | 180 Finish(instr); |
| 180 } | 181 } |
| 181 | 182 |
| 182 | 183 |
| 183 void HBasicBlock::AddLeaveInlined(HValue* return_value, | 184 void HBasicBlock::AddLeaveInlined(HValue* return_value, |
| 184 FunctionState* state) { | 185 FunctionState* state) { |
| 185 HBasicBlock* target = state->function_return(); | 186 HBasicBlock* target = state->function_return(); |
| 186 bool drop_extra = state->inlining_kind() == DROP_EXTRA_ON_RETURN; | 187 bool drop_extra = state->inlining_kind() == DROP_EXTRA_ON_RETURN; |
| 188 bool arguments_pushed = state->arguments_pushed(); |
| 187 | 189 |
| 188 ASSERT(target->IsInlineReturnTarget()); | 190 ASSERT(target->IsInlineReturnTarget()); |
| 189 ASSERT(return_value != NULL); | 191 ASSERT(return_value != NULL); |
| 190 AddInstruction(new(zone()) HLeaveInlined()); | 192 AddInstruction(new(zone()) HLeaveInlined(arguments_pushed)); |
| 191 last_environment_ = last_environment()->DiscardInlined(drop_extra); | 193 last_environment_ = last_environment()->DiscardInlined(drop_extra); |
| 192 last_environment()->Push(return_value); | 194 last_environment()->Push(return_value); |
| 193 AddSimulate(BailoutId::None()); | 195 AddSimulate(BailoutId::None()); |
| 194 HGoto* instr = new(zone()) HGoto(target); | 196 HGoto* instr = new(zone()) HGoto(target); |
| 195 Finish(instr); | 197 Finish(instr); |
| 196 } | 198 } |
| 197 | 199 |
| 198 | 200 |
| 199 void HBasicBlock::SetInitialEnvironment(HEnvironment* env) { | 201 void HBasicBlock::SetInitialEnvironment(HEnvironment* env) { |
| 200 ASSERT(!HasEnvironment()); | 202 ASSERT(!HasEnvironment()); |
| (...skipping 3222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3423 HValue* IndexBase() const { return index_base_; } | 3425 HValue* IndexBase() const { return index_base_; } |
| 3424 HValue* Length() const { return length_; } | 3426 HValue* Length() const { return length_; } |
| 3425 | 3427 |
| 3426 uint32_t Hash() { | 3428 uint32_t Hash() { |
| 3427 return static_cast<uint32_t>(index_base_->Hashcode() ^ length_->Hashcode()); | 3429 return static_cast<uint32_t>(index_base_->Hashcode() ^ length_->Hashcode()); |
| 3428 } | 3430 } |
| 3429 | 3431 |
| 3430 static BoundsCheckKey* Create(Zone* zone, | 3432 static BoundsCheckKey* Create(Zone* zone, |
| 3431 HBoundsCheck* check, | 3433 HBoundsCheck* check, |
| 3432 int32_t* offset) { | 3434 int32_t* offset) { |
| 3433 if (!check->index()->representation().IsInteger32()) return NULL; | |
| 3434 | |
| 3435 HValue* index_base = NULL; | 3435 HValue* index_base = NULL; |
| 3436 HConstant* constant = NULL; | 3436 HConstant* constant = NULL; |
| 3437 bool is_sub = false; | 3437 bool is_sub = false; |
| 3438 | 3438 |
| 3439 if (check->index()->IsAdd()) { | 3439 if (check->index()->IsAdd()) { |
| 3440 HAdd* index = HAdd::cast(check->index()); | 3440 HAdd* index = HAdd::cast(check->index()); |
| 3441 if (index->left()->IsConstant()) { | 3441 if (index->left()->IsConstant()) { |
| 3442 constant = HConstant::cast(index->left()); | 3442 constant = HConstant::cast(index->left()); |
| 3443 index_base = index->right(); | 3443 index_base = index->right(); |
| 3444 } else if (index->right()->IsConstant()) { | 3444 } else if (index->right()->IsConstant()) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3675 if (!i->IsBoundsCheck()) continue; | 3675 if (!i->IsBoundsCheck()) continue; |
| 3676 | 3676 |
| 3677 HBoundsCheck* check = HBoundsCheck::cast(i); | 3677 HBoundsCheck* check = HBoundsCheck::cast(i); |
| 3678 check->ReplaceAllUsesWith(check->index()); | 3678 check->ReplaceAllUsesWith(check->index()); |
| 3679 | 3679 |
| 3680 if (!FLAG_array_bounds_checks_elimination) continue; | 3680 if (!FLAG_array_bounds_checks_elimination) continue; |
| 3681 | 3681 |
| 3682 int32_t offset; | 3682 int32_t offset; |
| 3683 BoundsCheckKey* key = | 3683 BoundsCheckKey* key = |
| 3684 BoundsCheckKey::Create(zone(), check, &offset); | 3684 BoundsCheckKey::Create(zone(), check, &offset); |
| 3685 if (key == NULL) continue; | |
| 3686 BoundsCheckBbData** data_p = table->LookupOrInsert(key, zone()); | 3685 BoundsCheckBbData** data_p = table->LookupOrInsert(key, zone()); |
| 3687 BoundsCheckBbData* data = *data_p; | 3686 BoundsCheckBbData* data = *data_p; |
| 3688 if (data == NULL) { | 3687 if (data == NULL) { |
| 3689 bb_data_list = new(zone()) BoundsCheckBbData(key, | 3688 bb_data_list = new(zone()) BoundsCheckBbData(key, |
| 3690 offset, | 3689 offset, |
| 3691 offset, | 3690 offset, |
| 3692 bb, | 3691 bb, |
| 3693 check, | 3692 check, |
| 3694 check, | 3693 check, |
| 3695 bb_data_list, | 3694 bb_data_list, |
| (...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6544 | 6543 |
| 6545 | 6544 |
| 6546 void HGraphBuilder::EnsureArgumentsArePushedForAccess() { | 6545 void HGraphBuilder::EnsureArgumentsArePushedForAccess() { |
| 6547 // Outermost function already has arguments on the stack. | 6546 // Outermost function already has arguments on the stack. |
| 6548 if (function_state()->outer() == NULL) return; | 6547 if (function_state()->outer() == NULL) return; |
| 6549 | 6548 |
| 6550 if (function_state()->arguments_pushed()) return; | 6549 if (function_state()->arguments_pushed()) return; |
| 6551 | 6550 |
| 6552 // Push arguments when entering inlined function. | 6551 // Push arguments when entering inlined function. |
| 6553 HEnterInlined* entry = function_state()->entry(); | 6552 HEnterInlined* entry = function_state()->entry(); |
| 6554 entry->set_arguments_pushed(); | |
| 6555 | 6553 |
| 6556 ZoneList<HValue*>* arguments_values = entry->arguments_values(); | 6554 ZoneList<HValue*>* arguments_values = entry->arguments_values(); |
| 6557 | 6555 |
| 6558 HInstruction* insert_after = entry; | 6556 HInstruction* insert_after = entry; |
| 6559 for (int i = 0; i < arguments_values->length(); i++) { | 6557 for (int i = 0; i < arguments_values->length(); i++) { |
| 6560 HValue* argument = arguments_values->at(i); | 6558 HValue* argument = arguments_values->at(i); |
| 6561 HInstruction* push_argument = new(zone()) HPushArgument(argument); | 6559 HInstruction* push_argument = new(zone()) HPushArgument(argument); |
| 6562 push_argument->InsertAfter(insert_after); | 6560 push_argument->InsertAfter(insert_after); |
| 6563 insert_after = push_argument; | 6561 insert_after = push_argument; |
| 6564 } | 6562 } |
| (...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9387 Handle<JSFunction> closure, | 9385 Handle<JSFunction> closure, |
| 9388 Zone* zone) | 9386 Zone* zone) |
| 9389 : closure_(closure), | 9387 : closure_(closure), |
| 9390 values_(0, zone), | 9388 values_(0, zone), |
| 9391 assigned_variables_(4, zone), | 9389 assigned_variables_(4, zone), |
| 9392 frame_type_(JS_FUNCTION), | 9390 frame_type_(JS_FUNCTION), |
| 9393 parameter_count_(0), | 9391 parameter_count_(0), |
| 9394 specials_count_(1), | 9392 specials_count_(1), |
| 9395 local_count_(0), | 9393 local_count_(0), |
| 9396 outer_(outer), | 9394 outer_(outer), |
| 9397 entry_(NULL), | |
| 9398 pop_count_(0), | 9395 pop_count_(0), |
| 9399 push_count_(0), | 9396 push_count_(0), |
| 9400 ast_id_(BailoutId::None()), | 9397 ast_id_(BailoutId::None()), |
| 9401 zone_(zone) { | 9398 zone_(zone) { |
| 9402 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); | 9399 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); |
| 9403 } | 9400 } |
| 9404 | 9401 |
| 9405 | 9402 |
| 9406 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) | 9403 HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) |
| 9407 : values_(0, zone), | 9404 : values_(0, zone), |
| 9408 assigned_variables_(0, zone), | 9405 assigned_variables_(0, zone), |
| 9409 frame_type_(JS_FUNCTION), | 9406 frame_type_(JS_FUNCTION), |
| 9410 parameter_count_(0), | 9407 parameter_count_(0), |
| 9411 specials_count_(1), | 9408 specials_count_(1), |
| 9412 local_count_(0), | 9409 local_count_(0), |
| 9413 outer_(NULL), | 9410 outer_(NULL), |
| 9414 entry_(NULL), | |
| 9415 pop_count_(0), | 9411 pop_count_(0), |
| 9416 push_count_(0), | 9412 push_count_(0), |
| 9417 ast_id_(other->ast_id()), | 9413 ast_id_(other->ast_id()), |
| 9418 zone_(zone) { | 9414 zone_(zone) { |
| 9419 Initialize(other); | 9415 Initialize(other); |
| 9420 } | 9416 } |
| 9421 | 9417 |
| 9422 | 9418 |
| 9423 HEnvironment::HEnvironment(HEnvironment* outer, | 9419 HEnvironment::HEnvironment(HEnvironment* outer, |
| 9424 Handle<JSFunction> closure, | 9420 Handle<JSFunction> closure, |
| 9425 FrameType frame_type, | 9421 FrameType frame_type, |
| 9426 int arguments, | 9422 int arguments, |
| 9427 Zone* zone) | 9423 Zone* zone) |
| 9428 : closure_(closure), | 9424 : closure_(closure), |
| 9429 values_(arguments, zone), | 9425 values_(arguments, zone), |
| 9430 assigned_variables_(0, zone), | 9426 assigned_variables_(0, zone), |
| 9431 frame_type_(frame_type), | 9427 frame_type_(frame_type), |
| 9432 parameter_count_(arguments), | 9428 parameter_count_(arguments), |
| 9433 local_count_(0), | 9429 local_count_(0), |
| 9434 outer_(outer), | 9430 outer_(outer), |
| 9435 entry_(NULL), | |
| 9436 pop_count_(0), | 9431 pop_count_(0), |
| 9437 push_count_(0), | 9432 push_count_(0), |
| 9438 ast_id_(BailoutId::None()), | 9433 ast_id_(BailoutId::None()), |
| 9439 zone_(zone) { | 9434 zone_(zone) { |
| 9440 } | 9435 } |
| 9441 | 9436 |
| 9442 | 9437 |
| 9443 void HEnvironment::Initialize(int parameter_count, | 9438 void HEnvironment::Initialize(int parameter_count, |
| 9444 int local_count, | 9439 int local_count, |
| 9445 int stack_height) { | 9440 int stack_height) { |
| 9446 parameter_count_ = parameter_count; | 9441 parameter_count_ = parameter_count; |
| 9447 local_count_ = local_count; | 9442 local_count_ = local_count; |
| 9448 | 9443 |
| 9449 // Avoid reallocating the temporaries' backing store on the first Push. | 9444 // Avoid reallocating the temporaries' backing store on the first Push. |
| 9450 int total = parameter_count + specials_count_ + local_count + stack_height; | 9445 int total = parameter_count + specials_count_ + local_count + stack_height; |
| 9451 values_.Initialize(total + 4, zone()); | 9446 values_.Initialize(total + 4, zone()); |
| 9452 for (int i = 0; i < total; ++i) values_.Add(NULL, zone()); | 9447 for (int i = 0; i < total; ++i) values_.Add(NULL, zone()); |
| 9453 } | 9448 } |
| 9454 | 9449 |
| 9455 | 9450 |
| 9456 void HEnvironment::Initialize(const HEnvironment* other) { | 9451 void HEnvironment::Initialize(const HEnvironment* other) { |
| 9457 closure_ = other->closure(); | 9452 closure_ = other->closure(); |
| 9458 values_.AddAll(other->values_, zone()); | 9453 values_.AddAll(other->values_, zone()); |
| 9459 assigned_variables_.AddAll(other->assigned_variables_, zone()); | 9454 assigned_variables_.AddAll(other->assigned_variables_, zone()); |
| 9460 frame_type_ = other->frame_type_; | 9455 frame_type_ = other->frame_type_; |
| 9461 parameter_count_ = other->parameter_count_; | 9456 parameter_count_ = other->parameter_count_; |
| 9462 local_count_ = other->local_count_; | 9457 local_count_ = other->local_count_; |
| 9463 if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy. | 9458 if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy. |
| 9464 entry_ = other->entry_; | |
| 9465 pop_count_ = other->pop_count_; | 9459 pop_count_ = other->pop_count_; |
| 9466 push_count_ = other->push_count_; | 9460 push_count_ = other->push_count_; |
| 9467 ast_id_ = other->ast_id_; | 9461 ast_id_ = other->ast_id_; |
| 9468 } | 9462 } |
| 9469 | 9463 |
| 9470 | 9464 |
| 9471 void HEnvironment::AddIncomingEdge(HBasicBlock* block, HEnvironment* other) { | 9465 void HEnvironment::AddIncomingEdge(HBasicBlock* block, HEnvironment* other) { |
| 9472 ASSERT(!block->IsLoopHeader()); | 9466 ASSERT(!block->IsLoopHeader()); |
| 9473 ASSERT(values_.length() == other->values_.length()); | 9467 ASSERT(values_.length() == other->values_.length()); |
| 9474 | 9468 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9983 } | 9977 } |
| 9984 } | 9978 } |
| 9985 | 9979 |
| 9986 #ifdef DEBUG | 9980 #ifdef DEBUG |
| 9987 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9981 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 9988 if (allocator_ != NULL) allocator_->Verify(); | 9982 if (allocator_ != NULL) allocator_->Verify(); |
| 9989 #endif | 9983 #endif |
| 9990 } | 9984 } |
| 9991 | 9985 |
| 9992 } } // namespace v8::internal | 9986 } } // namespace v8::internal |
| OLD | NEW |