| 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 // Classes that describe assembly patterns as used by inline caches. | 4 // Classes that describe assembly patterns as used by inline caches. |
| 5 | 5 |
| 6 #ifndef RUNTIME_VM_INSTRUCTIONS_X64_H_ | 6 #ifndef RUNTIME_VM_INSTRUCTIONS_X64_H_ |
| 7 #define RUNTIME_VM_INSTRUCTIONS_X64_H_ | 7 #define RUNTIME_VM_INSTRUCTIONS_X64_H_ |
| 8 | 8 |
| 9 #ifndef RUNTIME_VM_INSTRUCTIONS_H_ | 9 #ifndef RUNTIME_VM_INSTRUCTIONS_H_ |
| 10 #error Do not include instructions_ia32.h directly; use instructions.h instead. | 10 #error Do not include instructions_ia32.h directly; use instructions.h instead. |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "vm/allocation.h" | 13 #include "vm/allocation.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 class RawClass; | 19 class RawClass; |
| 20 class Immediate; | 20 class Immediate; |
| 21 class RawObject; | 21 class RawObject; |
| 22 | 22 |
| 23 | |
| 24 intptr_t IndexFromPPLoad(uword start); | 23 intptr_t IndexFromPPLoad(uword start); |
| 25 intptr_t IndexFromPPLoadDisp8(uword start); | 24 intptr_t IndexFromPPLoadDisp8(uword start); |
| 26 | 25 |
| 27 | |
| 28 // Template class for all instruction pattern classes. | 26 // Template class for all instruction pattern classes. |
| 29 // P has to specify a static pattern and a pattern length method. | 27 // P has to specify a static pattern and a pattern length method. |
| 30 template <class P> | 28 template <class P> |
| 31 class InstructionPattern : public ValueObject { | 29 class InstructionPattern : public ValueObject { |
| 32 public: | 30 public: |
| 33 explicit InstructionPattern(uword pc) : start_(pc) { ASSERT(pc != 0); } | 31 explicit InstructionPattern(uword pc) : start_(pc) { ASSERT(pc != 0); } |
| 34 | 32 |
| 35 // Call to check if the instruction pattern at 'pc' match the instruction. | 33 // Call to check if the instruction pattern at 'pc' match the instruction. |
| 36 // 'P::pattern()' returns the expected byte pattern in form of an integer | 34 // 'P::pattern()' returns the expected byte pattern in form of an integer |
| 37 // array with length of 'P::pattern_length_in_bytes()'. A '-1' element means | 35 // array with length of 'P::pattern_length_in_bytes()'. A '-1' element means |
| (...skipping 19 matching lines...) Expand all Loading... |
| 57 } | 55 } |
| 58 } | 56 } |
| 59 return true; | 57 return true; |
| 60 } | 58 } |
| 61 | 59 |
| 62 const uword start_; | 60 const uword start_; |
| 63 | 61 |
| 64 DISALLOW_COPY_AND_ASSIGN(InstructionPattern); | 62 DISALLOW_COPY_AND_ASSIGN(InstructionPattern); |
| 65 }; | 63 }; |
| 66 | 64 |
| 67 | |
| 68 class ReturnPattern : public InstructionPattern<ReturnPattern> { | 65 class ReturnPattern : public InstructionPattern<ReturnPattern> { |
| 69 public: | 66 public: |
| 70 explicit ReturnPattern(uword pc) : InstructionPattern(pc) {} | 67 explicit ReturnPattern(uword pc) : InstructionPattern(pc) {} |
| 71 | 68 |
| 72 static const int* pattern() { | 69 static const int* pattern() { |
| 73 static const int kReturnPattern[kLengthInBytes] = {0xC3}; | 70 static const int kReturnPattern[kLengthInBytes] = {0xC3}; |
| 74 return kReturnPattern; | 71 return kReturnPattern; |
| 75 } | 72 } |
| 76 | 73 |
| 77 static int pattern_length_in_bytes() { return kLengthInBytes; } | 74 static int pattern_length_in_bytes() { return kLengthInBytes; } |
| 78 | 75 |
| 79 private: | 76 private: |
| 80 static const int kLengthInBytes = 1; | 77 static const int kLengthInBytes = 1; |
| 81 }; | 78 }; |
| 82 | 79 |
| 83 | |
| 84 // push rbp | 80 // push rbp |
| 85 // mov rbp, rsp | 81 // mov rbp, rsp |
| 86 class ProloguePattern : public InstructionPattern<ProloguePattern> { | 82 class ProloguePattern : public InstructionPattern<ProloguePattern> { |
| 87 public: | 83 public: |
| 88 explicit ProloguePattern(uword pc) : InstructionPattern(pc) {} | 84 explicit ProloguePattern(uword pc) : InstructionPattern(pc) {} |
| 89 | 85 |
| 90 static const int* pattern() { | 86 static const int* pattern() { |
| 91 static const int kProloguePattern[kLengthInBytes] = {0x55, 0x48, 0x89, | 87 static const int kProloguePattern[kLengthInBytes] = {0x55, 0x48, 0x89, |
| 92 0xe5}; | 88 0xe5}; |
| 93 return kProloguePattern; | 89 return kProloguePattern; |
| 94 } | 90 } |
| 95 | 91 |
| 96 static int pattern_length_in_bytes() { return kLengthInBytes; } | 92 static int pattern_length_in_bytes() { return kLengthInBytes; } |
| 97 | 93 |
| 98 private: | 94 private: |
| 99 static const int kLengthInBytes = 4; | 95 static const int kLengthInBytes = 4; |
| 100 }; | 96 }; |
| 101 | 97 |
| 102 | |
| 103 // mov rbp, rsp | 98 // mov rbp, rsp |
| 104 class SetFramePointerPattern | 99 class SetFramePointerPattern |
| 105 : public InstructionPattern<SetFramePointerPattern> { | 100 : public InstructionPattern<SetFramePointerPattern> { |
| 106 public: | 101 public: |
| 107 explicit SetFramePointerPattern(uword pc) : InstructionPattern(pc) {} | 102 explicit SetFramePointerPattern(uword pc) : InstructionPattern(pc) {} |
| 108 | 103 |
| 109 static const int* pattern() { | 104 static const int* pattern() { |
| 110 static const int kFramePointerPattern[kLengthInBytes] = {0x48, 0x89, 0xe5}; | 105 static const int kFramePointerPattern[kLengthInBytes] = {0x48, 0x89, 0xe5}; |
| 111 return kFramePointerPattern; | 106 return kFramePointerPattern; |
| 112 } | 107 } |
| 113 | 108 |
| 114 static int pattern_length_in_bytes() { return kLengthInBytes; } | 109 static int pattern_length_in_bytes() { return kLengthInBytes; } |
| 115 | 110 |
| 116 private: | 111 private: |
| 117 static const int kLengthInBytes = 3; | 112 static const int kLengthInBytes = 3; |
| 118 }; | 113 }; |
| 119 | 114 |
| 120 } // namespace dart | 115 } // namespace dart |
| 121 | 116 |
| 122 #endif // RUNTIME_VM_INSTRUCTIONS_X64_H_ | 117 #endif // RUNTIME_VM_INSTRUCTIONS_X64_H_ |
| OLD | NEW |