| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); | 122 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); |
| 123 AddInstruction(param); | 123 AddInstruction(param); |
| 124 start_environment->Bind(i, param); | 124 start_environment->Bind(i, param); |
| 125 parameters_[i] = param; | 125 parameters_[i] = param; |
| 126 } | 126 } |
| 127 | 127 |
| 128 HInstruction* stack_parameter_count; | 128 HInstruction* stack_parameter_count; |
| 129 if (descriptor_->stack_parameter_count_ != NULL) { | 129 if (descriptor_->stack_parameter_count_ != NULL) { |
| 130 ASSERT(descriptor_->environment_length() == (param_count + 1)); | 130 ASSERT(descriptor_->environment_length() == (param_count + 1)); |
| 131 stack_parameter_count = new(zone) HParameter(param_count, | 131 stack_parameter_count = new(zone) HParameter(param_count, |
| 132 HParameter::REGISTER_PARAMETER); | 132 HParameter::REGISTER_PARAMETER, |
| 133 Representation::Integer32()); |
| 133 // it's essential to bind this value to the environment in case of deopt | 134 // it's essential to bind this value to the environment in case of deopt |
| 134 start_environment->Bind(param_count, stack_parameter_count); | 135 start_environment->Bind(param_count, stack_parameter_count); |
| 135 AddInstruction(stack_parameter_count); | 136 AddInstruction(stack_parameter_count); |
| 136 arguments_length_ = stack_parameter_count; | 137 arguments_length_ = stack_parameter_count; |
| 137 } else { | 138 } else { |
| 138 ASSERT(descriptor_->environment_length() == param_count); | 139 ASSERT(descriptor_->environment_length() == param_count); |
| 139 stack_parameter_count = graph()->GetConstantMinus1(); | 140 stack_parameter_count = graph()->GetConstantMinus1(); |
| 140 arguments_length_ = graph()->GetConstant0(); | 141 arguments_length_ = graph()->GetConstant0(); |
| 141 } | 142 } |
| 142 | 143 |
| 143 context_ = new(zone) HContext(); | 144 context_ = new(zone) HContext(); |
| 144 AddInstruction(context_); | 145 AddInstruction(context_); |
| 145 start_environment->BindContext(context_); | 146 start_environment->BindContext(context_); |
| 146 | 147 |
| 147 AddSimulate(BailoutId::StubEntry()); | 148 AddSimulate(BailoutId::StubEntry()); |
| 148 | 149 |
| 149 HValue* return_value = BuildCodeStub(); | 150 HValue* return_value = BuildCodeStub(); |
| 151 |
| 152 // We might have extra expressions to pop from the stack in addition to the |
| 153 // arguments above |
| 154 HInstruction* stack_pop_count = stack_parameter_count; |
| 155 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { |
| 156 HInstruction* amount = graph()->GetConstant1(); |
| 157 stack_pop_count = AddInstruction( |
| 158 HAdd::New(zone, context_, stack_parameter_count, amount)); |
| 159 stack_pop_count->ChangeRepresentation(Representation::Integer32()); |
| 160 stack_pop_count->ClearFlag(HValue::kCanOverflow); |
| 161 } |
| 162 |
| 150 HReturn* hreturn_instruction = new(zone) HReturn(return_value, | 163 HReturn* hreturn_instruction = new(zone) HReturn(return_value, |
| 151 context_, | 164 context_, |
| 152 stack_parameter_count); | 165 stack_pop_count); |
| 153 current_block()->Finish(hreturn_instruction); | 166 current_block()->Finish(hreturn_instruction); |
| 154 return true; | 167 return true; |
| 155 } | 168 } |
| 156 | 169 |
| 170 |
| 157 template <class Stub> | 171 template <class Stub> |
| 158 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { | 172 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { |
| 159 public: | 173 public: |
| 160 explicit CodeStubGraphBuilder(Stub* stub) | 174 explicit CodeStubGraphBuilder(Stub* stub) |
| 161 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} | 175 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} |
| 162 | 176 |
| 163 protected: | 177 protected: |
| 164 virtual HValue* BuildCodeStub(); | 178 virtual HValue* BuildCodeStub(); |
| 165 Stub* casted_stub() { return static_cast<Stub*>(stub()); } | 179 Stub* casted_stub() { return static_cast<Stub*>(stub()); } |
| 166 }; | 180 }; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 current_block()->MarkAsDeoptimizing(); | 373 current_block()->MarkAsDeoptimizing(); |
| 360 return GetParameter(0); | 374 return GetParameter(0); |
| 361 } | 375 } |
| 362 | 376 |
| 363 | 377 |
| 364 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 378 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
| 365 return DoGenerateCode(this); | 379 return DoGenerateCode(this); |
| 366 } | 380 } |
| 367 | 381 |
| 368 } } // namespace v8::internal | 382 } } // namespace v8::internal |
| OLD | NEW |