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 15228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15239 #endif // DEBUG | 15239 #endif // DEBUG |
15240 | 15240 |
15241 | 15241 |
15242 bool Instance::CheckAndCanonicalizeFields(Thread* thread, | 15242 bool Instance::CheckAndCanonicalizeFields(Thread* thread, |
15243 const char** error_str) const { | 15243 const char** error_str) const { |
15244 if (GetClassId() >= kNumPredefinedCids) { | 15244 if (GetClassId() >= kNumPredefinedCids) { |
15245 // Iterate over all fields, canonicalize numbers and strings, expect all | 15245 // Iterate over all fields, canonicalize numbers and strings, expect all |
15246 // other instances to be canonical otherwise report error (return false). | 15246 // other instances to be canonical otherwise report error (return false). |
15247 Zone* zone = thread->zone(); | 15247 Zone* zone = thread->zone(); |
15248 Object& obj = Object::Handle(zone); | 15248 Object& obj = Object::Handle(zone); |
15249 intptr_t end_field_offset = SizeFromClass() - kWordSize; | 15249 const intptr_t instance_size = SizeFromClass(); |
15250 for (intptr_t field_offset = 0; | 15250 ASSERT(instance_size != 0); |
15251 field_offset <= end_field_offset; | 15251 for (intptr_t offset = Instance::NextFieldOffset(); |
15252 field_offset += kWordSize) { | 15252 offset < instance_size; |
15253 obj = *this->FieldAddrAtOffset(field_offset); | 15253 offset += kWordSize) { |
| 15254 obj = *this->FieldAddrAtOffset(offset); |
15254 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { | 15255 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { |
15255 if (obj.IsNumber() || obj.IsString()) { | 15256 if (obj.IsNumber() || obj.IsString()) { |
15256 obj = Instance::Cast(obj).CheckAndCanonicalize(thread, NULL); | 15257 obj = Instance::Cast(obj).CheckAndCanonicalize(thread, NULL); |
15257 ASSERT(!obj.IsNull()); | 15258 ASSERT(!obj.IsNull()); |
15258 this->SetFieldAtOffset(field_offset, obj); | 15259 this->SetFieldAtOffset(offset, obj); |
15259 } else { | 15260 } else { |
15260 ASSERT(error_str != NULL); | 15261 ASSERT(error_str != NULL); |
15261 char* chars = OS::SCreate(zone, "field: %s\n", obj.ToCString()); | 15262 char* chars = OS::SCreate(zone, "field: %s\n", obj.ToCString()); |
15262 *error_str = chars; | 15263 *error_str = chars; |
15263 return false; | 15264 return false; |
15264 } | 15265 } |
15265 } | 15266 } |
15266 } | 15267 } |
15267 } else { | 15268 } else { |
15268 #if defined(DEBUG) | 15269 #if defined(DEBUG) |
(...skipping 7340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22609 return UserTag::null(); | 22610 return UserTag::null(); |
22610 } | 22611 } |
22611 | 22612 |
22612 | 22613 |
22613 const char* UserTag::ToCString() const { | 22614 const char* UserTag::ToCString() const { |
22614 const String& tag_label = String::Handle(label()); | 22615 const String& tag_label = String::Handle(label()); |
22615 return tag_label.ToCString(); | 22616 return tag_label.ToCString(); |
22616 } | 22617 } |
22617 | 22618 |
22618 } // namespace dart | 22619 } // namespace dart |
OLD | NEW |