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; |
357 } | 377 } |
358 | 378 |
359 | 379 |
360 Object** RelocInfo::call_object_address() { | 380 Object** RelocInfo::call_object_address() { |
361 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 381 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
362 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 382 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
363 return reinterpret_cast<Object**>( | 383 return reinterpret_cast<Object**>( |
364 pc_ + Assembler::kPatchReturnSequenceAddressOffset); | 384 pc_ + Assembler::kPatchReturnSequenceAddressOffset); |
365 } | 385 } |
366 | 386 |
367 | 387 |
368 void RelocInfo::Visit(ObjectVisitor* visitor) { | 388 void RelocInfo::Visit(ObjectVisitor* visitor) { |
369 RelocInfo::Mode mode = rmode(); | 389 RelocInfo::Mode mode = rmode(); |
370 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 390 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
371 visitor->VisitPointer(target_object_address()); | 391 visitor->VisitEmbeddedPointer(host(), target_object_address()); |
372 CPU::FlushICache(pc_, sizeof(Address)); | 392 CPU::FlushICache(pc_, sizeof(Address)); |
373 } else if (RelocInfo::IsCodeTarget(mode)) { | 393 } else if (RelocInfo::IsCodeTarget(mode)) { |
374 visitor->VisitCodeTarget(this); | 394 visitor->VisitCodeTarget(this); |
375 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 395 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
376 visitor->VisitGlobalPropertyCell(this); | 396 visitor->VisitGlobalPropertyCell(this); |
377 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 397 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
378 visitor->VisitExternalReference(target_reference_address()); | 398 visitor->VisitExternalReference(target_reference_address()); |
379 CPU::FlushICache(pc_, sizeof(Address)); | 399 CPU::FlushICache(pc_, sizeof(Address)); |
380 #ifdef ENABLE_DEBUGGER_SUPPORT | 400 #ifdef ENABLE_DEBUGGER_SUPPORT |
381 // TODO(isolates): Get a cached isolate below. | 401 // TODO(isolates): Get a cached isolate below. |
382 } else if (((RelocInfo::IsJSReturn(mode) && | 402 } else if (((RelocInfo::IsJSReturn(mode) && |
383 IsPatchedReturnSequence()) || | 403 IsPatchedReturnSequence()) || |
384 (RelocInfo::IsDebugBreakSlot(mode) && | 404 (RelocInfo::IsDebugBreakSlot(mode) && |
385 IsPatchedDebugBreakSlotSequence())) && | 405 IsPatchedDebugBreakSlotSequence())) && |
386 Isolate::Current()->debug()->has_break_points()) { | 406 Isolate::Current()->debug()->has_break_points()) { |
387 visitor->VisitDebugTarget(this); | 407 visitor->VisitDebugTarget(this); |
388 #endif | 408 #endif |
389 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 409 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
390 visitor->VisitRuntimeEntry(this); | 410 visitor->VisitRuntimeEntry(this); |
391 } | 411 } |
392 } | 412 } |
393 | 413 |
394 | 414 |
395 template<typename StaticVisitor> | 415 template<typename StaticVisitor> |
396 void RelocInfo::Visit(Heap* heap) { | 416 void RelocInfo::Visit(Heap* heap) { |
397 RelocInfo::Mode mode = rmode(); | 417 RelocInfo::Mode mode = rmode(); |
398 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 418 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
399 StaticVisitor::VisitPointer(heap, target_object_address()); | 419 StaticVisitor::VisitEmbeddedPointer(heap, host(), target_object_address()); |
400 CPU::FlushICache(pc_, sizeof(Address)); | 420 CPU::FlushICache(pc_, sizeof(Address)); |
401 } else if (RelocInfo::IsCodeTarget(mode)) { | 421 } else if (RelocInfo::IsCodeTarget(mode)) { |
402 StaticVisitor::VisitCodeTarget(heap, this); | 422 StaticVisitor::VisitCodeTarget(heap, this); |
403 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 423 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
404 StaticVisitor::VisitGlobalPropertyCell(heap, this); | 424 StaticVisitor::VisitGlobalPropertyCell(heap, this); |
405 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 425 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
406 StaticVisitor::VisitExternalReference(target_reference_address()); | 426 StaticVisitor::VisitExternalReference(target_reference_address()); |
407 CPU::FlushICache(pc_, sizeof(Address)); | 427 CPU::FlushICache(pc_, sizeof(Address)); |
408 #ifdef ENABLE_DEBUGGER_SUPPORT | 428 #ifdef ENABLE_DEBUGGER_SUPPORT |
409 } else if (heap->isolate()->debug()->has_break_points() && | 429 } else if (heap->isolate()->debug()->has_break_points() && |
(...skipping 43 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 |