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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 void Assembler::emit_optional_rex_32(Register rm_reg) { | 198 void Assembler::emit_optional_rex_32(Register rm_reg) { |
199 if (rm_reg.high_bit()) emit(0x41); | 199 if (rm_reg.high_bit()) emit(0x41); |
200 } | 200 } |
201 | 201 |
202 | 202 |
203 void Assembler::emit_optional_rex_32(const Operand& op) { | 203 void Assembler::emit_optional_rex_32(const Operand& op) { |
204 if (op.rex_ != 0) emit(0x40 | op.rex_); | 204 if (op.rex_ != 0) emit(0x40 | op.rex_); |
205 } | 205 } |
206 | 206 |
207 | 207 |
208 Address Assembler::target_address_at(Address pc) { | 208 Address Assembler::target_address_at(Address pc, |
| 209 ConstantPoolArray* constant_pool) { |
209 return Memory::int32_at(pc) + pc + 4; | 210 return Memory::int32_at(pc) + pc + 4; |
210 } | 211 } |
211 | 212 |
212 | 213 |
213 void Assembler::set_target_address_at(Address pc, Address target) { | 214 void Assembler::set_target_address_at(Address pc, |
| 215 ConstantPoolArray* constant_pool, |
| 216 Address target) { |
214 Memory::int32_at(pc) = static_cast<int32_t>(target - pc - 4); | 217 Memory::int32_at(pc) = static_cast<int32_t>(target - pc - 4); |
215 CPU::FlushICache(pc, sizeof(int32_t)); | 218 CPU::FlushICache(pc, sizeof(int32_t)); |
216 } | 219 } |
217 | 220 |
218 | 221 |
219 Address Assembler::target_address_from_return_address(Address pc) { | 222 Address Assembler::target_address_from_return_address(Address pc) { |
220 return pc - kCallTargetAddressOffset; | 223 return pc - kCallTargetAddressOffset; |
221 } | 224 } |
222 | 225 |
223 | 226 |
(...skipping 24 matching lines...) Expand all Loading... |
248 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); | 251 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
249 *p -= static_cast<int32_t>(delta); // Relocate entry. | 252 *p -= static_cast<int32_t>(delta); // Relocate entry. |
250 CPU::FlushICache(p, sizeof(uint32_t)); | 253 CPU::FlushICache(p, sizeof(uint32_t)); |
251 } | 254 } |
252 } | 255 } |
253 } | 256 } |
254 | 257 |
255 | 258 |
256 Address RelocInfo::target_address() { | 259 Address RelocInfo::target_address() { |
257 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 260 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
258 return Assembler::target_address_at(pc_); | 261 return Assembler::target_address_at(pc_, host_); |
259 } | 262 } |
260 | 263 |
261 | 264 |
262 Address RelocInfo::target_address_address() { | 265 Address RelocInfo::target_address_address() { |
263 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) | 266 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) |
264 || rmode_ == EMBEDDED_OBJECT | 267 || rmode_ == EMBEDDED_OBJECT |
265 || rmode_ == EXTERNAL_REFERENCE); | 268 || rmode_ == EXTERNAL_REFERENCE); |
266 return reinterpret_cast<Address>(pc_); | 269 return reinterpret_cast<Address>(pc_); |
267 } | 270 } |
268 | 271 |
269 | 272 |
270 Address RelocInfo::constant_pool_entry_address() { | 273 Address RelocInfo::constant_pool_entry_address() { |
271 UNREACHABLE(); | 274 UNREACHABLE(); |
272 return NULL; | 275 return NULL; |
273 } | 276 } |
274 | 277 |
275 | 278 |
276 int RelocInfo::target_address_size() { | 279 int RelocInfo::target_address_size() { |
277 if (IsCodedSpecially()) { | 280 if (IsCodedSpecially()) { |
278 return Assembler::kSpecialTargetSize; | 281 return Assembler::kSpecialTargetSize; |
279 } else { | 282 } else { |
280 return kPointerSize; | 283 return kPointerSize; |
281 } | 284 } |
282 } | 285 } |
283 | 286 |
284 | 287 |
285 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 288 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
286 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 289 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
287 Assembler::set_target_address_at(pc_, target); | 290 Assembler::set_target_address_at(pc_, host_, target); |
288 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 291 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
289 Object* target_code = Code::GetCodeFromTargetAddress(target); | 292 Object* target_code = Code::GetCodeFromTargetAddress(target); |
290 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 293 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
291 host(), this, HeapObject::cast(target_code)); | 294 host(), this, HeapObject::cast(target_code)); |
292 } | 295 } |
293 } | 296 } |
294 | 297 |
295 | 298 |
296 Object* RelocInfo::target_object() { | 299 Object* RelocInfo::target_object() { |
297 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 300 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 host(), NULL, cell); | 371 host(), NULL, cell); |
369 } | 372 } |
370 } | 373 } |
371 | 374 |
372 | 375 |
373 void RelocInfo::WipeOut() { | 376 void RelocInfo::WipeOut() { |
374 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_)) { | 377 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_)) { |
375 Memory::Address_at(pc_) = NULL; | 378 Memory::Address_at(pc_) = NULL; |
376 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { | 379 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { |
377 // Effectively write zero into the relocation. | 380 // Effectively write zero into the relocation. |
378 Assembler::set_target_address_at(pc_, pc_ + sizeof(int32_t)); | 381 Assembler::set_target_address_at(pc_, host_, pc_ + sizeof(int32_t)); |
379 } else { | 382 } else { |
380 UNREACHABLE(); | 383 UNREACHABLE(); |
381 } | 384 } |
382 } | 385 } |
383 | 386 |
384 | 387 |
385 bool RelocInfo::IsPatchedReturnSequence() { | 388 bool RelocInfo::IsPatchedReturnSequence() { |
386 // The recognized call sequence is: | 389 // The recognized call sequence is: |
387 // movq(kScratchRegister, address); call(kScratchRegister); | 390 // movq(kScratchRegister, address); call(kScratchRegister); |
388 // It only needs to be distinguished from a return sequence | 391 // It only needs to be distinguished from a return sequence |
(...skipping 18 matching lines...) Expand all Loading... |
407 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 410 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
408 ASSERT(*pc_ == kCallOpcode); | 411 ASSERT(*pc_ == kCallOpcode); |
409 return origin->code_target_object_handle_at(pc_ + 1); | 412 return origin->code_target_object_handle_at(pc_ + 1); |
410 } | 413 } |
411 | 414 |
412 | 415 |
413 Code* RelocInfo::code_age_stub() { | 416 Code* RelocInfo::code_age_stub() { |
414 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 417 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
415 ASSERT(*pc_ == kCallOpcode); | 418 ASSERT(*pc_ == kCallOpcode); |
416 return Code::GetCodeFromTargetAddress( | 419 return Code::GetCodeFromTargetAddress( |
417 Assembler::target_address_at(pc_ + 1)); | 420 Assembler::target_address_at(pc_ + 1, host_)); |
418 } | 421 } |
419 | 422 |
420 | 423 |
421 void RelocInfo::set_code_age_stub(Code* stub) { | 424 void RelocInfo::set_code_age_stub(Code* stub) { |
422 ASSERT(*pc_ == kCallOpcode); | 425 ASSERT(*pc_ == kCallOpcode); |
423 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 426 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
424 Assembler::set_target_address_at(pc_ + 1, stub->instruction_start()); | 427 Assembler::set_target_address_at(pc_ + 1, host_, stub->instruction_start()); |
425 } | 428 } |
426 | 429 |
427 | 430 |
428 Address RelocInfo::call_address() { | 431 Address RelocInfo::call_address() { |
429 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 432 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
430 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 433 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
431 return Memory::Address_at( | 434 return Memory::Address_at( |
432 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); | 435 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); |
433 } | 436 } |
434 | 437 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 ASSERT(len_ == 1 || len_ == 2); | 560 ASSERT(len_ == 1 || len_ == 2); |
558 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 561 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
559 *p = disp; | 562 *p = disp; |
560 len_ += sizeof(int32_t); | 563 len_ += sizeof(int32_t); |
561 } | 564 } |
562 | 565 |
563 | 566 |
564 } } // namespace v8::internal | 567 } } // namespace v8::internal |
565 | 568 |
566 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 569 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
OLD | NEW |