OLD | NEW |
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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( | 295 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( |
296 Instruction* instr, int frame_state_offset) { | 296 Instruction* instr, int frame_state_offset) { |
297 InstructionOperandConverter i(this, instr); | 297 InstructionOperandConverter i(this, instr); |
298 InstructionSequence::StateId state_id = | 298 InstructionSequence::StateId state_id = |
299 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset)); | 299 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset)); |
300 return code()->GetFrameStateDescriptor(state_id); | 300 return code()->GetFrameStateDescriptor(state_id); |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 void CodeGenerator::BuildTranslationForFrameStateDescriptor( | 304 int CodeGenerator::BuildTranslation(Instruction* instr, int frame_state_offset, |
305 FrameStateDescriptor* descriptor, Instruction* instr, | 305 OutputFrameStateCombine state_combine) { |
306 Translation* translation, int frame_state_offset, | 306 FrameStateDescriptor* descriptor = |
307 OutputFrameStateCombine state_combine) { | 307 GetFrameStateDescriptor(instr, frame_state_offset); |
308 // Outer-most state must be added to translation first. | 308 frame_state_offset++; |
309 if (descriptor->outer_state() != NULL) { | |
310 BuildTranslationForFrameStateDescriptor( | |
311 descriptor->outer_state(), instr, translation, | |
312 frame_state_offset + descriptor->size(), kIgnoreOutput); | |
313 } | |
314 | 309 |
315 int height = descriptor->size() - descriptor->parameters_count(); | 310 int height = descriptor->size() - descriptor->parameters_count(); |
316 switch (state_combine) { | 311 switch (state_combine) { |
317 case kPushOutput: | 312 case kPushOutput: |
318 height++; | 313 height++; |
319 break; | 314 break; |
320 case kIgnoreOutput: | 315 case kIgnoreOutput: |
321 break; | 316 break; |
322 } | 317 } |
323 | 318 |
324 translation->BeginJSFrame(descriptor->bailout_id(), | 319 |
325 Translation::kSelfLiteralId, height); | 320 Translation translation(&translations_, 1, 1, zone()); |
| 321 translation.BeginJSFrame(descriptor->bailout_id(), |
| 322 Translation::kSelfLiteralId, height); |
326 | 323 |
327 for (int i = 0; i < descriptor->size(); i++) { | 324 for (int i = 0; i < descriptor->size(); i++) { |
328 AddTranslationForOperand(translation, instr, | 325 AddTranslationForOperand(&translation, instr, |
329 instr->InputAt(i + frame_state_offset)); | 326 instr->InputAt(i + frame_state_offset)); |
330 } | 327 } |
331 | 328 |
332 switch (state_combine) { | 329 switch (state_combine) { |
333 case kPushOutput: | 330 case kPushOutput: |
334 DCHECK(instr->OutputCount() == 1); | 331 DCHECK(instr->OutputCount() == 1); |
335 AddTranslationForOperand(translation, instr, instr->OutputAt(0)); | 332 AddTranslationForOperand(&translation, instr, instr->OutputAt(0)); |
336 break; | 333 break; |
337 case kIgnoreOutput: | 334 case kIgnoreOutput: |
338 break; | 335 break; |
339 } | 336 } |
340 } | |
341 | |
342 | |
343 int CodeGenerator::BuildTranslation(Instruction* instr, int frame_state_offset, | |
344 OutputFrameStateCombine state_combine) { | |
345 FrameStateDescriptor* descriptor = | |
346 GetFrameStateDescriptor(instr, frame_state_offset); | |
347 frame_state_offset++; | |
348 | |
349 int frame_count = descriptor->GetFrameCount(); | |
350 Translation translation(&translations_, frame_count, frame_count, zone()); | |
351 BuildTranslationForFrameStateDescriptor(descriptor, instr, &translation, | |
352 frame_state_offset, state_combine); | |
353 | 337 |
354 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); | 338 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); |
355 | 339 |
356 deoptimization_states_.push_back(new (zone()) DeoptimizationState( | 340 deoptimization_states_.push_back(new (zone()) DeoptimizationState( |
357 descriptor->bailout_id(), translation.index())); | 341 descriptor->bailout_id(), translation.index())); |
358 | 342 |
359 return deoptimization_id; | 343 return deoptimization_id; |
360 } | 344 } |
361 | 345 |
362 | 346 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 425 } |
442 | 426 |
443 | 427 |
444 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 428 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
445 | 429 |
446 #endif // !V8_TURBOFAN_BACKEND | 430 #endif // !V8_TURBOFAN_BACKEND |
447 | 431 |
448 } // namespace compiler | 432 } // namespace compiler |
449 } // namespace internal | 433 } // namespace internal |
450 } // namespace v8 | 434 } // namespace v8 |
OLD | NEW |