| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| 11 #include "vm/runtime_entry.h" | 11 #include "vm/runtime_entry.h" |
| 12 #include "vm/simulator.h" | 12 #include "vm/simulator.h" |
| 13 #include "vm/stack_frame.h" | 13 #include "vm/stack_frame.h" |
| 14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
| 15 | 15 |
| 16 // An extra check since we are assuming the existence of /proc/cpuinfo below. | 16 // An extra check since we are assuming the existence of /proc/cpuinfo below. |
| 17 #if !defined(USING_SIMULATOR) && !defined(__linux__) && !defined(ANDROID) | 17 #if !defined(USING_SIMULATOR) && !defined(__linux__) && !defined(ANDROID) |
| 18 #error ARM64 cross-compile only supported on Linux | 18 #error ARM64 cross-compile only supported on Linux |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); | 23 DEFINE_FLAG(bool, print_stop_message, false, "Print stop message."); |
| 24 DECLARE_FLAG(bool, inline_alloc); | 24 DECLARE_FLAG(bool, inline_alloc); |
| 25 | 25 |
| 26 | 26 |
| 27 Assembler::Assembler(bool use_far_branches) | 27 Assembler::Assembler(bool use_far_branches) |
| 28 : buffer_(), | 28 : buffer_(), |
| 29 object_pool_(GrowableObjectArray::Handle()), | 29 object_pool_(GrowableObjectArray::Handle()), |
| 30 patchable_pool_entries_(), | 30 patchable_pool_entries_(), |
| 31 prologue_offset_(-1), | 31 prologue_offset_(-1), |
| 32 use_far_branches_(use_far_branches), | 32 use_far_branches_(use_far_branches), |
| 33 comments_() { | 33 comments_() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 56 ASSERT(Utils::IsAligned(data, 4)); | 56 ASSERT(Utils::IsAligned(data, 4)); |
| 57 ASSERT(Utils::IsAligned(length, 4)); | 57 ASSERT(Utils::IsAligned(length, 4)); |
| 58 const uword end = data + length; | 58 const uword end = data + length; |
| 59 while (data < end) { | 59 while (data < end) { |
| 60 *reinterpret_cast<int32_t*>(data) = Instr::kBreakPointInstruction; | 60 *reinterpret_cast<int32_t*>(data) = Instr::kBreakPointInstruction; |
| 61 data += 4; | 61 data += 4; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 void Assembler::Stop(const char* message) { | |
| 67 UNIMPLEMENTED(); | |
| 68 } | |
| 69 | |
| 70 | |
| 71 void Assembler::Emit(int32_t value) { | 66 void Assembler::Emit(int32_t value) { |
| 72 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 67 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 73 buffer_.Emit<int32_t>(value); | 68 buffer_.Emit<int32_t>(value); |
| 74 } | 69 } |
| 75 | 70 |
| 76 | 71 |
| 77 static const char* cpu_reg_names[kNumberOfCpuRegisters] = { | 72 static const char* cpu_reg_names[kNumberOfCpuRegisters] = { |
| 78 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | 73 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 79 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", | 74 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", |
| 80 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", | 75 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 const int64_t dest = bound_pc - position; | 107 const int64_t dest = bound_pc - position; |
| 113 const int32_t next = buffer_.Load<int32_t>(position); | 108 const int32_t next = buffer_.Load<int32_t>(position); |
| 114 const int32_t encoded = EncodeImm19BranchOffset(dest, next); | 109 const int32_t encoded = EncodeImm19BranchOffset(dest, next); |
| 115 buffer_.Store<int32_t>(position, encoded); | 110 buffer_.Store<int32_t>(position, encoded); |
| 116 label->position_ = DecodeImm19BranchOffset(next); | 111 label->position_ = DecodeImm19BranchOffset(next); |
| 117 } | 112 } |
| 118 label->BindTo(bound_pc); | 113 label->BindTo(bound_pc); |
| 119 } | 114 } |
| 120 | 115 |
| 121 | 116 |
| 117 void Assembler::Stop(const char* message) { |
| 118 if (FLAG_print_stop_message) { |
| 119 UNIMPLEMENTED(); |
| 120 } |
| 121 Label stop; |
| 122 b(&stop); |
| 123 Emit(Utils::Low32Bits(reinterpret_cast<int64_t>(message))); |
| 124 Emit(Utils::High32Bits(reinterpret_cast<int64_t>(message))); |
| 125 Bind(&stop); |
| 126 hlt(kImmExceptionIsDebug); |
| 127 } |
| 128 |
| 129 |
| 122 static int CountLeadingZeros(uint64_t value, int width) { | 130 static int CountLeadingZeros(uint64_t value, int width) { |
| 123 ASSERT((width == 32) || (width == 64)); | 131 ASSERT((width == 32) || (width == 64)); |
| 124 if (value == 0) { | 132 if (value == 0) { |
| 125 return width; | 133 return width; |
| 126 } | 134 } |
| 127 int count = 0; | 135 int count = 0; |
| 128 do { | 136 do { |
| 129 count++; | 137 count++; |
| 130 } while (value >>= 1); | 138 } while (value >>= 1); |
| 131 return width - count; | 139 return width - count; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } else { | 439 } else { |
| 432 movz(reg, h3, 3); | 440 movz(reg, h3, 3); |
| 433 } | 441 } |
| 434 } | 442 } |
| 435 } | 443 } |
| 436 } | 444 } |
| 437 | 445 |
| 438 } // namespace dart | 446 } // namespace dart |
| 439 | 447 |
| 440 #endif // defined TARGET_ARCH_ARM64 | 448 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |