| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 RUNTIME_VM_ASSEMBLER_DBC_H_ | 5 #ifndef RUNTIME_VM_ASSEMBLER_DBC_H_ |
| 6 #define RUNTIME_VM_ASSEMBLER_DBC_H_ | 6 #define RUNTIME_VM_ASSEMBLER_DBC_H_ |
| 7 | 7 |
| 8 #ifndef RUNTIME_VM_ASSEMBLER_H_ | 8 #ifndef RUNTIME_VM_ASSEMBLER_H_ |
| 9 #error Do not include assembler_dbc.h directly; use assembler.h instead. | 9 #error Do not include assembler_dbc.h directly; use assembler.h instead. |
| 10 #endif | 10 #endif |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Dummy declaration to make things compile. | 23 // Dummy declaration to make things compile. |
| 24 class Address : public ValueObject { | 24 class Address : public ValueObject { |
| 25 private: | 25 private: |
| 26 Address(); | 26 Address(); |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 | 29 |
| 30 class Label : public ValueObject { | 30 class Label : public ValueObject { |
| 31 public: | 31 public: |
| 32 Label() : position_(0) { } | 32 Label() : position_(0) {} |
| 33 | 33 |
| 34 ~Label() { | 34 ~Label() { |
| 35 // Assert if label is being destroyed with unresolved branches pending. | 35 // Assert if label is being destroyed with unresolved branches pending. |
| 36 ASSERT(!IsLinked()); | 36 ASSERT(!IsLinked()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Returns the position for bound and linked labels. Cannot be used | 39 // Returns the position for bound and linked labels. Cannot be used |
| 40 // for unused labels. | 40 // for unused labels. |
| 41 intptr_t Position() const { | 41 intptr_t Position() const { |
| 42 ASSERT(!IsUnused()); | 42 ASSERT(!IsUnused()); |
| 43 return IsBound() ? -position_ - kWordSize : position_ - kWordSize; | 43 return IsBound() ? -position_ - kWordSize : position_ - kWordSize; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool IsBound() const { return position_ < 0; } | 46 bool IsBound() const { return position_ < 0; } |
| 47 bool IsUnused() const { return position_ == 0; } | 47 bool IsUnused() const { return position_ == 0; } |
| 48 bool IsLinked() const { return position_ > 0; } | 48 bool IsLinked() const { return position_ > 0; } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 intptr_t position_; | 51 intptr_t position_; |
| 52 | 52 |
| 53 void Reinitialize() { | 53 void Reinitialize() { position_ = 0; } |
| 54 position_ = 0; | |
| 55 } | |
| 56 | 54 |
| 57 void BindTo(intptr_t position) { | 55 void BindTo(intptr_t position) { |
| 58 ASSERT(!IsBound()); | 56 ASSERT(!IsBound()); |
| 59 position_ = -position - kWordSize; | 57 position_ = -position - kWordSize; |
| 60 ASSERT(IsBound()); | 58 ASSERT(IsBound()); |
| 61 } | 59 } |
| 62 | 60 |
| 63 void LinkTo(intptr_t position) { | 61 void LinkTo(intptr_t position) { |
| 64 ASSERT(!IsBound()); | 62 ASSERT(!IsBound()); |
| 65 position_ = position + kWordSize; | 63 position_ = position + kWordSize; |
| 66 ASSERT(IsLinked()); | 64 ASSERT(IsLinked()); |
| 67 } | 65 } |
| 68 | 66 |
| 69 friend class Assembler; | 67 friend class Assembler; |
| 70 DISALLOW_COPY_AND_ASSIGN(Label); | 68 DISALLOW_COPY_AND_ASSIGN(Label); |
| 71 }; | 69 }; |
| 72 | 70 |
| 73 | 71 |
| 74 class Assembler : public ValueObject { | 72 class Assembler : public ValueObject { |
| 75 public: | 73 public: |
| 76 explicit Assembler(bool use_far_branches = false) | 74 explicit Assembler(bool use_far_branches = false) : buffer_(), comments_() {} |
| 77 : buffer_(), | |
| 78 comments_() { | |
| 79 } | |
| 80 | 75 |
| 81 ~Assembler() { } | 76 ~Assembler() {} |
| 82 | 77 |
| 83 void Bind(Label* label); | 78 void Bind(Label* label); |
| 84 void Jump(Label* label); | 79 void Jump(Label* label); |
| 85 | 80 |
| 86 // Misc. functionality | 81 // Misc. functionality |
| 87 intptr_t CodeSize() const { return buffer_.Size(); } | 82 intptr_t CodeSize() const { return buffer_.Size(); } |
| 88 intptr_t prologue_offset() const { return 0; } | 83 intptr_t prologue_offset() const { return 0; } |
| 89 bool has_single_entry_point() const { return true; } | 84 bool has_single_entry_point() const { return true; } |
| 90 | 85 |
| 91 // Count the fixups that produce a pointer offset, without processing | 86 // Count the fixups that produce a pointer offset, without processing |
| (...skipping 23 matching lines...) Expand all Loading... |
| 115 | 110 |
| 116 static void InitializeMemoryWithBreakpoints(uword data, intptr_t length); | 111 static void InitializeMemoryWithBreakpoints(uword data, intptr_t length); |
| 117 | 112 |
| 118 void Comment(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 113 void Comment(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
| 119 static bool EmittingComments(); | 114 static bool EmittingComments(); |
| 120 | 115 |
| 121 const Code::Comments& GetCodeComments() const; | 116 const Code::Comments& GetCodeComments() const; |
| 122 | 117 |
| 123 static const char* RegisterName(Register reg); | 118 static const char* RegisterName(Register reg); |
| 124 | 119 |
| 125 static const char* FpuRegisterName(FpuRegister reg) { | 120 static const char* FpuRegisterName(FpuRegister reg) { return "?"; } |
| 126 return "?"; | |
| 127 } | |
| 128 | 121 |
| 129 static uword GetBreakInstructionFiller() { | 122 static uword GetBreakInstructionFiller() { return Bytecode::kTrap; } |
| 130 return Bytecode::kTrap; | |
| 131 } | |
| 132 | 123 |
| 133 static bool IsSafe(const Object& value) { return true; } | 124 static bool IsSafe(const Object& value) { return true; } |
| 134 static bool IsSafeSmi(const Object& value) { return false; } | 125 static bool IsSafeSmi(const Object& value) { return false; } |
| 135 | 126 |
| 136 // Bytecodes. | 127 // Bytecodes. |
| 137 | 128 |
| 138 #define DECLARE_EMIT(Name, Signature, Fmt0, Fmt1, Fmt2) \ | 129 #define DECLARE_EMIT(Name, Signature, Fmt0, Fmt1, Fmt2) \ |
| 139 void Name(PARAMS_##Signature); | 130 void Name(PARAMS_##Signature); |
| 140 | 131 |
| 141 #define PARAMS_0 | 132 #define PARAMS_0 |
| 142 #define PARAMS_A_D uintptr_t ra, uintptr_t rd | 133 #define PARAMS_A_D uintptr_t ra, uintptr_t rd |
| 143 #define PARAMS_D uintptr_t rd | 134 #define PARAMS_D uintptr_t rd |
| 144 #define PARAMS_A_B_C uintptr_t ra, uintptr_t rb, uintptr_t rc | 135 #define PARAMS_A_B_C uintptr_t ra, uintptr_t rb, uintptr_t rc |
| 145 #define PARAMS_A uintptr_t ra | 136 #define PARAMS_A uintptr_t ra |
| 146 #define PARAMS_X intptr_t x | 137 #define PARAMS_X intptr_t x |
| 147 #define PARAMS_T intptr_t x | 138 #define PARAMS_T intptr_t x |
| 148 #define PARAMS_A_X uintptr_t ra, intptr_t x | 139 #define PARAMS_A_X uintptr_t ra, intptr_t x |
| (...skipping 20 matching lines...) Expand all Loading... |
| 169 | 160 |
| 170 void Nop(intptr_t d) { Nop(0, d); } | 161 void Nop(intptr_t d) { Nop(0, d); } |
| 171 | 162 |
| 172 private: | 163 private: |
| 173 AssemblerBuffer buffer_; // Contains position independent code. | 164 AssemblerBuffer buffer_; // Contains position independent code. |
| 174 ObjectPoolWrapper object_pool_wrapper_; | 165 ObjectPoolWrapper object_pool_wrapper_; |
| 175 | 166 |
| 176 class CodeComment : public ZoneAllocated { | 167 class CodeComment : public ZoneAllocated { |
| 177 public: | 168 public: |
| 178 CodeComment(intptr_t pc_offset, const String& comment) | 169 CodeComment(intptr_t pc_offset, const String& comment) |
| 179 : pc_offset_(pc_offset), comment_(comment) { } | 170 : pc_offset_(pc_offset), comment_(comment) {} |
| 180 | 171 |
| 181 intptr_t pc_offset() const { return pc_offset_; } | 172 intptr_t pc_offset() const { return pc_offset_; } |
| 182 const String& comment() const { return comment_; } | 173 const String& comment() const { return comment_; } |
| 183 | 174 |
| 184 private: | 175 private: |
| 185 intptr_t pc_offset_; | 176 intptr_t pc_offset_; |
| 186 const String& comment_; | 177 const String& comment_; |
| 187 | 178 |
| 188 DISALLOW_COPY_AND_ASSIGN(CodeComment); | 179 DISALLOW_COPY_AND_ASSIGN(CodeComment); |
| 189 }; | 180 }; |
| 190 | 181 |
| 191 GrowableArray<CodeComment*> comments_; | 182 GrowableArray<CodeComment*> comments_; |
| 192 | 183 |
| 193 DISALLOW_ALLOCATION(); | 184 DISALLOW_ALLOCATION(); |
| 194 DISALLOW_COPY_AND_ASSIGN(Assembler); | 185 DISALLOW_COPY_AND_ASSIGN(Assembler); |
| 195 }; | 186 }; |
| 196 | 187 |
| 197 | 188 |
| 198 } // namespace dart | 189 } // namespace dart |
| 199 | 190 |
| 200 #endif // RUNTIME_VM_ASSEMBLER_DBC_H_ | 191 #endif // RUNTIME_VM_ASSEMBLER_DBC_H_ |
| OLD | NEW |