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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 return LStackSlot::Create(index, zone()); | 432 return LStackSlot::Create(index, zone()); |
432 } | 433 } |
433 } | 434 } |
434 | 435 |
435 | 436 |
436 LPlatformChunk* LChunkBuilder::Build() { | 437 LPlatformChunk* LChunkBuilder::Build() { |
437 ASSERT(is_unused()); | 438 ASSERT(is_unused()); |
438 chunk_ = new(zone()) LPlatformChunk(info(), graph()); | 439 chunk_ = new(zone()) LPlatformChunk(info(), graph()); |
439 LPhase phase("L_Building chunk", chunk_); | 440 LPhase phase("L_Building chunk", chunk_); |
440 status_ = BUILDING; | 441 status_ = BUILDING; |
| 442 |
| 443 // If compiling for OSR, reserve space for the unoptimized frame, |
| 444 // which will be subsumed into this frame. |
| 445 if (graph()->has_osr()) { |
| 446 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { |
| 447 chunk_->GetNextSpillIndex(false); |
| 448 } |
| 449 } |
| 450 |
441 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | 451 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
442 for (int i = 0; i < blocks->length(); i++) { | 452 for (int i = 0; i < blocks->length(); i++) { |
443 HBasicBlock* next = NULL; | 453 HBasicBlock* next = NULL; |
444 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 454 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
445 DoBasicBlock(blocks->at(i), next); | 455 DoBasicBlock(blocks->at(i), next); |
446 if (is_aborted()) return NULL; | 456 if (is_aborted()) return NULL; |
447 } | 457 } |
448 status_ = DONE; | 458 status_ = DONE; |
449 return chunk_; | 459 return chunk_; |
450 } | 460 } |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 CodeStubInterfaceDescriptor* descriptor = | 2344 CodeStubInterfaceDescriptor* descriptor = |
2335 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | 2345 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); |
2336 int index = static_cast<int>(instr->index()); | 2346 int index = static_cast<int>(instr->index()); |
2337 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2347 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
2338 return DefineFixed(result, reg); | 2348 return DefineFixed(result, reg); |
2339 } | 2349 } |
2340 } | 2350 } |
2341 | 2351 |
2342 | 2352 |
2343 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2353 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2344 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2354 // Use an index that corresponds to the location in the unoptimized frame, |
2345 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2355 // which the optimized frame will subsume. |
2346 Abort(kTooManySpillSlotsNeededForOSR); | 2356 int env_index = instr->index(); |
2347 spill_index = 0; | 2357 int spill_index = 0; |
| 2358 if (instr->environment()->is_parameter_index(env_index)) { |
| 2359 spill_index = chunk()->GetParameterStackSlot(env_index); |
| 2360 } else { |
| 2361 spill_index = env_index - instr->environment()->first_local_index(); |
| 2362 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
| 2363 Abort(kTooManySpillSlotsNeededForOSR); |
| 2364 spill_index = 0; |
| 2365 } |
2348 } | 2366 } |
2349 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2367 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
2350 } | 2368 } |
2351 | 2369 |
2352 | 2370 |
2353 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2371 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
2354 argument_count_ -= instr->argument_count(); | 2372 argument_count_ -= instr->argument_count(); |
2355 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr); | 2373 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr); |
2356 } | 2374 } |
2357 | 2375 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 | 2522 |
2505 | 2523 |
2506 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2524 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2507 LOperand* object = UseRegister(instr->object()); | 2525 LOperand* object = UseRegister(instr->object()); |
2508 LOperand* index = UseRegister(instr->index()); | 2526 LOperand* index = UseRegister(instr->index()); |
2509 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2527 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2510 } | 2528 } |
2511 | 2529 |
2512 | 2530 |
2513 } } // namespace v8::internal | 2531 } } // namespace v8::internal |
OLD | NEW |