| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef VM_ASSEMBLER_H_ | 5 #ifndef VM_ASSEMBLER_H_ |
| 6 #define VM_ASSEMBLER_H_ | 6 #define VM_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const char* name() const { return name_; } | 32 const char* name() const { return name_; } |
| 33 bool is_resolved() const { return address_ != 0; } | 33 bool is_resolved() const { return address_ != 0; } |
| 34 uword address() const { | 34 uword address() const { |
| 35 ASSERT(is_resolved()); | 35 ASSERT(is_resolved()); |
| 36 return address_; | 36 return address_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 const char* name_; | 40 const char* name_; |
| 41 const uword address_; | 41 const uword address_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(ExternalLabel); |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 | 46 |
| 45 // Assembler fixups are positions in generated code that hold relocation | 47 // Assembler fixups are positions in generated code that hold relocation |
| 46 // information that needs to be processed before finalizing the code | 48 // information that needs to be processed before finalizing the code |
| 47 // into executable memory. | 49 // into executable memory. |
| 48 class AssemblerFixup : public ZoneAllocated { | 50 class AssemblerFixup : public ZoneAllocated { |
| 49 public: | 51 public: |
| 50 virtual void Process(const MemoryRegion& region, int position) = 0; | 52 virtual void Process(const MemoryRegion& region, int position) = 0; |
| 51 | 53 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 class EnsureCapacity : public ValueObject { | 129 class EnsureCapacity : public ValueObject { |
| 128 public: | 130 public: |
| 129 explicit EnsureCapacity(AssemblerBuffer* buffer); | 131 explicit EnsureCapacity(AssemblerBuffer* buffer); |
| 130 ~EnsureCapacity(); | 132 ~EnsureCapacity(); |
| 131 | 133 |
| 132 private: | 134 private: |
| 133 AssemblerBuffer* buffer_; | 135 AssemblerBuffer* buffer_; |
| 134 intptr_t gap_; | 136 intptr_t gap_; |
| 135 | 137 |
| 136 intptr_t ComputeGap() { return buffer_->Capacity() - buffer_->Size(); } | 138 intptr_t ComputeGap() { return buffer_->Capacity() - buffer_->Size(); } |
| 139 DISALLOW_COPY_AND_ASSIGN(EnsureCapacity); |
| 137 }; | 140 }; |
| 138 | 141 |
| 139 bool has_ensured_capacity_; | 142 bool has_ensured_capacity_; |
| 140 bool HasEnsuredCapacity() const { return has_ensured_capacity_; } | 143 bool HasEnsuredCapacity() const { return has_ensured_capacity_; } |
| 141 #else | 144 #else |
| 142 class EnsureCapacity : public ValueObject { | 145 class EnsureCapacity : public ValueObject { |
| 143 public: | 146 public: |
| 144 explicit EnsureCapacity(AssemblerBuffer* buffer) { | 147 explicit EnsureCapacity(AssemblerBuffer* buffer) { |
| 145 if (buffer->cursor() >= buffer->limit()) buffer->ExtendCapacity(); | 148 if (buffer->cursor() >= buffer->limit()) buffer->ExtendCapacity(); |
| 146 } | 149 } |
| 150 private: |
| 151 DISALLOW_COPY_AND_ASSIGN(EnsureCapacity); |
| 147 }; | 152 }; |
| 148 | 153 |
| 149 // When building the C++ tests, assertion code is enabled. To allow | 154 // When building the C++ tests, assertion code is enabled. To allow |
| 150 // asserting that the user of the assembler buffer has ensured the | 155 // asserting that the user of the assembler buffer has ensured the |
| 151 // capacity needed for emitting, we add a dummy method in non-debug mode. | 156 // capacity needed for emitting, we add a dummy method in non-debug mode. |
| 152 bool HasEnsuredCapacity() const { return true; } | 157 bool HasEnsuredCapacity() const { return true; } |
| 153 #endif | 158 #endif |
| 154 | 159 |
| 155 // Returns the position in the instruction stream. | 160 // Returns the position in the instruction stream. |
| 156 intptr_t GetPosition() const { return cursor_ - contents_; } | 161 intptr_t GetPosition() const { return cursor_ - contents_; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 182 | 187 |
| 183 // Compute the limit based on the data area and the capacity. See | 188 // Compute the limit based on the data area and the capacity. See |
| 184 // description of kMinimumGap for the reasoning behind the value. | 189 // description of kMinimumGap for the reasoning behind the value. |
| 185 static uword ComputeLimit(uword data, intptr_t capacity) { | 190 static uword ComputeLimit(uword data, intptr_t capacity) { |
| 186 return data + capacity - kMinimumGap; | 191 return data + capacity - kMinimumGap; |
| 187 } | 192 } |
| 188 | 193 |
| 189 void ExtendCapacity(); | 194 void ExtendCapacity(); |
| 190 | 195 |
| 191 friend class AssemblerFixup; | 196 friend class AssemblerFixup; |
| 197 |
| 198 DISALLOW_COPY_AND_ASSIGN(AssemblerBuffer); |
| 192 }; | 199 }; |
| 193 | 200 |
| 194 } // namespace dart | 201 } // namespace dart |
| 195 | 202 |
| 196 | 203 |
| 197 #if defined(TARGET_ARCH_IA32) | 204 #if defined(TARGET_ARCH_IA32) |
| 198 #include "vm/assembler_ia32.h" | 205 #include "vm/assembler_ia32.h" |
| 199 #elif defined(TARGET_ARCH_X64) | 206 #elif defined(TARGET_ARCH_X64) |
| 200 #include "vm/assembler_x64.h" | 207 #include "vm/assembler_x64.h" |
| 201 #elif defined(TARGET_ARCH_ARM) | 208 #elif defined(TARGET_ARCH_ARM) |
| 202 #include "vm/assembler_arm.h" | 209 #include "vm/assembler_arm.h" |
| 203 #elif defined(TARGET_ARCH_MIPS) | 210 #elif defined(TARGET_ARCH_MIPS) |
| 204 #include "vm/assembler_mips.h" | 211 #include "vm/assembler_mips.h" |
| 205 #else | 212 #else |
| 206 #error Unknown architecture. | 213 #error Unknown architecture. |
| 207 #endif | 214 #endif |
| 208 | 215 |
| 209 #endif // VM_ASSEMBLER_H_ | 216 #endif // VM_ASSEMBLER_H_ |
| OLD | NEW |