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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 RawClass* Object::patch_class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 118 RawClass* Object::patch_class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
119 RawClass* Object::function_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 119 RawClass* Object::function_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
120 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 120 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
121 RawClass* Object::redirection_data_class_ = | 121 RawClass* Object::redirection_data_class_ = |
122 reinterpret_cast<RawClass*>(RAW_NULL); | 122 reinterpret_cast<RawClass*>(RAW_NULL); |
123 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 123 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
124 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 124 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
125 RawClass* Object::token_stream_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 125 RawClass* Object::token_stream_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
126 RawClass* Object::script_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 126 RawClass* Object::script_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
127 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 127 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
128 RawClass* Object::library_prefix_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | |
129 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 128 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
130 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 129 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
131 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 130 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
132 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 131 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
133 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 132 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
134 RawClass* Object::var_descriptors_class_ = | 133 RawClass* Object::var_descriptors_class_ = |
135 reinterpret_cast<RawClass*>(RAW_NULL); | 134 reinterpret_cast<RawClass*>(RAW_NULL); |
136 RawClass* Object::exception_handlers_class_ = | 135 RawClass* Object::exception_handlers_class_ = |
137 reinterpret_cast<RawClass*>(RAW_NULL); | 136 reinterpret_cast<RawClass*>(RAW_NULL); |
138 RawClass* Object::deopt_info_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 137 RawClass* Object::deopt_info_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 | 561 |
563 cls = Class::New<TokenStream>(); | 562 cls = Class::New<TokenStream>(); |
564 token_stream_class_ = cls.raw(); | 563 token_stream_class_ = cls.raw(); |
565 | 564 |
566 cls = Class::New<Script>(); | 565 cls = Class::New<Script>(); |
567 script_class_ = cls.raw(); | 566 script_class_ = cls.raw(); |
568 | 567 |
569 cls = Class::New<Library>(); | 568 cls = Class::New<Library>(); |
570 library_class_ = cls.raw(); | 569 library_class_ = cls.raw(); |
571 | 570 |
572 cls = Class::New<LibraryPrefix>(); | |
573 library_prefix_class_ = cls.raw(); | |
574 | |
575 cls = Class::New<Namespace>(); | 571 cls = Class::New<Namespace>(); |
576 namespace_class_ = cls.raw(); | 572 namespace_class_ = cls.raw(); |
577 | 573 |
578 cls = Class::New<Code>(); | 574 cls = Class::New<Code>(); |
579 code_class_ = cls.raw(); | 575 code_class_ = cls.raw(); |
580 | 576 |
581 cls = Class::New<Instructions>(); | 577 cls = Class::New<Instructions>(); |
582 instructions_class_ = cls.raw(); | 578 instructions_class_ = cls.raw(); |
583 | 579 |
584 cls = Class::New<PcDescriptors>(); | 580 cls = Class::New<PcDescriptors>(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
763 SET_CLASS_NAME(type_arguments, TypeArguments); | 759 SET_CLASS_NAME(type_arguments, TypeArguments); |
764 SET_CLASS_NAME(patch_class, PatchClass); | 760 SET_CLASS_NAME(patch_class, PatchClass); |
765 SET_CLASS_NAME(function, Function); | 761 SET_CLASS_NAME(function, Function); |
766 SET_CLASS_NAME(closure_data, ClosureData); | 762 SET_CLASS_NAME(closure_data, ClosureData); |
767 SET_CLASS_NAME(redirection_data, RedirectionData); | 763 SET_CLASS_NAME(redirection_data, RedirectionData); |
768 SET_CLASS_NAME(field, Field); | 764 SET_CLASS_NAME(field, Field); |
769 SET_CLASS_NAME(literal_token, LiteralToken); | 765 SET_CLASS_NAME(literal_token, LiteralToken); |
770 SET_CLASS_NAME(token_stream, TokenStream); | 766 SET_CLASS_NAME(token_stream, TokenStream); |
771 SET_CLASS_NAME(script, Script); | 767 SET_CLASS_NAME(script, Script); |
772 SET_CLASS_NAME(library, LibraryClass); | 768 SET_CLASS_NAME(library, LibraryClass); |
773 SET_CLASS_NAME(library_prefix, LibraryPrefix); | |
774 SET_CLASS_NAME(namespace, Namespace); | 769 SET_CLASS_NAME(namespace, Namespace); |
775 SET_CLASS_NAME(code, Code); | 770 SET_CLASS_NAME(code, Code); |
776 SET_CLASS_NAME(instructions, Instructions); | 771 SET_CLASS_NAME(instructions, Instructions); |
777 SET_CLASS_NAME(pc_descriptors, PcDescriptors); | 772 SET_CLASS_NAME(pc_descriptors, PcDescriptors); |
778 SET_CLASS_NAME(stackmap, Stackmap); | 773 SET_CLASS_NAME(stackmap, Stackmap); |
779 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); | 774 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); |
780 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); | 775 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); |
781 SET_CLASS_NAME(deopt_info, DeoptInfo); | 776 SET_CLASS_NAME(deopt_info, DeoptInfo); |
782 SET_CLASS_NAME(context, Context); | 777 SET_CLASS_NAME(context, Context); |
783 SET_CLASS_NAME(context_scope, ContextScope); | 778 SET_CLASS_NAME(context_scope, ContextScope); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 | 933 |
939 cls = Class::New<TypeParameter>(); | 934 cls = Class::New<TypeParameter>(); |
940 object_store->set_type_parameter_class(cls); | 935 object_store->set_type_parameter_class(cls); |
941 | 936 |
942 cls = Class::New<BoundedType>(); | 937 cls = Class::New<BoundedType>(); |
943 object_store->set_bounded_type_class(cls); | 938 object_store->set_bounded_type_class(cls); |
944 | 939 |
945 cls = Class::New<MixinAppType>(); | 940 cls = Class::New<MixinAppType>(); |
946 object_store->set_mixin_app_type_class(cls); | 941 object_store->set_mixin_app_type_class(cls); |
947 | 942 |
943 cls = Class::New<LibraryPrefix>(); | |
944 object_store->set_library_prefix_class(cls); | |
945 | |
948 // Pre-allocate the OneByteString class needed by the symbol table. | 946 // Pre-allocate the OneByteString class needed by the symbol table. |
949 cls = Class::NewStringClass(kOneByteStringCid); | 947 cls = Class::NewStringClass(kOneByteStringCid); |
950 object_store->set_one_byte_string_class(cls); | 948 object_store->set_one_byte_string_class(cls); |
951 | 949 |
952 // Pre-allocate the TwoByteString class needed by the symbol table. | 950 // Pre-allocate the TwoByteString class needed by the symbol table. |
953 cls = Class::NewStringClass(kTwoByteStringCid); | 951 cls = Class::NewStringClass(kTwoByteStringCid); |
954 object_store->set_two_byte_string_class(cls); | 952 object_store->set_two_byte_string_class(cls); |
955 | 953 |
956 // Setup the symbol table for the symbols created in the isolate. | 954 // Setup the symbol table for the symbols created in the isolate. |
957 Symbols::SetupSymbolTable(isolate); | 955 Symbols::SetupSymbolTable(isolate); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1056 pending_classes.Add(cls); | 1054 pending_classes.Add(cls); |
1057 | 1055 |
1058 cls = Class::New<Instance>(kNullCid); | 1056 cls = Class::New<Instance>(kNullCid); |
1059 object_store->set_null_class(cls); | 1057 object_store->set_null_class(cls); |
1060 cls.set_num_type_arguments(0); | 1058 cls.set_num_type_arguments(0); |
1061 cls.set_num_own_type_arguments(0); | 1059 cls.set_num_own_type_arguments(0); |
1062 cls.set_is_prefinalized(); | 1060 cls.set_is_prefinalized(); |
1063 RegisterClass(cls, Symbols::Null(), core_lib); | 1061 RegisterClass(cls, Symbols::Null(), core_lib); |
1064 pending_classes.Add(cls); | 1062 pending_classes.Add(cls); |
1065 | 1063 |
1064 cls = object_store->library_prefix_class(); | |
1065 ASSERT(!cls.IsNull()); | |
1066 RegisterPrivateClass(cls, Symbols::_LibraryPrefix(), core_lib); | |
1067 pending_classes.Add(cls); | |
1068 | |
1066 cls = object_store->type_class(); | 1069 cls = object_store->type_class(); |
1067 RegisterPrivateClass(cls, Symbols::Type(), core_lib); | 1070 RegisterPrivateClass(cls, Symbols::Type(), core_lib); |
1068 pending_classes.Add(cls); | 1071 pending_classes.Add(cls); |
1069 | 1072 |
1070 cls = object_store->type_ref_class(); | 1073 cls = object_store->type_ref_class(); |
1071 RegisterPrivateClass(cls, Symbols::TypeRef(), core_lib); | 1074 RegisterPrivateClass(cls, Symbols::TypeRef(), core_lib); |
1072 pending_classes.Add(cls); | 1075 pending_classes.Add(cls); |
1073 | 1076 |
1074 cls = object_store->type_parameter_class(); | 1077 cls = object_store->type_parameter_class(); |
1075 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib); | 1078 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1330 ObjectStore* object_store = isolate->object_store(); | 1333 ObjectStore* object_store = isolate->object_store(); |
1331 | 1334 |
1332 Class& cls = Class::Handle(); | 1335 Class& cls = Class::Handle(); |
1333 | 1336 |
1334 // Set up empty classes in the object store, these will get | 1337 // Set up empty classes in the object store, these will get |
1335 // initialized correctly when we read from the snapshot. | 1338 // initialized correctly when we read from the snapshot. |
1336 // This is done to allow bootstrapping of reading classes from the snapshot. | 1339 // This is done to allow bootstrapping of reading classes from the snapshot. |
1337 cls = Class::New<Instance>(kInstanceCid); | 1340 cls = Class::New<Instance>(kInstanceCid); |
1338 object_store->set_object_class(cls); | 1341 object_store->set_object_class(cls); |
1339 | 1342 |
1343 cls = Class::New<LibraryPrefix>(); | |
1344 object_store->set_library_prefix_class(cls); | |
1345 | |
1340 cls = Class::New<Type>(); | 1346 cls = Class::New<Type>(); |
1341 object_store->set_type_class(cls); | 1347 object_store->set_type_class(cls); |
1342 | 1348 |
1343 cls = Class::New<TypeRef>(); | 1349 cls = Class::New<TypeRef>(); |
1344 object_store->set_type_ref_class(cls); | 1350 object_store->set_type_ref_class(cls); |
1345 | 1351 |
1346 cls = Class::New<TypeParameter>(); | 1352 cls = Class::New<TypeParameter>(); |
1347 object_store->set_type_parameter_class(cls); | 1353 object_store->set_type_parameter_class(cls); |
1348 | 1354 |
1349 cls = Class::New<BoundedType>(); | 1355 cls = Class::New<BoundedType>(); |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2436 weak_property ^= code_objects.At(i); | 2442 weak_property ^= code_objects.At(i); |
2437 code ^= weak_property.key(); | 2443 code ^= weak_property.key(); |
2438 if (code.IsNull()) { | 2444 if (code.IsNull()) { |
2439 // Code was garbage collected already. | 2445 // Code was garbage collected already. |
2440 continue; | 2446 continue; |
2441 } | 2447 } |
2442 | 2448 |
2443 function ^= code.function(); | 2449 function ^= code.function(); |
2444 // If function uses dependent code switch it to unoptimized. | 2450 // If function uses dependent code switch it to unoptimized. |
2445 if (function.CurrentCode() == code.raw()) { | 2451 if (function.CurrentCode() == code.raw()) { |
2446 ASSERT(function.HasOptimizedCode()); | |
2447 ReportSwitchingCode(code); | 2452 ReportSwitchingCode(code); |
2448 function.SwitchToUnoptimizedCode(); | 2453 if (code.is_optimized()) { |
Ivan Posva
2014/03/27 07:38:48
What if we have optimized code that needs to be en
hausner
2014/03/27 20:45:39
I think we spoke about this before i implemented i
Ivan Posva
2014/03/27 21:41:18
I worry about the ordering of code removal a bit.
| |
2454 function.SwitchToUnoptimizedCode(); | |
2455 } else { | |
2456 function.ClearCode(); | |
2457 } | |
2449 } | 2458 } |
2450 } | 2459 } |
2451 } | 2460 } |
2452 | 2461 |
2453 private: | 2462 private: |
2454 const Array& array_; | 2463 const Array& array_; |
2455 DISALLOW_COPY_AND_ASSIGN(WeakCodeReferences); | 2464 DISALLOW_COPY_AND_ASSIGN(WeakCodeReferences); |
2456 }; | 2465 }; |
2457 | 2466 |
2458 | 2467 |
(...skipping 6275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8734 result.StorePointer(&result.raw_ptr()->metadata_, | 8743 result.StorePointer(&result.raw_ptr()->metadata_, |
8735 GrowableObjectArray::New(4, Heap::kOld)); | 8744 GrowableObjectArray::New(4, Heap::kOld)); |
8736 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); | 8745 result.raw_ptr()->anonymous_classes_ = Object::empty_array().raw(); |
8737 result.raw_ptr()->num_anonymous_ = 0; | 8746 result.raw_ptr()->num_anonymous_ = 0; |
8738 result.raw_ptr()->imports_ = Object::empty_array().raw(); | 8747 result.raw_ptr()->imports_ = Object::empty_array().raw(); |
8739 result.raw_ptr()->exports_ = Object::empty_array().raw(); | 8748 result.raw_ptr()->exports_ = Object::empty_array().raw(); |
8740 result.raw_ptr()->loaded_scripts_ = Array::null(); | 8749 result.raw_ptr()->loaded_scripts_ = Array::null(); |
8741 result.set_native_entry_resolver(NULL); | 8750 result.set_native_entry_resolver(NULL); |
8742 result.raw_ptr()->corelib_imported_ = true; | 8751 result.raw_ptr()->corelib_imported_ = true; |
8743 result.set_debuggable(false); | 8752 result.set_debuggable(false); |
8753 result.raw_ptr()->deferred_load_ = false; | |
8744 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; | 8754 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; |
8745 result.raw_ptr()->index_ = -1; | 8755 result.raw_ptr()->index_ = -1; |
8746 const intptr_t kInitialNameCacheSize = 64; | 8756 const intptr_t kInitialNameCacheSize = 64; |
8747 result.InitResolvedNamesCache(kInitialNameCacheSize); | 8757 result.InitResolvedNamesCache(kInitialNameCacheSize); |
8748 result.InitClassDictionary(); | 8758 result.InitClassDictionary(); |
8749 result.InitImportList(); | 8759 result.InitImportList(); |
8750 result.AllocatePrivateKey(); | 8760 result.AllocatePrivateKey(); |
8751 if (import_core_lib) { | 8761 if (import_core_lib) { |
8752 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 8762 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
8753 ASSERT(!core_lib.IsNull()); | 8763 ASSERT(!core_lib.IsNull()); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9100 } | 9110 } |
9101 } | 9111 } |
9102 } | 9112 } |
9103 return false; | 9113 return false; |
9104 } | 9114 } |
9105 | 9115 |
9106 | 9116 |
9107 void LibraryPrefix::AddImport(const Namespace& import) const { | 9117 void LibraryPrefix::AddImport(const Namespace& import) const { |
9108 intptr_t num_current_imports = num_imports(); | 9118 intptr_t num_current_imports = num_imports(); |
9109 | 9119 |
9120 // Prefixes with deferred libraries can only contain one library. | |
9121 ASSERT((num_current_imports == 0) || !is_deferred_load()); | |
9122 | |
9110 // The library needs to be added to the list. | 9123 // The library needs to be added to the list. |
9111 Array& imports = Array::Handle(this->imports()); | 9124 Array& imports = Array::Handle(this->imports()); |
9112 const intptr_t length = (imports.IsNull()) ? 0 : imports.Length(); | 9125 const intptr_t length = (imports.IsNull()) ? 0 : imports.Length(); |
9113 // Grow the list if it is full. | 9126 // Grow the list if it is full. |
9114 if (num_current_imports >= length) { | 9127 if (num_current_imports >= length) { |
9115 const intptr_t new_length = length + kIncrementSize; | 9128 const intptr_t new_length = length + kIncrementSize; |
9116 imports = Array::Grow(imports, new_length, Heap::kOld); | 9129 imports = Array::Grow(imports, new_length, Heap::kOld); |
9117 set_imports(imports); | 9130 set_imports(imports); |
9118 } | 9131 } |
9119 imports.SetAt(num_current_imports, import); | 9132 imports.SetAt(num_current_imports, import); |
9120 set_num_imports(num_current_imports + 1); | 9133 set_num_imports(num_current_imports + 1); |
9121 } | 9134 } |
9122 | 9135 |
9123 | 9136 |
9124 RawObject* LibraryPrefix::LookupObject(const String& name) const { | 9137 RawObject* LibraryPrefix::LookupObject(const String& name) const { |
9138 if (!is_loaded()) { | |
9139 return Object::null(); | |
9140 } | |
9125 Array& imports = Array::Handle(this->imports()); | 9141 Array& imports = Array::Handle(this->imports()); |
9126 Object& obj = Object::Handle(); | 9142 Object& obj = Object::Handle(); |
9127 Namespace& import = Namespace::Handle(); | 9143 Namespace& import = Namespace::Handle(); |
9128 Library& import_lib = Library::Handle(); | 9144 Library& import_lib = Library::Handle(); |
9129 String& import_lib_url = String::Handle(); | 9145 String& import_lib_url = String::Handle(); |
9130 String& first_import_lib_url = String::Handle(); | 9146 String& first_import_lib_url = String::Handle(); |
9131 Object& found_obj = Object::Handle(); | 9147 Object& found_obj = Object::Handle(); |
9132 for (intptr_t i = 0; i < num_imports(); i++) { | 9148 for (intptr_t i = 0; i < num_imports(); i++) { |
9133 import ^= imports.At(i); | 9149 import ^= imports.At(i); |
9134 obj = import.Lookup(name); | 9150 obj = import.Lookup(name); |
(...skipping 26 matching lines...) Expand all Loading... | |
9161 | 9177 |
9162 RawClass* LibraryPrefix::LookupClass(const String& class_name) const { | 9178 RawClass* LibraryPrefix::LookupClass(const String& class_name) const { |
9163 const Object& obj = Object::Handle(LookupObject(class_name)); | 9179 const Object& obj = Object::Handle(LookupObject(class_name)); |
9164 if (obj.IsClass()) { | 9180 if (obj.IsClass()) { |
9165 return Class::Cast(obj).raw(); | 9181 return Class::Cast(obj).raw(); |
9166 } | 9182 } |
9167 return Class::null(); | 9183 return Class::null(); |
9168 } | 9184 } |
9169 | 9185 |
9170 | 9186 |
9187 void LibraryPrefix::set_is_loaded() const { | |
9188 raw_ptr()->is_loaded_ = true; | |
9189 } | |
9190 | |
9191 | |
9192 void LibraryPrefix::LoadLibrary() const { | |
9193 if (!is_deferred_load()) { | |
9194 return; | |
9195 } | |
9196 if (is_loaded()) { | |
Ivan Posva
2014/03/27 07:38:48
What is the value of loaded for an eagerly loaded
hausner
2014/03/27 20:45:39
That is true. I'll change this to an assert to ens
| |
9197 return; | |
9198 } | |
9199 NukeDependentCode(); | |
9200 set_is_loaded(); | |
9201 } | |
9202 | |
9203 | |
9204 RawArray* LibraryPrefix::dependent_code() const { | |
9205 return raw_ptr()->dependent_code_; | |
9206 } | |
9207 | |
9208 | |
9209 void LibraryPrefix::set_dependent_code(const Array& array) const { | |
9210 StorePointer(&raw_ptr()->dependent_code_, array.raw()); | |
9211 } | |
9212 | |
9213 | |
9214 class PrefixDependentArray : public WeakCodeReferences { | |
9215 public: | |
9216 explicit PrefixDependentArray(const LibraryPrefix& prefix) | |
9217 : WeakCodeReferences(Array::Handle(prefix.dependent_code())), | |
9218 prefix_(prefix) {} | |
9219 | |
9220 virtual void UpdateArrayTo(const Array& value) { | |
9221 prefix_.set_dependent_code(value); | |
9222 } | |
9223 | |
9224 virtual void ReportDeoptimization(const Code& code) { | |
9225 // This gets called when the code object is on the stack | |
9226 // while nuking code that depends on a prefix. We don't expect | |
9227 // this to happen, so make sure we die loudly if we find | |
9228 // ourselves here. | |
9229 UNIMPLEMENTED(); | |
9230 } | |
9231 | |
9232 virtual void ReportSwitchingCode(const Code& code) { | |
9233 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | |
9234 OS::PrintErr("Prefix '%s': deleting code for function '%s'\n", | |
9235 String::Handle(prefix_.name()).ToCString(), | |
9236 Function::Handle(code.function()).ToCString()); | |
9237 } | |
9238 } | |
9239 | |
9240 private: | |
9241 const LibraryPrefix& prefix_; | |
9242 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); | |
9243 }; | |
9244 | |
9245 | |
9246 void LibraryPrefix::RegisterDependentCode(const Code& code) const { | |
9247 ASSERT(is_deferred_load()); | |
9248 ASSERT(!is_loaded()); | |
9249 PrefixDependentArray a(*this); | |
9250 a.Register(code); | |
9251 } | |
9252 | |
9253 | |
9254 void LibraryPrefix::NukeDependentCode() const { | |
9255 PrefixDependentArray a(*this); | |
9256 a.DisableCode(); | |
9257 } | |
9258 | |
9259 | |
9171 RawLibraryPrefix* LibraryPrefix::New() { | 9260 RawLibraryPrefix* LibraryPrefix::New() { |
9172 ASSERT(Object::library_prefix_class() != Class::null()); | 9261 ASSERT(Isolate::Current()->object_store()->library_prefix_class() != |
9262 Class::null()); | |
9173 RawObject* raw = Object::Allocate(LibraryPrefix::kClassId, | 9263 RawObject* raw = Object::Allocate(LibraryPrefix::kClassId, |
9174 LibraryPrefix::InstanceSize(), | 9264 LibraryPrefix::InstanceSize(), |
9175 Heap::kOld); | 9265 Heap::kOld); |
9176 return reinterpret_cast<RawLibraryPrefix*>(raw); | 9266 return reinterpret_cast<RawLibraryPrefix*>(raw); |
9177 } | 9267 } |
9178 | 9268 |
9179 | 9269 |
9180 RawLibraryPrefix* LibraryPrefix::New(const String& name, | 9270 RawLibraryPrefix* LibraryPrefix::New(const String& name, |
9181 const Namespace& import) { | 9271 const Namespace& import, |
9272 bool deferred_load) { | |
9182 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); | 9273 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); |
9183 result.set_name(name); | 9274 result.set_name(name); |
9184 result.set_num_imports(0); | 9275 result.set_num_imports(0); |
9276 result.raw_ptr()->is_deferred_load_ = deferred_load; | |
9277 result.raw_ptr()->is_loaded_ = !deferred_load; | |
9185 result.set_imports(Array::Handle(Array::New(kInitialSize))); | 9278 result.set_imports(Array::Handle(Array::New(kInitialSize))); |
9186 result.AddImport(import); | 9279 result.AddImport(import); |
9280 result.set_dependent_code(Object::null_array()); | |
9187 return result.raw(); | 9281 return result.raw(); |
9188 } | 9282 } |
9189 | 9283 |
9190 | 9284 |
9191 void LibraryPrefix::set_name(const String& value) const { | 9285 void LibraryPrefix::set_name(const String& value) const { |
9192 ASSERT(value.IsSymbol()); | 9286 ASSERT(value.IsSymbol()); |
9193 StorePointer(&raw_ptr()->name_, value.raw()); | 9287 StorePointer(&raw_ptr()->name_, value.raw()); |
9194 } | 9288 } |
9195 | 9289 |
9196 | 9290 |
(...skipping 8764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17961 return "_MirrorReference"; | 18055 return "_MirrorReference"; |
17962 } | 18056 } |
17963 | 18057 |
17964 | 18058 |
17965 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 18059 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
17966 Instance::PrintToJSONStream(stream, ref); | 18060 Instance::PrintToJSONStream(stream, ref); |
17967 } | 18061 } |
17968 | 18062 |
17969 | 18063 |
17970 } // namespace dart | 18064 } // namespace dart |
OLD | NEW |