OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/object_store.h" | 5 #include "vm/object_store.h" |
6 | 6 |
| 7 #include "vm/dart_entry.h" |
7 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
8 #include "vm/dart_entry.h" | |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
11 #include "vm/raw_object.h" | 11 #include "vm/raw_object.h" |
12 #include "vm/resolver.h" | 12 #include "vm/resolver.h" |
13 #include "vm/symbols.h" | 13 #include "vm/symbols.h" |
14 #include "vm/visitor.h" | 14 #include "vm/visitor.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
18 ObjectStore::ObjectStore() | 18 ObjectStore::ObjectStore() |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 token_objects_(GrowableObjectArray::null()), | 104 token_objects_(GrowableObjectArray::null()), |
105 token_objects_map_(Array::null()), | 105 token_objects_map_(Array::null()), |
106 megamorphic_cache_table_(GrowableObjectArray::null()), | 106 megamorphic_cache_table_(GrowableObjectArray::null()), |
107 megamorphic_miss_code_(Code::null()), | 107 megamorphic_miss_code_(Code::null()), |
108 megamorphic_miss_function_(Function::null()) { | 108 megamorphic_miss_function_(Function::null()) { |
109 for (RawObject** current = from(); current <= to(); current++) { | 109 for (RawObject** current = from(); current <= to(); current++) { |
110 ASSERT(*current == Object::null()); | 110 ASSERT(*current == Object::null()); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 | |
115 ObjectStore::~ObjectStore() {} | 114 ObjectStore::~ObjectStore() {} |
116 | 115 |
117 | |
118 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 116 void ObjectStore::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
119 ASSERT(visitor != NULL); | 117 ASSERT(visitor != NULL); |
120 visitor->VisitPointers(from(), to()); | 118 visitor->VisitPointers(from(), to()); |
121 } | 119 } |
122 | 120 |
123 | |
124 void ObjectStore::Init(Isolate* isolate) { | 121 void ObjectStore::Init(Isolate* isolate) { |
125 ASSERT(isolate->object_store() == NULL); | 122 ASSERT(isolate->object_store() == NULL); |
126 ObjectStore* store = new ObjectStore(); | 123 ObjectStore* store = new ObjectStore(); |
127 isolate->set_object_store(store); | 124 isolate->set_object_store(store); |
128 } | 125 } |
129 | 126 |
130 | |
131 #ifndef PRODUCT | 127 #ifndef PRODUCT |
132 void ObjectStore::PrintToJSONObject(JSONObject* jsobj) { | 128 void ObjectStore::PrintToJSONObject(JSONObject* jsobj) { |
133 if (!FLAG_support_service) { | 129 if (!FLAG_support_service) { |
134 return; | 130 return; |
135 } | 131 } |
136 jsobj->AddProperty("type", "_ObjectStore"); | 132 jsobj->AddProperty("type", "_ObjectStore"); |
137 | 133 |
138 { | 134 { |
139 JSONObject fields(jsobj, "fields"); | 135 JSONObject fields(jsobj, "fields"); |
140 Object& value = Object::Handle(); | 136 Object& value = Object::Handle(); |
141 #define PRINT_OBJECT_STORE_FIELD(type, name) \ | 137 #define PRINT_OBJECT_STORE_FIELD(type, name) \ |
142 value = name; \ | 138 value = name; \ |
143 fields.AddProperty(#name, value); | 139 fields.AddProperty(#name, value); |
144 OBJECT_STORE_FIELD_LIST(PRINT_OBJECT_STORE_FIELD); | 140 OBJECT_STORE_FIELD_LIST(PRINT_OBJECT_STORE_FIELD); |
145 #undef PRINT_OBJECT_STORE_FIELD | 141 #undef PRINT_OBJECT_STORE_FIELD |
146 } | 142 } |
147 } | 143 } |
148 #endif // !PRODUCT | 144 #endif // !PRODUCT |
149 | 145 |
150 | |
151 RawError* ObjectStore::PreallocateObjects() { | 146 RawError* ObjectStore::PreallocateObjects() { |
152 Thread* thread = Thread::Current(); | 147 Thread* thread = Thread::Current(); |
153 Isolate* isolate = thread->isolate(); | 148 Isolate* isolate = thread->isolate(); |
154 Zone* zone = thread->zone(); | 149 Zone* zone = thread->zone(); |
155 ASSERT(isolate != NULL && isolate->object_store() == this); | 150 ASSERT(isolate != NULL && isolate->object_store() == this); |
156 if (this->stack_overflow() != Instance::null()) { | 151 if (this->stack_overflow() != Instance::null()) { |
157 ASSERT(this->out_of_memory() != Instance::null()); | 152 ASSERT(this->out_of_memory() != Instance::null()); |
158 ASSERT(this->preallocated_stack_trace() != StackTrace::null()); | 153 ASSERT(this->preallocated_stack_trace() != StackTrace::null()); |
159 return Error::null(); | 154 return Error::null(); |
160 } | 155 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 const StackTrace& stack_trace = | 197 const StackTrace& stack_trace = |
203 StackTrace::Handle(zone, StackTrace::New(code_array, pc_offset_array)); | 198 StackTrace::Handle(zone, StackTrace::New(code_array, pc_offset_array)); |
204 // Expansion of inlined functions requires additional memory at run time, | 199 // Expansion of inlined functions requires additional memory at run time, |
205 // avoid it. | 200 // avoid it. |
206 stack_trace.set_expand_inlined(false); | 201 stack_trace.set_expand_inlined(false); |
207 set_preallocated_stack_trace(stack_trace); | 202 set_preallocated_stack_trace(stack_trace); |
208 | 203 |
209 return Error::null(); | 204 return Error::null(); |
210 } | 205 } |
211 | 206 |
212 | |
213 RawFunction* ObjectStore::PrivateObjectLookup(const String& name) { | 207 RawFunction* ObjectStore::PrivateObjectLookup(const String& name) { |
214 const Library& core_lib = Library::Handle(core_library()); | 208 const Library& core_lib = Library::Handle(core_library()); |
215 const String& mangled = String::ZoneHandle(core_lib.PrivateName(name)); | 209 const String& mangled = String::ZoneHandle(core_lib.PrivateName(name)); |
216 const Class& cls = Class::Handle(object_class()); | 210 const Class& cls = Class::Handle(object_class()); |
217 const Function& result = Function::Handle(cls.LookupDynamicFunction(mangled)); | 211 const Function& result = Function::Handle(cls.LookupDynamicFunction(mangled)); |
218 ASSERT(!result.IsNull()); | 212 ASSERT(!result.IsNull()); |
219 return result.raw(); | 213 return result.raw(); |
220 } | 214 } |
221 | 215 |
222 | |
223 void ObjectStore::InitKnownObjects() { | 216 void ObjectStore::InitKnownObjects() { |
224 #ifdef DART_PRECOMPILED_RUNTIME | 217 #ifdef DART_PRECOMPILED_RUNTIME |
225 // These objects are only needed for code generation. | 218 // These objects are only needed for code generation. |
226 return; | 219 return; |
227 #else | 220 #else |
228 Thread* thread = Thread::Current(); | 221 Thread* thread = Thread::Current(); |
229 Zone* zone = thread->zone(); | 222 Zone* zone = thread->zone(); |
230 Isolate* isolate = thread->isolate(); | 223 Isolate* isolate = thread->isolate(); |
231 ASSERT(isolate != NULL && isolate->object_store() == this); | 224 ASSERT(isolate != NULL && isolate->object_store() == this); |
232 | 225 |
(...skipping 21 matching lines...) Expand all Loading... |
254 set_async_set_thread_stack_trace(function); | 247 set_async_set_thread_stack_trace(function); |
255 | 248 |
256 function_name ^= async_lib.PrivateName(Symbols::ClearAsyncThreadStackTrace()); | 249 function_name ^= async_lib.PrivateName(Symbols::ClearAsyncThreadStackTrace()); |
257 ASSERT(!function_name.IsNull()); | 250 ASSERT(!function_name.IsNull()); |
258 function ^= | 251 function ^= |
259 Resolver::ResolveStatic(async_lib, Object::null_string(), function_name, | 252 Resolver::ResolveStatic(async_lib, Object::null_string(), function_name, |
260 0, 0, Object::null_array()); | 253 0, 0, Object::null_array()); |
261 ASSERT(!function.IsNull()); | 254 ASSERT(!function.IsNull()); |
262 set_async_clear_thread_stack_trace(function); | 255 set_async_clear_thread_stack_trace(function); |
263 | 256 |
264 | |
265 function_name ^= async_lib.PrivateName(Symbols::AsyncStarMoveNextHelper()); | 257 function_name ^= async_lib.PrivateName(Symbols::AsyncStarMoveNextHelper()); |
266 ASSERT(!function_name.IsNull()); | 258 ASSERT(!function_name.IsNull()); |
267 function ^= | 259 function ^= |
268 Resolver::ResolveStatic(async_lib, Object::null_string(), function_name, | 260 Resolver::ResolveStatic(async_lib, Object::null_string(), function_name, |
269 0, 1, Object::null_array()); | 261 0, 1, Object::null_array()); |
270 ASSERT(!function.IsNull()); | 262 ASSERT(!function.IsNull()); |
271 set_async_star_move_next_helper(function); | 263 set_async_star_move_next_helper(function); |
272 | 264 |
273 function_name ^= async_lib.PrivateName(Symbols::_CompleteOnAsyncReturn()); | 265 function_name ^= async_lib.PrivateName(Symbols::_CompleteOnAsyncReturn()); |
274 ASSERT(!function_name.IsNull()); | 266 ASSERT(!function_name.IsNull()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 simple_instance_of_function_ = | 307 simple_instance_of_function_ = |
316 PrivateObjectLookup(Symbols::_simpleInstanceOf()); | 308 PrivateObjectLookup(Symbols::_simpleInstanceOf()); |
317 simple_instance_of_true_function_ = | 309 simple_instance_of_true_function_ = |
318 PrivateObjectLookup(Symbols::_simpleInstanceOfTrue()); | 310 PrivateObjectLookup(Symbols::_simpleInstanceOfTrue()); |
319 simple_instance_of_false_function_ = | 311 simple_instance_of_false_function_ = |
320 PrivateObjectLookup(Symbols::_simpleInstanceOfFalse()); | 312 PrivateObjectLookup(Symbols::_simpleInstanceOfFalse()); |
321 #endif | 313 #endif |
322 } | 314 } |
323 | 315 |
324 } // namespace dart | 316 } // namespace dart |
OLD | NEW |