| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 // need it when reading in the token stream of bootstrap classes in the VM | 628 // need it when reading in the token stream of bootstrap classes in the VM |
| 629 // isolate. | 629 // isolate. |
| 630 Class::NewExternalTypedDataClass(kExternalTypedDataUint8ArrayCid); | 630 Class::NewExternalTypedDataClass(kExternalTypedDataUint8ArrayCid); |
| 631 | 631 |
| 632 // Needed for object pools of VM isolate stubs. | 632 // Needed for object pools of VM isolate stubs. |
| 633 Class::NewTypedDataClass(kTypedDataInt8ArrayCid); | 633 Class::NewTypedDataClass(kTypedDataInt8ArrayCid); |
| 634 | 634 |
| 635 // Allocate and initialize the empty_array instance. | 635 // Allocate and initialize the empty_array instance. |
| 636 { | 636 { |
| 637 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); | 637 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); |
| 638 InitializeObject(address, kArrayCid, Array::InstanceSize(0)); | 638 InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(0)); |
| 639 Array::initializeHandle( | 639 Array::initializeHandle( |
| 640 empty_array_, | 640 empty_array_, |
| 641 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); | 641 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); |
| 642 empty_array_->StoreSmi(&empty_array_->raw_ptr()->length_, Smi::New(0)); | 642 empty_array_->StoreSmi(&empty_array_->raw_ptr()->length_, Smi::New(0)); |
| 643 } | 643 } |
| 644 | 644 |
| 645 Smi& smi = Smi::Handle(); | 645 Smi& smi = Smi::Handle(); |
| 646 // Allocate and initialize the zero_array instance. | 646 // Allocate and initialize the zero_array instance. |
| 647 { | 647 { |
| 648 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); | 648 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); |
| 649 InitializeObject(address, kArrayCid, Array::InstanceSize(1)); | 649 InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(1)); |
| 650 Array::initializeHandle( | 650 Array::initializeHandle( |
| 651 zero_array_, | 651 zero_array_, |
| 652 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); | 652 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); |
| 653 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); | 653 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); |
| 654 smi = Smi::New(0); | 654 smi = Smi::New(0); |
| 655 zero_array_->SetAt(0, smi); | 655 zero_array_->SetAt(0, smi); |
| 656 } | 656 } |
| 657 | 657 |
| 658 // Allocate and initialize the canonical empty object pool object. | 658 // Allocate and initialize the canonical empty object pool object. |
| 659 { | 659 { |
| (...skipping 19066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19726 | 19726 |
| 19727 if (with_type_argument) { | 19727 if (with_type_argument) { |
| 19728 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments())); | 19728 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments())); |
| 19729 } | 19729 } |
| 19730 | 19730 |
| 19731 return dest.raw(); | 19731 return dest.raw(); |
| 19732 } | 19732 } |
| 19733 | 19733 |
| 19734 | 19734 |
| 19735 void Array::MakeImmutable() const { | 19735 void Array::MakeImmutable() const { |
| 19736 if (IsImmutable()) return; |
| 19736 NoSafepointScope no_safepoint; | 19737 NoSafepointScope no_safepoint; |
| 19737 uword tags = raw_ptr()->tags_; | 19738 uword tags = raw_ptr()->tags_; |
| 19738 uword old_tags; | 19739 uword old_tags; |
| 19739 do { | 19740 do { |
| 19740 old_tags = tags; | 19741 old_tags = tags; |
| 19741 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, | 19742 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, |
| 19742 old_tags); | 19743 old_tags); |
| 19743 tags = CompareAndSwapTags(old_tags, new_tags); | 19744 tags = CompareAndSwapTags(old_tags, new_tags); |
| 19744 } while (tags != old_tags); | 19745 } while (tags != old_tags); |
| 19745 } | 19746 } |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21274 return tag_label.ToCString(); | 21275 return tag_label.ToCString(); |
| 21275 } | 21276 } |
| 21276 | 21277 |
| 21277 | 21278 |
| 21278 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21279 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21279 Instance::PrintJSONImpl(stream, ref); | 21280 Instance::PrintJSONImpl(stream, ref); |
| 21280 } | 21281 } |
| 21281 | 21282 |
| 21282 | 21283 |
| 21283 } // namespace dart | 21284 } // namespace dart |
| OLD | NEW |