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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); | 121 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); |
122 AddInstruction(param); | 122 AddInstruction(param); |
123 start_environment->Bind(i, param); | 123 start_environment->Bind(i, param); |
124 parameters_[i] = param; | 124 parameters_[i] = param; |
125 } | 125 } |
126 | 126 |
127 HInstruction* stack_parameter_count; | 127 HInstruction* stack_parameter_count; |
128 if (descriptor_->stack_parameter_count_ != NULL) { | 128 if (descriptor_->stack_parameter_count_ != NULL) { |
129 ASSERT(descriptor_->environment_length() == (param_count + 1)); | 129 ASSERT(descriptor_->environment_length() == (param_count + 1)); |
130 stack_parameter_count = new(zone) HParameter(param_count, | 130 stack_parameter_count = new(zone) HParameter(param_count, |
131 HParameter::REGISTER_PARAMETER); | 131 HParameter::REGISTER_PARAMETER, |
132 Representation::Integer32()); | |
132 // it's essential to bind this value to the environment in case of deopt | 133 // it's essential to bind this value to the environment in case of deopt |
133 start_environment->Bind(param_count, stack_parameter_count); | 134 start_environment->Bind(param_count, stack_parameter_count); |
134 AddInstruction(stack_parameter_count); | 135 AddInstruction(stack_parameter_count); |
135 arguments_length_ = stack_parameter_count; | 136 arguments_length_ = stack_parameter_count; |
136 } else { | 137 } else { |
137 ASSERT(descriptor_->environment_length() == param_count); | 138 ASSERT(descriptor_->environment_length() == param_count); |
138 stack_parameter_count = graph()->GetConstantMinus1(); | 139 stack_parameter_count = graph()->GetConstantMinus1(); |
139 arguments_length_ = graph()->GetConstant0(); | 140 arguments_length_ = graph()->GetConstant0(); |
140 } | 141 } |
141 | 142 |
143 HInstruction* stack_pop_count = stack_parameter_count; | |
danno
2013/04/02 10:39:44
nit: can you please move this right before the if
mvstanton
2013/04/02 11:27:25
Done.
| |
144 | |
142 context_ = new(zone) HContext(); | 145 context_ = new(zone) HContext(); |
143 AddInstruction(context_); | 146 AddInstruction(context_); |
144 start_environment->BindContext(context_); | 147 start_environment->BindContext(context_); |
145 | 148 |
146 AddSimulate(BailoutId::StubEntry()); | 149 AddSimulate(BailoutId::StubEntry()); |
147 | 150 |
148 HValue* return_value = BuildCodeStub(); | 151 HValue* return_value = BuildCodeStub(); |
152 | |
153 // We might have extra expressions to pop from the stack in addition to the | |
154 // arguments above | |
155 if (descriptor_->function_mode_ == JS_FUNCTION_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 | |
149 HReturn* hreturn_instruction = new(zone) HReturn(return_value, | 163 HReturn* hreturn_instruction = new(zone) HReturn(return_value, |
150 context_, | 164 context_, |
151 stack_parameter_count); | 165 stack_pop_count); |
152 current_block()->Finish(hreturn_instruction); | 166 current_block()->Finish(hreturn_instruction); |
153 return true; | 167 return true; |
154 } | 168 } |
155 | 169 |
170 | |
156 template <class Stub> | 171 template <class Stub> |
157 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { | 172 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { |
158 public: | 173 public: |
159 explicit CodeStubGraphBuilder(Stub* stub) | 174 explicit CodeStubGraphBuilder(Stub* stub) |
160 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} | 175 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} |
161 | 176 |
162 protected: | 177 protected: |
163 virtual HValue* BuildCodeStub(); | 178 virtual HValue* BuildCodeStub(); |
164 Stub* casted_stub() { return static_cast<Stub*>(stub()); } | 179 Stub* casted_stub() { return static_cast<Stub*>(stub()); } |
165 }; | 180 }; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 } | 395 } |
381 | 396 |
382 | 397 |
383 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 398 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
384 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); | 399 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); |
385 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | 400 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
386 return chunk->Codegen(Code::COMPILED_STUB); | 401 return chunk->Codegen(Code::COMPILED_STUB); |
387 } | 402 } |
388 | 403 |
389 } } // namespace v8::internal | 404 } } // namespace v8::internal |
OLD | NEW |