OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 info_(info), | 41 info_(info), |
42 descriptor_(info->code_stub()), | 42 descriptor_(info->code_stub()), |
43 context_(NULL) { | 43 context_(NULL) { |
44 int parameter_count = GetParameterCount(); | 44 int parameter_count = GetParameterCount(); |
45 parameters_.Reset(new HParameter*[parameter_count]); | 45 parameters_.Reset(new HParameter*[parameter_count]); |
46 } | 46 } |
47 virtual bool BuildGraph(); | 47 virtual bool BuildGraph(); |
48 | 48 |
49 protected: | 49 protected: |
50 virtual HValue* BuildCodeStub() = 0; | 50 virtual HValue* BuildCodeStub() = 0; |
51 int GetParameterCount() const { | 51 int GetParameterCount() const { return descriptor_.GetParameterCount(); } |
| 52 int GetRegisterParameterCount() const { |
52 return descriptor_.GetRegisterParameterCount(); | 53 return descriptor_.GetRegisterParameterCount(); |
53 } | 54 } |
54 HParameter* GetParameter(int parameter) { | 55 HParameter* GetParameter(int parameter) { |
55 DCHECK(parameter < GetParameterCount()); | 56 DCHECK(parameter < GetParameterCount()); |
56 return parameters_[parameter]; | 57 return parameters_[parameter]; |
57 } | 58 } |
58 Representation GetParameterRepresentation(int parameter) { | 59 Representation GetParameterRepresentation(int parameter) { |
59 return RepresentationFromType(descriptor_.GetParameterType(parameter)); | 60 return RepresentationFromType(descriptor_.GetParameterType(parameter)); |
60 } | 61 } |
61 bool IsParameterCountRegister(int index) const { | 62 bool IsParameterCountRegister(int index) const { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 isolate()->counters()->code_stubs()->Increment(); | 132 isolate()->counters()->code_stubs()->Increment(); |
132 | 133 |
133 if (FLAG_trace_hydrogen_stubs) { | 134 if (FLAG_trace_hydrogen_stubs) { |
134 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); | 135 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); |
135 PrintF("-----------------------------------------------------------\n"); | 136 PrintF("-----------------------------------------------------------\n"); |
136 PrintF("Compiling stub %s using hydrogen\n", name); | 137 PrintF("Compiling stub %s using hydrogen\n", name); |
137 isolate()->GetHTracer()->TraceCompilation(info()); | 138 isolate()->GetHTracer()->TraceCompilation(info()); |
138 } | 139 } |
139 | 140 |
140 int param_count = GetParameterCount(); | 141 int param_count = GetParameterCount(); |
| 142 int register_param_count = GetRegisterParameterCount(); |
141 HEnvironment* start_environment = graph()->start_environment(); | 143 HEnvironment* start_environment = graph()->start_environment(); |
142 HBasicBlock* next_block = CreateBasicBlock(start_environment); | 144 HBasicBlock* next_block = CreateBasicBlock(start_environment); |
143 Goto(next_block); | 145 Goto(next_block); |
144 next_block->SetJoinId(BailoutId::StubEntry()); | 146 next_block->SetJoinId(BailoutId::StubEntry()); |
145 set_current_block(next_block); | 147 set_current_block(next_block); |
146 | 148 |
147 bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid(); | 149 bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid(); |
148 HInstruction* stack_parameter_count = NULL; | 150 HInstruction* stack_parameter_count = NULL; |
149 for (int i = 0; i < param_count; ++i) { | 151 for (int i = 0; i < param_count; ++i) { |
150 Representation r = GetParameterRepresentation(i); | 152 Representation r = GetParameterRepresentation(i); |
151 HParameter* param = Add<HParameter>(i, | 153 HParameter* param; |
152 HParameter::REGISTER_PARAMETER, r); | 154 if (i >= register_param_count) { |
| 155 param = Add<HParameter>(i - register_param_count, |
| 156 HParameter::STACK_PARAMETER, r); |
| 157 } else { |
| 158 param = Add<HParameter>(i, HParameter::REGISTER_PARAMETER, r); |
| 159 } |
153 start_environment->Bind(i, param); | 160 start_environment->Bind(i, param); |
154 parameters_[i] = param; | 161 parameters_[i] = param; |
155 if (IsParameterCountRegister(i)) { | 162 if (i < register_param_count && IsParameterCountRegister(i)) { |
156 param->set_type(HType::Smi()); | 163 param->set_type(HType::Smi()); |
157 stack_parameter_count = param; | 164 stack_parameter_count = param; |
158 arguments_length_ = stack_parameter_count; | 165 arguments_length_ = stack_parameter_count; |
159 } | 166 } |
160 } | 167 } |
161 | 168 |
162 DCHECK(!runtime_stack_params || arguments_length_ != NULL); | 169 DCHECK(!runtime_stack_params || arguments_length_ != NULL); |
163 if (!runtime_stack_params) { | 170 if (!runtime_stack_params) { |
164 stack_parameter_count = graph()->GetConstantMinus1(); | 171 stack_parameter_count = |
| 172 Add<HConstant>(param_count - register_param_count - 1); |
| 173 // graph()->GetConstantMinus1(); |
165 arguments_length_ = graph()->GetConstant0(); | 174 arguments_length_ = graph()->GetConstant0(); |
166 } | 175 } |
167 | 176 |
168 context_ = Add<HContext>(); | 177 context_ = Add<HContext>(); |
169 start_environment->BindContext(context_); | 178 start_environment->BindContext(context_); |
170 | 179 |
171 Add<HSimulate>(BailoutId::StubEntry()); | 180 Add<HSimulate>(BailoutId::StubEntry()); |
172 | 181 |
173 NoObservableSideEffectsScope no_effects(this); | 182 NoObservableSideEffectsScope no_effects(this); |
174 | 183 |
(...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2475 return Pop(); | 2484 return Pop(); |
2476 } | 2485 } |
2477 | 2486 |
2478 | 2487 |
2479 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2488 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
2480 return DoGenerateCode(this); | 2489 return DoGenerateCode(this); |
2481 } | 2490 } |
2482 | 2491 |
2483 } // namespace internal | 2492 } // namespace internal |
2484 } // namespace v8 | 2493 } // namespace v8 |
OLD | NEW |