OLD | NEW |
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 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #if V8_TARGET_ARCH_IA32 | 30 #if V8_TARGET_ARCH_IA32 |
31 | 31 |
32 #include "lithium-allocator-inl.h" | 32 #include "lithium-allocator-inl.h" |
33 #include "ia32/lithium-ia32.h" | 33 #include "ia32/lithium-ia32.h" |
34 #include "ia32/lithium-codegen-ia32.h" | 34 #include "ia32/lithium-codegen-ia32.h" |
| 35 #include "hydrogen-osr.h" |
35 | 36 |
36 namespace v8 { | 37 namespace v8 { |
37 namespace internal { | 38 namespace internal { |
38 | 39 |
39 #define DEFINE_COMPILE(type) \ | 40 #define DEFINE_COMPILE(type) \ |
40 void L##type::CompileToNative(LCodeGen* generator) { \ | 41 void L##type::CompileToNative(LCodeGen* generator) { \ |
41 generator->Do##type(this); \ | 42 generator->Do##type(this); \ |
42 } | 43 } |
43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 44 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
44 #undef DEFINE_COMPILE | 45 #undef DEFINE_COMPILE |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 LPhase phase("L_Building chunk", chunk_); | 477 LPhase phase("L_Building chunk", chunk_); |
477 status_ = BUILDING; | 478 status_ = BUILDING; |
478 | 479 |
479 // Reserve the first spill slot for the state of dynamic alignment. | 480 // Reserve the first spill slot for the state of dynamic alignment. |
480 if (info()->IsOptimizing()) { | 481 if (info()->IsOptimizing()) { |
481 int alignment_state_index = chunk_->GetNextSpillIndex(false); | 482 int alignment_state_index = chunk_->GetNextSpillIndex(false); |
482 ASSERT_EQ(alignment_state_index, 0); | 483 ASSERT_EQ(alignment_state_index, 0); |
483 USE(alignment_state_index); | 484 USE(alignment_state_index); |
484 } | 485 } |
485 | 486 |
| 487 // If compiling for OSR, reserve space for the unoptimized frame, |
| 488 // which will be subsumed into this frame. |
| 489 if (graph()->has_osr()) { |
| 490 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { |
| 491 chunk_->GetNextSpillIndex(false); |
| 492 } |
| 493 } |
| 494 |
486 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | 495 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
487 for (int i = 0; i < blocks->length(); i++) { | 496 for (int i = 0; i < blocks->length(); i++) { |
488 HBasicBlock* next = NULL; | 497 HBasicBlock* next = NULL; |
489 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 498 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
490 DoBasicBlock(blocks->at(i), next); | 499 DoBasicBlock(blocks->at(i), next); |
491 if (is_aborted()) return NULL; | 500 if (is_aborted()) return NULL; |
492 } | 501 } |
493 status_ = DONE; | 502 status_ = DONE; |
494 return chunk_; | 503 return chunk_; |
495 } | 504 } |
(...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 CodeStubInterfaceDescriptor* descriptor = | 2539 CodeStubInterfaceDescriptor* descriptor = |
2531 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | 2540 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); |
2532 int index = static_cast<int>(instr->index()); | 2541 int index = static_cast<int>(instr->index()); |
2533 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2542 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
2534 return DefineFixed(result, reg); | 2543 return DefineFixed(result, reg); |
2535 } | 2544 } |
2536 } | 2545 } |
2537 | 2546 |
2538 | 2547 |
2539 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2548 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2540 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2549 // Use an index that corresponds to the location in the unoptimized frame, |
2541 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2550 // which the optimized frame will subsume. |
2542 Abort(kTooManySpillSlotsNeededForOSR); | 2551 int env_index = instr->index(); |
2543 spill_index = 0; | 2552 int spill_index = 0; |
| 2553 if (instr->environment()->is_parameter_index(env_index)) { |
| 2554 spill_index = chunk()->GetParameterStackSlot(env_index); |
| 2555 } else { |
| 2556 spill_index = env_index - instr->environment()->first_local_index(); |
| 2557 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
| 2558 Abort(kNotEnoughSpillSlotsForOsr); |
| 2559 spill_index = 0; |
| 2560 } |
| 2561 if (spill_index == 0) { |
| 2562 // The dynamic frame alignment state overwrites the first local. |
| 2563 // The first local is saved at the end of the unoptimized frame. |
| 2564 spill_index = graph()->osr()->UnoptimizedFrameSlots(); |
| 2565 } |
2544 } | 2566 } |
2545 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2567 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
2546 } | 2568 } |
2547 | 2569 |
2548 | 2570 |
2549 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2571 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
2550 LOperand* context = UseFixed(instr->context(), esi); | 2572 LOperand* context = UseFixed(instr->context(), esi); |
2551 argument_count_ -= instr->argument_count(); | 2573 argument_count_ -= instr->argument_count(); |
2552 LCallStub* result = new(zone()) LCallStub(context); | 2574 LCallStub* result = new(zone()) LCallStub(context); |
2553 return MarkAsCall(DefineFixed(result, eax), instr); | 2575 return MarkAsCall(DefineFixed(result, eax), instr); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2734 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2713 LOperand* object = UseRegister(instr->object()); | 2735 LOperand* object = UseRegister(instr->object()); |
2714 LOperand* index = UseTempRegister(instr->index()); | 2736 LOperand* index = UseTempRegister(instr->index()); |
2715 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2737 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2716 } | 2738 } |
2717 | 2739 |
2718 | 2740 |
2719 } } // namespace v8::internal | 2741 } } // namespace v8::internal |
2720 | 2742 |
2721 #endif // V8_TARGET_ARCH_IA32 | 2743 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |