OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 565 |
566 void LoadIC::ClearInlinedVersion(Address address) { | 566 void LoadIC::ClearInlinedVersion(Address address) { |
567 // Reset the map check of the inlined inobject property load (if present) to | 567 // Reset the map check of the inlined inobject property load (if present) to |
568 // guarantee failure by holding an invalid map (the null value). The offset | 568 // guarantee failure by holding an invalid map (the null value). The offset |
569 // can be patched to anything. | 569 // can be patched to anything. |
570 PatchInlinedLoad(address, Heap::null_value(), 0); | 570 PatchInlinedLoad(address, Heap::null_value(), 0); |
571 } | 571 } |
572 | 572 |
573 | 573 |
574 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { | 574 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { |
575 // If the instruction after the call site is not a B instruction then this is | 575 // If the instruction after the call site is not the pseudo instruction nop1 |
576 // not related to an inlined in-object property load. The B instructions is | 576 // then this is not related to an inlined in-object property load. The nop1 |
577 // located just after the call to the IC in the deferred code handling the | 577 // instruction is located just after the call to the IC in the deferred code |
578 // miss in the inlined code. All other calls to a load IC should ensure there | 578 // handling the miss in the inlined code. After the nop1 instruction there is |
579 // in no B instruction directly following the call. | 579 // a B instruction for jumping back from the deferred code. |
580 Address address_after_call = address + Assembler::kCallTargetAddressOffset; | 580 Address address_after_call = address + Assembler::kCallTargetAddressOffset; |
581 Instr instr_after_call = Assembler::instr_at(address_after_call); | 581 Instr instr_after_call = Assembler::instr_at(address_after_call); |
582 if (!Assembler::IsB(instr_after_call)) return false; | 582 if (!Assembler::IsNop(instr_after_call, NAMED_PROPERTY_LOAD_INLINED)) { |
| 583 return false; |
| 584 } |
| 585 ASSERT_EQ(0, RegisterAllocator::kNumRegisters); |
| 586 Address address_after_nop1 = address_after_call + Assembler::kInstrSize; |
| 587 Instr instr_after_nop1 = Assembler::instr_at(address_after_nop1); |
| 588 ASSERT(Assembler::IsBranch(instr_after_nop1)); |
583 | 589 |
584 // Find the end of the inlined code for handling the load. | 590 // Find the end of the inlined code for handling the load. |
585 int b_offset = | 591 int b_offset = |
586 Assembler::GetBOffset(instr_after_call) + Assembler::kPcLoadDelta; | 592 Assembler::GetBranchOffset(instr_after_nop1) + Assembler::kPcLoadDelta; |
587 ASSERT(b_offset < 0); // Jumping back from deferred code. | 593 ASSERT(b_offset < 0); // Jumping back from deferred code. |
588 Address inline_end_address = address_after_call + b_offset; | 594 Address inline_end_address = address_after_nop1 + b_offset; |
589 | 595 |
590 // Patch the offset of the property load instruction (ldr r0, [r1, #+XXX]). | 596 // Patch the offset of the property load instruction (ldr r0, [r1, #+XXX]). |
| 597 // The immediate must be represenatble in 12 bits. |
| 598 ASSERT((JSObject::kMaxInstanceSize - JSObject::kHeaderSize) < (1 << 12)); |
591 Address ldr_property_instr_address = inline_end_address - 4; | 599 Address ldr_property_instr_address = inline_end_address - 4; |
592 ASSERT(Assembler::IsLdrRegisterImmediate( | 600 ASSERT(Assembler::IsLdrRegisterImmediate( |
593 Assembler::instr_at(ldr_property_instr_address))); | 601 Assembler::instr_at(ldr_property_instr_address))); |
594 Instr ldr_property_instr = Assembler::instr_at(ldr_property_instr_address); | 602 Instr ldr_property_instr = Assembler::instr_at(ldr_property_instr_address); |
595 ldr_property_instr = Assembler::SetLdrRegisterImmediateOffset( | 603 ldr_property_instr = Assembler::SetLdrRegisterImmediateOffset( |
596 ldr_property_instr, offset - kHeapObjectTag); | 604 ldr_property_instr, offset - kHeapObjectTag); |
597 Assembler::instr_at_put(ldr_property_instr_address, ldr_property_instr); | 605 Assembler::instr_at_put(ldr_property_instr_address, ldr_property_instr); |
598 | 606 |
599 // Indicate that code has changed. | 607 // Indicate that code has changed. |
600 CPU::FlushICache(ldr_property_instr_address, 1 * Assembler::kInstrSize); | 608 CPU::FlushICache(ldr_property_instr_address, 1 * Assembler::kInstrSize); |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 __ bind(&miss); | 1738 __ bind(&miss); |
1731 | 1739 |
1732 GenerateMiss(masm); | 1740 GenerateMiss(masm); |
1733 } | 1741 } |
1734 | 1742 |
1735 | 1743 |
1736 #undef __ | 1744 #undef __ |
1737 | 1745 |
1738 | 1746 |
1739 } } // namespace v8::internal | 1747 } } // namespace v8::internal |
OLD | NEW |