OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 VM_INSTRUCTIONS_ARM_H_ | 6 #ifndef VM_INSTRUCTIONS_ARM_H_ |
7 #define VM_INSTRUCTIONS_ARM_H_ | 7 #define VM_INSTRUCTIONS_ARM_H_ |
8 | 8 |
9 #ifndef VM_INSTRUCTIONS_H_ | 9 #ifndef VM_INSTRUCTIONS_H_ |
10 #error Do not include instructions_arm.h directly; use instructions.h instead. | 10 #error Do not include instructions_arm.h directly; use instructions.h instead. |
11 #endif | 11 #endif |
12 | 12 |
| 13 #include "vm/constants_arm.h" |
13 #include "vm/object.h" | 14 #include "vm/object.h" |
14 | 15 |
15 namespace dart { | 16 namespace dart { |
16 | 17 |
17 // Abstract class for all instruction pattern classes. | 18 class CallPattern : public ValueObject { |
18 class InstructionPattern : public ValueObject { | |
19 public: | |
20 explicit InstructionPattern(uword pc) : end_(reinterpret_cast<uword*>(pc)) { | |
21 ASSERT(pc != 0); | |
22 } | |
23 virtual ~InstructionPattern() { } | |
24 | |
25 protected: | |
26 uword Back(int n) const; | |
27 | |
28 private: | |
29 const uword* end_; | |
30 | |
31 DISALLOW_COPY_AND_ASSIGN(InstructionPattern); | |
32 }; | |
33 | |
34 | |
35 class CallPattern : public InstructionPattern { | |
36 public: | 19 public: |
37 CallPattern(uword pc, const Code& code); | 20 CallPattern(uword pc, const Code& code); |
38 | 21 |
39 uword TargetAddress() const; | 22 uword TargetAddress() const; |
40 void SetTargetAddress(uword target_address) const; | 23 void SetTargetAddress(uword target_address) const; |
41 | 24 |
42 private: | 25 private: |
| 26 uword Back(int n) const; |
43 int DecodePoolIndex(); | 27 int DecodePoolIndex(); |
| 28 const uword* end_; |
44 const int pool_index_; | 29 const int pool_index_; |
45 const Array& object_pool_; | 30 const Array& object_pool_; |
46 | 31 |
47 DISALLOW_COPY_AND_ASSIGN(CallPattern); | 32 DISALLOW_COPY_AND_ASSIGN(CallPattern); |
48 }; | 33 }; |
49 | 34 |
50 | 35 |
51 class JumpPattern : public InstructionPattern { | 36 class JumpPattern : public ValueObject { |
52 public: | 37 public: |
53 explicit JumpPattern(uword pc) : InstructionPattern(pc) { } | 38 explicit JumpPattern(uword pc); |
54 | 39 |
55 static const int kLengthInBytes = 3*kWordSize; | 40 static const int kLengthInBytes = 3 * Instr::kInstrSize; |
56 | 41 |
57 int pattern_length_in_bytes() const { | 42 int pattern_length_in_bytes() const { |
58 return kLengthInBytes; | 43 return kLengthInBytes; |
59 } | 44 } |
| 45 |
60 bool IsValid() const; | 46 bool IsValid() const; |
61 uword TargetAddress() const; | 47 uword TargetAddress() const; |
62 void SetTargetAddress(uword target_address) const; | 48 void SetTargetAddress(uword target_address) const; |
63 | 49 |
64 private: | 50 private: |
| 51 const uword pc_; |
| 52 |
65 DISALLOW_COPY_AND_ASSIGN(JumpPattern); | 53 DISALLOW_COPY_AND_ASSIGN(JumpPattern); |
66 }; | 54 }; |
67 | 55 |
68 } // namespace dart | 56 } // namespace dart |
69 | 57 |
70 #endif // VM_INSTRUCTIONS_ARM_H_ | 58 #endif // VM_INSTRUCTIONS_ARM_H_ |
71 | 59 |
OLD | NEW |