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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 // f.arguments), and those are the same in the pre-call and post-call | 259 // f.arguments), and those are the same in the pre-call and post-call |
260 // states. | 260 // states. |
261 if (descriptor->state_combine() != kIgnoreOutput) { | 261 if (descriptor->state_combine() != kIgnoreOutput) { |
262 deopt_state_id = | 262 deopt_state_id = |
263 BuildTranslation(instr, -1, frame_state_offset, kIgnoreOutput); | 263 BuildTranslation(instr, -1, frame_state_offset, kIgnoreOutput); |
264 } | 264 } |
265 #if DEBUG | 265 #if DEBUG |
266 // Make sure all the values live in stack slots or they are immediates. | 266 // Make sure all the values live in stack slots or they are immediates. |
267 // (The values should not live in register because registers are clobbered | 267 // (The values should not live in register because registers are clobbered |
268 // by calls.) | 268 // by calls.) |
269 for (int i = 0; i < descriptor->size(); i++) { | 269 for (size_t i = 0; i < descriptor->size(); i++) { |
270 InstructionOperand* op = instr->InputAt(frame_state_offset + 1 + i); | 270 InstructionOperand* op = instr->InputAt(frame_state_offset + 1 + i); |
271 CHECK(op->IsStackSlot() || op->IsImmediate()); | 271 CHECK(op->IsStackSlot() || op->IsImmediate()); |
272 } | 272 } |
273 #endif | 273 #endif |
274 safepoints()->RecordLazyDeoptimizationIndex(deopt_state_id); | 274 safepoints()->RecordLazyDeoptimizationIndex(deopt_state_id); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 | 278 |
279 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { | 279 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { |
(...skipping 14 matching lines...) Expand all Loading... | |
294 return code()->GetFrameStateDescriptor(state_id); | 294 return code()->GetFrameStateDescriptor(state_id); |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 void CodeGenerator::BuildTranslationForFrameStateDescriptor( | 298 void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
299 FrameStateDescriptor* descriptor, Instruction* instr, | 299 FrameStateDescriptor* descriptor, Instruction* instr, |
300 Translation* translation, int frame_state_offset, | 300 Translation* translation, int frame_state_offset, |
301 OutputFrameStateCombine state_combine) { | 301 OutputFrameStateCombine state_combine) { |
302 // Outer-most state must be added to translation first. | 302 // Outer-most state must be added to translation first. |
303 if (descriptor->outer_state() != NULL) { | 303 if (descriptor->outer_state() != NULL) { |
304 BuildTranslationForFrameStateDescriptor( | 304 BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr, |
305 descriptor->outer_state(), instr, translation, | 305 translation, frame_state_offset, |
306 frame_state_offset + descriptor->size(), kIgnoreOutput); | 306 kIgnoreOutput); |
307 } | 307 } |
308 | 308 |
309 int height = descriptor->size() - descriptor->parameters_count(); | 309 int id = Translation::kSelfLiteralId; |
310 switch (state_combine) { | 310 if (!descriptor->jsfunction().IsNull()) { |
311 case kPushOutput: | 311 id = DefineDeoptimizationLiteral( |
312 height++; | 312 Handle<Object>::cast(descriptor->jsfunction().handle())); |
313 } | |
314 | |
315 switch (descriptor->type()) { | |
316 case JS_FRAME: | |
317 translation->BeginJSFrame(descriptor->bailout_id(), id, | |
318 descriptor->GetHeight(state_combine)); | |
313 break; | 319 break; |
314 case kIgnoreOutput: | 320 case ARGUMENTS_ADAPTOR: |
321 translation->BeginArgumentsAdaptorFrame(id, | |
322 descriptor->parameters_count()); | |
315 break; | 323 break; |
316 } | 324 } |
317 | 325 |
318 translation->BeginJSFrame(descriptor->bailout_id(), | 326 for (size_t i = 0; i < descriptor->size(); i++) { |
319 Translation::kSelfLiteralId, height); | 327 AddTranslationForOperand( |
320 | 328 translation, instr, |
321 for (int i = 0; i < descriptor->size(); i++) { | 329 instr->InputAt(frame_state_offset + |
322 AddTranslationForOperand(translation, instr, | 330 descriptor->outer_state()->GetTotalSize() + i)); |
Jarin
2014/09/15 13:37:51
How about adding descriptor->outer_state()->GetTot
sigurds
2014/09/16 08:39:03
Done.
| |
323 instr->InputAt(i + frame_state_offset)); | |
324 } | 331 } |
325 | 332 |
326 switch (state_combine) { | 333 switch (state_combine) { |
327 case kPushOutput: | 334 case kPushOutput: |
328 DCHECK(instr->OutputCount() == 1); | 335 DCHECK(instr->OutputCount() == 1); |
329 AddTranslationForOperand(translation, instr, instr->OutputAt(0)); | 336 AddTranslationForOperand(translation, instr, instr->OutputAt(0)); |
330 break; | 337 break; |
331 case kIgnoreOutput: | 338 case kIgnoreOutput: |
332 break; | 339 break; |
333 } | 340 } |
334 } | 341 } |
335 | 342 |
336 | 343 |
337 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, | 344 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, |
338 int frame_state_offset, | 345 int frame_state_offset, |
339 OutputFrameStateCombine state_combine) { | 346 OutputFrameStateCombine state_combine) { |
340 FrameStateDescriptor* descriptor = | 347 FrameStateDescriptor* descriptor = |
341 GetFrameStateDescriptor(instr, frame_state_offset); | 348 GetFrameStateDescriptor(instr, frame_state_offset); |
342 frame_state_offset++; | 349 frame_state_offset++; |
343 | 350 |
344 int frame_count = descriptor->GetFrameCount(); | 351 Translation translation(&translations_, descriptor->GetFrameCount(), |
345 Translation translation(&translations_, frame_count, frame_count, zone()); | 352 descriptor->GetJSFrameCount(), zone()); |
346 BuildTranslationForFrameStateDescriptor(descriptor, instr, &translation, | 353 BuildTranslationForFrameStateDescriptor(descriptor, instr, &translation, |
347 frame_state_offset, state_combine); | 354 frame_state_offset, state_combine); |
348 | 355 |
349 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); | 356 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); |
350 | 357 |
351 deoptimization_states_.push_back(new (zone()) DeoptimizationState( | 358 deoptimization_states_.push_back(new (zone()) DeoptimizationState( |
352 descriptor->bailout_id(), translation.index(), pc_offset)); | 359 descriptor->bailout_id(), translation.index(), pc_offset)); |
353 | 360 |
354 return deoptimization_id; | 361 return deoptimization_id; |
355 } | 362 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 } | 443 } |
437 | 444 |
438 | 445 |
439 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 446 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
440 | 447 |
441 #endif // !V8_TURBOFAN_BACKEND | 448 #endif // !V8_TURBOFAN_BACKEND |
442 | 449 |
443 } // namespace compiler | 450 } // namespace compiler |
444 } // namespace internal | 451 } // namespace internal |
445 } // namespace v8 | 452 } // namespace v8 |
OLD | NEW |