| 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/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/dart_entry.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" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 error_listeners_(GrowableObjectArray::null()), | 83 error_listeners_(GrowableObjectArray::null()), |
| 84 empty_context_(Context::null()), | 84 empty_context_(Context::null()), |
| 85 stack_overflow_(Instance::null()), | 85 stack_overflow_(Instance::null()), |
| 86 out_of_memory_(Instance::null()), | 86 out_of_memory_(Instance::null()), |
| 87 preallocated_unhandled_exception_(UnhandledException::null()), | 87 preallocated_unhandled_exception_(UnhandledException::null()), |
| 88 preallocated_stack_trace_(Stacktrace::null()), | 88 preallocated_stack_trace_(Stacktrace::null()), |
| 89 lookup_port_handler_(Function::null()), | 89 lookup_port_handler_(Function::null()), |
| 90 empty_uint32_array_(TypedData::null()), | 90 empty_uint32_array_(TypedData::null()), |
| 91 handle_message_function_(Function::null()), | 91 handle_message_function_(Function::null()), |
| 92 library_load_error_table_(Array::null()), | 92 library_load_error_table_(Array::null()), |
| 93 simple_instance_of_function_(Function::null()), |
| 94 simple_instance_of_true_function_(Function::null()), |
| 95 simple_instance_of_false_function_(Function::null()), |
| 96 compile_time_constants_(Array::null()), |
| 93 unique_dynamic_targets_(Array::null()), | 97 unique_dynamic_targets_(Array::null()), |
| 94 token_objects_(GrowableObjectArray::null()), | 98 token_objects_(GrowableObjectArray::null()), |
| 95 token_objects_map_(Array::null()), | 99 token_objects_map_(Array::null()), |
| 96 megamorphic_cache_table_(GrowableObjectArray::null()), | 100 megamorphic_cache_table_(GrowableObjectArray::null()), |
| 97 megamorphic_miss_code_(Code::null()), | 101 megamorphic_miss_code_(Code::null()), |
| 98 megamorphic_miss_function_(Function::null()) { | 102 megamorphic_miss_function_(Function::null()) { |
| 99 for (RawObject** current = from(); current <= to(); current++) { | 103 for (RawObject** current = from(); current <= to(); current++) { |
| 100 ASSERT(*current == Object::null()); | 104 ASSERT(*current == Object::null()); |
| 101 } | 105 } |
| 102 } | 106 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 Stacktrace::New(code_array, pc_offset_array)); | 198 Stacktrace::New(code_array, pc_offset_array)); |
| 195 // Expansion of inlined functions requires additional memory at run time, | 199 // Expansion of inlined functions requires additional memory at run time, |
| 196 // avoid it. | 200 // avoid it. |
| 197 stack_trace.set_expand_inlined(false); | 201 stack_trace.set_expand_inlined(false); |
| 198 set_preallocated_stack_trace(stack_trace); | 202 set_preallocated_stack_trace(stack_trace); |
| 199 | 203 |
| 200 return Error::null(); | 204 return Error::null(); |
| 201 } | 205 } |
| 202 | 206 |
| 203 | 207 |
| 208 RawFunction* ObjectStore::PrivateObjectLookup(const String& name) { |
| 209 const Library& core_lib = Library::Handle(core_library()); |
| 210 const String& mangled = String::ZoneHandle(core_lib.PrivateName(name)); |
| 211 const Class& cls = Class::Handle(object_class()); |
| 212 const Function& result = Function::Handle(cls.LookupDynamicFunction(mangled)); |
| 213 ASSERT(!result.IsNull()); |
| 214 return result.raw(); |
| 215 } |
| 216 |
| 217 |
| 204 void ObjectStore::InitKnownObjects() { | 218 void ObjectStore::InitKnownObjects() { |
| 205 #ifdef DART_PRECOMPILED_RUNTIME | 219 #ifdef DART_PRECOMPILED_RUNTIME |
| 206 // These objects are only needed for code generation. | 220 // These objects are only needed for code generation. |
| 207 return; | 221 return; |
| 208 #else | 222 #else |
| 209 Thread* thread = Thread::Current(); | 223 Thread* thread = Thread::Current(); |
| 210 Zone* zone = thread->zone(); | 224 Zone* zone = thread->zone(); |
| 211 Isolate* isolate = thread->isolate(); | 225 Isolate* isolate = thread->isolate(); |
| 212 ASSERT(isolate != NULL && isolate->object_store() == this); | 226 ASSERT(isolate != NULL && isolate->object_store() == this); |
| 213 | 227 |
| 214 const Library& async_lib = Library::Handle(async_library()); | 228 const Library& async_lib = Library::Handle(async_library()); |
| 215 ASSERT(!async_lib.IsNull()); | 229 ASSERT(!async_lib.IsNull()); |
| 216 Class& cls = Class::Handle(zone); | 230 Class& cls = Class::Handle(zone); |
| 217 cls = async_lib.LookupClass(Symbols::Future()); | 231 cls = async_lib.LookupClass(Symbols::Future()); |
| 218 ASSERT(!cls.IsNull()); | 232 ASSERT(!cls.IsNull()); |
| 219 set_future_class(cls); | 233 set_future_class(cls); |
| 220 cls = async_lib.LookupClass(Symbols::Completer()); | 234 cls = async_lib.LookupClass(Symbols::Completer()); |
| 221 ASSERT(!cls.IsNull()); | 235 ASSERT(!cls.IsNull()); |
| 222 set_completer_class(cls); | 236 set_completer_class(cls); |
| 223 cls = async_lib.LookupClass(Symbols::StreamIterator()); | 237 cls = async_lib.LookupClass(Symbols::StreamIterator()); |
| 224 ASSERT(!cls.IsNull()); | 238 ASSERT(!cls.IsNull()); |
| 225 set_stream_iterator_class(cls); | 239 set_stream_iterator_class(cls); |
| 226 | 240 |
| 227 const Library& internal_lib = Library::Handle(internal_library()); | 241 const Library& internal_lib = Library::Handle(internal_library()); |
| 228 cls = internal_lib.LookupClass(Symbols::Symbol()); | 242 cls = internal_lib.LookupClass(Symbols::Symbol()); |
| 229 set_symbol_class(cls); | 243 set_symbol_class(cls); |
| 244 |
| 245 // Cache the core private functions used for fast instance of checks. |
| 246 simple_instance_of_function_ = |
| 247 PrivateObjectLookup(Symbols::_simpleInstanceOf()); |
| 248 simple_instance_of_true_function_ = |
| 249 PrivateObjectLookup(Symbols::_simpleInstanceOfTrue()); |
| 250 simple_instance_of_false_function_ = |
| 251 PrivateObjectLookup(Symbols::_simpleInstanceOfFalse()); |
| 230 #endif | 252 #endif |
| 231 } | 253 } |
| 232 | 254 |
| 233 } // namespace dart | 255 } // namespace dart |
| OLD | NEW |