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

Side by Side Diff: vm/heap.h

Issue 10223015: Add a stub_code_space in the heap alongside code_space so that stub code generation happens here an… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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 | « vm/gc_marker.cc ('k') | vm/heap.cc » ('j') | vm/heap.cc » ('J')
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_HEAP_H_ 5 #ifndef VM_HEAP_H_
6 #define VM_HEAP_H_ 6 #define VM_HEAP_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 11 matching lines...) Expand all
22 DECLARE_FLAG(bool, verbose_gc); 22 DECLARE_FLAG(bool, verbose_gc);
23 DECLARE_FLAG(bool, verify_before_gc); 23 DECLARE_FLAG(bool, verify_before_gc);
24 DECLARE_FLAG(bool, verify_after_gc); 24 DECLARE_FLAG(bool, verify_after_gc);
25 DECLARE_FLAG(bool, gc_at_alloc); 25 DECLARE_FLAG(bool, gc_at_alloc);
26 26
27 class Heap { 27 class Heap {
28 public: 28 public:
29 enum Space { 29 enum Space {
30 kNew, 30 kNew,
31 kOld, 31 kOld,
32 kExecutable 32 kDartCode,
33 kStubCode,
33 }; 34 };
34 35
35 enum ApiCallbacks { 36 enum ApiCallbacks {
36 kIgnoreApiCallbacks, 37 kIgnoreApiCallbacks,
37 kInvokeApiCallbacks 38 kInvokeApiCallbacks
38 }; 39 };
39 40
40 // Default allocation sizes in MB for the old gen and code heaps. 41 // Default allocation sizes in MB for the old gen and code heaps.
41 static const intptr_t kHeapSizeInMB = 512; 42 static const intptr_t kHeapSizeInMB = 512;
42 static const intptr_t kCodeHeapSizeInMB = 8; 43 static const intptr_t kCodeHeapSizeInMB = 8;
44 static const intptr_t kStubCodeHeapSizeInKB = 256;
43 45
44 ~Heap(); 46 ~Heap();
45 47
46 uword Allocate(intptr_t size, Space space) { 48 uword Allocate(intptr_t size, Space space) {
47 switch (space) { 49 switch (space) {
48 case kNew: 50 case kNew:
49 // Do not attempt to allocate very large objects in new space. 51 // Do not attempt to allocate very large objects in new space.
50 if (!PageSpace::IsPageAllocatableSize(size)) { 52 if (!PageSpace::IsPageAllocatableSize(size)) {
51 return AllocateOld(size); 53 return AllocateOld(size);
52 } 54 }
53 return AllocateNew(size); 55 return AllocateNew(size);
54 case kOld: 56 case kOld:
55 return AllocateOld(size); 57 return AllocateOld(size);
56 case kExecutable: 58 case kDartCode:
57 return AllocateCode(size); 59 return AllocateCode(code_space_, size);
60 case kStubCode:
61 return AllocateCode(stub_code_space_, size);
58 default: 62 default:
59 UNREACHABLE(); 63 UNREACHABLE();
60 } 64 }
61 return 0; 65 return 0;
62 } 66 }
63 67
64 uword TryAllocate(intptr_t size, Space space) { 68 uword TryAllocate(intptr_t size, Space space) {
65 switch (space) { 69 switch (space) {
66 case kNew: 70 case kNew:
67 return new_space_->TryAllocate(size); 71 return new_space_->TryAllocate(size);
68 case kOld: 72 case kOld:
69 return old_space_->TryAllocate(size); 73 return old_space_->TryAllocate(size);
70 case kExecutable: 74 case kDartCode:
71 return code_space_->TryAllocate(size); 75 return code_space_->TryAllocate(size);
76 case kStubCode:
77 return stub_code_space_->TryAllocate(size);
72 default: 78 default:
73 UNREACHABLE(); 79 UNREACHABLE();
74 } 80 }
75 return 0; 81 return 0;
76 } 82 }
77 83
78 // Heap contains the specified address. 84 // Heap contains the specified address.
79 bool Contains(uword addr) const; 85 bool Contains(uword addr) const;
80 bool CodeContains(uword addr) const; 86 bool CodeContains(uword addr) const;
87 bool StubCodeContains(uword addr) const;
81 88
82 // Visit all pointers in the space. 89 // Visit all pointers in the space.
83 void IterateNewPointers(ObjectPointerVisitor* visitor); 90 void IterateNewPointers(ObjectPointerVisitor* visitor);
84 void IterateOldPointers(ObjectPointerVisitor* visitor); 91 void IterateOldPointers(ObjectPointerVisitor* visitor);
85 void IterateCodePointers(ObjectPointerVisitor* visitor); 92 void IterateCodePointers(ObjectPointerVisitor* visitor);
93 void IterateStubCodePointers(ObjectPointerVisitor* visitor);
86 94
87 // Find an object by visiting all pointers in the specified heap space, 95 // Find an object by visiting all pointers in the specified heap space,
88 // the 'visitor' is used to determine if an object is found or not. 96 // the 'visitor' is used to determine if an object is found or not.
89 // The 'visitor' function should be set up to return true if the 97 // The 'visitor' function should be set up to return true if the
90 // object is found, traversal through the heap space stops at that 98 // object is found, traversal through the heap space stops at that
91 // point. 99 // point.
92 // The 'visitor' function should return false if the object is not found, 100 // The 'visitor' function should return false if the object is not found,
93 // traversal through the heap space continues. 101 // traversal through the heap space continues.
94 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor); 102 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor);
103 RawInstructions* FindObjectInStubCodeSpace(FindObjectVisitor* visitor);
95 104
96 void CollectGarbage(Space space); 105 void CollectGarbage(Space space);
97 void CollectGarbage(Space space, ApiCallbacks api_callbacks); 106 void CollectGarbage(Space space, ApiCallbacks api_callbacks);
98 void CollectAllGarbage(); 107 void CollectAllGarbage();
99 108
100 // Accessors for inlined allocation in generated code. 109 // Accessors for inlined allocation in generated code.
101 uword TopAddress(); 110 uword TopAddress();
102 uword EndAddress(); 111 uword EndAddress();
103 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } 112 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); }
104 113
105 // Initialize the heap and register it with the isolate. 114 // Initialize the heap and register it with the isolate.
106 static void Init(Isolate* isolate); 115 static void Init(Isolate* isolate);
107 116
108 // Verify that all pointers in the heap point to the heap. 117 // Verify that all pointers in the heap point to the heap.
109 bool Verify() const; 118 bool Verify() const;
110 119
111 private: 120 private:
112 Heap(); 121 Heap();
113 122
114 uword AllocateNew(intptr_t size); 123 uword AllocateNew(intptr_t size);
115 uword AllocateOld(intptr_t size); 124 uword AllocateOld(intptr_t size);
116 uword AllocateCode(intptr_t size); 125 uword AllocateCode(PageSpace* space, intptr_t size);
117 126
118 // The different spaces used for allocation. 127 // The different spaces used for allocation.
119 Scavenger* new_space_; 128 Scavenger* new_space_;
120 PageSpace* old_space_; 129 PageSpace* old_space_;
121 PageSpace* code_space_; 130 PageSpace* code_space_;
131 PageSpace* stub_code_space_;
122 132
123 DISALLOW_COPY_AND_ASSIGN(Heap); 133 DISALLOW_COPY_AND_ASSIGN(Heap);
124 }; 134 };
125 135
126 136
127 #if defined(DEBUG) 137 #if defined(DEBUG)
128 class NoGCScope : public StackResource { 138 class NoGCScope : public StackResource {
129 public: 139 public:
130 NoGCScope(); 140 NoGCScope();
131 ~NoGCScope(); 141 ~NoGCScope();
132 private: 142 private:
133 DISALLOW_COPY_AND_ASSIGN(NoGCScope); 143 DISALLOW_COPY_AND_ASSIGN(NoGCScope);
134 }; 144 };
135 #else // defined(DEBUG) 145 #else // defined(DEBUG)
136 class NoGCScope : public ValueObject { 146 class NoGCScope : public ValueObject {
137 public: 147 public:
138 NoGCScope() {} 148 NoGCScope() {}
139 private: 149 private:
140 DISALLOW_COPY_AND_ASSIGN(NoGCScope); 150 DISALLOW_COPY_AND_ASSIGN(NoGCScope);
141 }; 151 };
142 #endif // defined(DEBUG) 152 #endif // defined(DEBUG)
143 153
144 } // namespace dart 154 } // namespace dart
145 155
146 #endif // VM_HEAP_H_ 156 #endif // VM_HEAP_H_
OLDNEW
« no previous file with comments | « vm/gc_marker.cc ('k') | vm/heap.cc » ('j') | vm/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698