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

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

Issue 2702303002: [heap] Notify GC on potentially unsafe object layout changes. (Closed)
Patch Set: NULL -> nullptr Created 3 years, 10 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/objects.h » ('j') | src/objects.cc » ('J')
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/ast/context-slot-cache.h" 9 #include "src/ast/context-slot-cache.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 current_gc_flags_(Heap::kNoGCFlags), 152 current_gc_flags_(Heap::kNoGCFlags),
153 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), 153 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags),
154 external_string_table_(this), 154 external_string_table_(this),
155 gc_callbacks_depth_(0), 155 gc_callbacks_depth_(0),
156 deserialization_complete_(false), 156 deserialization_complete_(false),
157 strong_roots_list_(NULL), 157 strong_roots_list_(NULL),
158 heap_iterator_depth_(0), 158 heap_iterator_depth_(0),
159 local_embedder_heap_tracer_(nullptr), 159 local_embedder_heap_tracer_(nullptr),
160 fast_promotion_mode_(false), 160 fast_promotion_mode_(false),
161 force_oom_(false), 161 force_oom_(false),
162 delay_sweeper_tasks_for_testing_(false) { 162 delay_sweeper_tasks_for_testing_(false),
163 pending_layout_change_object_(nullptr) {
163 // Allow build-time customization of the max semispace size. Building 164 // Allow build-time customization of the max semispace size. Building
164 // V8 with snapshots and a non-default max semispace size is much 165 // V8 with snapshots and a non-default max semispace size is much
165 // easier if you can define it as part of the build environment. 166 // easier if you can define it as part of the build environment.
166 #if defined(V8_MAX_SEMISPACE_SIZE) 167 #if defined(V8_MAX_SEMISPACE_SIZE)
167 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; 168 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
168 #endif 169 #endif
169 170
170 // Ensure old_generation_size_ is a multiple of kPageSize. 171 // Ensure old_generation_size_ is a multiple of kPageSize.
171 DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0); 172 DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0);
172 173
(...skipping 4112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 if (ObjectMarking::IsBlack(obj)) { 4286 if (ObjectMarking::IsBlack(obj)) {
4286 incremental_marking()->IterateBlackObject(obj); 4287 incremental_marking()->IterateBlackObject(obj);
4287 } 4288 }
4288 addr += obj->Size(); 4289 addr += obj->Size();
4289 } 4290 }
4290 } 4291 }
4291 } 4292 }
4292 } 4293 }
4293 } 4294 }
4294 4295
4296 void Heap::NotifyObjectLayoutChange(HeapObject* object,
Igor Sheludko 2017/02/21 10:22:25 WDYT about putting this to heap-inl.h?
4297 const DisallowHeapAllocation&) {
4298 // TODO(ulan): Add synchronization with the concurrent marker.
4299 #ifdef VERIFY_HEAP
4300 DCHECK(pending_layout_change_object_ == nullptr);
4301 pending_layout_change_object_ = object;
4302 #endif
4303 }
4304
4305 #ifdef VERIFY_HEAP
4306 void Heap::VerifyObjectLayoutChange(HeapObject* object, Map* new_map) {
4307 if (pending_layout_change_object_ == nullptr) {
4308 DCHECK(!object->IsJSObject() ||
4309 !object->map()->TransitionRequiresSynchronizationWithGC(new_map));
4310 } else {
4311 DCHECK_EQ(pending_layout_change_object_, object);
4312 pending_layout_change_object_ = nullptr;
4313 }
4314 }
4315 #endif
4316
4295 GCIdleTimeHeapState Heap::ComputeHeapState() { 4317 GCIdleTimeHeapState Heap::ComputeHeapState() {
4296 GCIdleTimeHeapState heap_state; 4318 GCIdleTimeHeapState heap_state;
4297 heap_state.contexts_disposed = contexts_disposed_; 4319 heap_state.contexts_disposed = contexts_disposed_;
4298 heap_state.contexts_disposal_rate = 4320 heap_state.contexts_disposal_rate =
4299 tracer()->ContextDisposalRateInMilliseconds(); 4321 tracer()->ContextDisposalRateInMilliseconds();
4300 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); 4322 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects());
4301 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); 4323 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
4302 return heap_state; 4324 return heap_state;
4303 } 4325 }
4304 4326
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
6368 } 6390 }
6369 6391
6370 6392
6371 // static 6393 // static
6372 int Heap::GetStaticVisitorIdForMap(Map* map) { 6394 int Heap::GetStaticVisitorIdForMap(Map* map) {
6373 return StaticVisitorBase::GetVisitorId(map); 6395 return StaticVisitorBase::GetVisitorId(map);
6374 } 6396 }
6375 6397
6376 } // namespace internal 6398 } // namespace internal
6377 } // namespace v8 6399 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/objects.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698