| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
| 10 #include "codegen.h" | 10 #include "codegen.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 uint64_t r = static_cast<uint32_t>( | 53 uint64_t r = static_cast<uint32_t>( |
| 54 reinterpret_cast<intptr_t>(roots_register_value)); | 54 reinterpret_cast<intptr_t>(roots_register_value)); |
| 55 delta = o - r; | 55 delta = o - r; |
| 56 } | 56 } |
| 57 return delta; | 57 return delta; |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 Operand MacroAssembler::ExternalOperand(ExternalReference target, | 61 Operand MacroAssembler::ExternalOperand(ExternalReference target, |
| 62 Register scratch) { | 62 Register scratch) { |
| 63 if (root_array_available_ && !Serializer::enabled()) { | 63 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 64 int64_t delta = RootRegisterDelta(target); | 64 int64_t delta = RootRegisterDelta(target); |
| 65 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 65 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 66 return Operand(kRootRegister, static_cast<int32_t>(delta)); | 66 return Operand(kRootRegister, static_cast<int32_t>(delta)); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 Move(scratch, target); | 69 Move(scratch, target); |
| 70 return Operand(scratch, 0); | 70 return Operand(scratch, 0); |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 void MacroAssembler::Load(Register destination, ExternalReference source) { | 74 void MacroAssembler::Load(Register destination, ExternalReference source) { |
| 75 if (root_array_available_ && !Serializer::enabled()) { | 75 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 76 int64_t delta = RootRegisterDelta(source); | 76 int64_t delta = RootRegisterDelta(source); |
| 77 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 77 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 78 movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); | 78 movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 // Safe code. | 82 // Safe code. |
| 83 if (destination.is(rax)) { | 83 if (destination.is(rax)) { |
| 84 load_rax(source); | 84 load_rax(source); |
| 85 } else { | 85 } else { |
| 86 Move(kScratchRegister, source); | 86 Move(kScratchRegister, source); |
| 87 movp(destination, Operand(kScratchRegister, 0)); | 87 movp(destination, Operand(kScratchRegister, 0)); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 void MacroAssembler::Store(ExternalReference destination, Register source) { | 92 void MacroAssembler::Store(ExternalReference destination, Register source) { |
| 93 if (root_array_available_ && !Serializer::enabled()) { | 93 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 94 int64_t delta = RootRegisterDelta(destination); | 94 int64_t delta = RootRegisterDelta(destination); |
| 95 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 95 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 96 movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); | 96 movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 // Safe code. | 100 // Safe code. |
| 101 if (source.is(rax)) { | 101 if (source.is(rax)) { |
| 102 store_rax(destination); | 102 store_rax(destination); |
| 103 } else { | 103 } else { |
| 104 Move(kScratchRegister, destination); | 104 Move(kScratchRegister, destination); |
| 105 movp(Operand(kScratchRegister, 0), source); | 105 movp(Operand(kScratchRegister, 0), source); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 void MacroAssembler::LoadAddress(Register destination, | 110 void MacroAssembler::LoadAddress(Register destination, |
| 111 ExternalReference source) { | 111 ExternalReference source) { |
| 112 if (root_array_available_ && !Serializer::enabled()) { | 112 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 113 int64_t delta = RootRegisterDelta(source); | 113 int64_t delta = RootRegisterDelta(source); |
| 114 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 114 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 115 leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); | 115 leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 // Safe code. | 119 // Safe code. |
| 120 Move(destination, source); | 120 Move(destination, source); |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 int MacroAssembler::LoadAddressSize(ExternalReference source) { | 124 int MacroAssembler::LoadAddressSize(ExternalReference source) { |
| 125 if (root_array_available_ && !Serializer::enabled()) { | 125 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 126 // This calculation depends on the internals of LoadAddress. | 126 // This calculation depends on the internals of LoadAddress. |
| 127 // It's correctness is ensured by the asserts in the Call | 127 // It's correctness is ensured by the asserts in the Call |
| 128 // instruction below. | 128 // instruction below. |
| 129 int64_t delta = RootRegisterDelta(source); | 129 int64_t delta = RootRegisterDelta(source); |
| 130 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 130 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 131 // Operand is leap(scratch, Operand(kRootRegister, delta)); | 131 // Operand is leap(scratch, Operand(kRootRegister, delta)); |
| 132 // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. | 132 // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. |
| 133 int size = 4; | 133 int size = 4; |
| 134 if (!is_int8(static_cast<int32_t>(delta))) { | 134 if (!is_int8(static_cast<int32_t>(delta))) { |
| 135 size += 3; // Need full four-byte displacement in lea. | 135 size += 3; // Need full four-byte displacement in lea. |
| 136 } | 136 } |
| 137 return size; | 137 return size; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 // Size of movp(destination, src); | 140 // Size of movp(destination, src); |
| 141 return Assembler::kMoveAddressIntoScratchRegisterInstructionLength; | 141 return Assembler::kMoveAddressIntoScratchRegisterInstructionLength; |
| 142 } | 142 } |
| 143 | 143 |
| 144 | 144 |
| 145 void MacroAssembler::PushAddress(ExternalReference source) { | 145 void MacroAssembler::PushAddress(ExternalReference source) { |
| 146 int64_t address = reinterpret_cast<int64_t>(source.address()); | 146 int64_t address = reinterpret_cast<int64_t>(source.address()); |
| 147 if (is_int32(address) && !Serializer::enabled()) { | 147 if (is_int32(address) && !Serializer::enabled(isolate())) { |
| 148 if (emit_debug_code()) { | 148 if (emit_debug_code()) { |
| 149 Move(kScratchRegister, kZapValue, Assembler::RelocInfoNone()); | 149 Move(kScratchRegister, kZapValue, Assembler::RelocInfoNone()); |
| 150 } | 150 } |
| 151 Push(Immediate(static_cast<int32_t>(address))); | 151 Push(Immediate(static_cast<int32_t>(address))); |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 LoadAddress(kScratchRegister, source); | 154 LoadAddress(kScratchRegister, source); |
| 155 Push(kScratchRegister); | 155 Push(kScratchRegister); |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 bind(&done); | 245 bind(&done); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 void MacroAssembler::InNewSpace(Register object, | 250 void MacroAssembler::InNewSpace(Register object, |
| 251 Register scratch, | 251 Register scratch, |
| 252 Condition cc, | 252 Condition cc, |
| 253 Label* branch, | 253 Label* branch, |
| 254 Label::Distance distance) { | 254 Label::Distance distance) { |
| 255 if (Serializer::enabled()) { | 255 if (Serializer::enabled(isolate())) { |
| 256 // Can't do arithmetic on external references if it might get serialized. | 256 // Can't do arithmetic on external references if it might get serialized. |
| 257 // The mask isn't really an address. We load it as an external reference in | 257 // The mask isn't really an address. We load it as an external reference in |
| 258 // case the size of the new space is different between the snapshot maker | 258 // case the size of the new space is different between the snapshot maker |
| 259 // and the running system. | 259 // and the running system. |
| 260 if (scratch.is(object)) { | 260 if (scratch.is(object)) { |
| 261 Move(kScratchRegister, ExternalReference::new_space_mask(isolate())); | 261 Move(kScratchRegister, ExternalReference::new_space_mask(isolate())); |
| 262 andp(scratch, kScratchRegister); | 262 andp(scratch, kScratchRegister); |
| 263 } else { | 263 } else { |
| 264 Move(scratch, ExternalReference::new_space_mask(isolate())); | 264 Move(scratch, ExternalReference::new_space_mask(isolate())); |
| 265 andp(scratch, object); | 265 andp(scratch, object); |
| (...skipping 4980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5246 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); | 5246 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); |
| 5247 movl(rax, dividend); | 5247 movl(rax, dividend); |
| 5248 shrl(rax, Immediate(31)); | 5248 shrl(rax, Immediate(31)); |
| 5249 addl(rdx, rax); | 5249 addl(rdx, rax); |
| 5250 } | 5250 } |
| 5251 | 5251 |
| 5252 | 5252 |
| 5253 } } // namespace v8::internal | 5253 } } // namespace v8::internal |
| 5254 | 5254 |
| 5255 #endif // V8_TARGET_ARCH_X64 | 5255 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |