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

Side by Side Diff: src/lithium-codegen.cc

Issue 1175963002: Make writing of frame translation platform independent. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 6 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
« no previous file with comments | « src/lithium-codegen.h ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/lithium-codegen.h" 5 #include "src/lithium-codegen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 27 matching lines...) Expand all
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42 42
43 HGraph* LCodeGenBase::graph() const { 43 HGraph* LCodeGenBase::graph() const {
44 return chunk()->graph(); 44 return chunk()->graph();
45 } 45 }
46 46
47 47
48 LCodeGenBase::LCodeGenBase(LChunk* chunk, 48 LCodeGenBase::LCodeGenBase(LChunk* chunk, MacroAssembler* assembler,
49 MacroAssembler* assembler,
50 CompilationInfo* info) 49 CompilationInfo* info)
51 : chunk_(static_cast<LPlatformChunk*>(chunk)), 50 : chunk_(static_cast<LPlatformChunk*>(chunk)),
52 masm_(assembler), 51 masm_(assembler),
53 info_(info), 52 info_(info),
54 zone_(info->zone()), 53 zone_(info->zone()),
55 status_(UNUSED), 54 status_(UNUSED),
56 current_block_(-1), 55 current_block_(-1),
57 current_instruction_(-1), 56 current_instruction_(-1),
58 instructions_(chunk->instructions()), 57 instructions_(chunk->instructions()),
59 last_lazy_deopt_pc_(0) { 58 deoptimization_literals_(8, info->zone()),
60 } 59 last_lazy_deopt_pc_(0) {}
61 60
62 61
63 bool LCodeGenBase::GenerateBody() { 62 bool LCodeGenBase::GenerateBody() {
64 DCHECK(is_generating()); 63 DCHECK(is_generating());
65 bool emit_instructions = true; 64 bool emit_instructions = true;
66 LCodeGen* codegen = static_cast<LCodeGen*>(this); 65 LCodeGen* codegen = static_cast<LCodeGen*>(this);
67 for (current_instruction_ = 0; 66 for (current_instruction_ = 0;
68 !is_aborted() && current_instruction_ < instructions_->length(); 67 !is_aborted() && current_instruction_ < instructions_->length();
69 current_instruction_++) { 68 current_instruction_++) {
70 LInstruction* instr = instructions_->at(current_instruction_); 69 LInstruction* instr = instructions_->at(current_instruction_);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 chunk_->AddDeprecationDependency(map); 182 chunk_->AddDeprecationDependency(map);
184 } 183 }
185 184
186 185
187 void LCodeGenBase::AddStabilityDependency(Handle<Map> map) { 186 void LCodeGenBase::AddStabilityDependency(Handle<Map> map) {
188 if (!map->is_stable()) return Retry(kMapBecameUnstable); 187 if (!map->is_stable()) return Retry(kMapBecameUnstable);
189 chunk_->AddStabilityDependency(map); 188 chunk_->AddStabilityDependency(map);
190 } 189 }
191 190
192 191
192 int LCodeGenBase::DefineDeoptimizationLiteral(Handle<Object> literal) {
193 int result = deoptimization_literals_.length();
194 for (int i = 0; i < deoptimization_literals_.length(); ++i) {
195 if (deoptimization_literals_[i].is_identical_to(literal)) return i;
196 }
197 deoptimization_literals_.Add(literal, zone());
198 return result;
199 }
200
201
202 void LCodeGenBase::WriteTranslationFrame(LEnvironment* environment,
203 Translation* translation) {
204 int translation_size = environment->translation_size();
205 // The output frame height does not include the parameters.
206 int height = translation_size - environment->parameter_count();
207
208 switch (environment->frame_type()) {
209 case JS_FUNCTION: {
210 int shared_id = DefineDeoptimizationLiteral(
211 environment->entry() ? environment->entry()->shared()
212 : info()->shared_info());
213 translation->BeginJSFrame(environment->ast_id(), shared_id, height);
214 if (info()->closure().is_identical_to(environment->closure())) {
215 translation->StoreJSFrameFunction();
216 } else {
217 int closure_id = DefineDeoptimizationLiteral(environment->closure());
218 translation->StoreLiteral(closure_id);
219 }
220 break;
221 }
222 case JS_CONSTRUCT: {
223 int shared_id = DefineDeoptimizationLiteral(
224 environment->entry() ? environment->entry()->shared()
225 : info()->shared_info());
226 translation->BeginConstructStubFrame(shared_id, translation_size);
227 if (info()->closure().is_identical_to(environment->closure())) {
228 translation->StoreJSFrameFunction();
229 } else {
230 int closure_id = DefineDeoptimizationLiteral(environment->closure());
231 translation->StoreLiteral(closure_id);
232 }
233 break;
234 }
235 case JS_GETTER: {
236 DCHECK(translation_size == 1);
237 DCHECK(height == 0);
238 int shared_id = DefineDeoptimizationLiteral(
239 environment->entry() ? environment->entry()->shared()
240 : info()->shared_info());
241 translation->BeginGetterStubFrame(shared_id);
242 if (info()->closure().is_identical_to(environment->closure())) {
243 translation->StoreJSFrameFunction();
244 } else {
245 int closure_id = DefineDeoptimizationLiteral(environment->closure());
246 translation->StoreLiteral(closure_id);
247 }
248 break;
249 }
250 case JS_SETTER: {
251 DCHECK(translation_size == 2);
252 DCHECK(height == 0);
253 int shared_id = DefineDeoptimizationLiteral(
254 environment->entry() ? environment->entry()->shared()
255 : info()->shared_info());
256 translation->BeginSetterStubFrame(shared_id);
257 if (info()->closure().is_identical_to(environment->closure())) {
258 translation->StoreJSFrameFunction();
259 } else {
260 int closure_id = DefineDeoptimizationLiteral(environment->closure());
261 translation->StoreLiteral(closure_id);
262 }
263 break;
264 }
265 case ARGUMENTS_ADAPTOR: {
266 int shared_id = DefineDeoptimizationLiteral(
267 environment->entry() ? environment->entry()->shared()
268 : info()->shared_info());
269 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size);
270 if (info()->closure().is_identical_to(environment->closure())) {
271 translation->StoreJSFrameFunction();
272 } else {
273 int closure_id = DefineDeoptimizationLiteral(environment->closure());
274 translation->StoreLiteral(closure_id);
275 }
276 break;
277 }
278 case STUB:
279 translation->BeginCompiledStubFrame(translation_size);
280 break;
281 }
282 }
283
284
193 Deoptimizer::DeoptInfo LCodeGenBase::MakeDeoptInfo( 285 Deoptimizer::DeoptInfo LCodeGenBase::MakeDeoptInfo(
194 LInstruction* instr, Deoptimizer::DeoptReason deopt_reason) { 286 LInstruction* instr, Deoptimizer::DeoptReason deopt_reason) {
195 Deoptimizer::DeoptInfo deopt_info(instr->hydrogen_value()->position(), 287 Deoptimizer::DeoptInfo deopt_info(instr->hydrogen_value()->position(),
196 instr->Mnemonic(), deopt_reason); 288 instr->Mnemonic(), deopt_reason);
197 HEnterInlined* enter_inlined = instr->environment()->entry(); 289 HEnterInlined* enter_inlined = instr->environment()->entry();
198 deopt_info.inlining_id = enter_inlined ? enter_inlined->inlining_id() : 0; 290 deopt_info.inlining_id = enter_inlined ? enter_inlined->inlining_id() : 0;
199 return deopt_info; 291 return deopt_info;
200 } 292 }
201 } // namespace internal 293 } // namespace internal
202 } // namespace v8 294 } // namespace v8
OLDNEW
« no previous file with comments | « src/lithium-codegen.h ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698