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

Side by Side Diff: vm/object.h

Issue 8827016: Add a flags field to RawObject so that we can tag objects with certain (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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 | « vm/dart_api_impl_test.cc ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 kInvalidIndex = -1, 144 kInvalidIndex = -1,
145 }; 145 };
146 146
147 virtual ~Object() { } 147 virtual ~Object() { }
148 148
149 RawObject* raw() const { return raw_; } 149 RawObject* raw() const { return raw_; }
150 void operator=(RawObject* value) { SetRaw(value); } 150 void operator=(RawObject* value) { SetRaw(value); }
151 151
152 inline RawClass* clazz() const; 152 inline RawClass* clazz() const;
153 static intptr_t class_offset() { return OFFSET_OF(RawObject, class_); } 153 static intptr_t class_offset() { return OFFSET_OF(RawObject, class_); }
154 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); }
154 155
155 // Class testers. 156 // Class testers.
156 #define DEFINE_CLASS_TESTER(clazz) \ 157 #define DEFINE_CLASS_TESTER(clazz) \
157 virtual bool Is##clazz() const { return false; } 158 virtual bool Is##clazz() const { return false; }
158 CLASS_LIST_NO_OBJECT(DEFINE_CLASS_TESTER); 159 CLASS_LIST_NO_OBJECT(DEFINE_CLASS_TESTER);
159 #undef DEFINE_CLASS_TESTER 160 #undef DEFINE_CLASS_TESTER
160 161
161 bool IsNull() const { return raw_ == null_; } 162 bool IsNull() const { return raw_ == null_; }
162 163
163 virtual const char* ToCString() const { 164 virtual const char* ToCString() const {
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 return OFFSET_OF(RawTypeArguments, length_); 1030 return OFFSET_OF(RawTypeArguments, length_);
1030 } 1031 }
1031 1032
1032 static intptr_t InstanceSize() { 1033 static intptr_t InstanceSize() {
1033 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); 1034 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_));
1034 return 0; 1035 return 0;
1035 } 1036 }
1036 1037
1037 static intptr_t InstanceSize(intptr_t len) { 1038 static intptr_t InstanceSize(intptr_t len) {
1038 // Ensure that the types_ is not adding to the object length. 1039 // Ensure that the types_ is not adding to the object length.
1039 ASSERT(sizeof(RawTypeArguments) == 3 * kWordSize); 1040 ASSERT(sizeof(RawTypeArguments) == (sizeof(RawObject) + (2 * kWordSize)));
1040 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize)); 1041 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize));
1041 } 1042 }
1042 1043
1043 static RawTypeArguments* New(intptr_t len); 1044 static RawTypeArguments* New(intptr_t len);
1044 1045
1045 private: 1046 private:
1046 bool is_canonical() const; 1047 bool is_canonical() const;
1047 void set_is_canonical(bool value) const; 1048 void set_is_canonical(bool value) const;
1048 1049
1049 // Make sure that the array size cannot wrap around. 1050 // Make sure that the array size cannot wrap around.
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 static intptr_t type_arguments_offset() { 2936 static intptr_t type_arguments_offset() {
2936 return OFFSET_OF(RawArray, type_arguments_); 2937 return OFFSET_OF(RawArray, type_arguments_);
2937 } 2938 }
2938 2939
2939 static intptr_t InstanceSize() { 2940 static intptr_t InstanceSize() {
2940 ASSERT(sizeof(RawArray) == OFFSET_OF_RETURNED_VALUE(RawArray, data)); 2941 ASSERT(sizeof(RawArray) == OFFSET_OF_RETURNED_VALUE(RawArray, data));
2941 return 0; 2942 return 0;
2942 } 2943 }
2943 2944
2944 static intptr_t InstanceSize(intptr_t len) { 2945 static intptr_t InstanceSize(intptr_t len) {
2945 ASSERT(sizeof(RawArray) == 3 * kWordSize); 2946 // Ensure that variable length data is not adding to the object length.
2947 ASSERT(sizeof(RawArray) == (sizeof(RawObject) + (2 * kWordSize)));
2946 return RoundedAllocationSize(sizeof(RawArray) + (len * kWordSize)); 2948 return RoundedAllocationSize(sizeof(RawArray) + (len * kWordSize));
2947 } 2949 }
2948 2950
2949 // Make the array immutable to Dart code by switching the class pointer 2951 // Make the array immutable to Dart code by switching the class pointer
2950 // to ImmutableArray. 2952 // to ImmutableArray.
2951 void MakeImmutable() const; 2953 void MakeImmutable() const;
2952 2954
2953 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew) { 2955 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew) {
2954 return New(len, false, space); 2956 return New(len, false, space);
2955 } 2957 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 } 3274 }
3273 3275
3274 3276
3275 void Context::SetAt(intptr_t index, const Instance& value) const { 3277 void Context::SetAt(intptr_t index, const Instance& value) const {
3276 StorePointer(InstanceAddr(index), value.raw()); 3278 StorePointer(InstanceAddr(index), value.raw());
3277 } 3279 }
3278 3280
3279 } // namespace dart 3281 } // namespace dart
3280 3282
3281 #endif // VM_OBJECT_H_ 3283 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « vm/dart_api_impl_test.cc ('k') | vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698