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/constants_arm.h" |
14 #include "vm/object.h" | 14 #include "vm/object.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
| 18 class InstructionPattern : public AllStatic { |
| 19 public: |
| 20 // Decodes a load sequence ending at 'end' (the last instruction of the load |
| 21 // sequence is the instruction before the one at end). Returns a pointer to |
| 22 // the first instruction in the sequence. Returns the register being loaded |
| 23 // and the loaded object in the output parameters 'reg' and 'obj' |
| 24 // respectively. |
| 25 static const uword* DecodeLoadObject(const uword* end, |
| 26 const Array& object_pool, |
| 27 Register* reg, |
| 28 Object* obj); |
| 29 |
| 30 // Decodes a load sequence ending at 'end' (the last instruction of the load |
| 31 // sequence is the instruction before the one at end). Returns a pointer to |
| 32 // the first instruction in the sequence. Returns the register being loaded |
| 33 // and the loaded immediate value in the output parameters 'reg' and 'value' |
| 34 // respectively. |
| 35 static const uword* DecodeLoadWordImmediate(const uword* end, |
| 36 Register* reg, |
| 37 intptr_t* value); |
| 38 |
| 39 // Decodes a load sequence ending at 'end' (the last instruction of the load |
| 40 // sequence is the instruction before the one at end). Returns a pointer to |
| 41 // the first instruction in the sequence. Returns the register being loaded |
| 42 // and the index in the pool being read from in the output parameters 'reg' |
| 43 // and 'index' respectively. |
| 44 static const uword* DecodeLoadWordFromPool(const uword* end, |
| 45 Register* reg, |
| 46 intptr_t* index); |
| 47 }; |
| 48 |
| 49 |
18 class CallPattern : public ValueObject { | 50 class CallPattern : public ValueObject { |
19 public: | 51 public: |
20 CallPattern(uword pc, const Code& code); | 52 CallPattern(uword pc, const Code& code); |
21 | 53 |
22 RawICData* IcData(); | 54 RawICData* IcData(); |
23 RawArray* ClosureArgumentsDescriptor(); | 55 RawArray* ClosureArgumentsDescriptor(); |
24 | 56 |
25 uword TargetAddress() const; | 57 uword TargetAddress() const; |
26 void SetTargetAddress(uword target_address) const; | 58 void SetTargetAddress(uword target_address) const; |
27 | 59 |
28 // This constant length is only valid for inserted call patterns used for | 60 // This constant length is only valid for inserted call patterns used for |
29 // lazy deoptimization. Regular call pattern may vary in length. | 61 // lazy deoptimization. Regular call pattern may vary in length. |
30 static const int kFixedLengthInBytes = 3 * Instr::kInstrSize; | 62 static const int kFixedLengthInBytes = 3 * Instr::kInstrSize; |
31 | 63 |
32 static void InsertAt(uword pc, uword target_address); | 64 static void InsertAt(uword pc, uword target_address); |
33 | 65 |
34 private: | 66 private: |
35 uword Back(int n) const; | 67 const Array& object_pool_; |
36 int DecodeLoadObject(int end, Register* reg, Object* obj); | 68 |
37 int DecodeLoadWordImmediate(int end, Register* reg, int* value); | |
38 int DecodeLoadWordFromPool(int end, Register* reg, int* index); | |
39 const uword* end_; | 69 const uword* end_; |
40 int target_address_pool_index_; | 70 const uword* args_desc_load_end_; |
41 int args_desc_load_end_; | 71 const uword* ic_data_load_end_; |
| 72 |
| 73 intptr_t target_address_pool_index_; |
42 Array& args_desc_; | 74 Array& args_desc_; |
43 int ic_data_load_end_; | |
44 ICData& ic_data_; | 75 ICData& ic_data_; |
45 const Array& object_pool_; | |
46 | 76 |
47 DISALLOW_COPY_AND_ASSIGN(CallPattern); | 77 DISALLOW_COPY_AND_ASSIGN(CallPattern); |
48 }; | 78 }; |
49 | 79 |
50 | 80 |
51 class JumpPattern : public ValueObject { | 81 class JumpPattern : public ValueObject { |
52 public: | 82 public: |
53 JumpPattern(uword pc, const Code& code); | 83 JumpPattern(uword pc, const Code& code); |
54 | 84 |
55 static const int kLengthInBytes = 3 * Instr::kInstrSize; | 85 static const int kLengthInBytes = 3 * Instr::kInstrSize; |
56 | 86 |
57 int pattern_length_in_bytes() const { | 87 int pattern_length_in_bytes() const { |
58 return kLengthInBytes; | 88 return kLengthInBytes; |
59 } | 89 } |
60 | 90 |
61 bool IsValid() const; | 91 bool IsValid() const; |
62 uword TargetAddress() const; | 92 uword TargetAddress() const; |
63 void SetTargetAddress(uword target_address) const; | 93 void SetTargetAddress(uword target_address) const; |
64 | 94 |
65 private: | 95 private: |
66 const uword pc_; | 96 const uword pc_; |
67 | 97 |
68 DISALLOW_COPY_AND_ASSIGN(JumpPattern); | 98 DISALLOW_COPY_AND_ASSIGN(JumpPattern); |
69 }; | 99 }; |
70 | 100 |
71 } // namespace dart | 101 } // namespace dart |
72 | 102 |
73 #endif // VM_INSTRUCTIONS_ARM_H_ | 103 #endif // VM_INSTRUCTIONS_ARM_H_ |
74 | |
OLD | NEW |