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 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2764 | 2764 |
2765 return true; | 2765 return true; |
2766 } | 2766 } |
2767 | 2767 |
2768 | 2768 |
2769 void Assembler::GrowBuffer() { | 2769 void Assembler::GrowBuffer() { |
2770 if (!own_buffer_) FATAL("external code buffer is too small"); | 2770 if (!own_buffer_) FATAL("external code buffer is too small"); |
2771 | 2771 |
2772 // Compute new buffer size. | 2772 // Compute new buffer size. |
2773 CodeDesc desc; // the new buffer | 2773 CodeDesc desc; // the new buffer |
2774 if (buffer_size_ < 4 * KB) { | 2774 if (buffer_size_ == 0) { |
2775 desc.buffer_size = 4 * KB; | 2775 desc.buffer_size = kMinimalBufferSize; |
2776 } else if (buffer_size_ < 1 * MB) { | 2776 } else if (buffer_size_ < 1 * MB) { |
2777 desc.buffer_size = 2 * buffer_size_; | 2777 desc.buffer_size = 2 * buffer_size_; |
2778 } else { | 2778 } else { |
2779 desc.buffer_size = buffer_size_ + 1 * MB; | 2779 desc.buffer_size = buffer_size_ + 1 * MB; |
2780 } | 2780 } |
2781 CHECK_GT(desc.buffer_size, 0); // No overflow. | 2781 CHECK_GT(desc.buffer_size, 0); // No overflow. |
2782 | 2782 |
2783 byte* buffer = reinterpret_cast<byte*>(buffer_); | 2783 byte* buffer = reinterpret_cast<byte*>(buffer_); |
2784 | 2784 |
2785 // Set up new buffer. | 2785 // Set up new buffer. |
2786 desc.buffer = NewArray<byte>(desc.buffer_size); | 2786 desc.buffer = NewArray<byte>(desc.buffer_size); |
2787 | 2787 |
2788 desc.instr_size = pc_offset(); | 2788 desc.instr_size = pc_offset(); |
2789 desc.reloc_size = (buffer + buffer_size_) - reloc_info_writer.pos(); | 2789 desc.reloc_size = (buffer + buffer_size_) - reloc_info_writer.pos(); |
2790 | 2790 |
2791 // Copy the data. | 2791 // Copy the data. |
2792 intptr_t pc_delta = desc.buffer - buffer; | 2792 intptr_t pc_delta = desc.buffer - buffer; |
2793 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - | 2793 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - |
2794 (buffer + buffer_size_); | 2794 (buffer + buffer_size_); |
2795 memmove(desc.buffer, buffer, desc.instr_size); | 2795 memmove(desc.buffer, buffer, desc.instr_size); |
2796 memmove(reloc_info_writer.pos() + rc_delta, | 2796 memmove(reloc_info_writer.pos() + rc_delta, |
2797 reloc_info_writer.pos(), desc.reloc_size); | 2797 reloc_info_writer.pos(), desc.reloc_size); |
2798 | 2798 |
2799 // Switch buffers. | 2799 // Switch buffers. |
Igor Sheludko
2014/08/06 16:52:08
Same here.
| |
2800 DeleteArray(buffer_); | 2800 DeleteArray(buffer_); |
2801 buffer_ = desc.buffer; | 2801 buffer_ = desc.buffer; |
2802 buffer_size_ = desc.buffer_size; | 2802 buffer_size_ = desc.buffer_size; |
2803 pc_ = reinterpret_cast<byte*>(pc_) + pc_delta; | 2803 pc_ = reinterpret_cast<byte*>(pc_) + pc_delta; |
2804 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, | 2804 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, |
2805 reloc_info_writer.last_pc() + pc_delta); | 2805 reloc_info_writer.last_pc() + pc_delta); |
2806 | 2806 |
2807 // None of our relocation types are pc relative pointing outside the code | 2807 // None of our relocation types are pc relative pointing outside the code |
2808 // buffer nor pc absolute pointing inside the code buffer, so there is no need | 2808 // buffer nor pc absolute pointing inside the code buffer, so there is no need |
2809 // to relocate any emitted relocation entries. | 2809 // to relocate any emitted relocation entries. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3116 movz(scratch, (target_offset >> 16) & 0xFFFF, 16); | 3116 movz(scratch, (target_offset >> 16) & 0xFFFF, 16); |
3117 movk(scratch, (target_offset >> 32) & 0xFFFF, 32); | 3117 movk(scratch, (target_offset >> 32) & 0xFFFF, 32); |
3118 DCHECK((target_offset >> 48) == 0); | 3118 DCHECK((target_offset >> 48) == 0); |
3119 add(rd, rd, scratch); | 3119 add(rd, rd, scratch); |
3120 } | 3120 } |
3121 | 3121 |
3122 | 3122 |
3123 } } // namespace v8::internal | 3123 } } // namespace v8::internal |
3124 | 3124 |
3125 #endif // V8_TARGET_ARCH_ARM64 | 3125 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |