OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 3568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3579 | 3579 |
3580 | 3580 |
3581 ConstantPoolArray::LayoutSection ConstantPoolBuilder::AddEntry( | 3581 ConstantPoolArray::LayoutSection ConstantPoolBuilder::AddEntry( |
3582 Assembler* assm, const RelocInfo& rinfo) { | 3582 Assembler* assm, const RelocInfo& rinfo) { |
3583 RelocInfo::Mode rmode = rinfo.rmode(); | 3583 RelocInfo::Mode rmode = rinfo.rmode(); |
3584 ASSERT(rmode != RelocInfo::COMMENT && | 3584 ASSERT(rmode != RelocInfo::COMMENT && |
3585 rmode != RelocInfo::POSITION && | 3585 rmode != RelocInfo::POSITION && |
3586 rmode != RelocInfo::STATEMENT_POSITION && | 3586 rmode != RelocInfo::STATEMENT_POSITION && |
3587 rmode != RelocInfo::CONST_POOL); | 3587 rmode != RelocInfo::CONST_POOL); |
3588 | 3588 |
3589 | |
3590 // Try to merge entries which won't be patched. | 3589 // Try to merge entries which won't be patched. |
3591 int merged_index = -1; | 3590 int merged_index = -1; |
3592 ConstantPoolArray::LayoutSection entry_section = current_section_; | 3591 ConstantPoolArray::LayoutSection entry_section = current_section_; |
3593 if (RelocInfo::IsNone(rmode) || | 3592 if (RelocInfo::IsNone(rmode) || |
3594 (!assm->serializer_enabled() && (rmode >= RelocInfo::CELL))) { | 3593 (!assm->serializer_enabled() && (rmode >= RelocInfo::CELL))) { |
3595 size_t i; | 3594 size_t i; |
3596 std::vector<ConstantPoolEntry>::const_iterator it; | 3595 std::vector<ConstantPoolEntry>::const_iterator it; |
3597 for (it = entries_.begin(), i = 0; it != entries_.end(); it++, i++) { | 3596 for (it = entries_.begin(), i = 0; it != entries_.end(); it++, i++) { |
3598 if (RelocInfo::IsEqual(rinfo, it->rinfo_)) { | 3597 if (RelocInfo::IsEqual(rinfo, it->rinfo_)) { |
3599 // Merge with found entry. | 3598 // Merge with found entry. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3649 ConstantPoolArray* constant_pool) { | 3648 ConstantPoolArray* constant_pool) { |
3650 ASSERT_EQ(extended_entries()->is_empty(), | 3649 ASSERT_EQ(extended_entries()->is_empty(), |
3651 !constant_pool->is_extended_layout()); | 3650 !constant_pool->is_extended_layout()); |
3652 ASSERT(small_entries()->equals(ConstantPoolArray::NumberOfEntries( | 3651 ASSERT(small_entries()->equals(ConstantPoolArray::NumberOfEntries( |
3653 constant_pool, ConstantPoolArray::SMALL_SECTION))); | 3652 constant_pool, ConstantPoolArray::SMALL_SECTION))); |
3654 if (constant_pool->is_extended_layout()) { | 3653 if (constant_pool->is_extended_layout()) { |
3655 ASSERT(extended_entries()->equals(ConstantPoolArray::NumberOfEntries( | 3654 ASSERT(extended_entries()->equals(ConstantPoolArray::NumberOfEntries( |
3656 constant_pool, ConstantPoolArray::EXTENDED_SECTION))); | 3655 constant_pool, ConstantPoolArray::EXTENDED_SECTION))); |
3657 } | 3656 } |
3658 | 3657 |
3659 ConstantPoolArray::NumberOfEntries small_idx; | 3658 // Set up initial offsets. |
3660 ConstantPoolArray::NumberOfEntries extended_idx; | 3659 int offsets[ConstantPoolArray::NUMBER_OF_LAYOUT_SECTIONS] |
| 3660 [ConstantPoolArray::NUMBER_OF_TYPES]; |
| 3661 for (int section = 0; section <= constant_pool->final_section(); section++) { |
| 3662 int section_start = (section == ConstantPoolArray::EXTENDED_SECTION) |
| 3663 ? small_entries()->total_count() |
| 3664 : 0; |
| 3665 for (int i = 0; i < ConstantPoolArray::NUMBER_OF_TYPES; i++) { |
| 3666 ConstantPoolArray::Type type = static_cast<ConstantPoolArray::Type>(i); |
| 3667 if (number_of_entries_[section].count_of(type) != 0) { |
| 3668 offsets[section][type] = constant_pool->OffsetOfElementAt( |
| 3669 number_of_entries_[section].base_of(type) + section_start); |
| 3670 } |
| 3671 } |
| 3672 } |
| 3673 |
3661 for (std::vector<ConstantPoolEntry>::iterator entry = entries_.begin(); | 3674 for (std::vector<ConstantPoolEntry>::iterator entry = entries_.begin(); |
3662 entry != entries_.end(); entry++) { | 3675 entry != entries_.end(); entry++) { |
3663 RelocInfo rinfo = entry->rinfo_; | 3676 RelocInfo rinfo = entry->rinfo_; |
3664 RelocInfo::Mode rmode = entry->rinfo_.rmode(); | 3677 RelocInfo::Mode rmode = entry->rinfo_.rmode(); |
3665 ConstantPoolArray::Type type = GetConstantPoolType(rmode); | 3678 ConstantPoolArray::Type type = GetConstantPoolType(rmode); |
3666 | 3679 |
3667 // Update constant pool if necessary and get the entry's offset. | 3680 // Update constant pool if necessary and get the entry's offset. |
3668 int offset; | 3681 int offset; |
3669 if (entry->merged_index_ == -1) { | 3682 if (entry->merged_index_ == -1) { |
3670 int index; | 3683 offset = offsets[entry->section_][type]; |
3671 if (entry->section_ == ConstantPoolArray::EXTENDED_SECTION) { | 3684 offsets[entry->section_][type] += ConstantPoolArray::entry_size(type); |
3672 index = small_entries()->total_count() + | |
3673 extended_entries()->base_of(type) + extended_idx.count_of(type); | |
3674 extended_idx.increment(type); | |
3675 } else { | |
3676 ASSERT(entry->section_ == ConstantPoolArray::SMALL_SECTION); | |
3677 index = small_entries()->base_of(type) + small_idx.count_of(type); | |
3678 small_idx.increment(type); | |
3679 } | |
3680 if (type == ConstantPoolArray::INT64) { | 3685 if (type == ConstantPoolArray::INT64) { |
3681 constant_pool->set(index, rinfo.data64()); | 3686 constant_pool->set_at_offset(offset, rinfo.data64()); |
3682 } else if (type == ConstantPoolArray::INT32) { | 3687 } else if (type == ConstantPoolArray::INT32) { |
3683 constant_pool->set(index, static_cast<int32_t>(rinfo.data())); | 3688 constant_pool->set_at_offset(offset, rinfo.data()); |
3684 } else if (type == ConstantPoolArray::CODE_PTR) { | 3689 } else if (type == ConstantPoolArray::CODE_PTR) { |
3685 constant_pool->set(index, reinterpret_cast<Address>(rinfo.data())); | 3690 constant_pool->set_at_offset(offset, |
| 3691 reinterpret_cast<Address>(rinfo.data())); |
3686 } else { | 3692 } else { |
3687 ASSERT(type == ConstantPoolArray::HEAP_PTR); | 3693 ASSERT(type == ConstantPoolArray::HEAP_PTR); |
3688 constant_pool->set(index, reinterpret_cast<Object*>(rinfo.data())); | 3694 constant_pool->set_at_offset(offset, |
| 3695 reinterpret_cast<Object*>(rinfo.data())); |
3689 } | 3696 } |
3690 offset = constant_pool->OffsetOfElementAt(index) - kHeapObjectTag; | 3697 offset -= kHeapObjectTag; |
3691 entry->merged_index_ = offset; // Stash offset for merged entries. | 3698 entry->merged_index_ = offset; // Stash offset for merged entries. |
3692 } else { | 3699 } else { |
3693 ASSERT(entry->merged_index_ < (entry - entries_.begin())); | 3700 ASSERT(entry->merged_index_ < (entry - entries_.begin())); |
3694 offset = entries_[entry->merged_index_].merged_index_; | 3701 offset = entries_[entry->merged_index_].merged_index_; |
3695 } | 3702 } |
3696 | 3703 |
3697 // Patch vldr/ldr instruction with correct offset. | 3704 // Patch vldr/ldr instruction with correct offset. |
3698 Instr instr = assm->instr_at(rinfo.pc()); | 3705 Instr instr = assm->instr_at(rinfo.pc()); |
3699 if (entry->section_ == ConstantPoolArray::EXTENDED_SECTION) { | 3706 if (entry->section_ == ConstantPoolArray::EXTENDED_SECTION) { |
3700 // Instructions to patch must be 'movw rd, [#0]' and 'movt rd, [#0]. | 3707 // Instructions to patch must be 'movw rd, [#0]' and 'movt rd, [#0]. |
(...skipping 16 matching lines...) Expand all Loading... |
3717 instr, offset)); | 3724 instr, offset)); |
3718 } else { | 3725 } else { |
3719 // Instruction to patch must be 'ldr rd, [pp, #0]'. | 3726 // Instruction to patch must be 'ldr rd, [pp, #0]'. |
3720 ASSERT((Assembler::IsLdrPpImmediateOffset(instr) && | 3727 ASSERT((Assembler::IsLdrPpImmediateOffset(instr) && |
3721 Assembler::GetLdrRegisterImmediateOffset(instr) == 0)); | 3728 Assembler::GetLdrRegisterImmediateOffset(instr) == 0)); |
3722 ASSERT(is_uint12(offset)); | 3729 ASSERT(is_uint12(offset)); |
3723 assm->instr_at_put( | 3730 assm->instr_at_put( |
3724 rinfo.pc(), Assembler::SetLdrRegisterImmediateOffset(instr, offset)); | 3731 rinfo.pc(), Assembler::SetLdrRegisterImmediateOffset(instr, offset)); |
3725 } | 3732 } |
3726 } | 3733 } |
3727 | |
3728 ASSERT(small_idx.equals(*small_entries())); | |
3729 ASSERT(extended_idx.equals(*extended_entries())); | |
3730 } | 3734 } |
3731 | 3735 |
3732 | 3736 |
3733 } } // namespace v8::internal | 3737 } } // namespace v8::internal |
3734 | 3738 |
3735 #endif // V8_TARGET_ARCH_ARM | 3739 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |