OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_REMEMBERED_SET_H | 5 #ifndef V8_REMEMBERED_SET_H |
6 #define V8_REMEMBERED_SET_H | 6 #define V8_REMEMBERED_SET_H |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 return result; | 294 return result; |
295 } | 295 } |
296 | 296 |
297 // Updates a code target slot using an untyped slot callback. | 297 // Updates a code target slot using an untyped slot callback. |
298 // The callback accepts Object** and returns SlotCallbackResult. | 298 // The callback accepts Object** and returns SlotCallbackResult. |
299 template <typename Callback> | 299 template <typename Callback> |
300 static SlotCallbackResult UpdateCodeTarget(RelocInfo* rinfo, | 300 static SlotCallbackResult UpdateCodeTarget(RelocInfo* rinfo, |
301 Callback callback) { | 301 Callback callback) { |
302 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 302 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); |
303 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 303 Code* old_target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
304 Object* old_target = target; | 304 Object* new_target = old_target; |
305 SlotCallbackResult result = callback(&target); | 305 SlotCallbackResult result = callback(&new_target); |
306 if (target != old_target) { | 306 if (new_target != old_target) { |
307 rinfo->set_target_address(Code::cast(target)->instruction_start()); | 307 rinfo->set_target_address(old_target->GetIsolate(), |
| 308 Code::cast(new_target)->instruction_start()); |
308 } | 309 } |
309 return result; | 310 return result; |
310 } | 311 } |
311 | 312 |
312 // Updates an embedded pointer slot using an untyped slot callback. | 313 // Updates an embedded pointer slot using an untyped slot callback. |
313 // The callback accepts Object** and returns SlotCallbackResult. | 314 // The callback accepts Object** and returns SlotCallbackResult. |
314 template <typename Callback> | 315 template <typename Callback> |
315 static SlotCallbackResult UpdateEmbeddedPointer(RelocInfo* rinfo, | 316 static SlotCallbackResult UpdateEmbeddedPointer(RelocInfo* rinfo, |
316 Callback callback) { | 317 Callback callback) { |
317 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); | 318 DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
318 HeapObject* old_target = rinfo->target_object(); | 319 HeapObject* old_target = rinfo->target_object(); |
319 Object* new_target = old_target; | 320 Object* new_target = old_target; |
320 SlotCallbackResult result = callback(&new_target); | 321 SlotCallbackResult result = callback(&new_target); |
321 if (new_target != old_target) { | 322 if (new_target != old_target) { |
322 rinfo->set_target_object(HeapObject::cast(new_target)); | 323 rinfo->set_target_object(HeapObject::cast(new_target)); |
323 } | 324 } |
324 return result; | 325 return result; |
325 } | 326 } |
326 | 327 |
327 // Updates a debug target slot using an untyped slot callback. | 328 // Updates a debug target slot using an untyped slot callback. |
328 // The callback accepts Object** and returns SlotCallbackResult. | 329 // The callback accepts Object** and returns SlotCallbackResult. |
329 template <typename Callback> | 330 template <typename Callback> |
330 static SlotCallbackResult UpdateDebugTarget(RelocInfo* rinfo, | 331 static SlotCallbackResult UpdateDebugTarget(RelocInfo* rinfo, |
331 Callback callback) { | 332 Callback callback) { |
332 DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && | 333 DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && |
333 rinfo->IsPatchedDebugBreakSlotSequence()); | 334 rinfo->IsPatchedDebugBreakSlotSequence()); |
334 Object* target = | 335 Code* old_target = |
335 Code::GetCodeFromTargetAddress(rinfo->debug_call_address()); | 336 Code::GetCodeFromTargetAddress(rinfo->debug_call_address()); |
336 SlotCallbackResult result = callback(&target); | 337 Object* new_target = old_target; |
337 rinfo->set_debug_call_address(Code::cast(target)->instruction_start()); | 338 SlotCallbackResult result = callback(&new_target); |
| 339 rinfo->set_debug_call_address(old_target->GetIsolate(), |
| 340 Code::cast(new_target)->instruction_start()); |
338 return result; | 341 return result; |
339 } | 342 } |
340 | 343 |
341 // Updates a typed slot using an untyped slot callback. | 344 // Updates a typed slot using an untyped slot callback. |
342 // The callback accepts Object** and returns SlotCallbackResult. | 345 // The callback accepts Object** and returns SlotCallbackResult. |
343 template <typename Callback> | 346 template <typename Callback> |
344 static SlotCallbackResult UpdateTypedSlot(Isolate* isolate, | 347 static SlotCallbackResult UpdateTypedSlot(Isolate* isolate, |
345 SlotType slot_type, Address addr, | 348 SlotType slot_type, Address addr, |
346 Callback callback) { | 349 Callback callback) { |
347 switch (slot_type) { | 350 switch (slot_type) { |
348 case CODE_TARGET_SLOT: { | 351 case CODE_TARGET_SLOT: { |
349 RelocInfo rinfo(isolate, addr, RelocInfo::CODE_TARGET, 0, NULL); | 352 RelocInfo rinfo(addr, RelocInfo::CODE_TARGET, 0, NULL); |
350 return UpdateCodeTarget(&rinfo, callback); | 353 return UpdateCodeTarget(&rinfo, callback); |
351 } | 354 } |
352 case CELL_TARGET_SLOT: { | 355 case CELL_TARGET_SLOT: { |
353 RelocInfo rinfo(isolate, addr, RelocInfo::CELL, 0, NULL); | 356 RelocInfo rinfo(addr, RelocInfo::CELL, 0, NULL); |
354 return UpdateCell(&rinfo, callback); | 357 return UpdateCell(&rinfo, callback); |
355 } | 358 } |
356 case CODE_ENTRY_SLOT: { | 359 case CODE_ENTRY_SLOT: { |
357 return UpdateCodeEntry(addr, callback); | 360 return UpdateCodeEntry(addr, callback); |
358 } | 361 } |
359 case DEBUG_TARGET_SLOT: { | 362 case DEBUG_TARGET_SLOT: { |
360 RelocInfo rinfo(isolate, addr, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION, | 363 RelocInfo rinfo(addr, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION, 0, NULL); |
361 0, NULL); | |
362 if (rinfo.IsPatchedDebugBreakSlotSequence()) { | 364 if (rinfo.IsPatchedDebugBreakSlotSequence()) { |
363 return UpdateDebugTarget(&rinfo, callback); | 365 return UpdateDebugTarget(&rinfo, callback); |
364 } | 366 } |
365 return REMOVE_SLOT; | 367 return REMOVE_SLOT; |
366 } | 368 } |
367 case EMBEDDED_OBJECT_SLOT: { | 369 case EMBEDDED_OBJECT_SLOT: { |
368 RelocInfo rinfo(isolate, addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL); | 370 RelocInfo rinfo(addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL); |
369 return UpdateEmbeddedPointer(&rinfo, callback); | 371 return UpdateEmbeddedPointer(&rinfo, callback); |
370 } | 372 } |
371 case OBJECT_SLOT: { | 373 case OBJECT_SLOT: { |
372 return callback(reinterpret_cast<Object**>(addr)); | 374 return callback(reinterpret_cast<Object**>(addr)); |
373 } | 375 } |
374 case CLEARED_SLOT: | 376 case CLEARED_SLOT: |
375 break; | 377 break; |
376 } | 378 } |
377 UNREACHABLE(); | 379 UNREACHABLE(); |
378 return REMOVE_SLOT; | 380 return REMOVE_SLOT; |
(...skipping 11 matching lines...) Expand all Loading... |
390 return DEBUG_TARGET_SLOT; | 392 return DEBUG_TARGET_SLOT; |
391 } | 393 } |
392 UNREACHABLE(); | 394 UNREACHABLE(); |
393 return CLEARED_SLOT; | 395 return CLEARED_SLOT; |
394 } | 396 } |
395 | 397 |
396 } // namespace internal | 398 } // namespace internal |
397 } // namespace v8 | 399 } // namespace v8 |
398 | 400 |
399 #endif // V8_REMEMBERED_SET_H | 401 #endif // V8_REMEMBERED_SET_H |
OLD | NEW |