Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: runtime/vm/object.h

Issue 17104002: Fix a bug in instance canonicalization and add debug mode checks that we are not missing any fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 3513 matching lines...) Expand 10 before | Expand all | Expand 10 after
3524 class Instance : public Object { 3524 class Instance : public Object {
3525 public: 3525 public:
3526 virtual bool Equals(const Instance& other) const; 3526 virtual bool Equals(const Instance& other) const;
3527 // Returns Instance::null() if instance cannot be canonicalized. 3527 // Returns Instance::null() if instance cannot be canonicalized.
3528 // Any non-canonical number of string will be canonicalized here. 3528 // Any non-canonical number of string will be canonicalized here.
3529 // An instance cannot be canonicalized if it still contains non-canonical 3529 // An instance cannot be canonicalized if it still contains non-canonical
3530 // instances in its fields. 3530 // instances in its fields.
3531 // Returns error in error_str, pass NULL if an error cannot occur. 3531 // Returns error in error_str, pass NULL if an error cannot occur.
3532 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; 3532 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const;
3533 3533
3534 // Returns true if all fields are OK for canonicalization.
3535 virtual bool CheckAndCanonicalizeFields(const char** error_str) const;
3536
3534 RawObject* GetField(const Field& field) const { 3537 RawObject* GetField(const Field& field) const {
3535 return *FieldAddr(field); 3538 return *FieldAddr(field);
3536 } 3539 }
3537 3540
3538 void SetField(const Field& field, const Object& value) const { 3541 void SetField(const Field& field, const Object& value) const {
3539 StorePointer(FieldAddr(field), value.raw()); 3542 StorePointer(FieldAddr(field), value.raw());
3540 } 3543 }
3541 3544
3542 RawType* GetType() const; 3545 RawType* GetType() const;
3543 3546
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4977 return 0; 4980 return 0;
4978 } 4981 }
4979 4982
4980 static intptr_t InstanceSize(intptr_t len) { 4983 static intptr_t InstanceSize(intptr_t len) {
4981 // Ensure that variable length data is not adding to the object length. 4984 // Ensure that variable length data is not adding to the object length.
4982 ASSERT(sizeof(RawArray) == (sizeof(RawInstance) + (2 * kWordSize))); 4985 ASSERT(sizeof(RawArray) == (sizeof(RawInstance) + (2 * kWordSize)));
4983 ASSERT(0 <= len && len <= kMaxElements); 4986 ASSERT(0 <= len && len <= kMaxElements);
4984 return RoundedAllocationSize(sizeof(RawArray) + (len * kBytesPerElement)); 4987 return RoundedAllocationSize(sizeof(RawArray) + (len * kBytesPerElement));
4985 } 4988 }
4986 4989
4990 // Returns true if all elements are OK for canonicalization.
4991 virtual bool CheckAndCanonicalizeFields(const char** error_str) const;
4992
4987 // Make the array immutable to Dart code by switching the class pointer 4993 // Make the array immutable to Dart code by switching the class pointer
4988 // to ImmutableArray. 4994 // to ImmutableArray.
4989 void MakeImmutable() const; 4995 void MakeImmutable() const;
4990 4996
4991 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew); 4997 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew);
4992 4998
4993 // Creates and returns a new array with 'new_length'. Copies all elements from 4999 // Creates and returns a new array with 'new_length'. Copies all elements from
4994 // 'source' to the new array. 'new_length' must be greater than or equal to 5000 // 'source' to the new array. 'new_length' must be greater than or equal to
4995 // 'source.Length()'. 'source' can be null. 5001 // 'source.Length()'. 'source' can be null.
4996 static RawArray* Grow(const Array& source, 5002 static RawArray* Grow(const Array& source,
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
5911 5917
5912 5918
5913 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 5919 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
5914 intptr_t index) { 5920 intptr_t index) {
5915 return array.At((index * kEntryLength) + kTargetFunctionIndex); 5921 return array.At((index * kEntryLength) + kTargetFunctionIndex);
5916 } 5922 }
5917 5923
5918 } // namespace dart 5924 } // namespace dart
5919 5925
5920 #endif // VM_OBJECT_H_ 5926 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698