| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 void RelocInfo::set_target_address(Address target, Code* code) { | 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); | 245 Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 246 if (code != NULL) { | 246 if (code != NULL) { |
| 247 // TODO(gc) We do not compact code pages. |
| 247 code->GetHeap()->incremental_marking()->RecordWrite( | 248 code->GetHeap()->incremental_marking()->RecordWrite( |
| 248 code, HeapObject::cast(target_code)); | 249 code, NULL, HeapObject::cast(target_code)); |
| 249 } | 250 } |
| 250 } else { | 251 } else { |
| 251 Memory::Address_at(pc_) = target; | 252 Memory::Address_at(pc_) = target; |
| 252 CPU::FlushICache(pc_, sizeof(Address)); | 253 CPU::FlushICache(pc_, sizeof(Address)); |
| 253 } | 254 } |
| 254 } | 255 } |
| 255 | 256 |
| 256 | 257 |
| 257 Object* RelocInfo::target_object() { | 258 Object* RelocInfo::target_object() { |
| 258 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 259 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 277 | 278 |
| 278 | 279 |
| 279 Address* RelocInfo::target_reference_address() { | 280 Address* RelocInfo::target_reference_address() { |
| 280 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 281 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
| 281 return reinterpret_cast<Address*>(pc_); | 282 return reinterpret_cast<Address*>(pc_); |
| 282 } | 283 } |
| 283 | 284 |
| 284 | 285 |
| 285 void RelocInfo::set_target_object(Object* target, Code* code) { | 286 void RelocInfo::set_target_object(Object* target, Code* code) { |
| 286 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 287 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 287 *reinterpret_cast<Object**>(pc_) = target; | 288 Memory::Object_at(pc_) = target; |
| 288 CPU::FlushICache(pc_, sizeof(Address)); | 289 CPU::FlushICache(pc_, sizeof(Address)); |
| 289 if (code != NULL && target->IsHeapObject()) { | 290 if (code != NULL && target->IsHeapObject()) { |
| 290 code->GetHeap()->incremental_marking()->RecordWrite( | 291 code->GetHeap()->incremental_marking()->RecordWrite( |
| 291 code, HeapObject::cast(target)); | 292 code, &Memory::Object_at(pc_), HeapObject::cast(target)); |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 | 295 |
| 295 | 296 |
| 296 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 297 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 297 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 298 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 298 Address address = Memory::Address_at(pc_); | 299 Address address = Memory::Address_at(pc_); |
| 299 return Handle<JSGlobalPropertyCell>( | 300 return Handle<JSGlobalPropertyCell>( |
| 300 reinterpret_cast<JSGlobalPropertyCell**>(address)); | 301 reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 301 } | 302 } |
| 302 | 303 |
| 303 | 304 |
| 304 JSGlobalPropertyCell* RelocInfo::target_cell() { | 305 JSGlobalPropertyCell* RelocInfo::target_cell() { |
| 305 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 306 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 306 Address address = Memory::Address_at(pc_); | 307 Address address = Memory::Address_at(pc_); |
| 307 Object* object = HeapObject::FromAddress( | 308 Object* object = HeapObject::FromAddress( |
| 308 address - JSGlobalPropertyCell::kValueOffset); | 309 address - JSGlobalPropertyCell::kValueOffset); |
| 309 return reinterpret_cast<JSGlobalPropertyCell*>(object); | 310 return reinterpret_cast<JSGlobalPropertyCell*>(object); |
| 310 } | 311 } |
| 311 | 312 |
| 312 | 313 |
| 313 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell, Code* code) { | 314 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell, Code* code) { |
| 314 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 315 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 315 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; | 316 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; |
| 316 Memory::Address_at(pc_) = address; | 317 Memory::Address_at(pc_) = address; |
| 317 CPU::FlushICache(pc_, sizeof(Address)); | 318 CPU::FlushICache(pc_, sizeof(Address)); |
| 318 if (code != NULL) { | 319 if (code != NULL) { |
| 319 code->GetHeap()->incremental_marking()->RecordWrite(code, cell); | 320 code->GetHeap()->incremental_marking()->RecordWrite( |
| 321 code, &Memory::Object_at(pc_), cell); |
| 320 } | 322 } |
| 321 } | 323 } |
| 322 | 324 |
| 323 | 325 |
| 324 bool RelocInfo::IsPatchedReturnSequence() { | 326 bool RelocInfo::IsPatchedReturnSequence() { |
| 325 // The recognized call sequence is: | 327 // The recognized call sequence is: |
| 326 // movq(kScratchRegister, immediate64); call(kScratchRegister); | 328 // movq(kScratchRegister, immediate64); call(kScratchRegister); |
| 327 // It only needs to be distinguished from a return sequence | 329 // It only needs to be distinguished from a return sequence |
| 328 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 | 330 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 |
| 329 // The 11th byte is int3 (0xCC) in the return sequence and | 331 // The 11th byte is int3 (0xCC) in the return sequence and |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 ASSERT(len_ == 1 || len_ == 2); | 467 ASSERT(len_ == 1 || len_ == 2); |
| 466 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 468 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
| 467 *p = disp; | 469 *p = disp; |
| 468 len_ += sizeof(int32_t); | 470 len_ += sizeof(int32_t); |
| 469 } | 471 } |
| 470 | 472 |
| 471 | 473 |
| 472 } } // namespace v8::internal | 474 } } // namespace v8::internal |
| 473 | 475 |
| 474 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 476 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
| OLD | NEW |