| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 | 48 |
| 49 // Assembler fixups are positions in generated code that hold relocation | 49 // Assembler fixups are positions in generated code that hold relocation |
| 50 // information that needs to be processed before finalizing the code | 50 // information that needs to be processed before finalizing the code |
| 51 // into executable memory. | 51 // into executable memory. |
| 52 class AssemblerFixup : public ZoneAllocated { | 52 class AssemblerFixup : public ZoneAllocated { |
| 53 public: | 53 public: |
| 54 virtual void Process(const MemoryRegion& region, intptr_t position) = 0; | 54 virtual void Process(const MemoryRegion& region, intptr_t position) = 0; |
| 55 | 55 |
| 56 virtual bool IsPointerOffset() const = 0; |
| 57 |
| 56 // It would be ideal if the destructor method could be made private, | 58 // It would be ideal if the destructor method could be made private, |
| 57 // but the g++ compiler complains when this is subclassed. | 59 // but the g++ compiler complains when this is subclassed. |
| 58 virtual ~AssemblerFixup() { UNREACHABLE(); } | 60 virtual ~AssemblerFixup() { UNREACHABLE(); } |
| 59 | 61 |
| 60 private: | 62 private: |
| 61 AssemblerFixup* previous_; | 63 AssemblerFixup* previous_; |
| 62 intptr_t position_; | 64 intptr_t position_; |
| 63 | 65 |
| 64 AssemblerFixup* previous() const { return previous_; } | 66 AssemblerFixup* previous() const { return previous_; } |
| 65 void set_previous(AssemblerFixup* previous) { previous_ = previous; } | 67 void set_previous(AssemblerFixup* previous) { previous_ = previous; } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Emit an object pointer directly in the code. | 113 // Emit an object pointer directly in the code. |
| 112 void EmitObject(const Object& object); | 114 void EmitObject(const Object& object); |
| 113 | 115 |
| 114 // Emit a fixup at the current location. | 116 // Emit a fixup at the current location. |
| 115 void EmitFixup(AssemblerFixup* fixup) { | 117 void EmitFixup(AssemblerFixup* fixup) { |
| 116 fixup->set_previous(fixup_); | 118 fixup->set_previous(fixup_); |
| 117 fixup->set_position(Size()); | 119 fixup->set_position(Size()); |
| 118 fixup_ = fixup; | 120 fixup_ = fixup; |
| 119 } | 121 } |
| 120 | 122 |
| 123 // Count the fixups that produce a pointer offset, without processing |
| 124 // the fixups. |
| 125 intptr_t CountPointerOffsets() const; |
| 126 |
| 121 // Get the size of the emitted code. | 127 // Get the size of the emitted code. |
| 122 intptr_t Size() const { return cursor_ - contents_; } | 128 intptr_t Size() const { return cursor_ - contents_; } |
| 123 uword contents() const { return contents_; } | 129 uword contents() const { return contents_; } |
| 124 | 130 |
| 125 // Copy the assembled instructions into the specified memory block | 131 // Copy the assembled instructions into the specified memory block |
| 126 // and apply all fixups. | 132 // and apply all fixups. |
| 127 void FinalizeInstructions(const MemoryRegion& region); | 133 void FinalizeInstructions(const MemoryRegion& region); |
| 128 | 134 |
| 129 // To emit an instruction to the assembler buffer, the EnsureCapacity helper | 135 // To emit an instruction to the assembler buffer, the EnsureCapacity helper |
| 130 // must be used to guarantee that the underlying data area is big enough to | 136 // must be used to guarantee that the underlying data area is big enough to |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 #include "vm/assembler_x64.h" | 217 #include "vm/assembler_x64.h" |
| 212 #elif defined(TARGET_ARCH_ARM) | 218 #elif defined(TARGET_ARCH_ARM) |
| 213 #include "vm/assembler_arm.h" | 219 #include "vm/assembler_arm.h" |
| 214 #elif defined(TARGET_ARCH_MIPS) | 220 #elif defined(TARGET_ARCH_MIPS) |
| 215 #include "vm/assembler_mips.h" | 221 #include "vm/assembler_mips.h" |
| 216 #else | 222 #else |
| 217 #error Unknown architecture. | 223 #error Unknown architecture. |
| 218 #endif | 224 #endif |
| 219 | 225 |
| 220 #endif // VM_ASSEMBLER_H_ | 226 #endif // VM_ASSEMBLER_H_ |
| OLD | NEW |