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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 #include "lithium-allocator-inl.h" | 30 #include "lithium-allocator-inl.h" |
31 #include "mips/lithium-mips.h" | 31 #include "mips/lithium-mips.h" |
32 #include "mips/lithium-codegen-mips.h" | 32 #include "mips/lithium-codegen-mips.h" |
| 33 #include "hydrogen-osr.h" |
33 | 34 |
34 namespace v8 { | 35 namespace v8 { |
35 namespace internal { | 36 namespace internal { |
36 | 37 |
37 #define DEFINE_COMPILE(type) \ | 38 #define DEFINE_COMPILE(type) \ |
38 void L##type::CompileToNative(LCodeGen* generator) { \ | 39 void L##type::CompileToNative(LCodeGen* generator) { \ |
39 generator->Do##type(this); \ | 40 generator->Do##type(this); \ |
40 } | 41 } |
41 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 42 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
42 #undef DEFINE_COMPILE | 43 #undef DEFINE_COMPILE |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return LStackSlot::Create(index, zone()); | 424 return LStackSlot::Create(index, zone()); |
424 } | 425 } |
425 } | 426 } |
426 | 427 |
427 | 428 |
428 LPlatformChunk* LChunkBuilder::Build() { | 429 LPlatformChunk* LChunkBuilder::Build() { |
429 ASSERT(is_unused()); | 430 ASSERT(is_unused()); |
430 chunk_ = new(zone()) LPlatformChunk(info(), graph()); | 431 chunk_ = new(zone()) LPlatformChunk(info(), graph()); |
431 LPhase phase("L_Building chunk", chunk_); | 432 LPhase phase("L_Building chunk", chunk_); |
432 status_ = BUILDING; | 433 status_ = BUILDING; |
| 434 |
| 435 // If compiling for OSR, reserve space for the unoptimized frame, |
| 436 // which will be subsumed into this frame. |
| 437 if (graph()->has_osr()) { |
| 438 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { |
| 439 chunk_->GetNextSpillIndex(false); |
| 440 } |
| 441 } |
| 442 |
433 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | 443 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
434 for (int i = 0; i < blocks->length(); i++) { | 444 for (int i = 0; i < blocks->length(); i++) { |
435 HBasicBlock* next = NULL; | 445 HBasicBlock* next = NULL; |
436 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 446 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
437 DoBasicBlock(blocks->at(i), next); | 447 DoBasicBlock(blocks->at(i), next); |
438 if (is_aborted()) return NULL; | 448 if (is_aborted()) return NULL; |
439 } | 449 } |
440 status_ = DONE; | 450 status_ = DONE; |
441 return chunk_; | 451 return chunk_; |
442 } | 452 } |
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 CodeStubInterfaceDescriptor* descriptor = | 2372 CodeStubInterfaceDescriptor* descriptor = |
2363 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | 2373 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); |
2364 int index = static_cast<int>(instr->index()); | 2374 int index = static_cast<int>(instr->index()); |
2365 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2375 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
2366 return DefineFixed(result, reg); | 2376 return DefineFixed(result, reg); |
2367 } | 2377 } |
2368 } | 2378 } |
2369 | 2379 |
2370 | 2380 |
2371 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2381 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2372 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2382 // Use an index that corresponds to the location in the unoptimized frame, |
2373 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2383 // which the optimized frame will subsume. |
2374 Abort("Too many spill slots needed for OSR"); | 2384 int env_index = instr->index(); |
2375 spill_index = 0; | 2385 int spill_index = 0; |
| 2386 if (instr->environment()->is_parameter_index(env_index)) { |
| 2387 spill_index = chunk()->GetParameterStackSlot(env_index); |
| 2388 } else { |
| 2389 spill_index = env_index - instr->environment()->first_local_index(); |
| 2390 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
| 2391 Abort("Too many spill slots needed for OSR"); |
| 2392 spill_index = 0; |
| 2393 } |
2376 } | 2394 } |
2377 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2395 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
2378 } | 2396 } |
2379 | 2397 |
2380 | 2398 |
2381 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2399 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
2382 argument_count_ -= instr->argument_count(); | 2400 argument_count_ -= instr->argument_count(); |
2383 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr); | 2401 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr); |
2384 } | 2402 } |
2385 | 2403 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 | 2555 |
2538 | 2556 |
2539 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2557 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2540 LOperand* object = UseRegister(instr->object()); | 2558 LOperand* object = UseRegister(instr->object()); |
2541 LOperand* index = UseRegister(instr->index()); | 2559 LOperand* index = UseRegister(instr->index()); |
2542 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2560 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2543 } | 2561 } |
2544 | 2562 |
2545 | 2563 |
2546 } } // namespace v8::internal | 2564 } } // namespace v8::internal |
OLD | NEW |