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

Side by Side Diff: runtime/vm/raw_object.h

Issue 10452006: Implement a heap profiler for the Dart managed heap. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address final review comments Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/pages.cc ('k') | runtime/vm/raw_object.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_RAW_OBJECT_H_ 5 #ifndef VM_RAW_OBJECT_H_
6 #define VM_RAW_OBJECT_H_ 6 #define VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/token.h" 10 #include "vm/token.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 #define SNAPSHOT_WRITER_SUPPORT() \ 141 #define SNAPSHOT_WRITER_SUPPORT() \
142 void WriteTo( \ 142 void WriteTo( \
143 SnapshotWriter* writer, intptr_t object_id, Snapshot::Kind kind); \ 143 SnapshotWriter* writer, intptr_t object_id, Snapshot::Kind kind); \
144 friend class SnapshotWriter; \ 144 friend class SnapshotWriter; \
145 145
146 #define VISITOR_SUPPORT(object) \ 146 #define VISITOR_SUPPORT(object) \
147 static intptr_t Visit##object##Pointers(Raw##object* raw_obj, \ 147 static intptr_t Visit##object##Pointers(Raw##object* raw_obj, \
148 ObjectPointerVisitor* visitor); 148 ObjectPointerVisitor* visitor);
149 149
150 #define HEAP_PROFILER_SUPPORT() \
151 friend class HeapProfiler; \
152
150 #define RAW_OBJECT_IMPLEMENTATION(object) \ 153 #define RAW_OBJECT_IMPLEMENTATION(object) \
151 private: /* NOLINT */ \ 154 private: /* NOLINT */ \
152 VISITOR_SUPPORT(object) \ 155 VISITOR_SUPPORT(object) \
153 friend class object; \ 156 friend class object; \
154 friend class RawObject; \ 157 friend class RawObject; \
155 friend class Heap; \ 158 friend class Heap; \
156 DISALLOW_ALLOCATION(); \ 159 DISALLOW_ALLOCATION(); \
157 DISALLOW_IMPLICIT_CONSTRUCTORS(Raw##object) 160 DISALLOW_IMPLICIT_CONSTRUCTORS(Raw##object)
158 161
159 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \ 162 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \
160 private: \ 163 private: \
161 RAW_OBJECT_IMPLEMENTATION(object); \ 164 RAW_OBJECT_IMPLEMENTATION(object); \
162 Raw##object* ptr() const { \ 165 Raw##object* ptr() const { \
163 ASSERT(IsHeapObject()); \ 166 ASSERT(IsHeapObject()); \
164 return reinterpret_cast<Raw##object*>( \ 167 return reinterpret_cast<Raw##object*>( \
165 reinterpret_cast<uword>(this) - kHeapObjectTag); \ 168 reinterpret_cast<uword>(this) - kHeapObjectTag); \
166 } \ 169 } \
167 SNAPSHOT_WRITER_SUPPORT() \ 170 SNAPSHOT_WRITER_SUPPORT() \
171 HEAP_PROFILER_SUPPORT() \
168 172
169 173
170 // RawObject is the base class of all raw objects, even though it carries the 174 // RawObject is the base class of all raw objects, even though it carries the
171 // class_ field not all raw objects are allocated in the heap and thus cannot 175 // class_ field not all raw objects are allocated in the heap and thus cannot
172 // be dereferenced (e.g. RawSmi). 176 // be dereferenced (e.g. RawSmi).
173 class RawObject { 177 class RawObject {
174 public: 178 public:
175 // The tags field which is a part of the object header uses the following 179 // The tags field which is a part of the object header uses the following
176 // bit fields for storing tags. 180 // bit fields for storing tags.
177 enum TagBits { 181 enum TagBits {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 reinterpret_cast<uword>(this) - kHeapObjectTag); 336 reinterpret_cast<uword>(this) - kHeapObjectTag);
333 } 337 }
334 338
335 intptr_t SizeFromClass() const; 339 intptr_t SizeFromClass() const;
336 340
337 intptr_t GetClassId() const { 341 intptr_t GetClassId() const {
338 uword tags = ptr()->tags_; 342 uword tags = ptr()->tags_;
339 return ClassIdTag::decode(tags); 343 return ClassIdTag::decode(tags);
340 } 344 }
341 345
346 ObjectKind GetObjectKind() const;
347
342 friend class Api; 348 friend class Api;
343 friend class Array; 349 friend class Array;
344 friend class FreeListElement; 350 friend class FreeListElement;
345 friend class Heap; 351 friend class Heap;
352 friend class HeapProfiler;
353 friend class HeapProfilerRootVisitor;
346 friend class MarkingVisitor; 354 friend class MarkingVisitor;
347 friend class Object; 355 friend class Object;
348 friend class RawInstructions; 356 friend class RawInstructions;
349 friend class RawInstance; 357 friend class RawInstance;
350 friend class SnapshotReader; 358 friend class SnapshotReader;
351 friend class SnapshotWriter; 359 friend class SnapshotWriter;
352 360
353 DISALLOW_ALLOCATION(); 361 DISALLOW_ALLOCATION();
354 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); 362 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject);
355 }; 363 };
(...skipping 25 matching lines...) Expand all
381 RawFunction* signature_function_; // Associated function for signature class. 389 RawFunction* signature_function_; // Associated function for signature class.
382 RawArray* functions_cache_; // See class FunctionsCache. 390 RawArray* functions_cache_; // See class FunctionsCache.
383 RawArray* constants_; // Canonicalized values of this class. 391 RawArray* constants_; // Canonicalized values of this class.
384 RawArray* canonical_types_; // Canonicalized types of this class. 392 RawArray* canonical_types_; // Canonicalized types of this class.
385 RawCode* allocation_stub_; // Stub code for allocation of instances. 393 RawCode* allocation_stub_; // Stub code for allocation of instances.
386 RawObject** to() { 394 RawObject** to() {
387 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); 395 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_);
388 } 396 }
389 397
390 cpp_vtable handle_vtable_; 398 cpp_vtable handle_vtable_;
391 intptr_t instance_size_; 399 intptr_t instance_size_; // Size if fixed length or 0 if variable length.
392 ObjectKind instance_kind_; 400 ObjectKind instance_kind_;
393 intptr_t id_; // Class Id, also index in the class table. 401 intptr_t id_; // Class Id, also index in the class table.
394 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. 402 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments.
395 intptr_t next_field_offset_; // Offset of then next instance field. 403 intptr_t next_field_offset_; // Offset of the next instance field.
396 intptr_t num_native_fields_; // Number of native fields in class. 404 intptr_t num_native_fields_; // Number of native fields in class.
397 intptr_t token_index_; 405 intptr_t token_index_;
398 int8_t class_state_; // Of type ClassState. 406 int8_t class_state_; // Of type ClassState.
399 bool is_const_; 407 bool is_const_;
400 bool is_interface_; 408 bool is_interface_;
401 409
402 friend class Object; 410 friend class Object;
403 friend class RawInstance; 411 friend class RawInstance;
404 friend class RawInstructions; 412 friend class RawInstructions;
405 friend class SnapshotReader; 413 friend class SnapshotReader;
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 kExternalUint64Array == kByteArray + 18 && 1506 kExternalUint64Array == kByteArray + 18 &&
1499 kExternalFloat32Array == kByteArray + 19 && 1507 kExternalFloat32Array == kByteArray + 19 &&
1500 kExternalFloat64Array == kByteArray + 20 && 1508 kExternalFloat64Array == kByteArray + 20 &&
1501 kClosure == kByteArray + 21); 1509 kClosure == kByteArray + 21);
1502 return (index >= kByteArray && index <= kClosure); 1510 return (index >= kByteArray && index <= kClosure);
1503 } 1511 }
1504 1512
1505 } // namespace dart 1513 } // namespace dart
1506 1514
1507 #endif // VM_RAW_OBJECT_H_ 1515 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/pages.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698