OLD | NEW |
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 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 "When possible, partially or fully overlap the type arguments of a type " | 52 "When possible, partially or fully overlap the type arguments of a type " |
53 "with the type arguments of its super type."); | 53 "with the type arguments of its super type."); |
54 DEFINE_FLAG(bool, show_internal_names, false, | 54 DEFINE_FLAG(bool, show_internal_names, false, |
55 "Show names of internal classes (e.g. \"OneByteString\") in error messages " | 55 "Show names of internal classes (e.g. \"OneByteString\") in error messages " |
56 "instead of showing the corresponding interface names (e.g. \"String\")"); | 56 "instead of showing the corresponding interface names (e.g. \"String\")"); |
57 DEFINE_FLAG(bool, trace_disabling_optimized_code, false, | 57 DEFINE_FLAG(bool, trace_disabling_optimized_code, false, |
58 "Trace disabling optimized code."); | 58 "Trace disabling optimized code."); |
59 DEFINE_FLAG(bool, throw_on_javascript_int_overflow, false, | 59 DEFINE_FLAG(bool, throw_on_javascript_int_overflow, false, |
60 "Throw an exception when the result of an integer calculation will not " | 60 "Throw an exception when the result of an integer calculation will not " |
61 "fit into a javascript integer."); | 61 "fit into a javascript integer."); |
| 62 DEFINE_FLAG(bool, use_lib_cache, true, "Use library name cache"); |
| 63 |
62 DECLARE_FLAG(bool, eliminate_type_checks); | 64 DECLARE_FLAG(bool, eliminate_type_checks); |
63 DECLARE_FLAG(bool, enable_type_checks); | 65 DECLARE_FLAG(bool, enable_type_checks); |
64 DECLARE_FLAG(bool, error_on_bad_override); | 66 DECLARE_FLAG(bool, error_on_bad_override); |
65 DECLARE_FLAG(bool, trace_compiler); | 67 DECLARE_FLAG(bool, trace_compiler); |
66 DECLARE_FLAG(bool, trace_deoptimization); | 68 DECLARE_FLAG(bool, trace_deoptimization); |
67 DECLARE_FLAG(bool, trace_deoptimization_verbose); | 69 DECLARE_FLAG(bool, trace_deoptimization_verbose); |
68 DECLARE_FLAG(bool, verbose_stacktrace); | 70 DECLARE_FLAG(bool, verbose_stacktrace); |
69 DECLARE_FLAG(charp, coverage_dir); | 71 DECLARE_FLAG(charp, coverage_dir); |
70 | 72 |
71 static const char* kGetterPrefix = "get:"; | 73 static const char* kGetterPrefix = "get:"; |
(...skipping 6210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6282 return "RedirectionData class"; | 6284 return "RedirectionData class"; |
6283 } | 6285 } |
6284 | 6286 |
6285 | 6287 |
6286 void RedirectionData::PrintToJSONStream(JSONStream* stream, bool ref) const { | 6288 void RedirectionData::PrintToJSONStream(JSONStream* stream, bool ref) const { |
6287 JSONObject jsobj(stream); | 6289 JSONObject jsobj(stream); |
6288 } | 6290 } |
6289 | 6291 |
6290 | 6292 |
6291 RawString* Field::GetterName(const String& field_name) { | 6293 RawString* Field::GetterName(const String& field_name) { |
| 6294 CompilerStats::make_accessor_name++; |
6292 return String::Concat(Symbols::GetterPrefix(), field_name); | 6295 return String::Concat(Symbols::GetterPrefix(), field_name); |
6293 } | 6296 } |
6294 | 6297 |
6295 | 6298 |
6296 RawString* Field::GetterSymbol(const String& field_name) { | 6299 RawString* Field::GetterSymbol(const String& field_name) { |
6297 const String& str = String::Handle(Field::GetterName(field_name)); | 6300 const String& str = String::Handle(Field::GetterName(field_name)); |
6298 return Symbols::New(str); | 6301 return Symbols::New(str); |
6299 } | 6302 } |
6300 | 6303 |
6301 | 6304 |
6302 RawString* Field::SetterName(const String& field_name) { | 6305 RawString* Field::SetterName(const String& field_name) { |
| 6306 CompilerStats::make_accessor_name++; |
6303 return String::Concat(Symbols::SetterPrefix(), field_name); | 6307 return String::Concat(Symbols::SetterPrefix(), field_name); |
6304 } | 6308 } |
6305 | 6309 |
6306 | 6310 |
6307 RawString* Field::SetterSymbol(const String& field_name) { | 6311 RawString* Field::SetterSymbol(const String& field_name) { |
6308 const String& str = String::Handle(Field::SetterName(field_name)); | 6312 const String& str = String::Handle(Field::SetterName(field_name)); |
6309 return Symbols::New(str); | 6313 return Symbols::New(str); |
6310 } | 6314 } |
6311 | 6315 |
6312 | 6316 |
6313 RawString* Field::NameFromGetter(const String& getter_name) { | 6317 RawString* Field::NameFromGetter(const String& getter_name) { |
| 6318 CompilerStats::make_field_name++; |
6314 return String::SubString(getter_name, strlen(kGetterPrefix)); | 6319 return String::SubString(getter_name, strlen(kGetterPrefix)); |
6315 } | 6320 } |
6316 | 6321 |
6317 | 6322 |
6318 RawString* Field::NameFromSetter(const String& setter_name) { | 6323 RawString* Field::NameFromSetter(const String& setter_name) { |
| 6324 CompilerStats::make_field_name++; |
6319 return String::SubString(setter_name, strlen(kSetterPrefix)); | 6325 return String::SubString(setter_name, strlen(kSetterPrefix)); |
6320 } | 6326 } |
6321 | 6327 |
6322 | 6328 |
6323 bool Field::IsGetterName(const String& function_name) { | 6329 bool Field::IsGetterName(const String& function_name) { |
6324 return function_name.StartsWith(Symbols::GetterPrefix()); | 6330 return function_name.StartsWith(Symbols::GetterPrefix()); |
6325 } | 6331 } |
6326 | 6332 |
6327 | 6333 |
6328 bool Field::IsSetterName(const String& function_name) { | 6334 bool Field::IsSetterName(const String& function_name) { |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7879 field.token_pos()); | 7885 field.token_pos()); |
7880 if (metadata.IsArray()) { | 7886 if (metadata.IsArray()) { |
7881 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); | 7887 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); |
7882 field.set_value(Array::Cast(metadata)); | 7888 field.set_value(Array::Cast(metadata)); |
7883 } | 7889 } |
7884 } | 7890 } |
7885 return metadata.raw(); | 7891 return metadata.raw(); |
7886 } | 7892 } |
7887 | 7893 |
7888 | 7894 |
| 7895 RawObject* Library::ResolveName(const String& name) const { |
| 7896 Object& obj = Object::Handle(); |
| 7897 if (FLAG_use_lib_cache && LookupResolvedNamesCache(name, &obj)) { |
| 7898 return obj.raw(); |
| 7899 } |
| 7900 obj = LookupLocalObject(name); |
| 7901 if (!obj.IsNull()) { |
| 7902 // Names that are in this library's dictionary and are unmangled |
| 7903 // are not cached. This reduces the size of the the cache. |
| 7904 return obj.raw(); |
| 7905 } |
| 7906 String& accessor_name = String::Handle(Field::GetterName(name)); |
| 7907 obj = LookupLocalObject(accessor_name); |
| 7908 if (obj.IsNull()) { |
| 7909 accessor_name = Field::SetterName(name); |
| 7910 obj = LookupLocalObject(accessor_name); |
| 7911 if (obj.IsNull()) { |
| 7912 obj = LookupImportedObject(name); |
| 7913 } |
| 7914 } |
| 7915 AddToResolvedNamesCache(name, obj); |
| 7916 return obj.raw(); |
| 7917 } |
| 7918 |
| 7919 |
| 7920 static intptr_t ResolvedNameCacheSize(const Array& cache) { |
| 7921 return (cache.Length() - 1) / 2; |
| 7922 } |
| 7923 |
| 7924 |
| 7925 // Returns true if the name is found in the cache, false no cache hit. |
| 7926 // obj is set to the cached entry. It may be null, indicating that the |
| 7927 // name does not resolve to anything in this library. |
| 7928 bool Library::LookupResolvedNamesCache(const String& name, |
| 7929 Object* obj) const { |
| 7930 const Array& cache = Array::Handle(resolved_names()); |
| 7931 const intptr_t cache_size = ResolvedNameCacheSize(cache); |
| 7932 intptr_t index = name.Hash() % cache_size; |
| 7933 String& entry_name = String::Handle(); |
| 7934 entry_name ^= cache.At(index); |
| 7935 while (!entry_name.IsNull()) { |
| 7936 if (entry_name.Equals(name)) { |
| 7937 CompilerStats::num_lib_cache_hit++; |
| 7938 *obj = cache.At(index + cache_size); |
| 7939 return true; |
| 7940 } |
| 7941 index = (index + 1) % cache_size; |
| 7942 entry_name ^= cache.At(index); |
| 7943 } |
| 7944 *obj = Object::null(); |
| 7945 return false; |
| 7946 } |
| 7947 |
| 7948 |
| 7949 void Library::GrowResolvedNamesCache() const { |
| 7950 const Array& old_cache = Array::Handle(resolved_names()); |
| 7951 const intptr_t old_cache_size = ResolvedNameCacheSize(old_cache); |
| 7952 |
| 7953 // Create empty new cache and add entries from the old cache. |
| 7954 const intptr_t new_cache_size = old_cache_size * 3 / 2; |
| 7955 InitResolvedNamesCache(new_cache_size); |
| 7956 String& name = String::Handle(); |
| 7957 Object& entry = Object::Handle(); |
| 7958 for (intptr_t i = 0; i < old_cache_size; i++) { |
| 7959 name ^= old_cache.At(i); |
| 7960 if (!name.IsNull()) { |
| 7961 entry = old_cache.At(i + old_cache_size); |
| 7962 AddToResolvedNamesCache(name, entry); |
| 7963 } |
| 7964 } |
| 7965 } |
| 7966 |
| 7967 |
| 7968 // Add a name to the resolved name cache. This name resolves to the |
| 7969 // given object in this library scope. obj may be null, which means |
| 7970 // the name does not resolve to anything in this library scope. |
| 7971 void Library::AddToResolvedNamesCache(const String& name, |
| 7972 const Object& obj) const { |
| 7973 if (!FLAG_use_lib_cache) { |
| 7974 return; |
| 7975 } |
| 7976 const Array& cache = Array::Handle(resolved_names()); |
| 7977 // let N = cache.Length(); |
| 7978 // The entry cache[N-1] is used as a counter |
| 7979 // The array entries [0..N-2] are used as cache entries. |
| 7980 // cache[i] contains the name of the entry |
| 7981 // cache[i+(N-1)/2] contains the resolved entity, or NULL if that name |
| 7982 // is not present in the library. |
| 7983 const intptr_t counter_index = cache.Length() - 1; |
| 7984 intptr_t cache_size = ResolvedNameCacheSize(cache); |
| 7985 intptr_t index = name.Hash() % cache_size; |
| 7986 String& entry_name = String::Handle(); |
| 7987 entry_name ^= cache.At(index); |
| 7988 // An empty spot will be found because we keep the hash set at most 75% full. |
| 7989 while (!entry_name.IsNull()) { |
| 7990 index = (index + 1) % cache_size; |
| 7991 entry_name ^= cache.At(index); |
| 7992 } |
| 7993 // Insert the object at the empty slot. |
| 7994 cache.SetAt(index, name); |
| 7995 ASSERT(cache.At(index + cache_size) == Object::null()); |
| 7996 cache.SetAt(index + cache_size, obj); |
| 7997 |
| 7998 // One more element added. |
| 7999 intptr_t num_used = Smi::Value(Smi::RawCast(cache.At(counter_index))) + 1; |
| 8000 cache.SetAt(counter_index, Smi::Handle(Smi::New(num_used))); |
| 8001 CompilerStats::num_names_cached++; |
| 8002 |
| 8003 // Rehash if symbol_table is 75% full. |
| 8004 if (num_used > ((cache_size / 4) * 3)) { |
| 8005 CompilerStats::num_names_cached -= num_used; |
| 8006 GrowResolvedNamesCache(); |
| 8007 } |
| 8008 } |
| 8009 |
| 8010 |
| 8011 void Library::InvalidateResolvedName(const String& name) const { |
| 8012 Object& entry = Object::Handle(); |
| 8013 if (LookupResolvedNamesCache(name, &entry)) { |
| 8014 InvalidateResolvedNamesCache(); |
| 8015 } |
| 8016 } |
| 8017 |
| 8018 |
| 8019 void Library::InvalidateResolvedNamesCache() const { |
| 8020 const intptr_t kInvalidatedCacheSize = 16; |
| 8021 InitResolvedNamesCache(kInvalidatedCacheSize); |
| 8022 } |
| 8023 |
| 8024 |
7889 void Library::GrowDictionary(const Array& dict, intptr_t dict_size) const { | 8025 void Library::GrowDictionary(const Array& dict, intptr_t dict_size) const { |
7890 // TODO(iposva): Avoid exponential growth. | 8026 // TODO(iposva): Avoid exponential growth. |
7891 intptr_t new_dict_size = dict_size * 2; | 8027 intptr_t new_dict_size = dict_size * 2; |
7892 const Array& new_dict = | 8028 const Array& new_dict = |
7893 Array::Handle(Array::New(new_dict_size + 1, Heap::kOld)); | 8029 Array::Handle(Array::New(new_dict_size + 1, Heap::kOld)); |
7894 // Rehash all elements from the original dictionary | 8030 // Rehash all elements from the original dictionary |
7895 // to the newly allocated array. | 8031 // to the newly allocated array. |
7896 Object& entry = Class::Handle(); | 8032 Object& entry = Class::Handle(); |
7897 String& entry_name = String::Handle(); | 8033 String& entry_name = String::Handle(); |
7898 Object& new_entry = Object::Handle(); | 8034 Object& new_entry = Object::Handle(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8011 | 8147 |
8012 intptr_t index; | 8148 intptr_t index; |
8013 LookupEntry(name, &index); | 8149 LookupEntry(name, &index); |
8014 // The value is guaranteed to be found. | 8150 // The value is guaranteed to be found. |
8015 const Array& dict = Array::Handle(dictionary()); | 8151 const Array& dict = Array::Handle(dictionary()); |
8016 dict.SetAt(index, obj); | 8152 dict.SetAt(index, obj); |
8017 } | 8153 } |
8018 | 8154 |
8019 | 8155 |
8020 void Library::AddClass(const Class& cls) const { | 8156 void Library::AddClass(const Class& cls) const { |
8021 AddObject(cls, String::Handle(cls.Name())); | 8157 const String& class_name = String::Handle(cls.Name()); |
| 8158 AddObject(cls, class_name); |
8022 // Link class to this library. | 8159 // Link class to this library. |
8023 cls.set_library(*this); | 8160 cls.set_library(*this); |
| 8161 InvalidateResolvedName(class_name); |
8024 } | 8162 } |
8025 | 8163 |
8026 static void AddScriptIfUnique(const GrowableObjectArray& scripts, | 8164 static void AddScriptIfUnique(const GrowableObjectArray& scripts, |
8027 Script& candidate) { | 8165 Script& candidate) { |
8028 if (candidate.IsNull()) { | 8166 if (candidate.IsNull()) { |
8029 return; | 8167 return; |
8030 } | 8168 } |
8031 Script& script_obj = Script::Handle(); | 8169 Script& script_obj = Script::Handle(); |
8032 | 8170 |
8033 for (int i = 0; i < scripts.Length(); i++) { | 8171 for (int i = 0; i < scripts.Length(); i++) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8195 // Do not look up private names in imported libraries. | 8333 // Do not look up private names in imported libraries. |
8196 if (ShouldBePrivate(name)) { | 8334 if (ShouldBePrivate(name)) { |
8197 return Object::null(); | 8335 return Object::null(); |
8198 } | 8336 } |
8199 | 8337 |
8200 // Now check if name is found in any imported libs. | 8338 // Now check if name is found in any imported libs. |
8201 return LookupImportedObject(name); | 8339 return LookupImportedObject(name); |
8202 } | 8340 } |
8203 | 8341 |
8204 | 8342 |
8205 RawObject* Library::LookupObject(const String& name) const { | |
8206 // First check if name is found in the local scope of the library. | |
8207 Object& obj = Object::Handle(LookupLocalObject(name)); | |
8208 if (!obj.IsNull()) { | |
8209 return obj.raw(); | |
8210 } | |
8211 // Now check if name is found in any imported libs. | |
8212 return LookupImportedObject(name); | |
8213 } | |
8214 | |
8215 | |
8216 RawObject* Library::LookupImportedObject(const String& name) const { | 8343 RawObject* Library::LookupImportedObject(const String& name) const { |
8217 Object& obj = Object::Handle(); | 8344 Object& obj = Object::Handle(); |
8218 Namespace& import = Namespace::Handle(); | 8345 Namespace& import = Namespace::Handle(); |
8219 Library& import_lib = Library::Handle(); | 8346 Library& import_lib = Library::Handle(); |
8220 String& import_lib_url = String::Handle(); | 8347 String& import_lib_url = String::Handle(); |
8221 String& first_import_lib_url = String::Handle(); | 8348 String& first_import_lib_url = String::Handle(); |
8222 Object& found_obj = Object::Handle(); | 8349 Object& found_obj = Object::Handle(); |
8223 for (intptr_t i = 0; i < num_imports(); i++) { | 8350 for (intptr_t i = 0; i < num_imports(); i++) { |
8224 import ^= ImportAt(i); | 8351 import ^= ImportAt(i); |
8225 obj = import.Lookup(name); | 8352 obj = import.Lookup(name); |
(...skipping 18 matching lines...) Expand all Loading... |
8244 return Object::null(); | 8371 return Object::null(); |
8245 } | 8372 } |
8246 } | 8373 } |
8247 } | 8374 } |
8248 } | 8375 } |
8249 return found_obj.raw(); | 8376 return found_obj.raw(); |
8250 } | 8377 } |
8251 | 8378 |
8252 | 8379 |
8253 RawClass* Library::LookupClass(const String& name) const { | 8380 RawClass* Library::LookupClass(const String& name) const { |
8254 Object& obj = Object::Handle(LookupObject(name)); | 8381 Object& obj = Object::Handle(ResolveName(name)); |
8255 if (obj.IsClass()) { | 8382 if (obj.IsClass()) { |
8256 return Class::Cast(obj).raw(); | 8383 return Class::Cast(obj).raw(); |
8257 } | 8384 } |
8258 return Class::null(); | 8385 return Class::null(); |
8259 } | 8386 } |
8260 | 8387 |
8261 | 8388 |
8262 RawClass* Library::LookupLocalClass(const String& name) const { | 8389 RawClass* Library::LookupLocalClass(const String& name) const { |
8263 Object& obj = Object::Handle(LookupLocalObject(name)); | 8390 Object& obj = Object::Handle(LookupLocalObject(name)); |
8264 if (obj.IsClass()) { | 8391 if (obj.IsClass()) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8383 // re-exports are quite rare. | 8510 // re-exports are quite rare. |
8384 void Library::AddExport(const Namespace& ns) const { | 8511 void Library::AddExport(const Namespace& ns) const { |
8385 Array &exports = Array::Handle(this->exports()); | 8512 Array &exports = Array::Handle(this->exports()); |
8386 intptr_t num_exports = exports.Length(); | 8513 intptr_t num_exports = exports.Length(); |
8387 exports = Array::Grow(exports, num_exports + 1); | 8514 exports = Array::Grow(exports, num_exports + 1); |
8388 StorePointer(&raw_ptr()->exports_, exports.raw()); | 8515 StorePointer(&raw_ptr()->exports_, exports.raw()); |
8389 exports.SetAt(num_exports, ns); | 8516 exports.SetAt(num_exports, ns); |
8390 } | 8517 } |
8391 | 8518 |
8392 | 8519 |
| 8520 static RawArray* NewDictionary(intptr_t initial_size) { |
| 8521 const Array& dict = Array::Handle(Array::New(initial_size + 1, Heap::kOld)); |
| 8522 // The last element of the dictionary specifies the number of in use slots. |
| 8523 dict.SetAt(initial_size, Smi::Handle(Smi::New(0))); |
| 8524 return dict.raw(); |
| 8525 } |
| 8526 |
| 8527 |
| 8528 void Library::InitResolvedNamesCache(intptr_t size) const { |
| 8529 // Need space for 'size' names and 'size' resolved object entries. |
| 8530 StorePointer(&raw_ptr()->resolved_names_, NewDictionary(2 * size)); |
| 8531 } |
| 8532 |
| 8533 |
8393 void Library::InitClassDictionary() const { | 8534 void Library::InitClassDictionary() const { |
8394 // The last element of the dictionary specifies the number of in use slots. | |
8395 // TODO(iposva): Find reasonable initial size. | 8535 // TODO(iposva): Find reasonable initial size. |
8396 const int kInitialElementCount = 16; | 8536 const int kInitialElementCount = 16; |
8397 | 8537 StorePointer(&raw_ptr()->dictionary_, NewDictionary(kInitialElementCount)); |
8398 const Array& dictionary = | |
8399 Array::Handle(Array::New(kInitialElementCount + 1, Heap::kOld)); | |
8400 dictionary.SetAt(kInitialElementCount, Smi::Handle(Smi::New(0))); | |
8401 StorePointer(&raw_ptr()->dictionary_, dictionary.raw()); | |
8402 } | 8538 } |
8403 | 8539 |
8404 | 8540 |
8405 void Library::InitImportList() const { | 8541 void Library::InitImportList() const { |
8406 const Array& imports = | 8542 const Array& imports = |
8407 Array::Handle(Array::New(kInitialImportsCapacity, Heap::kOld)); | 8543 Array::Handle(Array::New(kInitialImportsCapacity, Heap::kOld)); |
8408 StorePointer(&raw_ptr()->imports_, imports.raw()); | 8544 StorePointer(&raw_ptr()->imports_, imports.raw()); |
8409 raw_ptr()->num_imports_ = 0; | 8545 raw_ptr()->num_imports_ = 0; |
8410 } | 8546 } |
8411 | 8547 |
8412 | 8548 |
8413 RawLibrary* Library::New() { | 8549 RawLibrary* Library::New() { |
8414 ASSERT(Object::library_class() != Class::null()); | 8550 ASSERT(Object::library_class() != Class::null()); |
8415 RawObject* raw = Object::Allocate(Library::kClassId, | 8551 RawObject* raw = Object::Allocate(Library::kClassId, |
8416 Library::InstanceSize(), | 8552 Library::InstanceSize(), |
8417 Heap::kOld); | 8553 Heap::kOld); |
8418 return reinterpret_cast<RawLibrary*>(raw); | 8554 return reinterpret_cast<RawLibrary*>(raw); |
8419 } | 8555 } |
8420 | 8556 |
8421 | 8557 |
8422 RawLibrary* Library::NewLibraryHelper(const String& url, | 8558 RawLibrary* Library::NewLibraryHelper(const String& url, |
8423 bool import_core_lib) { | 8559 bool import_core_lib) { |
8424 const Library& result = Library::Handle(Library::New()); | 8560 const Library& result = Library::Handle(Library::New()); |
8425 result.StorePointer(&result.raw_ptr()->name_, Symbols::Empty().raw()); | 8561 result.StorePointer(&result.raw_ptr()->name_, Symbols::Empty().raw()); |
8426 result.StorePointer(&result.raw_ptr()->url_, url.raw()); | 8562 result.StorePointer(&result.raw_ptr()->url_, url.raw()); |
8427 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); | 8563 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); |
| 8564 result.raw_ptr()->resolved_names_ = Object::empty_array().raw(); |
8428 result.raw_ptr()->dictionary_ = Object::empty_array().raw(); | 8565 result.raw_ptr()->dictionary_ = Object::empty_array().raw(); |
8429 result.StorePointer(&result.raw_ptr()->metadata_, | 8566 result.StorePointer(&result.raw_ptr()->metadata_, |
8430 GrowableObjectArray::New(4, Heap::kOld)); | 8567 GrowableObjectArray::New(4, Heap::kOld)); |
8431 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); | 8568 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); |
8432 result.raw_ptr()->num_anonymous_ = 0; | 8569 result.raw_ptr()->num_anonymous_ = 0; |
8433 result.raw_ptr()->imports_ = Object::empty_array().raw(); | 8570 result.raw_ptr()->imports_ = Object::empty_array().raw(); |
8434 result.raw_ptr()->exports_ = Object::empty_array().raw(); | 8571 result.raw_ptr()->exports_ = Object::empty_array().raw(); |
8435 result.raw_ptr()->loaded_scripts_ = Array::null(); | 8572 result.raw_ptr()->loaded_scripts_ = Array::null(); |
8436 result.set_native_entry_resolver(NULL); | 8573 result.set_native_entry_resolver(NULL); |
8437 result.raw_ptr()->corelib_imported_ = true; | 8574 result.raw_ptr()->corelib_imported_ = true; |
8438 result.set_debuggable(false); | 8575 result.set_debuggable(false); |
8439 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; | 8576 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; |
8440 result.raw_ptr()->index_ = -1; | 8577 result.raw_ptr()->index_ = -1; |
| 8578 const intptr_t kInitialNameCacheSize = 64; |
| 8579 result.InitResolvedNamesCache(kInitialNameCacheSize); |
8441 result.InitClassDictionary(); | 8580 result.InitClassDictionary(); |
8442 result.InitImportList(); | 8581 result.InitImportList(); |
8443 if (import_core_lib) { | 8582 if (import_core_lib) { |
8444 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 8583 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
8445 ASSERT(!core_lib.IsNull()); | 8584 ASSERT(!core_lib.IsNull()); |
8446 const Namespace& ns = Namespace::Handle( | 8585 const Namespace& ns = Namespace::Handle( |
8447 Namespace::New(core_lib, Object::null_array(), Object::null_array())); | 8586 Namespace::New(core_lib, Object::null_array(), Object::null_array())); |
8448 result.AddImport(ns); | 8587 result.AddImport(ns); |
8449 } | 8588 } |
8450 return result.raw(); | 8589 return result.raw(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8505 kNameLength, | 8644 kNameLength, |
8506 "%s%d", | 8645 "%s%d", |
8507 kNativeWrappersClass, | 8646 kNativeWrappersClass, |
8508 fld_cnt); | 8647 fld_cnt); |
8509 cls_name = Symbols::New(name_buffer); | 8648 cls_name = Symbols::New(name_buffer); |
8510 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); | 8649 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); |
8511 } | 8650 } |
8512 } | 8651 } |
8513 | 8652 |
8514 | 8653 |
| 8654 // Returns library with given url in current isolate, or NULL. |
8515 RawLibrary* Library::LookupLibrary(const String &url) { | 8655 RawLibrary* Library::LookupLibrary(const String &url) { |
8516 Isolate* isolate = Isolate::Current(); | 8656 Isolate* isolate = Isolate::Current(); |
8517 Library& lib = Library::Handle(isolate, Library::null()); | 8657 Library& lib = Library::Handle(isolate, Library::null()); |
8518 String& lib_url = String::Handle(isolate, String::null()); | 8658 String& lib_url = String::Handle(isolate, String::null()); |
8519 GrowableObjectArray& libs = GrowableObjectArray::Handle( | 8659 GrowableObjectArray& libs = GrowableObjectArray::Handle( |
8520 isolate, isolate->object_store()->libraries()); | 8660 isolate, isolate->object_store()->libraries()); |
8521 for (int i = 0; i < libs.Length(); i++) { | 8661 for (int i = 0; i < libs.Length(); i++) { |
8522 lib ^= libs.At(i); | 8662 lib ^= libs.At(i); |
8523 lib_url ^= lib.url(); | 8663 lib_url ^= lib.url(); |
8524 if (lib_url.Equals(url)) { | 8664 if (lib_url.Equals(url)) { |
(...skipping 8802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17327 return "_MirrorReference"; | 17467 return "_MirrorReference"; |
17328 } | 17468 } |
17329 | 17469 |
17330 | 17470 |
17331 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17471 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
17332 Instance::PrintToJSONStream(stream, ref); | 17472 Instance::PrintToJSONStream(stream, ref); |
17333 } | 17473 } |
17334 | 17474 |
17335 | 17475 |
17336 } // namespace dart | 17476 } // namespace dart |
OLD | NEW |