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 18157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
18168 | 18168 |
18169 // If there is any left over space fill it with either an Array object or | 18169 // If there is any left over space fill it with either an Array object or |
18170 // just a plain object (depending on the amount of left over space) so | 18170 // just a plain object (depending on the amount of left over space) so |
18171 // that it can be traversed over successfully during garbage collection. | 18171 // that it can be traversed over successfully during garbage collection. |
18172 Object::MakeUnusedSpaceTraversable(array, capacity_size, used_size); | 18172 Object::MakeUnusedSpaceTraversable(array, capacity_size, used_size); |
18173 | 18173 |
18174 return array.raw(); | 18174 return array.raw(); |
18175 } | 18175 } |
18176 | 18176 |
18177 | 18177 |
18178 void Array::CopyFrom(intptr_t dst_start, | |
Ivan Posva
2014/09/02 15:27:07
As discussed offline we will need to keep this as
Vyacheslav Egorov (Google)
2014/09/02 16:02:53
It is not completely clear how to implement this.
| |
18179 const Array& source, | |
18180 intptr_t src_start, | |
18181 intptr_t count) const { | |
18182 if (count < 0) { | |
18183 Exceptions::ThrowByType(Exceptions::kArgument, Object::empty_array()); | |
18184 } | |
18185 if (count == 0) { | |
18186 return; | |
18187 } | |
18188 if ((src_start < 0) || ((src_start + count) > source.Length())) { | |
18189 Exceptions::ThrowRangeError(Smi::Handle(Smi::New(src_start))); | |
18190 } | |
18191 if ((dst_start < 0) || ((dst_start + count) > Length())) { | |
18192 Exceptions::ThrowRangeError(Smi::Handle(Smi::New(dst_start))); | |
18193 } | |
18194 | |
18195 NoGCScope no_gc_scope; | |
18196 memmove(ObjectAddr(dst_start), | |
18197 source.ObjectAddr(src_start), | |
18198 count * kWordSize); | |
18199 // Instead of calling write-barrier for every single element be pessimistic: | |
18200 // put this object into store buffer if it is in the old space and there is | |
18201 // a possibility that it now contains pointers into new space. | |
18202 if (raw()->IsOldObject() && | |
18203 !raw()->IsRemembered() && | |
18204 (source.raw()->IsNewObject() || source.raw()->IsRemembered())) { | |
18205 raw()->SetRememberedBit(); | |
18206 Isolate::Current()->store_buffer()->AddObject(raw()); | |
18207 } | |
18208 } | |
18209 | |
18210 | |
18178 bool Array::CheckAndCanonicalizeFields(const char** error_str) const { | 18211 bool Array::CheckAndCanonicalizeFields(const char** error_str) const { |
18179 Object& obj = Object::Handle(); | 18212 Object& obj = Object::Handle(); |
18180 // Iterate over all elements, canonicalize numbers and strings, expect all | 18213 // Iterate over all elements, canonicalize numbers and strings, expect all |
18181 // other instances to be canonical otherwise report error (return false). | 18214 // other instances to be canonical otherwise report error (return false). |
18182 for (intptr_t i = 0; i < Length(); i++) { | 18215 for (intptr_t i = 0; i < Length(); i++) { |
18183 obj = At(i); | 18216 obj = At(i); |
18184 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { | 18217 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { |
18185 if (obj.IsNumber() || obj.IsString()) { | 18218 if (obj.IsNumber() || obj.IsString()) { |
18186 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); | 18219 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); |
18187 ASSERT(!obj.IsNull()); | 18220 ASSERT(!obj.IsNull()); |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19582 return tag_label.ToCString(); | 19615 return tag_label.ToCString(); |
19583 } | 19616 } |
19584 | 19617 |
19585 | 19618 |
19586 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19619 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19587 Instance::PrintJSONImpl(stream, ref); | 19620 Instance::PrintJSONImpl(stream, ref); |
19588 } | 19621 } |
19589 | 19622 |
19590 | 19623 |
19591 } // namespace dart | 19624 } // namespace dart |
OLD | NEW |