OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011, 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_X64_H_ | |
7 #define VM_INSTRUCTIONS_X64_H_ | |
8 | |
9 #ifndef VM_INSTRUCTIONS_H_ | |
10 #error Do not include instructions_ia32.h directly; use instructions.h instead. | |
11 #endif | |
12 | |
srdjan
2011/12/09 22:39:07
Does this header file differ from instructions_ia3
regis
2011/12/09 22:46:31
They are different, because of the constant defini
srdjan
2011/12/21 22:30:31
Agreed.
| |
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 Instruction : public ValueObject { | |
24 public: | |
25 explicit Instruction(uword pc) : start_(pc) { | |
26 ASSERT(pc != 0); | |
27 } | |
28 virtual ~Instruction() {} | |
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(Instruction); | |
52 }; | |
53 | |
54 | |
55 class CallOrJump : public Instruction { | |
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 CallOrJump(uword pc) : Instruction(pc) {} | |
65 static const int kLengthInBytes = 13; | |
66 | |
67 private: | |
68 DISALLOW_COPY_AND_ASSIGN(CallOrJump); | |
69 }; | |
70 | |
71 | |
72 class Call : public CallOrJump { | |
73 public: | |
74 explicit Call(uword pc) : CallOrJump(pc) {} | |
75 static int InstructionLength() { | |
76 return kLengthInBytes; | |
77 } | |
78 | |
79 private: | |
80 virtual const int* pattern() const; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(Call); | |
83 }; | |
84 | |
85 | |
86 class Jump : public CallOrJump { | |
87 public: | |
88 explicit Jump(uword pc) : CallOrJump(pc) {} | |
89 | |
90 private: | |
91 virtual const int* pattern() const; | |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(Jump); | |
94 }; | |
95 | |
96 | |
97 } // namespace dart | |
98 | |
99 #endif // VM_INSTRUCTIONS_X64_H_ | |
OLD | NEW |