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 18648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18659 } | 18659 } |
18660 | 18660 |
18661 | 18661 |
18662 void UserTag::MakeActive() const { | 18662 void UserTag::MakeActive() const { |
18663 Isolate* isolate = Isolate::Current(); | 18663 Isolate* isolate = Isolate::Current(); |
18664 ASSERT(isolate != NULL); | 18664 ASSERT(isolate != NULL); |
18665 isolate->set_current_tag(*this); | 18665 isolate->set_current_tag(*this); |
18666 } | 18666 } |
18667 | 18667 |
18668 | 18668 |
18669 void UserTag::ClearActive() { | |
18670 Isolate* isolate = Isolate::Current(); | |
18671 ASSERT(isolate != NULL); | |
18672 isolate->clear_current_tag(); | |
18673 } | |
18674 | |
18675 | |
18676 RawUserTag* UserTag::New(const String& label, Heap::Space space) { | 18669 RawUserTag* UserTag::New(const String& label, Heap::Space space) { |
18677 Isolate* isolate = Isolate::Current(); | 18670 Isolate* isolate = Isolate::Current(); |
18678 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); | 18671 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); |
18679 // Canonicalize by name. | 18672 // Canonicalize by name. |
18680 UserTag& result = UserTag::Handle(FindTagInIsolate(isolate, label)); | 18673 UserTag& result = UserTag::Handle(FindTagInIsolate(isolate, label)); |
18681 if (!result.IsNull()) { | 18674 if (!result.IsNull()) { |
18682 // Tag already exists, return existing instance. | 18675 // Tag already exists, return existing instance. |
18683 return result.raw(); | 18676 return result.raw(); |
18684 } | 18677 } |
18685 if (TagTableIsFull(isolate)) { | 18678 if (TagTableIsFull(isolate)) { |
(...skipping 11 matching lines...) Expand all Loading... |
18697 space); | 18690 space); |
18698 NoGCScope no_gc; | 18691 NoGCScope no_gc; |
18699 result ^= raw; | 18692 result ^= raw; |
18700 } | 18693 } |
18701 result.set_label(label); | 18694 result.set_label(label); |
18702 AddTagToIsolate(isolate, result); | 18695 AddTagToIsolate(isolate, result); |
18703 return result.raw(); | 18696 return result.raw(); |
18704 } | 18697 } |
18705 | 18698 |
18706 | 18699 |
| 18700 RawUserTag* UserTag::DefaultTag() { |
| 18701 Isolate* isolate = Isolate::Current(); |
| 18702 ASSERT(isolate != NULL); |
| 18703 ASSERT(isolate->object_store() != NULL); |
| 18704 if (isolate->object_store()->default_tag() != UserTag::null()) { |
| 18705 // Already created. |
| 18706 return isolate->object_store()->default_tag(); |
| 18707 } |
| 18708 // Create default tag. |
| 18709 const UserTag& result = UserTag::Handle(isolate, |
| 18710 UserTag::New(Symbols::Default())); |
| 18711 ASSERT(result.tag() == UserTags::kDefaultUserTag); |
| 18712 isolate->object_store()->set_default_tag(result); |
| 18713 return result.raw(); |
| 18714 } |
| 18715 |
| 18716 |
18707 RawUserTag* UserTag::FindTagInIsolate(Isolate* isolate, const String& label) { | 18717 RawUserTag* UserTag::FindTagInIsolate(Isolate* isolate, const String& label) { |
18708 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); | 18718 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); |
18709 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( | 18719 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( |
18710 isolate, isolate->tag_table()); | 18720 isolate, isolate->tag_table()); |
18711 UserTag& other = UserTag::Handle(isolate); | 18721 UserTag& other = UserTag::Handle(isolate); |
18712 String& tag_label = String::Handle(isolate); | 18722 String& tag_label = String::Handle(isolate); |
18713 for (intptr_t i = 0; i < tag_table.Length(); i++) { | 18723 for (intptr_t i = 0; i < tag_table.Length(); i++) { |
18714 other ^= tag_table.At(i); | 18724 other ^= tag_table.At(i); |
18715 ASSERT(!other.IsNull()); | 18725 ASSERT(!other.IsNull()); |
18716 tag_label ^= other.label(); | 18726 tag_label ^= other.label(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18777 return tag_label.ToCString(); | 18787 return tag_label.ToCString(); |
18778 } | 18788 } |
18779 | 18789 |
18780 | 18790 |
18781 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 18791 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
18782 Instance::PrintJSONImpl(stream, ref); | 18792 Instance::PrintJSONImpl(stream, ref); |
18783 } | 18793 } |
18784 | 18794 |
18785 | 18795 |
18786 } // namespace dart | 18796 } // namespace dart |
OLD | NEW |