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

Side by Side Diff: src/heap/heap.cc

Issue 1305163007: [heap] Remove raw unchecked root set accessors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix no-snap builds. Created 5 years, 3 months 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/heap/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 } 2569 }
2570 2570
2571 2571
2572 AllocationResult Heap::AllocatePartialMap(InstanceType instance_type, 2572 AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
2573 int instance_size) { 2573 int instance_size) {
2574 Object* result = nullptr; 2574 Object* result = nullptr;
2575 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE); 2575 AllocationResult allocation = AllocateRaw(Map::kSize, MAP_SPACE, MAP_SPACE);
2576 if (!allocation.To(&result)) return allocation; 2576 if (!allocation.To(&result)) return allocation;
2577 2577
2578 // Map::cast cannot be used due to uninitialized map field. 2578 // Map::cast cannot be used due to uninitialized map field.
2579 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); 2579 reinterpret_cast<Map*>(result)->set_map(
2580 reinterpret_cast<Map*>(root(kMetaMapRootIndex)));
2580 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); 2581 reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
2581 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); 2582 reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
2582 // Initialize to only containing tagged fields. 2583 // Initialize to only containing tagged fields.
2583 reinterpret_cast<Map*>(result)->set_visitor_id( 2584 reinterpret_cast<Map*>(result)->set_visitor_id(
2584 StaticVisitorBase::GetVisitorId(instance_type, instance_size, false)); 2585 StaticVisitorBase::GetVisitorId(instance_type, instance_size, false));
2585 if (FLAG_unbox_double_fields) { 2586 if (FLAG_unbox_double_fields) {
2586 reinterpret_cast<Map*>(result) 2587 reinterpret_cast<Map*>(result)
2587 ->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); 2588 ->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
2588 } 2589 }
2589 reinterpret_cast<Map*>(result)->clear_unused(); 2590 reinterpret_cast<Map*>(result)->clear_unused();
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
3554 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); 3555 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length);
3555 3556
3556 return result; 3557 return result;
3557 } 3558 }
3558 3559
3559 3560
3560 void Heap::CreateFillerObjectAt(Address addr, int size) { 3561 void Heap::CreateFillerObjectAt(Address addr, int size) {
3561 if (size == 0) return; 3562 if (size == 0) return;
3562 HeapObject* filler = HeapObject::FromAddress(addr); 3563 HeapObject* filler = HeapObject::FromAddress(addr);
3563 if (size == kPointerSize) { 3564 if (size == kPointerSize) {
3564 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); 3565 filler->set_map_no_write_barrier(
3566 reinterpret_cast<Map*>(root(kOnePointerFillerMapRootIndex)));
3565 } else if (size == 2 * kPointerSize) { 3567 } else if (size == 2 * kPointerSize) {
3566 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); 3568 filler->set_map_no_write_barrier(
3569 reinterpret_cast<Map*>(root(kTwoPointerFillerMapRootIndex)));
3567 } else { 3570 } else {
3568 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); 3571 filler->set_map_no_write_barrier(
3572 reinterpret_cast<Map*>(root(kFreeSpaceMapRootIndex)));
3569 FreeSpace::cast(filler)->nobarrier_set_size(size); 3573 FreeSpace::cast(filler)->nobarrier_set_size(size);
3570 } 3574 }
3571 // At this point, we may be deserializing the heap from a snapshot, and 3575 // At this point, we may be deserializing the heap from a snapshot, and
3572 // none of the maps have been created yet and are NULL. 3576 // none of the maps have been created yet and are NULL.
3573 DCHECK((filler->map() == NULL && !deserialization_complete_) || 3577 DCHECK((filler->map() == NULL && !deserialization_complete_) ||
3574 filler->map()->IsMap()); 3578 filler->map()->IsMap());
3575 } 3579 }
3576 3580
3577 3581
3578 bool Heap::CanMoveObjectStart(HeapObject* object) { 3582 bool Heap::CanMoveObjectStart(HeapObject* object) {
(...skipping 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
6259 MarkRecursively(root, &mark_visitor); 6263 MarkRecursively(root, &mark_visitor);
6260 6264
6261 UnmarkVisitor unmark_visitor(this); 6265 UnmarkVisitor unmark_visitor(this);
6262 UnmarkRecursively(root, &unmark_visitor); 6266 UnmarkRecursively(root, &unmark_visitor);
6263 6267
6264 ProcessResults(); 6268 ProcessResults();
6265 } 6269 }
6266 6270
6267 6271
6268 static bool SafeIsNativeContext(HeapObject* obj) { 6272 static bool SafeIsNativeContext(HeapObject* obj) {
6269 return obj->map() == obj->GetHeap()->raw_unchecked_native_context_map(); 6273 return obj->map() == obj->GetHeap()->root(Heap::kNativeContextMapRootIndex);
6270 } 6274 }
6271 6275
6272 6276
6273 void PathTracer::MarkRecursively(Object** p, MarkVisitor* mark_visitor) { 6277 void PathTracer::MarkRecursively(Object** p, MarkVisitor* mark_visitor) {
6274 if (!(*p)->IsHeapObject()) return; 6278 if (!(*p)->IsHeapObject()) return;
6275 6279
6276 HeapObject* obj = HeapObject::cast(*p); 6280 HeapObject* obj = HeapObject::cast(*p);
6277 6281
6278 MapWord map_word = obj->map_word(); 6282 MapWord map_word = obj->map_word();
6279 if (!map_word.ToMap()->IsHeapObject()) return; // visited before 6283 if (!map_word.ToMap()->IsHeapObject()) return; // visited before
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
6790 *object_type = "CODE_TYPE"; \ 6794 *object_type = "CODE_TYPE"; \
6791 *object_sub_type = "CODE_AGE/" #name; \ 6795 *object_sub_type = "CODE_AGE/" #name; \
6792 return true; 6796 return true;
6793 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6797 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6794 #undef COMPARE_AND_RETURN_NAME 6798 #undef COMPARE_AND_RETURN_NAME
6795 } 6799 }
6796 return false; 6800 return false;
6797 } 6801 }
6798 } // namespace internal 6802 } // namespace internal
6799 } // namespace v8 6803 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698