OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 2813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2824 desc.buffer_size = 2 * buffer_size_; | 2824 desc.buffer_size = 2 * buffer_size_; |
2825 } else { | 2825 } else { |
2826 desc.buffer_size = buffer_size_ + 1 * MB; | 2826 desc.buffer_size = buffer_size_ + 1 * MB; |
2827 } | 2827 } |
2828 CHECK_GT(desc.buffer_size, 0); // No overflow. | 2828 CHECK_GT(desc.buffer_size, 0); // No overflow. |
2829 | 2829 |
2830 byte* buffer = reinterpret_cast<byte*>(buffer_); | 2830 byte* buffer = reinterpret_cast<byte*>(buffer_); |
2831 | 2831 |
2832 // Set up new buffer. | 2832 // Set up new buffer. |
2833 desc.buffer = NewArray<byte>(desc.buffer_size); | 2833 desc.buffer = NewArray<byte>(desc.buffer_size); |
| 2834 desc.origin = this; |
2834 | 2835 |
2835 desc.instr_size = pc_offset(); | 2836 desc.instr_size = pc_offset(); |
2836 desc.reloc_size = | 2837 desc.reloc_size = |
2837 static_cast<int>((buffer + buffer_size_) - reloc_info_writer.pos()); | 2838 static_cast<int>((buffer + buffer_size_) - reloc_info_writer.pos()); |
2838 | 2839 |
2839 // Copy the data. | 2840 // Copy the data. |
2840 intptr_t pc_delta = desc.buffer - buffer; | 2841 intptr_t pc_delta = desc.buffer - buffer; |
2841 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - | 2842 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - |
2842 (buffer + buffer_size_); | 2843 (buffer + buffer_size_); |
2843 memmove(desc.buffer, buffer, desc.instr_size); | 2844 memmove(desc.buffer, buffer, desc.instr_size); |
(...skipping 17 matching lines...) Expand all Loading... |
2861 intptr_t* p = reinterpret_cast<intptr_t*>(buffer_ + pos); | 2862 intptr_t* p = reinterpret_cast<intptr_t*>(buffer_ + pos); |
2862 *p += pc_delta; | 2863 *p += pc_delta; |
2863 } | 2864 } |
2864 | 2865 |
2865 // Pending relocation entries are also relative, no need to relocate. | 2866 // Pending relocation entries are also relative, no need to relocate. |
2866 } | 2867 } |
2867 | 2868 |
2868 | 2869 |
2869 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { | 2870 void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { |
2870 // We do not try to reuse pool constants. | 2871 // We do not try to reuse pool constants. |
2871 RelocInfo rinfo(reinterpret_cast<byte*>(pc_), rmode, data, NULL); | 2872 RelocInfo rinfo(isolate(), reinterpret_cast<byte*>(pc_), rmode, data, NULL); |
2872 if (((rmode >= RelocInfo::COMMENT) && | 2873 if (((rmode >= RelocInfo::COMMENT) && |
2873 (rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL)) || | 2874 (rmode <= RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL)) || |
2874 (rmode == RelocInfo::INTERNAL_REFERENCE) || | 2875 (rmode == RelocInfo::INTERNAL_REFERENCE) || |
2875 (rmode == RelocInfo::CONST_POOL) || (rmode == RelocInfo::VENEER_POOL) || | 2876 (rmode == RelocInfo::CONST_POOL) || (rmode == RelocInfo::VENEER_POOL) || |
2876 (rmode == RelocInfo::DEOPT_REASON) || | 2877 (rmode == RelocInfo::DEOPT_REASON) || |
2877 (rmode == RelocInfo::GENERATOR_CONTINUATION)) { | 2878 (rmode == RelocInfo::GENERATOR_CONTINUATION)) { |
2878 // Adjust code for new modes. | 2879 // Adjust code for new modes. |
2879 DCHECK(RelocInfo::IsDebugBreakSlot(rmode) || RelocInfo::IsComment(rmode) || | 2880 DCHECK(RelocInfo::IsDebugBreakSlot(rmode) || RelocInfo::IsComment(rmode) || |
2880 RelocInfo::IsDeoptReason(rmode) || RelocInfo::IsPosition(rmode) || | 2881 RelocInfo::IsDeoptReason(rmode) || RelocInfo::IsPosition(rmode) || |
2881 RelocInfo::IsInternalReference(rmode) || | 2882 RelocInfo::IsInternalReference(rmode) || |
2882 RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode) || | 2883 RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode) || |
2883 RelocInfo::IsGeneratorContinuation(rmode)); | 2884 RelocInfo::IsGeneratorContinuation(rmode)); |
2884 // These modes do not need an entry in the constant pool. | 2885 // These modes do not need an entry in the constant pool. |
2885 } else { | 2886 } else { |
2886 constpool_.RecordEntry(data, rmode); | 2887 constpool_.RecordEntry(data, rmode); |
2887 // Make sure the constant pool is not emitted in place of the next | 2888 // Make sure the constant pool is not emitted in place of the next |
2888 // instruction for which we just recorded relocation info. | 2889 // instruction for which we just recorded relocation info. |
2889 BlockConstPoolFor(1); | 2890 BlockConstPoolFor(1); |
2890 } | 2891 } |
2891 | 2892 |
2892 if (!RelocInfo::IsNone(rmode)) { | 2893 if (!RelocInfo::IsNone(rmode)) { |
2893 // Don't record external references unless the heap will be serialized. | 2894 // Don't record external references unless the heap will be serialized. |
2894 if (rmode == RelocInfo::EXTERNAL_REFERENCE && | 2895 if (rmode == RelocInfo::EXTERNAL_REFERENCE && |
2895 !serializer_enabled() && !emit_debug_code()) { | 2896 !serializer_enabled() && !emit_debug_code()) { |
2896 return; | 2897 return; |
2897 } | 2898 } |
2898 DCHECK(buffer_space() >= kMaxRelocSize); // too late to grow buffer here | 2899 DCHECK(buffer_space() >= kMaxRelocSize); // too late to grow buffer here |
2899 if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { | 2900 if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { |
2900 RelocInfo reloc_info_with_ast_id( | 2901 RelocInfo reloc_info_with_ast_id(isolate(), reinterpret_cast<byte*>(pc_), |
2901 reinterpret_cast<byte*>(pc_), rmode, RecordedAstId().ToInt(), NULL); | 2902 rmode, RecordedAstId().ToInt(), NULL); |
2902 ClearRecordedAstId(); | 2903 ClearRecordedAstId(); |
2903 reloc_info_writer.Write(&reloc_info_with_ast_id); | 2904 reloc_info_writer.Write(&reloc_info_with_ast_id); |
2904 } else { | 2905 } else { |
2905 reloc_info_writer.Write(&rinfo); | 2906 reloc_info_writer.Write(&rinfo); |
2906 } | 2907 } |
2907 } | 2908 } |
2908 } | 2909 } |
2909 | 2910 |
2910 | 2911 |
2911 void Assembler::BlockConstPoolFor(int instructions) { | 2912 void Assembler::BlockConstPoolFor(int instructions) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 | 2981 |
2981 bool Assembler::ShouldEmitVeneer(int max_reachable_pc, int margin) { | 2982 bool Assembler::ShouldEmitVeneer(int max_reachable_pc, int margin) { |
2982 // Account for the branch around the veneers and the guard. | 2983 // Account for the branch around the veneers and the guard. |
2983 int protection_offset = 2 * kInstructionSize; | 2984 int protection_offset = 2 * kInstructionSize; |
2984 return pc_offset() > max_reachable_pc - margin - protection_offset - | 2985 return pc_offset() > max_reachable_pc - margin - protection_offset - |
2985 static_cast<int>(unresolved_branches_.size() * kMaxVeneerCodeSize); | 2986 static_cast<int>(unresolved_branches_.size() * kMaxVeneerCodeSize); |
2986 } | 2987 } |
2987 | 2988 |
2988 | 2989 |
2989 void Assembler::RecordVeneerPool(int location_offset, int size) { | 2990 void Assembler::RecordVeneerPool(int location_offset, int size) { |
2990 RelocInfo rinfo(buffer_ + location_offset, | 2991 RelocInfo rinfo(isolate(), buffer_ + location_offset, RelocInfo::VENEER_POOL, |
2991 RelocInfo::VENEER_POOL, static_cast<intptr_t>(size), | 2992 static_cast<intptr_t>(size), NULL); |
2992 NULL); | |
2993 reloc_info_writer.Write(&rinfo); | 2993 reloc_info_writer.Write(&rinfo); |
2994 } | 2994 } |
2995 | 2995 |
2996 | 2996 |
2997 void Assembler::EmitVeneers(bool force_emit, bool need_protection, int margin) { | 2997 void Assembler::EmitVeneers(bool force_emit, bool need_protection, int margin) { |
2998 BlockPoolsScope scope(this); | 2998 BlockPoolsScope scope(this); |
2999 RecordComment("[ Veneers"); | 2999 RecordComment("[ Veneers"); |
3000 | 3000 |
3001 // The exact size of the veneer pool must be recorded (see the comment at the | 3001 // The exact size of the veneer pool must be recorded (see the comment at the |
3002 // declaration site of RecordConstPool()), but computing the number of | 3002 // declaration site of RecordConstPool()), but computing the number of |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3137 movk(scratch, (target_offset >> 32) & 0xFFFF, 32); | 3137 movk(scratch, (target_offset >> 32) & 0xFFFF, 32); |
3138 DCHECK((target_offset >> 48) == 0); | 3138 DCHECK((target_offset >> 48) == 0); |
3139 add(rd, rd, scratch); | 3139 add(rd, rd, scratch); |
3140 } | 3140 } |
3141 | 3141 |
3142 | 3142 |
3143 } // namespace internal | 3143 } // namespace internal |
3144 } // namespace v8 | 3144 } // namespace v8 |
3145 | 3145 |
3146 #endif // V8_TARGET_ARCH_ARM64 | 3146 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |