Chromium Code Reviews| 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 18079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18090 Object::Allocate(class_id, | 18090 Object::Allocate(class_id, |
| 18091 Array::InstanceSize(len), | 18091 Array::InstanceSize(len), |
| 18092 space)); | 18092 space)); |
| 18093 NoGCScope no_gc; | 18093 NoGCScope no_gc; |
| 18094 raw->ptr()->length_ = Smi::New(len); | 18094 raw->ptr()->length_ = Smi::New(len); |
| 18095 return raw; | 18095 return raw; |
| 18096 } | 18096 } |
| 18097 } | 18097 } |
| 18098 | 18098 |
| 18099 | 18099 |
| 18100 RawArray* Array::Slice(intptr_t start, | |
| 18101 intptr_t count, | |
| 18102 bool with_type_argument) const { | |
| 18103 Array& dest = Array::Handle(Array::New(count)); | |
|
Ivan Posva
2014/09/03 19:10:00
Please add a TODO to allocate new arrays, which wi
Vyacheslav Egorov (Google)
2014/09/03 20:35:18
Done.
| |
| 18104 if (dest.raw()->IsNewObject()) { | |
| 18105 NoGCScope no_gc_scope; | |
| 18106 memmove(dest.ObjectAddr(0), ObjectAddr(start), count * kWordSize); | |
| 18107 } else { | |
| 18108 PassiveObject& obj = PassiveObject::Handle(); | |
| 18109 for (intptr_t i = 0; i < count; i++) { | |
| 18110 obj = At(start + i); | |
| 18111 dest.SetAt(i, obj); | |
| 18112 } | |
| 18113 } | |
| 18114 | |
| 18115 if (with_type_argument) { | |
| 18116 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments())); | |
| 18117 } | |
| 18118 | |
| 18119 return dest.raw(); | |
| 18120 } | |
| 18121 | |
| 18122 | |
| 18100 void Array::MakeImmutable() const { | 18123 void Array::MakeImmutable() const { |
| 18101 NoGCScope no_gc; | 18124 NoGCScope no_gc; |
| 18102 uword tags = raw_ptr()->tags_; | 18125 uword tags = raw_ptr()->tags_; |
| 18103 uword old_tags; | 18126 uword old_tags; |
| 18104 do { | 18127 do { |
| 18105 old_tags = tags; | 18128 old_tags = tags; |
| 18106 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, | 18129 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, |
| 18107 old_tags); | 18130 old_tags); |
| 18108 tags = AtomicOperations::CompareAndSwapWord( | 18131 tags = AtomicOperations::CompareAndSwapWord( |
| 18109 &raw_ptr()->tags_, old_tags, new_tags); | 18132 &raw_ptr()->tags_, old_tags, new_tags); |
| (...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19620 return tag_label.ToCString(); | 19643 return tag_label.ToCString(); |
| 19621 } | 19644 } |
| 19622 | 19645 |
| 19623 | 19646 |
| 19624 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19647 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19625 Instance::PrintJSONImpl(stream, ref); | 19648 Instance::PrintJSONImpl(stream, ref); |
| 19626 } | 19649 } |
| 19627 | 19650 |
| 19628 | 19651 |
| 19629 } // namespace dart | 19652 } // namespace dart |
| OLD | NEW |