| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 generating_stub_(false), | 47 generating_stub_(false), |
| 48 has_frame_(false), | 48 has_frame_(false), |
| 49 root_array_available_(true) { | 49 root_array_available_(true) { |
| 50 if (isolate() != NULL) { | 50 if (isolate() != NULL) { |
| 51 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), | 51 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), |
| 52 isolate()); | 52 isolate()); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 static const int kInvalidRootRegisterDelta = -1; | 57 static const int64_t kInvalidRootRegisterDelta = -1; |
| 58 | 58 |
| 59 | 59 |
| 60 intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) { | 60 int64_t MacroAssembler::RootRegisterDelta(ExternalReference other) { |
| 61 if (predictable_code_size() && | 61 if (predictable_code_size() && |
| 62 (other.address() < reinterpret_cast<Address>(isolate()) || | 62 (other.address() < reinterpret_cast<Address>(isolate()) || |
| 63 other.address() >= reinterpret_cast<Address>(isolate() + 1))) { | 63 other.address() >= reinterpret_cast<Address>(isolate() + 1))) { |
| 64 return kInvalidRootRegisterDelta; | 64 return kInvalidRootRegisterDelta; |
| 65 } | 65 } |
| 66 Address roots_register_value = kRootRegisterBias + | 66 Address roots_register_value = kRootRegisterBias + |
| 67 reinterpret_cast<Address>(isolate()->heap()->roots_array_start()); | 67 reinterpret_cast<Address>(isolate()->heap()->roots_array_start()); |
| 68 intptr_t delta = other.address() - roots_register_value; | 68 |
| 69 int64_t delta = kInvalidRootRegisterDelta; // Bogus initialization. |
| 70 if (kPointerSize == kInt64Size) { |
| 71 delta = other.address() - roots_register_value; |
| 72 } else { |
| 73 // For x32, zero extend the address to 64-bit and calculate the delta. |
| 74 uint64_t o = static_cast<uint32_t>( |
| 75 reinterpret_cast<intptr_t>(other.address())); |
| 76 uint64_t r = static_cast<uint32_t>( |
| 77 reinterpret_cast<intptr_t>(roots_register_value)); |
| 78 delta = o - r; |
| 79 } |
| 69 return delta; | 80 return delta; |
| 70 } | 81 } |
| 71 | 82 |
| 72 | 83 |
| 73 Operand MacroAssembler::ExternalOperand(ExternalReference target, | 84 Operand MacroAssembler::ExternalOperand(ExternalReference target, |
| 74 Register scratch) { | 85 Register scratch) { |
| 75 if (root_array_available_ && !Serializer::enabled()) { | 86 if (root_array_available_ && !Serializer::enabled()) { |
| 76 intptr_t delta = RootRegisterDelta(target); | 87 int64_t delta = RootRegisterDelta(target); |
| 77 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 88 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 78 Serializer::TooLateToEnableNow(); | 89 Serializer::TooLateToEnableNow(); |
| 79 return Operand(kRootRegister, static_cast<int32_t>(delta)); | 90 return Operand(kRootRegister, static_cast<int32_t>(delta)); |
| 80 } | 91 } |
| 81 } | 92 } |
| 82 Move(scratch, target); | 93 Move(scratch, target); |
| 83 return Operand(scratch, 0); | 94 return Operand(scratch, 0); |
| 84 } | 95 } |
| 85 | 96 |
| 86 | 97 |
| 87 void MacroAssembler::Load(Register destination, ExternalReference source) { | 98 void MacroAssembler::Load(Register destination, ExternalReference source) { |
| 88 if (root_array_available_ && !Serializer::enabled()) { | 99 if (root_array_available_ && !Serializer::enabled()) { |
| 89 intptr_t delta = RootRegisterDelta(source); | 100 int64_t delta = RootRegisterDelta(source); |
| 90 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 101 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 91 Serializer::TooLateToEnableNow(); | 102 Serializer::TooLateToEnableNow(); |
| 92 movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); | 103 movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
| 93 return; | 104 return; |
| 94 } | 105 } |
| 95 } | 106 } |
| 96 // Safe code. | 107 // Safe code. |
| 97 if (destination.is(rax)) { | 108 if (destination.is(rax)) { |
| 98 load_rax(source); | 109 load_rax(source); |
| 99 } else { | 110 } else { |
| 100 Move(kScratchRegister, source); | 111 Move(kScratchRegister, source); |
| 101 movp(destination, Operand(kScratchRegister, 0)); | 112 movp(destination, Operand(kScratchRegister, 0)); |
| 102 } | 113 } |
| 103 } | 114 } |
| 104 | 115 |
| 105 | 116 |
| 106 void MacroAssembler::Store(ExternalReference destination, Register source) { | 117 void MacroAssembler::Store(ExternalReference destination, Register source) { |
| 107 if (root_array_available_ && !Serializer::enabled()) { | 118 if (root_array_available_ && !Serializer::enabled()) { |
| 108 intptr_t delta = RootRegisterDelta(destination); | 119 int64_t delta = RootRegisterDelta(destination); |
| 109 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 120 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 110 Serializer::TooLateToEnableNow(); | 121 Serializer::TooLateToEnableNow(); |
| 111 movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); | 122 movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); |
| 112 return; | 123 return; |
| 113 } | 124 } |
| 114 } | 125 } |
| 115 // Safe code. | 126 // Safe code. |
| 116 if (source.is(rax)) { | 127 if (source.is(rax)) { |
| 117 store_rax(destination); | 128 store_rax(destination); |
| 118 } else { | 129 } else { |
| 119 Move(kScratchRegister, destination); | 130 Move(kScratchRegister, destination); |
| 120 movp(Operand(kScratchRegister, 0), source); | 131 movp(Operand(kScratchRegister, 0), source); |
| 121 } | 132 } |
| 122 } | 133 } |
| 123 | 134 |
| 124 | 135 |
| 125 void MacroAssembler::LoadAddress(Register destination, | 136 void MacroAssembler::LoadAddress(Register destination, |
| 126 ExternalReference source) { | 137 ExternalReference source) { |
| 127 if (root_array_available_ && !Serializer::enabled()) { | 138 if (root_array_available_ && !Serializer::enabled()) { |
| 128 intptr_t delta = RootRegisterDelta(source); | 139 int64_t delta = RootRegisterDelta(source); |
| 129 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 140 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 130 Serializer::TooLateToEnableNow(); | 141 Serializer::TooLateToEnableNow(); |
| 131 leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); | 142 leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
| 132 return; | 143 return; |
| 133 } | 144 } |
| 134 } | 145 } |
| 135 // Safe code. | 146 // Safe code. |
| 136 Move(destination, source); | 147 Move(destination, source); |
| 137 } | 148 } |
| 138 | 149 |
| 139 | 150 |
| 140 int MacroAssembler::LoadAddressSize(ExternalReference source) { | 151 int MacroAssembler::LoadAddressSize(ExternalReference source) { |
| 141 if (root_array_available_ && !Serializer::enabled()) { | 152 if (root_array_available_ && !Serializer::enabled()) { |
| 142 // This calculation depends on the internals of LoadAddress. | 153 // This calculation depends on the internals of LoadAddress. |
| 143 // It's correctness is ensured by the asserts in the Call | 154 // It's correctness is ensured by the asserts in the Call |
| 144 // instruction below. | 155 // instruction below. |
| 145 intptr_t delta = RootRegisterDelta(source); | 156 int64_t delta = RootRegisterDelta(source); |
| 146 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { | 157 if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
| 147 Serializer::TooLateToEnableNow(); | 158 Serializer::TooLateToEnableNow(); |
| 148 // Operand is leap(scratch, Operand(kRootRegister, delta)); | 159 // Operand is leap(scratch, Operand(kRootRegister, delta)); |
| 149 // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. | 160 // Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. |
| 150 int size = 4; | 161 int size = 4; |
| 151 if (!is_int8(static_cast<int32_t>(delta))) { | 162 if (!is_int8(static_cast<int32_t>(delta))) { |
| 152 size += 3; // Need full four-byte displacement in lea. | 163 size += 3; // Need full four-byte displacement in lea. |
| 153 } | 164 } |
| 154 return size; | 165 return size; |
| 155 } | 166 } |
| (...skipping 4993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5149 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); | 5160 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); |
| 5150 movl(rax, dividend); | 5161 movl(rax, dividend); |
| 5151 shrl(rax, Immediate(31)); | 5162 shrl(rax, Immediate(31)); |
| 5152 addl(rdx, rax); | 5163 addl(rdx, rax); |
| 5153 } | 5164 } |
| 5154 | 5165 |
| 5155 | 5166 |
| 5156 } } // namespace v8::internal | 5167 } } // namespace v8::internal |
| 5157 | 5168 |
| 5158 #endif // V8_TARGET_ARCH_X64 | 5169 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |