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/raw_object.h" | 5 #include "vm/raw_object.h" |
6 | 6 |
7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 default: | 210 default: |
211 UNREACHABLE(); | 211 UNREACHABLE(); |
212 break; | 212 break; |
213 } | 213 } |
214 } | 214 } |
215 ASSERT(instance_size != 0); | 215 ASSERT(instance_size != 0); |
216 #if defined(DEBUG) | 216 #if defined(DEBUG) |
217 uword tags = ptr()->tags_; | 217 uword tags = ptr()->tags_; |
218 intptr_t tags_size = SizeTag::decode(tags); | 218 intptr_t tags_size = SizeTag::decode(tags); |
| 219 if ((class_id == kArrayCid) && (instance_size > tags_size && tags_size > 0)) { |
| 220 // TODO(22501): Array::MakeArray could be in the process of shrinking |
| 221 // the array (see comment therein), having already updated the tags but not |
| 222 // yet set the new length. Wait a millisecond and try again. |
| 223 int retries_remaining = 1000; // ... but not forever. |
| 224 do { |
| 225 OS::Sleep(1); |
| 226 const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); |
| 227 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 228 instance_size = Array::InstanceSize(array_length); |
| 229 } while ((instance_size > tags_size) && (--retries_remaining > 0)); |
| 230 } |
219 if ((instance_size != tags_size) && (tags_size != 0)) { | 231 if ((instance_size != tags_size) && (tags_size != 0)) { |
220 FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n", | 232 FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n", |
221 instance_size, tags_size, tags); | 233 instance_size, tags_size, tags); |
222 } | 234 } |
223 #endif // DEBUG | 235 #endif // DEBUG |
224 return instance_size; | 236 return instance_size; |
225 } | 237 } |
226 | 238 |
227 | 239 |
228 #if defined(DEBUG) | 240 #if defined(DEBUG) |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 intptr_t RawUserTag::VisitUserTagPointers( | 936 intptr_t RawUserTag::VisitUserTagPointers( |
925 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 937 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
926 // Make sure that we got here with the tagged pointer as this. | 938 // Make sure that we got here with the tagged pointer as this. |
927 ASSERT(raw_obj->IsHeapObject()); | 939 ASSERT(raw_obj->IsHeapObject()); |
928 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 940 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
929 return UserTag::InstanceSize(); | 941 return UserTag::InstanceSize(); |
930 } | 942 } |
931 | 943 |
932 | 944 |
933 } // namespace dart | 945 } // namespace dart |
OLD | NEW |