| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } else { | 235 } else { |
| 236 return Assembler::kExternalTargetSize; | 236 return Assembler::kExternalTargetSize; |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 void RelocInfo::set_target_address(Address target) { | 241 void RelocInfo::set_target_address(Address target) { |
| 242 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 242 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 243 if (IsCodeTarget(rmode_)) { | 243 if (IsCodeTarget(rmode_)) { |
| 244 Assembler::set_target_address_at(pc_, target); | 244 Assembler::set_target_address_at(pc_, target); |
| 245 Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 246 if (host() != NULL) { |
| 247 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
| 248 host(), this, HeapObject::cast(target_code)); |
| 249 } |
| 245 } else { | 250 } else { |
| 246 Memory::Address_at(pc_) = target; | 251 Memory::Address_at(pc_) = target; |
| 247 CPU::FlushICache(pc_, sizeof(Address)); | 252 CPU::FlushICache(pc_, sizeof(Address)); |
| 248 } | 253 } |
| 249 } | 254 } |
| 250 | 255 |
| 251 | 256 |
| 252 Object* RelocInfo::target_object() { | 257 Object* RelocInfo::target_object() { |
| 253 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 258 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 254 return Memory::Object_at(pc_); | 259 return Memory::Object_at(pc_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 272 | 277 |
| 273 | 278 |
| 274 Address* RelocInfo::target_reference_address() { | 279 Address* RelocInfo::target_reference_address() { |
| 275 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 280 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
| 276 return reinterpret_cast<Address*>(pc_); | 281 return reinterpret_cast<Address*>(pc_); |
| 277 } | 282 } |
| 278 | 283 |
| 279 | 284 |
| 280 void RelocInfo::set_target_object(Object* target) { | 285 void RelocInfo::set_target_object(Object* target) { |
| 281 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 286 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 282 *reinterpret_cast<Object**>(pc_) = target; | 287 Memory::Object_at(pc_) = target; |
| 283 CPU::FlushICache(pc_, sizeof(Address)); | 288 CPU::FlushICache(pc_, sizeof(Address)); |
| 289 if (host() != NULL && target->IsHeapObject()) { |
| 290 host()->GetHeap()->incremental_marking()->RecordWrite( |
| 291 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
| 292 } |
| 284 } | 293 } |
| 285 | 294 |
| 286 | 295 |
| 287 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 296 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 288 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 297 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 289 Address address = Memory::Address_at(pc_); | 298 Address address = Memory::Address_at(pc_); |
| 290 return Handle<JSGlobalPropertyCell>( | 299 return Handle<JSGlobalPropertyCell>( |
| 291 reinterpret_cast<JSGlobalPropertyCell**>(address)); | 300 reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 292 } | 301 } |
| 293 | 302 |
| 294 | 303 |
| 295 JSGlobalPropertyCell* RelocInfo::target_cell() { | 304 JSGlobalPropertyCell* RelocInfo::target_cell() { |
| 296 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 305 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 297 Address address = Memory::Address_at(pc_); | 306 Address address = Memory::Address_at(pc_); |
| 298 Object* object = HeapObject::FromAddress( | 307 Object* object = HeapObject::FromAddress( |
| 299 address - JSGlobalPropertyCell::kValueOffset); | 308 address - JSGlobalPropertyCell::kValueOffset); |
| 300 return reinterpret_cast<JSGlobalPropertyCell*>(object); | 309 return reinterpret_cast<JSGlobalPropertyCell*>(object); |
| 301 } | 310 } |
| 302 | 311 |
| 303 | 312 |
| 304 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { | 313 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { |
| 305 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 314 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 306 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; | 315 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; |
| 307 Memory::Address_at(pc_) = address; | 316 Memory::Address_at(pc_) = address; |
| 308 CPU::FlushICache(pc_, sizeof(Address)); | 317 CPU::FlushICache(pc_, sizeof(Address)); |
| 318 if (host() != NULL) { |
| 319 // TODO(1550) We are passing NULL as a slot because cell can never be on |
| 320 // evacuation candidate. |
| 321 host()->GetHeap()->incremental_marking()->RecordWrite( |
| 322 host(), NULL, cell); |
| 323 } |
| 309 } | 324 } |
| 310 | 325 |
| 311 | 326 |
| 312 bool RelocInfo::IsPatchedReturnSequence() { | 327 bool RelocInfo::IsPatchedReturnSequence() { |
| 313 // The recognized call sequence is: | 328 // The recognized call sequence is: |
| 314 // movq(kScratchRegister, immediate64); call(kScratchRegister); | 329 // movq(kScratchRegister, immediate64); call(kScratchRegister); |
| 315 // It only needs to be distinguished from a return sequence | 330 // It only needs to be distinguished from a return sequence |
| 316 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 | 331 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 |
| 317 // The 11th byte is int3 (0xCC) in the return sequence and | 332 // The 11th byte is int3 (0xCC) in the return sequence and |
| 318 // REX.WB (0x48+register bit) for the call sequence. | 333 // REX.WB (0x48+register bit) for the call sequence. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 337 } | 352 } |
| 338 | 353 |
| 339 | 354 |
| 340 void RelocInfo::set_call_address(Address target) { | 355 void RelocInfo::set_call_address(Address target) { |
| 341 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 356 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
| 342 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 357 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
| 343 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = | 358 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = |
| 344 target; | 359 target; |
| 345 CPU::FlushICache(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset, | 360 CPU::FlushICache(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset, |
| 346 sizeof(Address)); | 361 sizeof(Address)); |
| 362 if (host() != NULL) { |
| 363 Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 364 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
| 365 host(), this, HeapObject::cast(target_code)); |
| 366 } |
| 347 } | 367 } |
| 348 | 368 |
| 349 | 369 |
| 350 Object* RelocInfo::call_object() { | 370 Object* RelocInfo::call_object() { |
| 351 return *call_object_address(); | 371 return *call_object_address(); |
| 352 } | 372 } |
| 353 | 373 |
| 354 | 374 |
| 355 void RelocInfo::set_call_object(Object* target) { | 375 void RelocInfo::set_call_object(Object* target) { |
| 356 *call_object_address() = target; | 376 *call_object_address() = target; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 ASSERT(len_ == 1 || len_ == 2); | 473 ASSERT(len_ == 1 || len_ == 2); |
| 454 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 474 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
| 455 *p = disp; | 475 *p = disp; |
| 456 len_ += sizeof(int32_t); | 476 len_ += sizeof(int32_t); |
| 457 } | 477 } |
| 458 | 478 |
| 459 | 479 |
| 460 } } // namespace v8::internal | 480 } } // namespace v8::internal |
| 461 | 481 |
| 462 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 482 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
| OLD | NEW |