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 AddResolvedName(name, obj); | |
siva
2014/02/06 21:01:29
AddToResolvedNamesCache would be a more readable m
hausner
2014/02/06 21:31:45
Done.
| |
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 AddResolvedName(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::AddResolvedName(const String& name, const Object& obj) const { | |
7972 if (!FLAG_use_lib_cache) { | |
7973 return; | |
7974 } | |
7975 const Array& cache = Array::Handle(resolved_names()); | |
7976 // let N = cache.Length(); | |
7977 // The entry cache[N-1] is used a counter | |
siva
2014/02/06 21:01:29
used as a counter
hausner
2014/02/06 21:31:45
Done
| |
7978 // The array entries [0..N-2] are used as cache entries. | |
7979 // cache[i] contains the name of the entry | |
7980 // cache[i+(N-1)/2] contains the resolved entity, or NULL if that name | |
7981 // is not present in the library. | |
7982 const intptr_t counter_index = cache.Length() - 1; | |
7983 intptr_t cache_size = ResolvedNameCacheSize(cache); | |
7984 intptr_t index = name.Hash() % cache_size; | |
7985 String& entry_name = String::Handle(); | |
7986 entry_name ^= cache.At(index); | |
7987 // An empty spot will be found because we keep the hash set at most 75% full. | |
7988 while (!entry_name.IsNull()) { | |
7989 index = (index + 1) % cache_size; | |
7990 entry_name ^= cache.At(index); | |
7991 } | |
7992 // Insert the object at the empty slot. | |
7993 cache.SetAt(index, name); | |
7994 ASSERT(cache.At(index + cache_size) == Object::null()); | |
7995 cache.SetAt(index + cache_size, obj); | |
7996 | |
7997 // One more element added. | |
7998 intptr_t num_used = Smi::Value(Smi::RawCast(cache.At(counter_index))) + 1; | |
7999 cache.SetAt(counter_index, Smi::Handle(Smi::New(num_used))); | |
8000 CompilerStats::num_names_cached++; | |
8001 | |
8002 // Rehash if symbol_table is 75% full. | |
8003 if (num_used > ((cache_size / 4) * 3)) { | |
8004 CompilerStats::num_names_cached -= num_used; | |
8005 GrowResolvedNamesCache(); | |
8006 } | |
8007 } | |
8008 | |
8009 | |
8010 void Library::InvalidateResolvedName(const String& name) const { | |
8011 Object& entry = Object::Handle(); | |
8012 if (LookupResolvedNamesCache(name, &entry)) { | |
8013 InvalidateResolvedNamesCache(); | |
8014 } | |
8015 } | |
8016 | |
8017 | |
8018 void Library::InvalidateResolvedNamesCache() const { | |
8019 const intptr_t kInvalidatedCacheSize = 16; | |
8020 InitResolvedNamesCache(kInvalidatedCacheSize); | |
8021 } | |
8022 | |
8023 | |
7889 void Library::GrowDictionary(const Array& dict, intptr_t dict_size) const { | 8024 void Library::GrowDictionary(const Array& dict, intptr_t dict_size) const { |
7890 // TODO(iposva): Avoid exponential growth. | 8025 // TODO(iposva): Avoid exponential growth. |
7891 intptr_t new_dict_size = dict_size * 2; | 8026 intptr_t new_dict_size = dict_size * 2; |
7892 const Array& new_dict = | 8027 const Array& new_dict = |
7893 Array::Handle(Array::New(new_dict_size + 1, Heap::kOld)); | 8028 Array::Handle(Array::New(new_dict_size + 1, Heap::kOld)); |
7894 // Rehash all elements from the original dictionary | 8029 // Rehash all elements from the original dictionary |
7895 // to the newly allocated array. | 8030 // to the newly allocated array. |
7896 Object& entry = Class::Handle(); | 8031 Object& entry = Class::Handle(); |
7897 String& entry_name = String::Handle(); | 8032 String& entry_name = String::Handle(); |
7898 Object& new_entry = Object::Handle(); | 8033 Object& new_entry = Object::Handle(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8011 | 8146 |
8012 intptr_t index; | 8147 intptr_t index; |
8013 LookupEntry(name, &index); | 8148 LookupEntry(name, &index); |
8014 // The value is guaranteed to be found. | 8149 // The value is guaranteed to be found. |
8015 const Array& dict = Array::Handle(dictionary()); | 8150 const Array& dict = Array::Handle(dictionary()); |
8016 dict.SetAt(index, obj); | 8151 dict.SetAt(index, obj); |
8017 } | 8152 } |
8018 | 8153 |
8019 | 8154 |
8020 void Library::AddClass(const Class& cls) const { | 8155 void Library::AddClass(const Class& cls) const { |
8021 AddObject(cls, String::Handle(cls.Name())); | 8156 const String& class_name = String::Handle(cls.Name()); |
8157 AddObject(cls, class_name); | |
8022 // Link class to this library. | 8158 // Link class to this library. |
8023 cls.set_library(*this); | 8159 cls.set_library(*this); |
8160 InvalidateResolvedName(class_name); | |
siva
2014/02/06 21:01:29
Should we also invalidate this cache when a class
hausner
2014/02/06 21:31:45
I don't think this is necessary. The name of the c
| |
8024 } | 8161 } |
8025 | 8162 |
8026 static void AddScriptIfUnique(const GrowableObjectArray& scripts, | 8163 static void AddScriptIfUnique(const GrowableObjectArray& scripts, |
8027 Script& candidate) { | 8164 Script& candidate) { |
8028 if (candidate.IsNull()) { | 8165 if (candidate.IsNull()) { |
8029 return; | 8166 return; |
8030 } | 8167 } |
8031 Script& script_obj = Script::Handle(); | 8168 Script& script_obj = Script::Handle(); |
8032 | 8169 |
8033 for (int i = 0; i < scripts.Length(); i++) { | 8170 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. | 8332 // Do not look up private names in imported libraries. |
8196 if (ShouldBePrivate(name)) { | 8333 if (ShouldBePrivate(name)) { |
8197 return Object::null(); | 8334 return Object::null(); |
8198 } | 8335 } |
8199 | 8336 |
8200 // Now check if name is found in any imported libs. | 8337 // Now check if name is found in any imported libs. |
8201 return LookupImportedObject(name); | 8338 return LookupImportedObject(name); |
8202 } | 8339 } |
8203 | 8340 |
8204 | 8341 |
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 { | 8342 RawObject* Library::LookupImportedObject(const String& name) const { |
8217 Object& obj = Object::Handle(); | 8343 Object& obj = Object::Handle(); |
8218 Namespace& import = Namespace::Handle(); | 8344 Namespace& import = Namespace::Handle(); |
8219 Library& import_lib = Library::Handle(); | 8345 Library& import_lib = Library::Handle(); |
8220 String& import_lib_url = String::Handle(); | 8346 String& import_lib_url = String::Handle(); |
8221 String& first_import_lib_url = String::Handle(); | 8347 String& first_import_lib_url = String::Handle(); |
8222 Object& found_obj = Object::Handle(); | 8348 Object& found_obj = Object::Handle(); |
8223 for (intptr_t i = 0; i < num_imports(); i++) { | 8349 for (intptr_t i = 0; i < num_imports(); i++) { |
8224 import ^= ImportAt(i); | 8350 import ^= ImportAt(i); |
8225 obj = import.Lookup(name); | 8351 obj = import.Lookup(name); |
(...skipping 18 matching lines...) Expand all Loading... | |
8244 return Object::null(); | 8370 return Object::null(); |
8245 } | 8371 } |
8246 } | 8372 } |
8247 } | 8373 } |
8248 } | 8374 } |
8249 return found_obj.raw(); | 8375 return found_obj.raw(); |
8250 } | 8376 } |
8251 | 8377 |
8252 | 8378 |
8253 RawClass* Library::LookupClass(const String& name) const { | 8379 RawClass* Library::LookupClass(const String& name) const { |
8254 Object& obj = Object::Handle(LookupObject(name)); | 8380 Object& obj = Object::Handle(ResolveName(name)); |
8255 if (obj.IsClass()) { | 8381 if (obj.IsClass()) { |
8256 return Class::Cast(obj).raw(); | 8382 return Class::Cast(obj).raw(); |
8257 } | 8383 } |
8258 return Class::null(); | 8384 return Class::null(); |
8259 } | 8385 } |
8260 | 8386 |
8261 | 8387 |
8262 RawClass* Library::LookupLocalClass(const String& name) const { | 8388 RawClass* Library::LookupLocalClass(const String& name) const { |
8263 Object& obj = Object::Handle(LookupLocalObject(name)); | 8389 Object& obj = Object::Handle(LookupLocalObject(name)); |
8264 if (obj.IsClass()) { | 8390 if (obj.IsClass()) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8383 // re-exports are quite rare. | 8509 // re-exports are quite rare. |
8384 void Library::AddExport(const Namespace& ns) const { | 8510 void Library::AddExport(const Namespace& ns) const { |
8385 Array &exports = Array::Handle(this->exports()); | 8511 Array &exports = Array::Handle(this->exports()); |
8386 intptr_t num_exports = exports.Length(); | 8512 intptr_t num_exports = exports.Length(); |
8387 exports = Array::Grow(exports, num_exports + 1); | 8513 exports = Array::Grow(exports, num_exports + 1); |
8388 StorePointer(&raw_ptr()->exports_, exports.raw()); | 8514 StorePointer(&raw_ptr()->exports_, exports.raw()); |
8389 exports.SetAt(num_exports, ns); | 8515 exports.SetAt(num_exports, ns); |
8390 } | 8516 } |
8391 | 8517 |
8392 | 8518 |
8519 static RawArray* NewDictionary(intptr_t initial_size) { | |
8520 const Array& dict = Array::Handle(Array::New(initial_size + 1, Heap::kOld)); | |
8521 // The last element of the dictionary specifies the number of in use slots. | |
8522 dict.SetAt(initial_size, Smi::Handle(Smi::New(0))); | |
8523 return dict.raw(); | |
8524 } | |
8525 | |
8526 | |
8527 void Library::InitResolvedNamesCache(intptr_t size) const { | |
8528 // Need space for 'size' names and 'size' resolved object entries. | |
8529 StorePointer(&raw_ptr()->resolved_names_, NewDictionary(2 * size)); | |
8530 } | |
8531 | |
8532 | |
8393 void Library::InitClassDictionary() const { | 8533 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. | 8534 // TODO(iposva): Find reasonable initial size. |
8396 const int kInitialElementCount = 16; | 8535 const int kInitialElementCount = 16; |
8397 | 8536 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 } | 8537 } |
8403 | 8538 |
8404 | 8539 |
8405 void Library::InitImportList() const { | 8540 void Library::InitImportList() const { |
8406 const Array& imports = | 8541 const Array& imports = |
8407 Array::Handle(Array::New(kInitialImportsCapacity, Heap::kOld)); | 8542 Array::Handle(Array::New(kInitialImportsCapacity, Heap::kOld)); |
8408 StorePointer(&raw_ptr()->imports_, imports.raw()); | 8543 StorePointer(&raw_ptr()->imports_, imports.raw()); |
8409 raw_ptr()->num_imports_ = 0; | 8544 raw_ptr()->num_imports_ = 0; |
8410 } | 8545 } |
8411 | 8546 |
8412 | 8547 |
8413 RawLibrary* Library::New() { | 8548 RawLibrary* Library::New() { |
8414 ASSERT(Object::library_class() != Class::null()); | 8549 ASSERT(Object::library_class() != Class::null()); |
8415 RawObject* raw = Object::Allocate(Library::kClassId, | 8550 RawObject* raw = Object::Allocate(Library::kClassId, |
8416 Library::InstanceSize(), | 8551 Library::InstanceSize(), |
8417 Heap::kOld); | 8552 Heap::kOld); |
8418 return reinterpret_cast<RawLibrary*>(raw); | 8553 return reinterpret_cast<RawLibrary*>(raw); |
8419 } | 8554 } |
8420 | 8555 |
8421 | 8556 |
8422 RawLibrary* Library::NewLibraryHelper(const String& url, | 8557 RawLibrary* Library::NewLibraryHelper(const String& url, |
8423 bool import_core_lib) { | 8558 bool import_core_lib) { |
8424 const Library& result = Library::Handle(Library::New()); | 8559 const Library& result = Library::Handle(Library::New()); |
8425 result.StorePointer(&result.raw_ptr()->name_, Symbols::Empty().raw()); | 8560 result.StorePointer(&result.raw_ptr()->name_, Symbols::Empty().raw()); |
8426 result.StorePointer(&result.raw_ptr()->url_, url.raw()); | 8561 result.StorePointer(&result.raw_ptr()->url_, url.raw()); |
8427 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); | 8562 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); |
8563 result.raw_ptr()->resolved_names_ = Object::empty_array().raw(); | |
8428 result.raw_ptr()->dictionary_ = Object::empty_array().raw(); | 8564 result.raw_ptr()->dictionary_ = Object::empty_array().raw(); |
8429 result.StorePointer(&result.raw_ptr()->metadata_, | 8565 result.StorePointer(&result.raw_ptr()->metadata_, |
8430 GrowableObjectArray::New(4, Heap::kOld)); | 8566 GrowableObjectArray::New(4, Heap::kOld)); |
8431 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); | 8567 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); |
8432 result.raw_ptr()->num_anonymous_ = 0; | 8568 result.raw_ptr()->num_anonymous_ = 0; |
8433 result.raw_ptr()->imports_ = Object::empty_array().raw(); | 8569 result.raw_ptr()->imports_ = Object::empty_array().raw(); |
8434 result.raw_ptr()->exports_ = Object::empty_array().raw(); | 8570 result.raw_ptr()->exports_ = Object::empty_array().raw(); |
8435 result.raw_ptr()->loaded_scripts_ = Array::null(); | 8571 result.raw_ptr()->loaded_scripts_ = Array::null(); |
8436 result.set_native_entry_resolver(NULL); | 8572 result.set_native_entry_resolver(NULL); |
8437 result.raw_ptr()->corelib_imported_ = true; | 8573 result.raw_ptr()->corelib_imported_ = true; |
8438 result.set_debuggable(false); | 8574 result.set_debuggable(false); |
8439 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; | 8575 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; |
8440 result.raw_ptr()->index_ = -1; | 8576 result.raw_ptr()->index_ = -1; |
8577 const intptr_t initial_name_cache_size = 64; | |
siva
2014/02/06 21:01:29
const intptr_t kInitialNameCacheSize = 64;
hausner
2014/02/06 21:31:45
Done.
| |
8578 result.InitResolvedNamesCache(initial_name_cache_size); | |
8441 result.InitClassDictionary(); | 8579 result.InitClassDictionary(); |
8442 result.InitImportList(); | 8580 result.InitImportList(); |
8443 if (import_core_lib) { | 8581 if (import_core_lib) { |
8444 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 8582 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
8445 ASSERT(!core_lib.IsNull()); | 8583 ASSERT(!core_lib.IsNull()); |
8446 const Namespace& ns = Namespace::Handle( | 8584 const Namespace& ns = Namespace::Handle( |
8447 Namespace::New(core_lib, Object::null_array(), Object::null_array())); | 8585 Namespace::New(core_lib, Object::null_array(), Object::null_array())); |
8448 result.AddImport(ns); | 8586 result.AddImport(ns); |
8449 } | 8587 } |
8450 return result.raw(); | 8588 return result.raw(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8505 kNameLength, | 8643 kNameLength, |
8506 "%s%d", | 8644 "%s%d", |
8507 kNativeWrappersClass, | 8645 kNativeWrappersClass, |
8508 fld_cnt); | 8646 fld_cnt); |
8509 cls_name = Symbols::New(name_buffer); | 8647 cls_name = Symbols::New(name_buffer); |
8510 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); | 8648 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); |
8511 } | 8649 } |
8512 } | 8650 } |
8513 | 8651 |
8514 | 8652 |
8653 // Returns library with given url in current isolate, or NULL. | |
8515 RawLibrary* Library::LookupLibrary(const String &url) { | 8654 RawLibrary* Library::LookupLibrary(const String &url) { |
8516 Isolate* isolate = Isolate::Current(); | 8655 Isolate* isolate = Isolate::Current(); |
8517 Library& lib = Library::Handle(isolate, Library::null()); | 8656 Library& lib = Library::Handle(isolate, Library::null()); |
8518 String& lib_url = String::Handle(isolate, String::null()); | 8657 String& lib_url = String::Handle(isolate, String::null()); |
8519 GrowableObjectArray& libs = GrowableObjectArray::Handle( | 8658 GrowableObjectArray& libs = GrowableObjectArray::Handle( |
8520 isolate, isolate->object_store()->libraries()); | 8659 isolate, isolate->object_store()->libraries()); |
8521 for (int i = 0; i < libs.Length(); i++) { | 8660 for (int i = 0; i < libs.Length(); i++) { |
8522 lib ^= libs.At(i); | 8661 lib ^= libs.At(i); |
8523 lib_url ^= lib.url(); | 8662 lib_url ^= lib.url(); |
8524 if (lib_url.Equals(url)) { | 8663 if (lib_url.Equals(url)) { |
(...skipping 8802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17327 return "_MirrorReference"; | 17466 return "_MirrorReference"; |
17328 } | 17467 } |
17329 | 17468 |
17330 | 17469 |
17331 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17470 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
17332 Instance::PrintToJSONStream(stream, ref); | 17471 Instance::PrintToJSONStream(stream, ref); |
17333 } | 17472 } |
17334 | 17473 |
17335 | 17474 |
17336 } // namespace dart | 17475 } // namespace dart |
OLD | NEW |