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

Side by Side Diff: src/context-measure.cc

Issue 2780773002: [heap] Two minor fixes in EstimatedSize (Closed)
Patch Set: Remove unused variables Created 3 years, 8 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 | « no previous file | test/cctest/heap/test-heap.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/context-measure.h" 5 #include "src/context-measure.h"
6 6
7 #include "src/base/logging.h" 7 #include "src/base/logging.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 ContextMeasure::ContextMeasure(Context* context) 14 ContextMeasure::ContextMeasure(Context* context)
15 : context_(context), 15 : context_(context),
16 root_index_map_(context->GetIsolate()), 16 root_index_map_(context->GetIsolate()),
17 recursion_depth_(0), 17 recursion_depth_(0),
18 count_(0), 18 count_(0),
19 size_(0) { 19 size_(0) {
20 DCHECK(context_->IsNativeContext()); 20 DCHECK(context_->IsNativeContext());
21 Object* next_link = context_->next_context_link(); 21 Object* next_link = context_->next_context_link();
22 context_->set(Context::NEXT_CONTEXT_LINK,
23 context->GetIsolate()->heap()->undefined_value());
22 MeasureObject(context_); 24 MeasureObject(context_);
23 MeasureDeferredObjects(); 25 MeasureDeferredObjects();
24 context_->set(Context::NEXT_CONTEXT_LINK, next_link); 26 context_->set(Context::NEXT_CONTEXT_LINK, next_link);
25 } 27 }
26 28
27 29
28 bool ContextMeasure::IsShared(HeapObject* object) { 30 bool ContextMeasure::IsShared(HeapObject* object) {
29 if (object->IsScript()) return true; 31 if (object->IsScript()) return true;
30 if (object->IsSharedFunctionInfo()) return true; 32 if (object->IsSharedFunctionInfo()) return true;
31 if (object->IsScopeInfo()) return true; 33 if (object->IsScopeInfo()) return true;
32 if (object->IsCode() && !Code::cast(object)->is_optimized_code()) return true; 34 if (object->IsCode() && !Code::cast(object)->is_optimized_code()) return true;
33 if (object->IsAccessorInfo()) return true; 35 if (object->IsAccessorInfo()) return true;
34 if (object->IsWeakCell()) return true; 36 if (object->IsWeakCell()) return true;
37 if (object->IsMap()) return true;
Yang 2017/03/28 12:11:36 This is not the right thing to do. Most maps actua
Dan Ehrenberg 2017/03/28 16:51:06 Sorry for my confusion; of course they do. The new
35 return false; 38 return false;
36 } 39 }
37 40
38 41
39 void ContextMeasure::MeasureObject(HeapObject* object) { 42 void ContextMeasure::MeasureObject(HeapObject* object) {
40 if (reference_map_.Lookup(object).is_valid()) return; 43 if (reference_map_.Lookup(object).is_valid()) return;
41 if (root_index_map_.Lookup(object) != RootIndexMap::kInvalidRootIndex) return; 44 if (root_index_map_.Lookup(object) != RootIndexMap::kInvalidRootIndex) return;
42 if (IsShared(object)) return; 45 if (IsShared(object)) return;
43 reference_map_.Add(object, SerializerReference::DummyReference()); 46 reference_map_.Add(object, SerializerReference::DummyReference());
44 recursion_depth_++; 47 recursion_depth_++;
(...skipping 24 matching lines...) Expand all
69 72
70 73
71 void ContextMeasure::VisitPointers(Object** start, Object** end) { 74 void ContextMeasure::VisitPointers(Object** start, Object** end) {
72 for (Object** current = start; current < end; current++) { 75 for (Object** current = start; current < end; current++) {
73 if ((*current)->IsSmi()) continue; 76 if ((*current)->IsSmi()) continue;
74 MeasureObject(HeapObject::cast(*current)); 77 MeasureObject(HeapObject::cast(*current));
75 } 78 }
76 } 79 }
77 } // namespace internal 80 } // namespace internal
78 } // namespace v8 81 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698