OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 // Classes that describe assembly patterns as used by inline caches. |
| 5 |
| 6 #ifndef VM_INSTRUCTIONS_ARM_H_ |
| 7 #define VM_INSTRUCTIONS_ARM_H_ |
| 8 |
| 9 #ifndef VM_INSTRUCTIONS_H_ |
| 10 #error Do not include instructions_arm.h directly; use instructions.h instead. |
| 11 #endif |
| 12 |
| 13 #include "vm/allocation.h" |
| 14 |
| 15 namespace dart { |
| 16 |
| 17 // Forward declarations. |
| 18 class RawClass; |
| 19 class Immediate; |
| 20 class RawObject; |
| 21 |
| 22 // Abstract class for all instruction pattern classes. |
| 23 class InstructionPattern : public ValueObject { |
| 24 public: |
| 25 explicit InstructionPattern(uword pc) : start_(pc) { |
| 26 ASSERT(pc != 0); |
| 27 } |
| 28 virtual ~InstructionPattern() {} |
| 29 |
| 30 // Call to check if the instruction pattern at 'pc' match the instruction. |
| 31 virtual bool IsValid() const { |
| 32 return TestBytesWith(pattern(), pattern_length_in_bytes()); |
| 33 } |
| 34 |
| 35 // 'pattern' returns the expected byte pattern in form of an integer array |
| 36 // with length of 'pattern_length_in_bytes'. A '-1' element means 'any byte'. |
| 37 virtual const int* pattern() const = 0; |
| 38 virtual int pattern_length_in_bytes() const = 0; |
| 39 |
| 40 protected: |
| 41 uword start() const { return start_; } |
| 42 |
| 43 private: |
| 44 // Returns true if the 'num_bytes' bytes at 'start_' correspond to |
| 45 // array of integers 'data'. 'data' elements are either a byte or -1, which |
| 46 // represents any byte. |
| 47 bool TestBytesWith(const int* data, int num_bytes) const; |
| 48 |
| 49 const uword start_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(InstructionPattern); |
| 52 }; |
| 53 |
| 54 |
| 55 class CallOrJumpPattern : public InstructionPattern { |
| 56 public: |
| 57 virtual int pattern_length_in_bytes() const { |
| 58 return kLengthInBytes; |
| 59 } |
| 60 uword TargetAddress() const; |
| 61 void SetTargetAddress(uword new_target) const; |
| 62 |
| 63 protected: |
| 64 explicit CallOrJumpPattern(uword pc) : InstructionPattern(pc) {} |
| 65 static const int kLengthInBytes = 0; |
| 66 |
| 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(CallOrJumpPattern); |
| 69 }; |
| 70 |
| 71 |
| 72 class CallPattern : public CallOrJumpPattern { |
| 73 public: |
| 74 explicit CallPattern(uword pc) : CallOrJumpPattern(pc) {} |
| 75 static int InstructionLength() { |
| 76 return kLengthInBytes; |
| 77 } |
| 78 |
| 79 private: |
| 80 virtual const int* pattern() const; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(CallPattern); |
| 83 }; |
| 84 |
| 85 |
| 86 class JumpPattern : public CallOrJumpPattern { |
| 87 public: |
| 88 explicit JumpPattern(uword pc) : CallOrJumpPattern(pc) {} |
| 89 |
| 90 private: |
| 91 virtual const int* pattern() const; |
| 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(JumpPattern); |
| 94 }; |
| 95 |
| 96 } // namespace dart |
| 97 |
| 98 #endif // VM_INSTRUCTIONS_ARM_H_ |
| 99 |
OLD | NEW |