| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 uint64_t r = static_cast<uint32_t>( | 76 uint64_t r = static_cast<uint32_t>( |
| 77 reinterpret_cast<intptr_t>(roots_register_value)); | 77 reinterpret_cast<intptr_t>(roots_register_value)); |
| 78 delta = o - r; | 78 delta = o - r; |
| 79 } | 79 } |
| 80 return delta; | 80 return delta; |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 Operand MacroAssembler::ExternalOperand(ExternalReference target, | 84 Operand MacroAssembler::ExternalOperand(ExternalReference target, |
| 85 Register scratch) { | 85 Register scratch) { |
| 86 if (root_array_available_ && !Serializer::enabled()) { | 86 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 87 int64_t delta = RootRegisterDelta(target); | 87 int64_t delta = RootRegisterDelta(target); |
| 88 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 88 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 89 return Operand(kRootRegister, static_cast<int32_t>(delta)); | 89 return Operand(kRootRegister, static_cast<int32_t>(delta)); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 Move(scratch, target); | 92 Move(scratch, target); |
| 93 return Operand(scratch, 0); | 93 return Operand(scratch, 0); |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 void MacroAssembler::Load(Register destination, ExternalReference source) { | 97 void MacroAssembler::Load(Register destination, ExternalReference source) { |
| 98 if (root_array_available_ && !Serializer::enabled()) { | 98 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 99 int64_t delta = RootRegisterDelta(source); | 99 int64_t delta = RootRegisterDelta(source); |
| 100 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 100 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 101 movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); | 101 movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 // Safe code. | 105 // Safe code. |
| 106 if (destination.is(rax)) { | 106 if (destination.is(rax)) { |
| 107 load_rax(source); | 107 load_rax(source); |
| 108 } else { | 108 } else { |
| 109 Move(kScratchRegister, source); | 109 Move(kScratchRegister, source); |
| 110 movp(destination, Operand(kScratchRegister, 0)); | 110 movp(destination, Operand(kScratchRegister, 0)); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 void MacroAssembler::Store(ExternalReference destination, Register source) { | 115 void MacroAssembler::Store(ExternalReference destination, Register source) { |
| 116 if (root_array_available_ && !Serializer::enabled()) { | 116 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 117 int64_t delta = RootRegisterDelta(destination); | 117 int64_t delta = RootRegisterDelta(destination); |
| 118 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 118 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 119 movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); | 119 movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 // Safe code. | 123 // Safe code. |
| 124 if (source.is(rax)) { | 124 if (source.is(rax)) { |
| 125 store_rax(destination); | 125 store_rax(destination); |
| 126 } else { | 126 } else { |
| 127 Move(kScratchRegister, destination); | 127 Move(kScratchRegister, destination); |
| 128 movp(Operand(kScratchRegister, 0), source); | 128 movp(Operand(kScratchRegister, 0), source); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 void MacroAssembler::LoadAddress(Register destination, | 133 void MacroAssembler::LoadAddress(Register destination, |
| 134 ExternalReference source) { | 134 ExternalReference source) { |
| 135 if (root_array_available_ && !Serializer::enabled()) { | 135 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 136 int64_t delta = RootRegisterDelta(source); | 136 int64_t delta = RootRegisterDelta(source); |
| 137 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 137 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 138 leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); | 138 leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
| 139 return; | 139 return; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 // Safe code. | 142 // Safe code. |
| 143 Move(destination, source); | 143 Move(destination, source); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 int MacroAssembler::LoadAddressSize(ExternalReference source) { | 147 int MacroAssembler::LoadAddressSize(ExternalReference source) { |
| 148 if (root_array_available_ && !Serializer::enabled()) { | 148 if (root_array_available_ && !Serializer::enabled(isolate())) { |
| 149 // This calculation depends on the internals of LoadAddress. | 149 // This calculation depends on the internals of LoadAddress. |
| 150 // It's correctness is ensured by the asserts in the Call | 150 // It's correctness is ensured by the asserts in the Call |
| 151 // instruction below. | 151 // instruction below. |
| 152 int64_t delta = RootRegisterDelta(source); | 152 int64_t delta = RootRegisterDelta(source); |
| 153 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 153 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 154 // Operand is leap(scratch, Operand(kRootRegister, delta)); | 154 // Operand is leap(scratch, Operand(kRootRegister, delta)); |
| 155 // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. | 155 // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. |
| 156 int size = 4; | 156 int size = 4; |
| 157 if (!is_int8(static_cast<int32_t>(delta))) { | 157 if (!is_int8(static_cast<int32_t>(delta))) { |
| 158 size += 3; // Need full four-byte displacement in lea. | 158 size += 3; // Need full four-byte displacement in lea. |
| 159 } | 159 } |
| 160 return size; | 160 return size; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 // Size of movp(destination, src); | 163 // Size of movp(destination, src); |
| 164 return Assembler::kMoveAddressIntoScratchRegisterInstructionLength; | 164 return Assembler::kMoveAddressIntoScratchRegisterInstructionLength; |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 void MacroAssembler::PushAddress(ExternalReference source) { | 168 void MacroAssembler::PushAddress(ExternalReference source) { |
| 169 int64_t address = reinterpret_cast<int64_t>(source.address()); | 169 int64_t address = reinterpret_cast<int64_t>(source.address()); |
| 170 if (is_int32(address) && !Serializer::enabled()) { | 170 if (is_int32(address) && !Serializer::enabled(isolate())) { |
| 171 if (emit_debug_code()) { | 171 if (emit_debug_code()) { |
| 172 Move(kScratchRegister, kZapValue, Assembler::RelocInfoNone()); | 172 Move(kScratchRegister, kZapValue, Assembler::RelocInfoNone()); |
| 173 } | 173 } |
| 174 Push(Immediate(static_cast<int32_t>(address))); | 174 Push(Immediate(static_cast<int32_t>(address))); |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 LoadAddress(kScratchRegister, source); | 177 LoadAddress(kScratchRegister, source); |
| 178 Push(kScratchRegister); | 178 Push(kScratchRegister); |
| 179 } | 179 } |
| 180 | 180 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 bind(&done); | 268 bind(&done); |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 | 272 |
| 273 void MacroAssembler::InNewSpace(Register object, | 273 void MacroAssembler::InNewSpace(Register object, |
| 274 Register scratch, | 274 Register scratch, |
| 275 Condition cc, | 275 Condition cc, |
| 276 Label* branch, | 276 Label* branch, |
| 277 Label::Distance distance) { | 277 Label::Distance distance) { |
| 278 if (Serializer::enabled()) { | 278 if (Serializer::enabled(isolate())) { |
| 279 // Can't do arithmetic on external references if it might get serialized. | 279 // Can't do arithmetic on external references if it might get serialized. |
| 280 // The mask isn't really an address. We load it as an external reference in | 280 // The mask isn't really an address. We load it as an external reference in |
| 281 // case the size of the new space is different between the snapshot maker | 281 // case the size of the new space is different between the snapshot maker |
| 282 // and the running system. | 282 // and the running system. |
| 283 if (scratch.is(object)) { | 283 if (scratch.is(object)) { |
| 284 Move(kScratchRegister, ExternalReference::new_space_mask(isolate())); | 284 Move(kScratchRegister, ExternalReference::new_space_mask(isolate())); |
| 285 andp(scratch, kScratchRegister); | 285 andp(scratch, kScratchRegister); |
| 286 } else { | 286 } else { |
| 287 Move(scratch, ExternalReference::new_space_mask(isolate())); | 287 Move(scratch, ExternalReference::new_space_mask(isolate())); |
| 288 andp(scratch, object); | 288 andp(scratch, object); |
| (...skipping 4910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5199 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); | 5199 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); |
| 5200 movl(rax, dividend); | 5200 movl(rax, dividend); |
| 5201 shrl(rax, Immediate(31)); | 5201 shrl(rax, Immediate(31)); |
| 5202 addl(rdx, rax); | 5202 addl(rdx, rax); |
| 5203 } | 5203 } |
| 5204 | 5204 |
| 5205 | 5205 |
| 5206 } } // namespace v8::internal | 5206 } } // namespace v8::internal |
| 5207 | 5207 |
| 5208 #endif // V8_TARGET_ARCH_X64 | 5208 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |