| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 isolate()->GetHTracer()->TraceCompilation(&info_); | 143 isolate()->GetHTracer()->TraceCompilation(&info_); |
| 144 } | 144 } |
| 145 | 145 |
| 146 int param_count = descriptor_->register_param_count_; | 146 int param_count = descriptor_->register_param_count_; |
| 147 HEnvironment* start_environment = graph()->start_environment(); | 147 HEnvironment* start_environment = graph()->start_environment(); |
| 148 HBasicBlock* next_block = CreateBasicBlock(start_environment); | 148 HBasicBlock* next_block = CreateBasicBlock(start_environment); |
| 149 Goto(next_block); | 149 Goto(next_block); |
| 150 next_block->SetJoinId(BailoutId::StubEntry()); | 150 next_block->SetJoinId(BailoutId::StubEntry()); |
| 151 set_current_block(next_block); | 151 set_current_block(next_block); |
| 152 | 152 |
| 153 bool runtime_stack_params = descriptor_->stack_parameter_count_.is_valid(); |
| 154 HInstruction* stack_parameter_count = NULL; |
| 153 for (int i = 0; i < param_count; ++i) { | 155 for (int i = 0; i < param_count; ++i) { |
| 154 HParameter* param = | 156 Representation r = descriptor_->IsParameterCountRegister(i) |
| 155 Add<HParameter>(i, HParameter::REGISTER_PARAMETER); | 157 ? Representation::Integer32() |
| 158 : Representation::Tagged(); |
| 159 HParameter* param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r); |
| 156 start_environment->Bind(i, param); | 160 start_environment->Bind(i, param); |
| 157 parameters_[i] = param; | 161 parameters_[i] = param; |
| 162 if (descriptor_->IsParameterCountRegister(i)) { |
| 163 param->set_type(HType::Smi()); |
| 164 stack_parameter_count = param; |
| 165 arguments_length_ = stack_parameter_count; |
| 166 } |
| 158 } | 167 } |
| 159 | 168 |
| 160 HInstruction* stack_parameter_count; | 169 ASSERT(!runtime_stack_params || arguments_length_ != NULL); |
| 161 if (descriptor_->stack_parameter_count_.is_valid()) { | 170 if (!runtime_stack_params) { |
| 162 ASSERT(descriptor_->environment_length() == (param_count + 1)); | |
| 163 stack_parameter_count = New<HParameter>(param_count, | |
| 164 HParameter::REGISTER_PARAMETER, | |
| 165 Representation::Integer32()); | |
| 166 stack_parameter_count->set_type(HType::Smi()); | |
| 167 // It's essential to bind this value to the environment in case of deopt. | |
| 168 AddInstruction(stack_parameter_count); | |
| 169 start_environment->Bind(param_count, stack_parameter_count); | |
| 170 arguments_length_ = stack_parameter_count; | |
| 171 } else { | |
| 172 ASSERT(descriptor_->environment_length() == param_count); | |
| 173 stack_parameter_count = graph()->GetConstantMinus1(); | 171 stack_parameter_count = graph()->GetConstantMinus1(); |
| 174 arguments_length_ = graph()->GetConstant0(); | 172 arguments_length_ = graph()->GetConstant0(); |
| 175 } | 173 } |
| 176 | 174 |
| 177 context_ = Add<HContext>(); | 175 context_ = Add<HContext>(); |
| 178 start_environment->BindContext(context_); | 176 start_environment->BindContext(context_); |
| 179 | 177 |
| 180 Add<HSimulate>(BailoutId::StubEntry()); | 178 Add<HSimulate>(BailoutId::StubEntry()); |
| 181 | 179 |
| 182 NoObservableSideEffectsScope no_effects(this); | 180 NoObservableSideEffectsScope no_effects(this); |
| 183 | 181 |
| 184 HValue* return_value = BuildCodeStub(); | 182 HValue* return_value = BuildCodeStub(); |
| 185 | 183 |
| 186 // We might have extra expressions to pop from the stack in addition to the | 184 // We might have extra expressions to pop from the stack in addition to the |
| 187 // arguments above. | 185 // arguments above. |
| 188 HInstruction* stack_pop_count = stack_parameter_count; | 186 HInstruction* stack_pop_count = stack_parameter_count; |
| 189 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { | 187 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { |
| 190 if (!stack_parameter_count->IsConstant() && | 188 if (!stack_parameter_count->IsConstant() && |
| 191 descriptor_->hint_stack_parameter_count_ < 0) { | 189 descriptor_->hint_stack_parameter_count_ < 0) { |
| 192 HInstruction* amount = graph()->GetConstant1(); | 190 HInstruction* constant_one = graph()->GetConstant1(); |
| 193 stack_pop_count = Add<HAdd>(stack_parameter_count, amount); | 191 stack_pop_count = Add<HAdd>(stack_parameter_count, constant_one); |
| 194 stack_pop_count->ChangeRepresentation(Representation::Integer32()); | |
| 195 stack_pop_count->ClearFlag(HValue::kCanOverflow); | 192 stack_pop_count->ClearFlag(HValue::kCanOverflow); |
| 193 // TODO(mvstanton): verify that stack_parameter_count+1 really fits in a |
| 194 // smi. |
| 196 } else { | 195 } else { |
| 197 int count = descriptor_->hint_stack_parameter_count_; | 196 int count = descriptor_->hint_stack_parameter_count_; |
| 198 stack_pop_count = Add<HConstant>(count); | 197 stack_pop_count = Add<HConstant>(count); |
| 199 } | 198 } |
| 200 } | 199 } |
| 201 | 200 |
| 202 if (current_block() != NULL) { | 201 if (current_block() != NULL) { |
| 203 HReturn* hreturn_instruction = New<HReturn>(return_value, | 202 HReturn* hreturn_instruction = New<HReturn>(return_value, |
| 204 stack_pop_count); | 203 stack_pop_count); |
| 205 FinishCurrentBlock(hreturn_instruction); | 204 FinishCurrentBlock(hreturn_instruction); |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 return js_function; | 1286 return js_function; |
| 1288 } | 1287 } |
| 1289 | 1288 |
| 1290 | 1289 |
| 1291 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1290 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
| 1292 return DoGenerateCode(isolate, this); | 1291 return DoGenerateCode(isolate, this); |
| 1293 } | 1292 } |
| 1294 | 1293 |
| 1295 | 1294 |
| 1296 } } // namespace v8::internal | 1295 } } // namespace v8::internal |
| OLD | NEW |