| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 Instance* Object::sentinel_ = NULL; | 109 Instance* Object::sentinel_ = NULL; |
| 110 Instance* Object::transition_sentinel_ = NULL; | 110 Instance* Object::transition_sentinel_ = NULL; |
| 111 Instance* Object::unknown_constant_ = NULL; | 111 Instance* Object::unknown_constant_ = NULL; |
| 112 Instance* Object::non_constant_ = NULL; | 112 Instance* Object::non_constant_ = NULL; |
| 113 Bool* Object::bool_true_ = NULL; | 113 Bool* Object::bool_true_ = NULL; |
| 114 Bool* Object::bool_false_ = NULL; | 114 Bool* Object::bool_false_ = NULL; |
| 115 Smi* Object::smi_illegal_cid_ = NULL; | 115 Smi* Object::smi_illegal_cid_ = NULL; |
| 116 LanguageError* Object::snapshot_writer_error_ = NULL; | 116 LanguageError* Object::snapshot_writer_error_ = NULL; |
| 117 LanguageError* Object::branch_offset_error_ = NULL; | 117 LanguageError* Object::branch_offset_error_ = NULL; |
| 118 LanguageError* Object::speculative_inlining_error_ = NULL; | 118 LanguageError* Object::speculative_inlining_error_ = NULL; |
| 119 LanguageError* Object::background_compilation_error_ = NULL; |
| 119 Array* Object::vm_isolate_snapshot_object_table_ = NULL; | 120 Array* Object::vm_isolate_snapshot_object_table_ = NULL; |
| 120 Type* Object::dynamic_type_ = NULL; | 121 Type* Object::dynamic_type_ = NULL; |
| 121 Type* Object::void_type_ = NULL; | 122 Type* Object::void_type_ = NULL; |
| 122 | 123 |
| 123 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); | 124 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); |
| 124 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 125 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 125 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 126 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 126 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 127 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 127 RawClass* Object::unresolved_class_class_ = | 128 RawClass* Object::unresolved_class_class_ = |
| 128 reinterpret_cast<RawClass*>(RAW_NULL); | 129 reinterpret_cast<RawClass*>(RAW_NULL); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 sentinel_ = Instance::ReadOnlyHandle(); | 486 sentinel_ = Instance::ReadOnlyHandle(); |
| 486 transition_sentinel_ = Instance::ReadOnlyHandle(); | 487 transition_sentinel_ = Instance::ReadOnlyHandle(); |
| 487 unknown_constant_ = Instance::ReadOnlyHandle(); | 488 unknown_constant_ = Instance::ReadOnlyHandle(); |
| 488 non_constant_ = Instance::ReadOnlyHandle(); | 489 non_constant_ = Instance::ReadOnlyHandle(); |
| 489 bool_true_ = Bool::ReadOnlyHandle(); | 490 bool_true_ = Bool::ReadOnlyHandle(); |
| 490 bool_false_ = Bool::ReadOnlyHandle(); | 491 bool_false_ = Bool::ReadOnlyHandle(); |
| 491 smi_illegal_cid_ = Smi::ReadOnlyHandle(); | 492 smi_illegal_cid_ = Smi::ReadOnlyHandle(); |
| 492 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); | 493 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); |
| 493 branch_offset_error_ = LanguageError::ReadOnlyHandle(); | 494 branch_offset_error_ = LanguageError::ReadOnlyHandle(); |
| 494 speculative_inlining_error_ = LanguageError::ReadOnlyHandle(); | 495 speculative_inlining_error_ = LanguageError::ReadOnlyHandle(); |
| 496 background_compilation_error_ = LanguageError::ReadOnlyHandle(); |
| 495 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle(); | 497 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle(); |
| 496 dynamic_type_ = Type::ReadOnlyHandle(); | 498 dynamic_type_ = Type::ReadOnlyHandle(); |
| 497 void_type_ = Type::ReadOnlyHandle(); | 499 void_type_ = Type::ReadOnlyHandle(); |
| 498 | 500 |
| 499 *null_object_ = Object::null(); | 501 *null_object_ = Object::null(); |
| 500 *null_array_ = Array::null(); | 502 *null_array_ = Array::null(); |
| 501 *null_string_ = String::null(); | 503 *null_string_ = String::null(); |
| 502 *null_instance_ = Instance::null(); | 504 *null_instance_ = Instance::null(); |
| 503 *null_type_arguments_ = TypeArguments::null(); | 505 *null_type_arguments_ = TypeArguments::null(); |
| 504 | 506 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 Report::kError, | 837 Report::kError, |
| 836 Heap::kOld); | 838 Heap::kOld); |
| 837 error_str = String::New("Branch offset overflow", Heap::kOld); | 839 error_str = String::New("Branch offset overflow", Heap::kOld); |
| 838 *branch_offset_error_ = LanguageError::New(error_str, | 840 *branch_offset_error_ = LanguageError::New(error_str, |
| 839 Report::kBailout, | 841 Report::kBailout, |
| 840 Heap::kOld); | 842 Heap::kOld); |
| 841 error_str = String::New("Speculative inlining failed", Heap::kOld); | 843 error_str = String::New("Speculative inlining failed", Heap::kOld); |
| 842 *speculative_inlining_error_ = LanguageError::New(error_str, | 844 *speculative_inlining_error_ = LanguageError::New(error_str, |
| 843 Report::kBailout, | 845 Report::kBailout, |
| 844 Heap::kOld); | 846 Heap::kOld); |
| 847 error_str = String::New("Background Compilation Failed", Heap::kOld); |
| 848 *background_compilation_error_ = LanguageError::New(error_str, |
| 849 Report::kBailout, |
| 850 Heap::kOld); |
| 845 | 851 |
| 846 // Some thread fields need to be reinitialized as null constants have not been | 852 // Some thread fields need to be reinitialized as null constants have not been |
| 847 // initialized until now. | 853 // initialized until now. |
| 848 Thread* thr = Thread::Current(); | 854 Thread* thr = Thread::Current(); |
| 849 ASSERT(thr != NULL); | 855 ASSERT(thr != NULL); |
| 850 thr->clear_sticky_error(); | 856 thr->clear_sticky_error(); |
| 851 thr->clear_pending_functions(); | 857 thr->clear_pending_functions(); |
| 852 | 858 |
| 853 ASSERT(!null_object_->IsSmi()); | 859 ASSERT(!null_object_->IsSmi()); |
| 854 ASSERT(!null_array_->IsSmi()); | 860 ASSERT(!null_array_->IsSmi()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 883 ASSERT(bool_true_->IsBool()); | 889 ASSERT(bool_true_->IsBool()); |
| 884 ASSERT(!bool_false_->IsSmi()); | 890 ASSERT(!bool_false_->IsSmi()); |
| 885 ASSERT(bool_false_->IsBool()); | 891 ASSERT(bool_false_->IsBool()); |
| 886 ASSERT(smi_illegal_cid_->IsSmi()); | 892 ASSERT(smi_illegal_cid_->IsSmi()); |
| 887 ASSERT(!snapshot_writer_error_->IsSmi()); | 893 ASSERT(!snapshot_writer_error_->IsSmi()); |
| 888 ASSERT(snapshot_writer_error_->IsLanguageError()); | 894 ASSERT(snapshot_writer_error_->IsLanguageError()); |
| 889 ASSERT(!branch_offset_error_->IsSmi()); | 895 ASSERT(!branch_offset_error_->IsSmi()); |
| 890 ASSERT(branch_offset_error_->IsLanguageError()); | 896 ASSERT(branch_offset_error_->IsLanguageError()); |
| 891 ASSERT(!speculative_inlining_error_->IsSmi()); | 897 ASSERT(!speculative_inlining_error_->IsSmi()); |
| 892 ASSERT(speculative_inlining_error_->IsLanguageError()); | 898 ASSERT(speculative_inlining_error_->IsLanguageError()); |
| 899 ASSERT(!background_compilation_error_->IsSmi()); |
| 900 ASSERT(background_compilation_error_->IsLanguageError()); |
| 893 ASSERT(!vm_isolate_snapshot_object_table_->IsSmi()); | 901 ASSERT(!vm_isolate_snapshot_object_table_->IsSmi()); |
| 894 ASSERT(vm_isolate_snapshot_object_table_->IsArray()); | 902 ASSERT(vm_isolate_snapshot_object_table_->IsArray()); |
| 895 } | 903 } |
| 896 | 904 |
| 897 | 905 |
| 898 // An object visitor which will mark all visited objects. This is used to | 906 // An object visitor which will mark all visited objects. This is used to |
| 899 // premark all objects in the vm_isolate_ heap. | 907 // premark all objects in the vm_isolate_ heap. |
| 900 class PremarkingVisitor : public ObjectVisitor { | 908 class PremarkingVisitor : public ObjectVisitor { |
| 901 public: | 909 public: |
| 902 explicit PremarkingVisitor(Isolate* isolate) : ObjectVisitor(isolate) {} | 910 explicit PremarkingVisitor(Isolate* isolate) : ObjectVisitor(isolate) {} |
| (...skipping 5827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6730 } | 6738 } |
| 6731 | 6739 |
| 6732 | 6740 |
| 6733 void Function::RestoreICDataMap( | 6741 void Function::RestoreICDataMap( |
| 6734 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, | 6742 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, |
| 6735 bool clone_descriptors) const { | 6743 bool clone_descriptors) const { |
| 6736 ASSERT(deopt_id_to_ic_data->is_empty()); | 6744 ASSERT(deopt_id_to_ic_data->is_empty()); |
| 6737 Zone* zone = Thread::Current()->zone(); | 6745 Zone* zone = Thread::Current()->zone(); |
| 6738 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); | 6746 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); |
| 6739 if (saved_ic_data.IsNull()) { | 6747 if (saved_ic_data.IsNull()) { |
| 6748 // Could happen with deferred loading. |
| 6740 return; | 6749 return; |
| 6741 } | 6750 } |
| 6742 const intptr_t saved_length = saved_ic_data.Length(); | 6751 const intptr_t saved_length = saved_ic_data.Length(); |
| 6743 ASSERT(saved_length > 0); | 6752 ASSERT(saved_length > 0); |
| 6744 if (saved_length > 1) { | 6753 if (saved_length > 1) { |
| 6745 const intptr_t restored_length = ICData::Cast(Object::Handle( | 6754 const intptr_t restored_length = ICData::Cast(Object::Handle( |
| 6746 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; | 6755 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; |
| 6747 deopt_id_to_ic_data->SetLength(restored_length); | 6756 deopt_id_to_ic_data->SetLength(restored_length); |
| 6748 for (intptr_t i = 0; i < restored_length; i++) { | 6757 for (intptr_t i = 0; i < restored_length; i++) { |
| 6749 (*deopt_id_to_ic_data)[i] = NULL; | 6758 (*deopt_id_to_ic_data)[i] = NULL; |
| (...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10249 } | 10258 } |
| 10250 | 10259 |
| 10251 private: | 10260 private: |
| 10252 const LibraryPrefix& prefix_; | 10261 const LibraryPrefix& prefix_; |
| 10253 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); | 10262 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); |
| 10254 }; | 10263 }; |
| 10255 | 10264 |
| 10256 | 10265 |
| 10257 void LibraryPrefix::RegisterDependentCode(const Code& code) const { | 10266 void LibraryPrefix::RegisterDependentCode(const Code& code) const { |
| 10258 ASSERT(is_deferred_load()); | 10267 ASSERT(is_deferred_load()); |
| 10259 ASSERT(!is_loaded()); | 10268 // In background compilation, a library can be loaded while we are compiling. |
| 10269 // The generated code will be rejected in that case, |
| 10270 ASSERT(!is_loaded() || Compiler::IsBackgroundCompilation()); |
| 10260 PrefixDependentArray a(*this); | 10271 PrefixDependentArray a(*this); |
| 10261 a.Register(code); | 10272 a.Register(code); |
| 10262 } | 10273 } |
| 10263 | 10274 |
| 10264 | 10275 |
| 10265 void LibraryPrefix::InvalidateDependentCode() const { | 10276 void LibraryPrefix::InvalidateDependentCode() const { |
| 10266 PrefixDependentArray a(*this); | 10277 PrefixDependentArray a(*this); |
| 10267 a.DisableCode(); | 10278 a.DisableCode(); |
| 10268 set_is_loaded(); | 10279 set_is_loaded(); |
| 10269 } | 10280 } |
| (...skipping 11106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21376 return UserTag::null(); | 21387 return UserTag::null(); |
| 21377 } | 21388 } |
| 21378 | 21389 |
| 21379 | 21390 |
| 21380 const char* UserTag::ToCString() const { | 21391 const char* UserTag::ToCString() const { |
| 21381 const String& tag_label = String::Handle(label()); | 21392 const String& tag_label = String::Handle(label()); |
| 21382 return tag_label.ToCString(); | 21393 return tag_label.ToCString(); |
| 21383 } | 21394 } |
| 21384 | 21395 |
| 21385 } // namespace dart | 21396 } // namespace dart |
| OLD | NEW |