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/become.h" | 10 #include "vm/become.h" |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 ASSERT(speculative_inlining_error_->IsLanguageError()); | 986 ASSERT(speculative_inlining_error_->IsLanguageError()); |
987 ASSERT(!background_compilation_error_->IsSmi()); | 987 ASSERT(!background_compilation_error_->IsSmi()); |
988 ASSERT(background_compilation_error_->IsLanguageError()); | 988 ASSERT(background_compilation_error_->IsLanguageError()); |
989 ASSERT(!vm_isolate_snapshot_object_table_->IsSmi()); | 989 ASSERT(!vm_isolate_snapshot_object_table_->IsSmi()); |
990 ASSERT(vm_isolate_snapshot_object_table_->IsArray()); | 990 ASSERT(vm_isolate_snapshot_object_table_->IsArray()); |
991 } | 991 } |
992 | 992 |
993 | 993 |
994 // An object visitor which will mark all visited objects. This is used to | 994 // An object visitor which will mark all visited objects. This is used to |
995 // premark all objects in the vm_isolate_ heap. | 995 // premark all objects in the vm_isolate_ heap. |
996 class PremarkingVisitor : public ObjectVisitor { | 996 class PremarkingVisitor : public ObjectVisitor { |
Vyacheslav Egorov (Google)
2017/06/07 06:21:15
Maybe this name needs to be changed?
erikcorry
2017/06/16 09:26:39
VMIsolateFixingVisitor
| |
997 public: | 997 public: |
998 PremarkingVisitor() {} | 998 PremarkingVisitor() : counter_(1337) {} |
999 | 999 |
1000 void VisitObject(RawObject* obj) { | 1000 void VisitObject(RawObject* obj) { |
1001 // Free list elements should never be marked. | 1001 // Free list elements should never be marked. |
1002 ASSERT(!obj->IsMarked()); | 1002 ASSERT(!obj->IsMarked()); |
1003 // No forwarding corpses in the VM isolate. | 1003 // No forwarding corpses in the VM isolate. |
1004 ASSERT(!obj->IsForwardingCorpse()); | 1004 ASSERT(!obj->IsForwardingCorpse()); |
1005 if (!obj->IsFreeListElement()) { | 1005 if (!obj->IsFreeListElement()) { |
1006 ASSERT(obj->IsVMHeapObject()); | 1006 ASSERT(obj->IsVMHeapObject()); |
1007 obj->SetMarkBitUnsynchronized(); | 1007 obj->SetMarkBitUnsynchronized(); |
1008 #if defined(HASH_IN_OBJECT_HEADER) | |
1009 // These objects end up in the read-only VM isolate which is shared | |
1010 // between isolates, so we have to prepopulate them with identity hash | |
1011 // codes, since we can't add hash codes later. | |
1012 if (Object::GetCachedHash(obj) == 0) { | |
1013 // Some classes have identity hash codes that depend on their contents, | |
1014 // not per object. | |
1015 ASSERT(!obj->IsStringInstance()); | |
1016 if (!obj->IsMint() && !obj->IsDouble() && !obj->IsBigint() && | |
1017 !obj->IsRawNull() && !obj->IsBool()) { | |
1018 counter_ += 2011; // The year Dart was announced and a prime. | |
1019 counter_ &= 0x3fffffff; | |
1020 if (counter_ == 0) counter_++; | |
1021 Object::SetCachedHash(obj, counter_); | |
1022 } | |
1023 } | |
1024 #endif | |
1008 } | 1025 } |
1009 } | 1026 } |
1027 | |
1028 private: | |
1029 int counter_; | |
1010 }; | 1030 }; |
1011 | 1031 |
1012 | 1032 |
1013 #define SET_CLASS_NAME(class_name, name) \ | 1033 #define SET_CLASS_NAME(class_name, name) \ |
1014 cls = class_name##_class(); \ | 1034 cls = class_name##_class(); \ |
1015 cls.set_name(Symbols::name()); | 1035 cls.set_name(Symbols::name()); |
1016 | 1036 |
1017 void Object::FinalizeVMIsolate(Isolate* isolate) { | 1037 void Object::FinalizeVMIsolate(Isolate* isolate) { |
1018 // Should only be run by the vm isolate. | 1038 // Should only be run by the vm isolate. |
1019 ASSERT(isolate == Dart::vm_isolate()); | 1039 ASSERT(isolate == Dart::vm_isolate()); |
(...skipping 22333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
23353 return UserTag::null(); | 23373 return UserTag::null(); |
23354 } | 23374 } |
23355 | 23375 |
23356 | 23376 |
23357 const char* UserTag::ToCString() const { | 23377 const char* UserTag::ToCString() const { |
23358 const String& tag_label = String::Handle(label()); | 23378 const String& tag_label = String::Handle(label()); |
23359 return tag_label.ToCString(); | 23379 return tag_label.ToCString(); |
23360 } | 23380 } |
23361 | 23381 |
23362 } // namespace dart | 23382 } // namespace dart |
OLD | NEW |