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 19161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19172 | 19172 |
19173 // Update the size in the header field and length of the array object. | 19173 // Update the size in the header field and length of the array object. |
19174 uword tags = array.raw_ptr()->tags_; | 19174 uword tags = array.raw_ptr()->tags_; |
19175 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); | 19175 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); |
19176 uword old_tags; | 19176 uword old_tags; |
19177 do { | 19177 do { |
19178 old_tags = tags; | 19178 old_tags = tags; |
19179 uword new_tags = RawObject::SizeTag::update(used_size, old_tags); | 19179 uword new_tags = RawObject::SizeTag::update(used_size, old_tags); |
19180 tags = array.CompareAndSwapTags(old_tags, new_tags); | 19180 tags = array.CompareAndSwapTags(old_tags, new_tags); |
19181 } while (tags != old_tags); | 19181 } while (tags != old_tags); |
| 19182 // TODO(22501): For the heap to remain walkable by the sweeper, it must |
| 19183 // observe the creation of the filler object no later than the new length |
| 19184 // of the array. This assumption holds on ia32/x64 or if the CAS above is a |
| 19185 // full memory barrier. |
| 19186 // |
| 19187 // Also, between the CAS of the header above and the SetLength below, |
| 19188 // the array is temporarily in an inconsistent state. The header is considered |
| 19189 // the overriding source of object size by RawObject::Size, but the ASSERTs |
| 19190 // in RawObject::SizeFromClass must handle this special case. |
19182 array.SetLength(used_len); | 19191 array.SetLength(used_len); |
19183 | 19192 |
19184 // Null the GrowableObjectArray, we are removing it's backing array. | 19193 // Null the GrowableObjectArray, we are removing its backing array. |
19185 growable_array.SetLength(0); | 19194 growable_array.SetLength(0); |
19186 growable_array.SetData(Object::empty_array()); | 19195 growable_array.SetData(Object::empty_array()); |
19187 | 19196 |
19188 return array.raw(); | 19197 return array.raw(); |
19189 } | 19198 } |
19190 | 19199 |
19191 | 19200 |
19192 bool Array::CheckAndCanonicalizeFields(const char** error_str) const { | 19201 bool Array::CheckAndCanonicalizeFields(const char** error_str) const { |
19193 Object& obj = Object::Handle(); | 19202 Object& obj = Object::Handle(); |
19194 // Iterate over all elements, canonicalize numbers and strings, expect all | 19203 // Iterate over all elements, canonicalize numbers and strings, expect all |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20615 return tag_label.ToCString(); | 20624 return tag_label.ToCString(); |
20616 } | 20625 } |
20617 | 20626 |
20618 | 20627 |
20619 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20628 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20620 Instance::PrintJSONImpl(stream, ref); | 20629 Instance::PrintJSONImpl(stream, ref); |
20621 } | 20630 } |
20622 | 20631 |
20623 | 20632 |
20624 } // namespace dart | 20633 } // namespace dart |
OLD | NEW |