| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file | 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 | 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_IA32_H_ | 6 #ifndef VM_INSTRUCTIONS_IA32_H_ | 
| 7 #define VM_INSTRUCTIONS_IA32_H_ | 7 #define VM_INSTRUCTIONS_IA32_H_ | 
| 8 | 8 | 
| 9 #ifndef VM_INSTRUCTIONS_H_ | 9 #ifndef 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. | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 45   // array of integers 'data'. 'data' elements are either a byte or -1, which | 45   // array of integers 'data'. 'data' elements are either a byte or -1, which | 
| 46   // represents any byte. | 46   // represents any byte. | 
| 47   bool TestBytesWith(const int* data, int num_bytes) const; | 47   bool TestBytesWith(const int* data, int num_bytes) const; | 
| 48 | 48 | 
| 49   const uword start_; | 49   const uword start_; | 
| 50 | 50 | 
| 51   DISALLOW_COPY_AND_ASSIGN(Instruction); | 51   DISALLOW_COPY_AND_ASSIGN(Instruction); | 
| 52 }; | 52 }; | 
| 53 | 53 | 
| 54 | 54 | 
| 55 // Pattern to load receiver from stack into EAX, with caller's return |  | 
| 56 // address on TOS and EDX containing the number of arguments. Pattern: |  | 
| 57 // 'mov eax, 0xb(edx)'. |  | 
| 58 // 'mov eax, (esp+eax*0x2)'. |  | 
| 59 class ICLoadReceiver : public Instruction { |  | 
| 60  public: |  | 
| 61   explicit ICLoadReceiver(uword pc) : Instruction(pc) {} |  | 
| 62 |  | 
| 63   virtual int pattern_length_in_bytes() const { |  | 
| 64     return kLengthInBytes; |  | 
| 65   } |  | 
| 66 |  | 
| 67  private: |  | 
| 68   virtual const int* pattern() const; |  | 
| 69 |  | 
| 70   static const int kLengthInBytes = 6; |  | 
| 71 |  | 
| 72   DISALLOW_COPY_AND_ASSIGN(ICLoadReceiver); |  | 
| 73 }; |  | 
| 74 |  | 
| 75 |  | 
| 76 // Pattern for a conditional jump (if zero) to a far address. Pattern: |  | 
| 77 // 'jz <target-address>' |  | 
| 78 class JumpIfZero : public Instruction { |  | 
| 79  public: |  | 
| 80   explicit JumpIfZero(uword pc) : Instruction(pc) {} |  | 
| 81   uword TargetAddress() const; |  | 
| 82   virtual int pattern_length_in_bytes() const { |  | 
| 83     return kLengthInBytes; |  | 
| 84   } |  | 
| 85 |  | 
| 86   void SetTargetAddress(uword pc); |  | 
| 87 |  | 
| 88  private: |  | 
| 89   friend class TestEaxIsSmi; |  | 
| 90   friend class ICCheckReceiverClass; |  | 
| 91 |  | 
| 92   virtual const int* pattern() const; |  | 
| 93 |  | 
| 94   static const int kLengthInBytes = 6; |  | 
| 95 |  | 
| 96   DISALLOW_COPY_AND_ASSIGN(JumpIfZero); |  | 
| 97 }; |  | 
| 98 |  | 
| 99 |  | 
| 100 // Pattern for comparison of an immediate with EAX. Pattern: |  | 
| 101 // 'cmp eax, <immediate>'. |  | 
| 102 class CmpEaxWithImmediate : public Instruction { |  | 
| 103  public: |  | 
| 104   explicit CmpEaxWithImmediate(uword pc) : Instruction(pc) {} |  | 
| 105   Immediate* immediate() const { |  | 
| 106     ASSERT(IsValid()); |  | 
| 107     return reinterpret_cast<Immediate*>(start() + 1); |  | 
| 108   } |  | 
| 109   virtual int pattern_length_in_bytes() const { |  | 
| 110     return kLengthInBytes; |  | 
| 111   } |  | 
| 112 |  | 
| 113  private: |  | 
| 114   virtual const int* pattern() const; |  | 
| 115 |  | 
| 116   static const int kLengthInBytes = 5; |  | 
| 117 |  | 
| 118   DISALLOW_COPY_AND_ASSIGN(CmpEaxWithImmediate); |  | 
| 119 }; |  | 
| 120 |  | 
| 121 |  | 
| 122 // Pattern to test if EAX contains a Smi. Pattern: |  | 
| 123 // 'test al, 0x1' |  | 
| 124 // 'jz <is-smi-target>'. |  | 
| 125 class TestEaxIsSmi : public Instruction { |  | 
| 126  public: |  | 
| 127   explicit TestEaxIsSmi(uword pc) |  | 
| 128       : Instruction(pc), |  | 
| 129         jz_(pc + kTestLengthInBytes) {} |  | 
| 130   uword TargetAddress() const { |  | 
| 131     ASSERT(IsValid()); |  | 
| 132     return jz_.TargetAddress(); |  | 
| 133   } |  | 
| 134 |  | 
| 135   void SetTargetAddress(uword new_target) { |  | 
| 136     ASSERT(IsValid()); |  | 
| 137     jz_.SetTargetAddress(new_target); |  | 
| 138     ASSERT(IsValid()); |  | 
| 139   } |  | 
| 140 |  | 
| 141   virtual int pattern_length_in_bytes() const { |  | 
| 142     return kTestLengthInBytes + jz_.pattern_length_in_bytes(); |  | 
| 143   } |  | 
| 144   virtual bool IsValid() const { |  | 
| 145     return Instruction::IsValid() && jz_.IsValid(); |  | 
| 146   } |  | 
| 147 |  | 
| 148  private: |  | 
| 149   virtual const int* pattern() const; |  | 
| 150 |  | 
| 151   static const int kTestLengthInBytes = 2; |  | 
| 152   JumpIfZero jz_; |  | 
| 153 |  | 
| 154   DISALLOW_COPY_AND_ASSIGN(TestEaxIsSmi); |  | 
| 155 }; |  | 
| 156 |  | 
| 157 |  | 
| 158 // Pattern for checking class of the receiver (class in EBX). Pattern: |  | 
| 159 // cmp ebx, <test-class> |  | 
| 160 // jz <is-class-target>' |  | 
| 161 class ICCheckReceiverClass : public Instruction { |  | 
| 162  public: |  | 
| 163   explicit ICCheckReceiverClass(uword pc) |  | 
| 164       : Instruction(pc), |  | 
| 165         jz_(pc + kTestLengthInBytes) {} |  | 
| 166   virtual int pattern_length_in_bytes() const { |  | 
| 167     return kTestLengthInBytes + jz_.pattern_length_in_bytes(); |  | 
| 168   } |  | 
| 169   virtual bool IsValid() const { |  | 
| 170     return Instruction::IsValid() && jz_.IsValid(); |  | 
| 171   } |  | 
| 172   uword TargetAddress() const { |  | 
| 173     ASSERT(IsValid()); |  | 
| 174     return jz_.TargetAddress(); |  | 
| 175   } |  | 
| 176   RawClass* TestClass() const; |  | 
| 177 |  | 
| 178   void SetTargetAddress(uword new_target) { |  | 
| 179     ASSERT(IsValid()); |  | 
| 180     jz_.SetTargetAddress(new_target); |  | 
| 181     ASSERT(IsValid()); |  | 
| 182   } |  | 
| 183 |  | 
| 184  private: |  | 
| 185   virtual const int* pattern() const; |  | 
| 186 |  | 
| 187   static const int kTestLengthInBytes = 6; |  | 
| 188   JumpIfZero jz_; |  | 
| 189 |  | 
| 190   DISALLOW_COPY_AND_ASSIGN(ICCheckReceiverClass); |  | 
| 191 }; |  | 
| 192 |  | 
| 193 |  | 
| 194 class LoadObjectClass : public Instruction { |  | 
| 195  public: |  | 
| 196   explicit LoadObjectClass(uword pc) : Instruction(pc) {} |  | 
| 197   virtual int pattern_length_in_bytes() const { |  | 
| 198     return kLoadObjectClassLengthInBytes; |  | 
| 199   } |  | 
| 200  private: |  | 
| 201   virtual const int* pattern() const; |  | 
| 202   static const int kLoadObjectClassLengthInBytes = 3; |  | 
| 203 |  | 
| 204   DISALLOW_COPY_AND_ASSIGN(LoadObjectClass); |  | 
| 205 }; |  | 
| 206 |  | 
| 207 |  | 
| 208 class CallOrJump : public Instruction { | 55 class CallOrJump : public Instruction { | 
| 209  public: | 56  public: | 
| 210   virtual int pattern_length_in_bytes() const { | 57   virtual int pattern_length_in_bytes() const { | 
| 211     return kLengthInBytes; | 58     return kLengthInBytes; | 
| 212   } | 59   } | 
| 213   uword TargetAddress() const; | 60   uword TargetAddress() const; | 
| 214   void SetTargetAddress(uword new_target) const; | 61   void SetTargetAddress(uword new_target) const; | 
| 215 | 62 | 
| 216  protected: | 63  protected: | 
| 217   explicit CallOrJump(uword pc) : Instruction(pc) {} | 64   explicit CallOrJump(uword pc) : Instruction(pc) {} | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 243  private: | 90  private: | 
| 244   virtual const int* pattern() const; | 91   virtual const int* pattern() const; | 
| 245 | 92 | 
| 246   DISALLOW_COPY_AND_ASSIGN(Jump); | 93   DISALLOW_COPY_AND_ASSIGN(Jump); | 
| 247 }; | 94 }; | 
| 248 | 95 | 
| 249 | 96 | 
| 250 }  // namespace dart | 97 }  // namespace dart | 
| 251 | 98 | 
| 252 #endif  // VM_INSTRUCTIONS_IA32_H_ | 99 #endif  // VM_INSTRUCTIONS_IA32_H_ | 
| OLD | NEW | 
|---|