| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 int RelocInfo::target_address_size() { | 232 int RelocInfo::target_address_size() { |
| 233 if (IsCodedSpecially()) { | 233 if (IsCodedSpecially()) { |
| 234 return Assembler::kCallTargetSize; | 234 return Assembler::kCallTargetSize; |
| 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, Code* code) { |
| 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 (code != NULL) { |
| 247 code->GetHeap()->incremental_marking()->RecordWrite( |
| 248 code, 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 15 matching lines...) Expand all Loading... |
| 270 return reinterpret_cast<Object**>(pc_); | 275 return reinterpret_cast<Object**>(pc_); |
| 271 } | 276 } |
| 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, Code* code) { |
| 281 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 286 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 282 *reinterpret_cast<Object**>(pc_) = target; | 287 *reinterpret_cast<Object**>(pc_) = target; |
| 283 CPU::FlushICache(pc_, sizeof(Address)); | 288 CPU::FlushICache(pc_, sizeof(Address)); |
| 289 if (code != NULL && target->IsHeapObject()) { |
| 290 code->GetHeap()->incremental_marking()->RecordWrite( |
| 291 code, 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, Code* code) { |
| 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 (code != NULL) { |
| 319 code->GetHeap()->incremental_marking()->RecordWrite(code, cell); |
| 320 } |
| 309 } | 321 } |
| 310 | 322 |
| 311 | 323 |
| 312 bool RelocInfo::IsPatchedReturnSequence() { | 324 bool RelocInfo::IsPatchedReturnSequence() { |
| 313 // The recognized call sequence is: | 325 // The recognized call sequence is: |
| 314 // movq(kScratchRegister, immediate64); call(kScratchRegister); | 326 // movq(kScratchRegister, immediate64); call(kScratchRegister); |
| 315 // It only needs to be distinguished from a return sequence | 327 // It only needs to be distinguished from a return sequence |
| 316 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 | 328 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 |
| 317 // The 11th byte is int3 (0xCC) in the return sequence and | 329 // The 11th byte is int3 (0xCC) in the return sequence and |
| 318 // REX.WB (0x48+register bit) for the call sequence. | 330 // REX.WB (0x48+register bit) for the call sequence. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 ASSERT(len_ == 1 || len_ == 2); | 465 ASSERT(len_ == 1 || len_ == 2); |
| 454 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 466 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
| 455 *p = disp; | 467 *p = disp; |
| 456 len_ += sizeof(int32_t); | 468 len_ += sizeof(int32_t); |
| 457 } | 469 } |
| 458 | 470 |
| 459 | 471 |
| 460 } } // namespace v8::internal | 472 } } // namespace v8::internal |
| 461 | 473 |
| 462 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 474 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
| OLD | NEW |