Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1111)

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 12490013: Deoptimizer support for hydrogen stubs that accept a variable number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Deoptimizer and BuildGraph() support for variable argument stubs Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 graph()->set_undefined_constant(undefined_constant); 117 graph()->set_undefined_constant(undefined_constant);
118 118
119 for (int i = 0; i < param_count; ++i) { 119 for (int i = 0; i < param_count; ++i) {
120 HParameter* param = 120 HParameter* param =
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_pop_count;
danno 2013/03/20 21:07:33 nit: Can you define this down where you initially
mvstanton 2013/03/21 11:47:35 Done.
127 HInstruction* stack_parameter_count; 128 HInstruction* stack_parameter_count;
128 if (descriptor_->stack_parameter_count_ != NULL) { 129 if (descriptor_->stack_parameter_count_ != NULL) {
129 ASSERT(descriptor_->environment_length() == (param_count + 1)); 130 ASSERT(descriptor_->environment_length() == (param_count + 1));
130 stack_parameter_count = new(zone) HParameter(param_count, 131 stack_parameter_count = new(zone) HParameter(param_count,
131 HParameter::REGISTER_PARAMETER); 132 HParameter::REGISTER_PARAMETER,
133 Representation::Integer32());
132 // 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
133 start_environment->Bind(param_count, stack_parameter_count); 135 start_environment->Bind(param_count, stack_parameter_count);
134 AddInstruction(stack_parameter_count); 136 AddInstruction(stack_parameter_count);
135 arguments_length_ = stack_parameter_count; 137 arguments_length_ = stack_parameter_count;
136 } else { 138 } else {
137 ASSERT(descriptor_->environment_length() == param_count); 139 ASSERT(descriptor_->environment_length() == param_count);
138 stack_parameter_count = graph()->GetConstantMinus1(); 140 stack_parameter_count = graph()->GetConstantMinus1();
139 arguments_length_ = graph()->GetConstant0(); 141 arguments_length_ = graph()->GetConstant0();
140 } 142 }
141 143
144 stack_pop_count = stack_parameter_count;
145
142 context_ = new(zone) HContext(); 146 context_ = new(zone) HContext();
143 AddInstruction(context_); 147 AddInstruction(context_);
144 start_environment->BindContext(context_); 148 start_environment->BindContext(context_);
145 149
146 AddSimulate(BailoutId::StubEntry()); 150 AddSimulate(BailoutId::StubEntry());
147 151
148 HValue* return_value = BuildCodeStub(); 152 HValue* return_value = BuildCodeStub();
153
154 // We might have extra expressions to pop from the stack in addition to the
155 // arguments above
156 if (descriptor_->acting_as_js_function_) {
157 HInstruction* amount = graph()->GetConstant1();
158 stack_pop_count = AddInstruction(
159 HAdd::New(zone, context_, stack_parameter_count, amount));
160 stack_pop_count->ChangeRepresentation(Representation::Integer32());
161 stack_pop_count->ClearFlag(HValue::kCanOverflow);
162 }
163
149 HReturn* hreturn_instruction = new(zone) HReturn(return_value, 164 HReturn* hreturn_instruction = new(zone) HReturn(return_value,
150 context_, 165 context_,
151 stack_parameter_count); 166 stack_pop_count);
152 current_block()->Finish(hreturn_instruction); 167 current_block()->Finish(hreturn_instruction);
153 return true; 168 return true;
154 } 169 }
155 170
171
156 template <class Stub> 172 template <class Stub>
157 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { 173 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
158 public: 174 public:
159 explicit CodeStubGraphBuilder(Stub* stub) 175 explicit CodeStubGraphBuilder(Stub* stub)
160 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} 176 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {}
161 177
162 protected: 178 protected:
163 virtual HValue* BuildCodeStub(); 179 virtual HValue* BuildCodeStub();
164 Stub* casted_stub() { return static_cast<Stub*>(stub()); } 180 Stub* casted_stub() { return static_cast<Stub*>(stub()); }
165 }; 181 };
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 391 }
376 392
377 393
378 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { 394 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
379 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); 395 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this);
380 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 396 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
381 return chunk->Codegen(Code::COMPILED_STUB); 397 return chunk->Codegen(Code::COMPILED_STUB);
382 } 398 }
383 399
384 } } // namespace v8::internal 400 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/deoptimizer.h » ('j') | src/deoptimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698