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

Side by Side Diff: runtime/vm/object_store.cc

Issue 2147123002: Made simple instance-of checks fast for unoptimized code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Removed compile_time_constants_ from object_store. Created 4 years, 5 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 | « runtime/vm/object_store.h ('k') | runtime/vm/symbols.h » ('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) 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 exit_listeners_(GrowableObjectArray::null()), 82 exit_listeners_(GrowableObjectArray::null()),
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 simple_instance_of_function_(Function::null()),
93 simple_instance_of_true_function_(Function::null()),
94 simple_instance_of_false_function_(Function::null()),
92 library_load_error_table_(Array::null()), 95 library_load_error_table_(Array::null()),
93 unique_dynamic_targets_(Array::null()), 96 unique_dynamic_targets_(Array::null()),
94 token_objects_(GrowableObjectArray::null()), 97 token_objects_(GrowableObjectArray::null()),
95 token_objects_map_(Array::null()), 98 token_objects_map_(Array::null()),
96 megamorphic_cache_table_(GrowableObjectArray::null()), 99 megamorphic_cache_table_(GrowableObjectArray::null()),
97 megamorphic_miss_code_(Code::null()), 100 megamorphic_miss_code_(Code::null()),
98 megamorphic_miss_function_(Function::null()) { 101 megamorphic_miss_function_(Function::null()) {
99 for (RawObject** current = from(); current <= to(); current++) { 102 for (RawObject** current = from(); current <= to(); current++) {
100 ASSERT(*current == Object::null()); 103 ASSERT(*current == Object::null());
101 } 104 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 Stacktrace::New(code_array, pc_offset_array)); 197 Stacktrace::New(code_array, pc_offset_array));
195 // Expansion of inlined functions requires additional memory at run time, 198 // Expansion of inlined functions requires additional memory at run time,
196 // avoid it. 199 // avoid it.
197 stack_trace.set_expand_inlined(false); 200 stack_trace.set_expand_inlined(false);
198 set_preallocated_stack_trace(stack_trace); 201 set_preallocated_stack_trace(stack_trace);
199 202
200 return Error::null(); 203 return Error::null();
201 } 204 }
202 205
203 206
207 RawFunction* ObjectStore::PrivateObjectLookup(const String& name) {
208 const Library& core_lib = Library::Handle(core_library());
209 const String& mangled = String::ZoneHandle(core_lib.PrivateName(name));
210 const Class& cls = Class::Handle(object_class());
211 const Function& result = Function::Handle(cls.LookupDynamicFunction(mangled));
212 ASSERT(!result.IsNull());
213 return result.raw();
214 }
215
216
204 void ObjectStore::InitKnownObjects() { 217 void ObjectStore::InitKnownObjects() {
205 #ifdef DART_PRECOMPILED_RUNTIME 218 #ifdef DART_PRECOMPILED_RUNTIME
206 // These objects are only needed for code generation. 219 // These objects are only needed for code generation.
207 return; 220 return;
208 #else 221 #else
209 Thread* thread = Thread::Current(); 222 Thread* thread = Thread::Current();
210 Zone* zone = thread->zone(); 223 Zone* zone = thread->zone();
211 Isolate* isolate = thread->isolate(); 224 Isolate* isolate = thread->isolate();
212 ASSERT(isolate != NULL && isolate->object_store() == this); 225 ASSERT(isolate != NULL && isolate->object_store() == this);
213 226
214 const Library& async_lib = Library::Handle(async_library()); 227 const Library& async_lib = Library::Handle(async_library());
215 ASSERT(!async_lib.IsNull()); 228 ASSERT(!async_lib.IsNull());
216 Class& cls = Class::Handle(zone); 229 Class& cls = Class::Handle(zone);
217 cls = async_lib.LookupClass(Symbols::Future()); 230 cls = async_lib.LookupClass(Symbols::Future());
218 ASSERT(!cls.IsNull()); 231 ASSERT(!cls.IsNull());
219 set_future_class(cls); 232 set_future_class(cls);
220 cls = async_lib.LookupClass(Symbols::Completer()); 233 cls = async_lib.LookupClass(Symbols::Completer());
221 ASSERT(!cls.IsNull()); 234 ASSERT(!cls.IsNull());
222 set_completer_class(cls); 235 set_completer_class(cls);
223 cls = async_lib.LookupClass(Symbols::StreamIterator()); 236 cls = async_lib.LookupClass(Symbols::StreamIterator());
224 ASSERT(!cls.IsNull()); 237 ASSERT(!cls.IsNull());
225 set_stream_iterator_class(cls); 238 set_stream_iterator_class(cls);
226 239
227 const Library& internal_lib = Library::Handle(internal_library()); 240 const Library& internal_lib = Library::Handle(internal_library());
228 cls = internal_lib.LookupClass(Symbols::Symbol()); 241 cls = internal_lib.LookupClass(Symbols::Symbol());
229 set_symbol_class(cls); 242 set_symbol_class(cls);
243
244 // Cache the core private functions used for fast instance of checks.
245 simple_instance_of_function_ =
246 PrivateObjectLookup(Symbols::_simpleInstanceOf());
247 simple_instance_of_true_function_ =
248 PrivateObjectLookup(Symbols::_simpleInstanceOfTrue());
249 simple_instance_of_false_function_ =
250 PrivateObjectLookup(Symbols::_simpleInstanceOfFalse());
230 #endif 251 #endif
231 } 252 }
232 253
233 } // namespace dart 254 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_store.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698