Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: src/arm/assembler-arm.cc

Issue 1217673003: Make sure the constant pool size is as promised. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 3778
3779 int needed_space = size + kGap; 3779 int needed_space = size + kGap;
3780 while (buffer_space() <= needed_space) GrowBuffer(); 3780 while (buffer_space() <= needed_space) GrowBuffer();
3781 3781
3782 { 3782 {
3783 // Block recursive calls to CheckConstPool. 3783 // Block recursive calls to CheckConstPool.
3784 BlockConstPoolScope block_const_pool(this); 3784 BlockConstPoolScope block_const_pool(this);
3785 RecordComment("[ Constant Pool"); 3785 RecordComment("[ Constant Pool");
3786 RecordConstPool(size); 3786 RecordConstPool(size);
3787 3787
3788 Label size_check;
3789 bind(&size_check);
3790
3788 // Emit jump over constant pool if necessary. 3791 // Emit jump over constant pool if necessary.
3789 Label after_pool; 3792 Label after_pool;
3790 if (require_jump) { 3793 if (require_jump) {
3791 b(&after_pool); 3794 b(&after_pool);
3792 } 3795 }
3793 3796
3794 // Put down constant pool marker "Undefined instruction". 3797 // Put down constant pool marker "Undefined instruction".
3795 // The data size helps disassembly know what to print. 3798 // The data size helps disassembly know what to print.
3796 emit(kConstantPoolMarker | 3799 emit(kConstantPoolMarker |
3797 EncodeConstantPoolLength(size_after_marker / kPointerSize)); 3800 EncodeConstantPoolLength(size_after_marker / kPointerSize));
3798 3801
3799 if (require_64_bit_align) { 3802 if (require_64_bit_align) {
3800 emit(kConstantPoolMarker); 3803 emit(kConstantPoolMarker);
3801 } 3804 }
3802 3805
3803 // Emit 64-bit constant pool entries first: their range is smaller than 3806 // Emit 64-bit constant pool entries first: their range is smaller than
3804 // 32-bit entries. 3807 // 32-bit entries.
3805 for (int i = 0; i < num_pending_64_bit_constants_; i++) { 3808 for (int i = 0; i < num_pending_64_bit_constants_; i++) {
3806 ConstantPoolEntry& entry = pending_64_bit_constants_[i]; 3809 ConstantPoolEntry& entry = pending_64_bit_constants_[i];
3807 3810
3808 DCHECK(!((uintptr_t)pc_ & 0x7)); // Check 64-bit alignment. 3811 DCHECK(!((uintptr_t)pc_ & 0x7)); // Check 64-bit alignment.
3809 3812
3810 Instr instr = instr_at(entry.position()); 3813 Instr instr = instr_at(entry.position());
3811 // Instruction to patch must be 'vldr rd, [pc, #offset]' with offset == 0. 3814 // Instruction to patch must be 'vldr rd, [pc, #offset]' with offset == 0.
3812 DCHECK((IsVldrDPcImmediateOffset(instr) && 3815 DCHECK((IsVldrDPcImmediateOffset(instr) &&
3813 GetVldrDRegisterImmediateOffset(instr) == 0)); 3816 GetVldrDRegisterImmediateOffset(instr) == 0));
3814 3817
3815 int delta = pc_offset() - entry.position() - kPcLoadDelta; 3818 int delta = pc_offset() - entry.position() - kPcLoadDelta;
3816 DCHECK(is_uint10(delta)); 3819 DCHECK(is_uint10(delta));
3817
3818 bool found = false;
3819 uint64_t value = entry.value64();
3820 for (int j = 0; j < i; j++) {
3821 ConstantPoolEntry& entry2 = pending_64_bit_constants_[j];
3822 if (value == entry2.value64()) {
3823 found = true;
3824 Instr instr2 = instr_at(entry2.position());
3825 DCHECK(IsVldrDPcImmediateOffset(instr2));
3826 delta = GetVldrDRegisterImmediateOffset(instr2);
3827 delta += entry2.position() - entry.position();
3828 break;
3829 }
3830 }
3831
3832 instr_at_put(entry.position(), 3820 instr_at_put(entry.position(),
3833 SetVldrDRegisterImmediateOffset(instr, delta)); 3821 SetVldrDRegisterImmediateOffset(instr, delta));
3834 3822 dq(entry.value64());
3835 if (!found) {
3836 dq(entry.value64());
3837 }
3838 } 3823 }
3839 3824
3840 // Emit 32-bit constant pool entries. 3825 // Emit 32-bit constant pool entries.
3841 for (int i = 0; i < num_pending_32_bit_constants_; i++) { 3826 for (int i = 0; i < num_pending_32_bit_constants_; i++) {
3842 ConstantPoolEntry& entry = pending_32_bit_constants_[i]; 3827 ConstantPoolEntry& entry = pending_32_bit_constants_[i];
3843 Instr instr = instr_at(entry.position()); 3828 Instr instr = instr_at(entry.position());
3844 3829
3845 // 64-bit loads shouldn't get here. 3830 // 64-bit loads shouldn't get here.
3846 DCHECK(!IsVldrDPcImmediateOffset(instr)); 3831 DCHECK(!IsVldrDPcImmediateOffset(instr));
3847 3832
3848 if (IsLdrPcImmediateOffset(instr) && 3833 if (IsLdrPcImmediateOffset(instr) &&
3849 GetLdrRegisterImmediateOffset(instr) == 0) { 3834 GetLdrRegisterImmediateOffset(instr) == 0) {
3850 int delta = pc_offset() - entry.position() - kPcLoadDelta; 3835 int delta = pc_offset() - entry.position() - kPcLoadDelta;
3851 DCHECK(is_uint12(delta)); 3836 DCHECK(is_uint12(delta));
3852 // 0 is the smallest delta: 3837 // 0 is the smallest delta:
3853 // ldr rd, [pc, #0] 3838 // ldr rd, [pc, #0]
3854 // constant pool marker 3839 // constant pool marker
3855 // data 3840 // data
3856
3857 bool found = false;
3858 if (entry.sharing_ok()) {
3859 for (int j = 0; j < i; j++) {
rmcilroy 2015/07/02 13:59:48 By removing this sharing you are going to increase
3860 ConstantPoolEntry& entry2 = pending_32_bit_constants_[j];
3861
3862 if (entry2.value() == entry.value()) {
3863 Instr instr2 = instr_at(entry2.position());
3864 if (IsLdrPcImmediateOffset(instr2)) {
3865 delta = GetLdrRegisterImmediateOffset(instr2);
3866 delta += entry2.position() - entry.position();
3867 found = true;
3868 break;
3869 }
3870 }
3871 }
3872 }
3873
3874 instr_at_put(entry.position(), 3841 instr_at_put(entry.position(),
3875 SetLdrRegisterImmediateOffset(instr, delta)); 3842 SetLdrRegisterImmediateOffset(instr, delta));
3876 3843 emit(entry.value());
3877 if (!found) {
3878 emit(entry.value());
3879 }
3880 } else { 3844 } else {
3881 DCHECK(IsMovW(instr)); 3845 DCHECK(IsMovW(instr));
3882 } 3846 }
3883 } 3847 }
3884 3848
3885 num_pending_32_bit_constants_ = 0; 3849 num_pending_32_bit_constants_ = 0;
3886 num_pending_64_bit_constants_ = 0; 3850 num_pending_64_bit_constants_ = 0;
3887 first_const_pool_32_use_ = -1; 3851 first_const_pool_32_use_ = -1;
3888 first_const_pool_64_use_ = -1; 3852 first_const_pool_64_use_ = -1;
3889 3853
3890 RecordComment("]"); 3854 RecordComment("]");
3891 3855
3856 DCHECK_EQ(size, SizeOfCodeGeneratedSince(&size_check));
3857
3892 if (after_pool.is_linked()) { 3858 if (after_pool.is_linked()) {
3893 bind(&after_pool); 3859 bind(&after_pool);
3894 } 3860 }
3895 } 3861 }
3896 3862
3897 // Since a constant pool was just emitted, move the check offset forward by 3863 // Since a constant pool was just emitted, move the check offset forward by
3898 // the standard interval. 3864 // the standard interval.
3899 next_buffer_check_ = pc_offset() + kCheckPoolInterval; 3865 next_buffer_check_ = pc_offset() + kCheckPoolInterval;
3900 } 3866 }
3901 3867
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3951 DCHECK(is_uint12(offset)); 3917 DCHECK(is_uint12(offset));
3952 instr_at_put(pc, SetLdrRegisterImmediateOffset(instr, offset)); 3918 instr_at_put(pc, SetLdrRegisterImmediateOffset(instr, offset));
3953 } 3919 }
3954 } 3920 }
3955 3921
3956 3922
3957 } // namespace internal 3923 } // namespace internal
3958 } // namespace v8 3924 } // namespace v8
3959 3925
3960 #endif // V8_TARGET_ARCH_ARM 3926 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698