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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (current > 0 && code_targets_.last().is_identical_to(target)) { | 79 if (current > 0 && code_targets_.last().is_identical_to(target)) { |
80 // Optimization if we keep jumping to the same code target. | 80 // Optimization if we keep jumping to the same code target. |
81 emitl(current - 1); | 81 emitl(current - 1); |
82 } else { | 82 } else { |
83 code_targets_.Add(target); | 83 code_targets_.Add(target); |
84 emitl(current); | 84 emitl(current); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 | 88 |
| 89 void Assembler::emit_deopt_entry(Address entry, RelocInfo::Mode rmode) { |
| 90 ASSERT(RelocInfo::IsDeoptEntry(rmode)); |
| 91 RecordRelocInfo(rmode); |
| 92 int current = deopt_entries_.length(); |
| 93 if (current > 0 && deopt_entries_.last() == entry) { |
| 94 // Optimization if we keep jumping to the same entry. |
| 95 emitl(current - 1); |
| 96 } else { |
| 97 deopt_entries_.Add(entry); |
| 98 emitl(current); |
| 99 } |
| 100 } |
| 101 |
| 102 |
89 void Assembler::emit_rex_64(Register reg, Register rm_reg) { | 103 void Assembler::emit_rex_64(Register reg, Register rm_reg) { |
90 emit(0x48 | reg.high_bit() << 2 | rm_reg.high_bit()); | 104 emit(0x48 | reg.high_bit() << 2 | rm_reg.high_bit()); |
91 } | 105 } |
92 | 106 |
93 | 107 |
94 void Assembler::emit_rex_64(XMMRegister reg, Register rm_reg) { | 108 void Assembler::emit_rex_64(XMMRegister reg, Register rm_reg) { |
95 emit(0x48 | (reg.code() & 0x8) >> 1 | rm_reg.code() >> 3); | 109 emit(0x48 | (reg.code() & 0x8) >> 1 | rm_reg.code() >> 3); |
96 } | 110 } |
97 | 111 |
98 | 112 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 215 |
202 Address Assembler::target_address_from_return_address(Address pc) { | 216 Address Assembler::target_address_from_return_address(Address pc) { |
203 return pc - kCallTargetAddressOffset; | 217 return pc - kCallTargetAddressOffset; |
204 } | 218 } |
205 | 219 |
206 | 220 |
207 Handle<Object> Assembler::code_target_object_handle_at(Address pc) { | 221 Handle<Object> Assembler::code_target_object_handle_at(Address pc) { |
208 return code_targets_[Memory::int32_at(pc)]; | 222 return code_targets_[Memory::int32_at(pc)]; |
209 } | 223 } |
210 | 224 |
| 225 |
| 226 Address Assembler::deopt_entry_at(Address pc) { |
| 227 return deopt_entries_[Memory::int32_at(pc)]; |
| 228 } |
| 229 |
211 // ----------------------------------------------------------------------------- | 230 // ----------------------------------------------------------------------------- |
212 // Implementation of RelocInfo | 231 // Implementation of RelocInfo |
213 | 232 |
214 // The modes possibly affected by apply must be in kApplyMask. | 233 // The modes possibly affected by apply must be in kApplyMask. |
215 void RelocInfo::apply(intptr_t delta) { | 234 void RelocInfo::apply(intptr_t delta) { |
216 if (IsInternalReference(rmode_)) { | 235 if (IsInternalReference(rmode_)) { |
217 // absolute code pointer inside code object moves with the code object. | 236 // absolute code pointer inside code object moves with the code object. |
218 Memory::Address_at(pc_) += static_cast<int32_t>(delta); | 237 Memory::Address_at(pc_) += static_cast<int32_t>(delta); |
219 CPU::FlushICache(pc_, sizeof(Address)); | 238 CPU::FlushICache(pc_, sizeof(Address)); |
220 } else if (IsCodeTarget(rmode_)) { | 239 } else if (IsCodeTarget(rmode_) || IsDeoptEntry(rmode_)) { |
221 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); | 240 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); |
222 CPU::FlushICache(pc_, sizeof(int32_t)); | 241 CPU::FlushICache(pc_, sizeof(int32_t)); |
223 } else if (rmode_ == CODE_AGE_SEQUENCE) { | 242 } else if (rmode_ == CODE_AGE_SEQUENCE) { |
224 if (*pc_ == kCallOpcode) { | 243 if (*pc_ == kCallOpcode) { |
225 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); | 244 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
226 *p -= static_cast<int32_t>(delta); // Relocate entry. | 245 *p -= static_cast<int32_t>(delta); // Relocate entry. |
227 CPU::FlushICache(p, sizeof(uint32_t)); | 246 CPU::FlushICache(p, sizeof(uint32_t)); |
228 } | 247 } |
229 } | 248 } |
230 } | 249 } |
231 | 250 |
232 | 251 |
233 Address RelocInfo::target_address() { | 252 Address RelocInfo::target_address() { |
234 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 253 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY |
235 if (IsCodeTarget(rmode_)) { | 254 || IsDeoptEntry(rmode_)); |
| 255 if (IsCodeTarget(rmode_) || (IsDeoptEntry(rmode_))) { |
236 return Assembler::target_address_at(pc_); | 256 return Assembler::target_address_at(pc_); |
237 } else { | 257 } else { |
238 return Memory::Address_at(pc_); | 258 return Memory::Address_at(pc_); |
239 } | 259 } |
240 } | 260 } |
241 | 261 |
242 | 262 |
243 Address RelocInfo::target_address_address() { | 263 Address RelocInfo::target_address_address() { |
244 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY | 264 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY |
| 265 || IsDeoptEntry(rmode_) |
245 || rmode_ == EMBEDDED_OBJECT | 266 || rmode_ == EMBEDDED_OBJECT |
246 || rmode_ == EXTERNAL_REFERENCE); | 267 || rmode_ == EXTERNAL_REFERENCE); |
247 return reinterpret_cast<Address>(pc_); | 268 return reinterpret_cast<Address>(pc_); |
248 } | 269 } |
249 | 270 |
250 | 271 |
251 int RelocInfo::target_address_size() { | 272 int RelocInfo::target_address_size() { |
252 if (IsCodedSpecially()) { | 273 if (IsCodedSpecially()) { |
253 return Assembler::kSpecialTargetSize; | 274 return Assembler::kSpecialTargetSize; |
254 } else { | 275 } else { |
255 return kPointerSize; | 276 return kPointerSize; |
256 } | 277 } |
257 } | 278 } |
258 | 279 |
259 | 280 |
260 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 281 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
261 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 282 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY |
262 if (IsCodeTarget(rmode_)) { | 283 || IsDeoptEntry(rmode_)); |
| 284 if (IsCodeTarget(rmode_) || IsDeoptEntry(rmode_)) { |
263 Assembler::set_target_address_at(pc_, target); | 285 Assembler::set_target_address_at(pc_, target); |
264 Object* target_code = Code::GetCodeFromTargetAddress(target); | 286 if (mode == UPDATE_WRITE_BARRIER && host() != NULL |
265 if (mode == UPDATE_WRITE_BARRIER && host() != NULL) { | 287 && IsCodeTarget(rmode_)) { |
| 288 Object* target_code = Code::GetCodeFromTargetAddress(target); |
266 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 289 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
267 host(), this, HeapObject::cast(target_code)); | 290 host(), this, HeapObject::cast(target_code)); |
268 } | 291 } |
269 } else { | 292 } else { |
270 Memory::Address_at(pc_) = target; | 293 Memory::Address_at(pc_) = target; |
271 CPU::FlushICache(pc_, sizeof(Address)); | 294 CPU::FlushICache(pc_, sizeof(Address)); |
272 } | 295 } |
273 } | 296 } |
274 | 297 |
275 | 298 |
276 Object* RelocInfo::target_object() { | 299 Object* RelocInfo::target_object() { |
277 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 300 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
278 return Memory::Object_at(pc_); | 301 return Memory::Object_at(pc_); |
279 } | 302 } |
280 | 303 |
281 | 304 |
282 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 305 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
283 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 306 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
284 if (rmode_ == EMBEDDED_OBJECT) { | 307 if (rmode_ == EMBEDDED_OBJECT) { |
285 return Memory::Object_Handle_at(pc_); | 308 return Memory::Object_Handle_at(pc_); |
286 } else { | 309 } else { |
287 return origin->code_target_object_handle_at(pc_); | 310 return origin->code_target_object_handle_at(pc_); |
288 } | 311 } |
289 } | 312 } |
290 | 313 |
291 | 314 |
| 315 Address RelocInfo::target_deopt_entry(Assembler* origin) { |
| 316 ASSERT(IsDeoptEntry(rmode_)); |
| 317 return origin->deopt_entry_at(pc_); |
| 318 } |
| 319 |
| 320 |
292 Object** RelocInfo::target_object_address() { | 321 Object** RelocInfo::target_object_address() { |
293 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 322 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
294 return reinterpret_cast<Object**>(pc_); | 323 return reinterpret_cast<Object**>(pc_); |
295 } | 324 } |
296 | 325 |
297 | 326 |
298 Address* RelocInfo::target_reference_address() { | 327 Address* RelocInfo::target_reference_address() { |
299 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 328 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
300 return reinterpret_cast<Address*>(pc_); | 329 return reinterpret_cast<Address*>(pc_); |
301 } | 330 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 ASSERT(len_ == 1 || len_ == 2); | 541 ASSERT(len_ == 1 || len_ == 2); |
513 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 542 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
514 *p = disp; | 543 *p = disp; |
515 len_ += sizeof(int32_t); | 544 len_ += sizeof(int32_t); |
516 } | 545 } |
517 | 546 |
518 | 547 |
519 } } // namespace v8::internal | 548 } } // namespace v8::internal |
520 | 549 |
521 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 550 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
OLD | NEW |