| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/instructions.h" | 8 #include "vm/instructions.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 bool Instruction::TestBytesWith(const int* data, int num_bytes) const { | 13 bool InstructionPattern::TestBytesWith(const int* data, int num_bytes) const { |
| 14 ASSERT(data != NULL); | 14 ASSERT(data != NULL); |
| 15 const uint8_t* byte_array = reinterpret_cast<const uint8_t*>(start_); | 15 const uint8_t* byte_array = reinterpret_cast<const uint8_t*>(start_); |
| 16 for (int i = 0; i < num_bytes; i++) { | 16 for (int i = 0; i < num_bytes; i++) { |
| 17 // Skip comparison for data[i] < 0. | 17 // Skip comparison for data[i] < 0. |
| 18 if ((data[i] >= 0) && (byte_array[i] != (0xFF & data[i]))) { | 18 if ((data[i] >= 0) && (byte_array[i] != (0xFF & data[i]))) { |
| 19 return false; | 19 return false; |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 return true; | 22 return true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 | 25 |
| 26 uword CallOrJump::TargetAddress() const { | 26 uword CallOrJumpPattern::TargetAddress() const { |
| 27 ASSERT(IsValid()); | 27 ASSERT(IsValid()); |
| 28 return *reinterpret_cast<uword*>(start() + 2); | 28 return *reinterpret_cast<uword*>(start() + 2); |
| 29 } | 29 } |
| 30 | 30 |
| 31 | 31 |
| 32 void CallOrJump::SetTargetAddress(uword target) const { | 32 void CallOrJumpPattern::SetTargetAddress(uword target) const { |
| 33 ASSERT(IsValid()); | 33 ASSERT(IsValid()); |
| 34 *reinterpret_cast<uword*>(start() + 2) = target; | 34 *reinterpret_cast<uword*>(start() + 2) = target; |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 const int* Call::pattern() const { | 38 const int* CallPattern::pattern() const { |
| 39 // movq $target, TMP | 39 // movq $target, TMP |
| 40 // callq *TMP | 40 // callq *TMP |
| 41 static const int kCallPattern[kLengthInBytes] = | 41 static const int kCallPattern[kLengthInBytes] = |
| 42 {0x49, 0xBB, -1, -1, -1, -1, -1, -1, -1, -1, 0x41, 0xFF, 0xD3}; | 42 {0x49, 0xBB, -1, -1, -1, -1, -1, -1, -1, -1, 0x41, 0xFF, 0xD3}; |
| 43 return kCallPattern; | 43 return kCallPattern; |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 const int* Jump::pattern() const { | 47 const int* JumpPattern::pattern() const { |
| 48 // movq $target, TMP | 48 // movq $target, TMP |
| 49 // jmpq TMP | 49 // jmpq TMP |
| 50 static const int kJumpPattern[kLengthInBytes] = | 50 static const int kJumpPattern[kLengthInBytes] = |
| 51 {0x49, 0xBB, -1, -1, -1, -1, -1, -1, -1, -1, 0x41, 0xFF, 0xE3}; | 51 {0x49, 0xBB, -1, -1, -1, -1, -1, -1, -1, -1, 0x41, 0xFF, 0xE3}; |
| 52 return kJumpPattern; | 52 return kJumpPattern; |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 } // namespace dart | 56 } // namespace dart |
| 57 | 57 |
| 58 #endif // defined TARGET_ARCH_X64 | 58 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |