Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: src/heap.cc

Issue 8698022: When scavenging update source slot before migrating object it points to. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 heap->new_space()->RecordAllocation(obj); 1479 heap->new_space()->RecordAllocation(obj);
1480 } else { 1480 } else {
1481 heap->new_space()->RecordPromotion(obj); 1481 heap->new_space()->RecordPromotion(obj);
1482 } 1482 }
1483 } 1483 }
1484 } 1484 }
1485 1485
1486 // Helper function used by CopyObject to copy a source object to an 1486 // Helper function used by CopyObject to copy a source object to an
1487 // allocated target object and update the forwarding pointer in the source 1487 // allocated target object and update the forwarding pointer in the source
1488 // object. Returns the target object. 1488 // object. Returns the target object.
1489 INLINE(static HeapObject* MigrateObject(Heap* heap, 1489 INLINE(static void MigrateObject(Heap* heap,
1490 HeapObject* source, 1490 HeapObject* source,
1491 HeapObject* target, 1491 HeapObject* target,
1492 int size)) { 1492 int size)) {
1493 // Copy the content of source to target. 1493 // Copy the content of source to target.
1494 heap->CopyBlock(target->address(), source->address(), size); 1494 heap->CopyBlock(target->address(), source->address(), size);
1495 1495
1496 // Set the forwarding address. 1496 // Set the forwarding address.
1497 source->set_map_word(MapWord::FromForwardingAddress(target)); 1497 source->set_map_word(MapWord::FromForwardingAddress(target));
1498 1498
1499 if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) { 1499 if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) {
1500 // Update NewSpace stats if necessary. 1500 // Update NewSpace stats if necessary.
1501 RecordCopiedObject(heap, target); 1501 RecordCopiedObject(heap, target);
1502 HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address())); 1502 HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address()));
1503 Isolate* isolate = heap->isolate(); 1503 Isolate* isolate = heap->isolate();
1504 if (isolate->logger()->is_logging() || 1504 if (isolate->logger()->is_logging() ||
1505 CpuProfiler::is_profiling(isolate)) { 1505 CpuProfiler::is_profiling(isolate)) {
1506 if (target->IsSharedFunctionInfo()) { 1506 if (target->IsSharedFunctionInfo()) {
1507 PROFILE(isolate, SharedFunctionInfoMoveEvent( 1507 PROFILE(isolate, SharedFunctionInfoMoveEvent(
1508 source->address(), target->address())); 1508 source->address(), target->address()));
1509 } 1509 }
1510 } 1510 }
1511 } 1511 }
1512 1512
1513 if (marks_handling == TRANSFER_MARKS) { 1513 if (marks_handling == TRANSFER_MARKS) {
1514 if (Marking::TransferColor(source, target)) { 1514 if (Marking::TransferColor(source, target)) {
1515 MemoryChunk::IncrementLiveBytes(target->address(), size); 1515 MemoryChunk::IncrementLiveBytes(target->address(), size);
1516 } 1516 }
1517 } 1517 }
1518
1519 return target;
1520 } 1518 }
1521 1519
1522 template<ObjectContents object_contents, SizeRestriction size_restriction> 1520 template<ObjectContents object_contents, SizeRestriction size_restriction>
1523 static inline void EvacuateObject(Map* map, 1521 static inline void EvacuateObject(Map* map,
1524 HeapObject** slot, 1522 HeapObject** slot,
1525 HeapObject* object, 1523 HeapObject* object,
1526 int object_size) { 1524 int object_size) {
1527 SLOW_ASSERT((size_restriction != SMALL) || 1525 SLOW_ASSERT((size_restriction != SMALL) ||
1528 (object_size <= Page::kMaxHeapObjectSize)); 1526 (object_size <= Page::kMaxHeapObjectSize));
1529 SLOW_ASSERT(object->Size() == object_size); 1527 SLOW_ASSERT(object->Size() == object_size);
(...skipping 10 matching lines...) Expand all
1540 if (object_contents == DATA_OBJECT) { 1538 if (object_contents == DATA_OBJECT) {
1541 maybe_result = heap->old_data_space()->AllocateRaw(object_size); 1539 maybe_result = heap->old_data_space()->AllocateRaw(object_size);
1542 } else { 1540 } else {
1543 maybe_result = heap->old_pointer_space()->AllocateRaw(object_size); 1541 maybe_result = heap->old_pointer_space()->AllocateRaw(object_size);
1544 } 1542 }
1545 } 1543 }
1546 1544
1547 Object* result = NULL; // Initialization to please compiler. 1545 Object* result = NULL; // Initialization to please compiler.
1548 if (maybe_result->ToObject(&result)) { 1546 if (maybe_result->ToObject(&result)) {
1549 HeapObject* target = HeapObject::cast(result); 1547 HeapObject* target = HeapObject::cast(result);
1550 *slot = MigrateObject(heap, object , target, object_size); 1548
1549 // Order is important: slot might be inside of the target if target
1550 // was allocated over a dead object and slot comes from the store
1551 // buffer.
1552 *slot = target;
1553 MigrateObject(heap, object, target, object_size);
1551 1554
1552 if (object_contents == POINTER_OBJECT) { 1555 if (object_contents == POINTER_OBJECT) {
1553 heap->promotion_queue()->insert(target, object_size); 1556 heap->promotion_queue()->insert(target, object_size);
1554 } 1557 }
1555 1558
1556 heap->tracer()->increment_promoted_objects_size(object_size); 1559 heap->tracer()->increment_promoted_objects_size(object_size);
1557 return; 1560 return;
1558 } 1561 }
1559 } 1562 }
1560 MaybeObject* allocation = heap->new_space()->AllocateRaw(object_size); 1563 MaybeObject* allocation = heap->new_space()->AllocateRaw(object_size);
1561 heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); 1564 heap->promotion_queue()->SetNewLimit(heap->new_space()->top());
1562 Object* result = allocation->ToObjectUnchecked(); 1565 Object* result = allocation->ToObjectUnchecked();
1566 HeapObject* target = HeapObject::cast(result);
1563 1567
1564 *slot = MigrateObject(heap, object, HeapObject::cast(result), object_size); 1568 // Order is important: slot might be inside of the target if target
1569 // was allocated over a dead object and slot comes from the store
1570 // buffer.
1571 *slot = target;
1572 MigrateObject(heap, object, target, object_size);
1565 return; 1573 return;
1566 } 1574 }
1567 1575
1568 1576
1569 static inline void EvacuateJSFunction(Map* map, 1577 static inline void EvacuateJSFunction(Map* map,
1570 HeapObject** slot, 1578 HeapObject** slot,
1571 HeapObject* object) { 1579 HeapObject* object) {
1572 ObjectEvacuationStrategy<POINTER_OBJECT>:: 1580 ObjectEvacuationStrategy<POINTER_OBJECT>::
1573 template VisitSpecialized<JSFunction::kSize>(map, slot, object); 1581 template VisitSpecialized<JSFunction::kSize>(map, slot, object);
1574 1582
(...skipping 4908 matching lines...) Expand 10 before | Expand all | Expand 10 after
6483 isolate_->heap()->store_buffer()->Compact(); 6491 isolate_->heap()->store_buffer()->Compact();
6484 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6492 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6485 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6493 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6486 next = chunk->next_chunk(); 6494 next = chunk->next_chunk();
6487 isolate_->memory_allocator()->Free(chunk); 6495 isolate_->memory_allocator()->Free(chunk);
6488 } 6496 }
6489 chunks_queued_for_free_ = NULL; 6497 chunks_queued_for_free_ = NULL;
6490 } 6498 }
6491 6499
6492 } } // namespace v8::internal 6500 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698