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