| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 int RelocInfo::target_address_size() { | 226 int RelocInfo::target_address_size() { |
| 227 if (IsCodedSpecially()) { | 227 if (IsCodedSpecially()) { |
| 228 return Assembler::kCallTargetSize; | 228 return Assembler::kCallTargetSize; |
| 229 } else { | 229 } else { |
| 230 return Assembler::kExternalTargetSize; | 230 return Assembler::kExternalTargetSize; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 void RelocInfo::set_target_address(Address target) { | 235 void RelocInfo::set_target_address(Address target, Code* code) { |
| 236 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 236 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 237 if (IsCodeTarget(rmode_)) { | 237 if (code != NULL && IsCodeTarget(rmode_)) { |
| 238 Assembler::set_target_address_at(pc_, target); | 238 Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 239 } else { | 239 IncrementalMarking::RecordWrite(code, HeapObject::cast(target_code)); |
| 240 Memory::Address_at(pc_) = target; | |
| 241 CPU::FlushICache(pc_, sizeof(Address)); | |
| 242 } | 240 } |
| 241 Assembler::set_target_address_at(pc_, target); |
| 243 } | 242 } |
| 244 | 243 |
| 245 | 244 |
| 246 Object* RelocInfo::target_object() { | 245 Object* RelocInfo::target_object() { |
| 247 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 246 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 248 return Memory::Object_at(pc_); | 247 return Memory::Object_at(pc_); |
| 249 } | 248 } |
| 250 | 249 |
| 251 | 250 |
| 252 Handle<Object> RelocInfo::target_object_handle(Assembler *origin) { | 251 Handle<Object> RelocInfo::target_object_handle(Assembler *origin) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 264 return reinterpret_cast<Object**>(pc_); | 263 return reinterpret_cast<Object**>(pc_); |
| 265 } | 264 } |
| 266 | 265 |
| 267 | 266 |
| 268 Address* RelocInfo::target_reference_address() { | 267 Address* RelocInfo::target_reference_address() { |
| 269 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 268 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
| 270 return reinterpret_cast<Address*>(pc_); | 269 return reinterpret_cast<Address*>(pc_); |
| 271 } | 270 } |
| 272 | 271 |
| 273 | 272 |
| 274 void RelocInfo::set_target_object(Object* target) { | 273 void RelocInfo::set_target_object(Object* target, Code* code) { |
| 275 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 274 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 276 *reinterpret_cast<Object**>(pc_) = target; | 275 *reinterpret_cast<Object**>(pc_) = target; |
| 277 CPU::FlushICache(pc_, sizeof(Address)); | 276 CPU::FlushICache(pc_, sizeof(Address)); |
| 277 if (code != NULL && target->IsHeapObject()) { |
| 278 IncrementalMarking::RecordWrite(code, HeapObject::cast(target)); |
| 279 } |
| 278 } | 280 } |
| 279 | 281 |
| 280 | 282 |
| 281 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 283 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 282 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 284 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 283 Address address = Memory::Address_at(pc_); | 285 Address address = Memory::Address_at(pc_); |
| 284 return Handle<JSGlobalPropertyCell>( | 286 return Handle<JSGlobalPropertyCell>( |
| 285 reinterpret_cast<JSGlobalPropertyCell**>(address)); | 287 reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 286 } | 288 } |
| 287 | 289 |
| 288 | 290 |
| 289 JSGlobalPropertyCell* RelocInfo::target_cell() { | 291 JSGlobalPropertyCell* RelocInfo::target_cell() { |
| 290 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 292 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 291 Address address = Memory::Address_at(pc_); | 293 Address address = Memory::Address_at(pc_); |
| 292 Object* object = HeapObject::FromAddress( | 294 Object* object = HeapObject::FromAddress( |
| 293 address - JSGlobalPropertyCell::kValueOffset); | 295 address - JSGlobalPropertyCell::kValueOffset); |
| 294 return reinterpret_cast<JSGlobalPropertyCell*>(object); | 296 return reinterpret_cast<JSGlobalPropertyCell*>(object); |
| 295 } | 297 } |
| 296 | 298 |
| 297 | 299 |
| 298 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { | 300 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell, Code* code) { |
| 299 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 301 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 300 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; | 302 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; |
| 301 Memory::Address_at(pc_) = address; | 303 Memory::Address_at(pc_) = address; |
| 302 CPU::FlushICache(pc_, sizeof(Address)); | 304 CPU::FlushICache(pc_, sizeof(Address)); |
| 305 if (code != NULL) IncrementalMarking::RecordWrite(code, cell); |
| 303 } | 306 } |
| 304 | 307 |
| 305 | 308 |
| 306 bool RelocInfo::IsPatchedReturnSequence() { | 309 bool RelocInfo::IsPatchedReturnSequence() { |
| 307 // The recognized call sequence is: | 310 // The recognized call sequence is: |
| 308 // movq(kScratchRegister, immediate64); call(kScratchRegister); | 311 // movq(kScratchRegister, immediate64); call(kScratchRegister); |
| 309 // It only needs to be distinguished from a return sequence | 312 // It only needs to be distinguished from a return sequence |
| 310 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 | 313 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 |
| 311 // The 11th byte is int3 (0xCC) in the return sequence and | 314 // The 11th byte is int3 (0xCC) in the return sequence and |
| 312 // REX.WB (0x48+register bit) for the call sequence. | 315 // REX.WB (0x48+register bit) for the call sequence. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 ASSERT(len_ == 1 || len_ == 2); | 449 ASSERT(len_ == 1 || len_ == 2); |
| 447 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 450 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
| 448 *p = disp; | 451 *p = disp; |
| 449 len_ += sizeof(int32_t); | 452 len_ += sizeof(int32_t); |
| 450 } | 453 } |
| 451 | 454 |
| 452 | 455 |
| 453 } } // namespace v8::internal | 456 } } // namespace v8::internal |
| 454 | 457 |
| 455 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 458 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
| OLD | NEW |