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

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

Issue 304703002: Split GuardField into GuardFieldType and GuardFieldLength instructions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
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 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 } 2207 }
2208 // Return the list length that any list stored in this field is guaranteed 2208 // Return the list length that any list stored in this field is guaranteed
2209 // to have. If length is kUnknownFixedLength the length has not 2209 // to have. If length is kUnknownFixedLength the length has not
2210 // been determined. If length is kNoFixedLength this field has multiple 2210 // been determined. If length is kNoFixedLength this field has multiple
2211 // list lengths associated with it and cannot be predicted. 2211 // list lengths associated with it and cannot be predicted.
2212 intptr_t guarded_list_length() const; 2212 intptr_t guarded_list_length() const;
2213 void set_guarded_list_length(intptr_t list_length) const; 2213 void set_guarded_list_length(intptr_t list_length) const;
2214 static intptr_t guarded_list_length_offset() { 2214 static intptr_t guarded_list_length_offset() {
2215 return OFFSET_OF(RawField, guarded_list_length_); 2215 return OFFSET_OF(RawField, guarded_list_length_);
2216 } 2216 }
2217 intptr_t guarded_list_length_in_object_offset() const;
2218 void set_guarded_list_length_in_object_offset(intptr_t offset) const;
2219 static intptr_t guarded_list_length_in_object_offset_offset() {
2220 return OFFSET_OF(RawField, guarded_list_length_in_object_offset_);
2221 }
2222
2217 bool needs_length_check() const { 2223 bool needs_length_check() const {
2218 const bool r = guarded_list_length() >= Field::kUnknownFixedLength; 2224 const bool r = guarded_list_length() >= Field::kUnknownFixedLength;
2219 ASSERT(!r || is_final()); 2225 ASSERT(!r || is_final());
2220 return r; 2226 return r;
2221 } 2227 }
2222 2228
2229 const char* GuardedPropertiesAsCString() const;
2230
2223 intptr_t UnboxedFieldCid() const { 2231 intptr_t UnboxedFieldCid() const {
2224 ASSERT(IsUnboxedField()); 2232 ASSERT(IsUnboxedField());
2225 return guarded_cid(); 2233 return guarded_cid();
2226 } 2234 }
2227 2235
2228 bool IsUnboxedField() const; 2236 bool IsUnboxedField() const;
2229 2237
2230 bool IsPotentialUnboxedField() const; 2238 bool IsPotentialUnboxedField() const;
2231 2239
2232 bool is_unboxing_candidate() const { 2240 bool is_unboxing_candidate() const {
2233 return UnboxingCandidateBit::decode(raw_ptr()->kind_bits_); 2241 return UnboxingCandidateBit::decode(raw_ptr()->kind_bits_);
2234 } 2242 }
2235 void set_is_unboxing_candidate(bool b) const { 2243 void set_is_unboxing_candidate(bool b) const {
2236 set_kind_bits(UnboxingCandidateBit::update(b, raw_ptr()->kind_bits_)); 2244 set_kind_bits(UnboxingCandidateBit::update(b, raw_ptr()->kind_bits_));
2237 } 2245 }
2238 2246
2239 static bool IsExternalizableCid(intptr_t cid) { 2247 static bool IsExternalizableCid(intptr_t cid) {
2240 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); 2248 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid);
2241 } 2249 }
2242 2250
2243 enum { 2251 enum {
2252 kUnknownLengthOffset = -1,
2244 kUnknownFixedLength = -1, 2253 kUnknownFixedLength = -1,
2245 kNoFixedLength = -2, 2254 kNoFixedLength = -2,
2246 }; 2255 };
2247 // Returns false if any value read from this field is guaranteed to be 2256 // Returns false if any value read from this field is guaranteed to be
2248 // not null. 2257 // not null.
2249 // Internally we is_nullable_ field contains either kNullCid (nullable) or 2258 // Internally we is_nullable_ field contains either kNullCid (nullable) or
2250 // any other value (non-nullable) instead of boolean. This is done to simplify 2259 // any other value (non-nullable) instead of boolean. This is done to simplify
2251 // guarding sequence in the generated code. 2260 // guarding sequence in the generated code.
2252 bool is_nullable() const { 2261 bool is_nullable() const {
2253 return raw_ptr()->is_nullable_ == kNullCid; 2262 return raw_ptr()->is_nullable_ == kNullCid;
2254 } 2263 }
2255 void set_is_nullable(bool val) const { 2264 void set_is_nullable(bool val) const {
2256 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; 2265 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid;
2257 } 2266 }
2258 static intptr_t is_nullable_offset() { 2267 static intptr_t is_nullable_offset() {
2259 return OFFSET_OF(RawField, is_nullable_); 2268 return OFFSET_OF(RawField, is_nullable_);
2260 } 2269 }
2261 2270
2262 // Update guarded cid and guarded length for this field. May trigger 2271 // Record store of the given value into this field. May trigger
2263 // deoptimization of dependent optimized code. 2272 // deoptimization of dependent optimized code.
2264 bool UpdateGuardedCidAndLength(const Object& value) const; 2273 void RecordStore(const Object& value) const;
2274
2275 void InitializeGuardedListLengthInObjectOffset() const;
2265 2276
2266 // Return the list of optimized code objects that were optimized under 2277 // Return the list of optimized code objects that were optimized under
2267 // assumptions about guarded class id and nullability of this field. 2278 // assumptions about guarded class id and nullability of this field.
2268 // These code objects must be deoptimized when field's properties change. 2279 // These code objects must be deoptimized when field's properties change.
2269 // Code objects are held weakly via an indirection through WeakProperty. 2280 // Code objects are held weakly via an indirection through WeakProperty.
2270 RawArray* dependent_code() const; 2281 RawArray* dependent_code() const;
2271 void set_dependent_code(const Array& array) const; 2282 void set_dependent_code(const Array& array) const;
2272 2283
2273 // Add the given code object to the list of dependent ones. 2284 // Add the given code object to the list of dependent ones.
2274 void RegisterDependentCode(const Code& code) const; 2285 void RegisterDependentCode(const Code& code) const;
(...skipping 24 matching lines...) Expand all
2299 kUnboxingCandidateBit 2310 kUnboxingCandidateBit
2300 }; 2311 };
2301 class ConstBit : public BitField<bool, kConstBit, 1> {}; 2312 class ConstBit : public BitField<bool, kConstBit, 1> {};
2302 class StaticBit : public BitField<bool, kStaticBit, 1> {}; 2313 class StaticBit : public BitField<bool, kStaticBit, 1> {};
2303 class FinalBit : public BitField<bool, kFinalBit, 1> {}; 2314 class FinalBit : public BitField<bool, kFinalBit, 1> {};
2304 class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {}; 2315 class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {};
2305 class UnboxingCandidateBit : public BitField<bool, 2316 class UnboxingCandidateBit : public BitField<bool,
2306 kUnboxingCandidateBit, 1> { 2317 kUnboxingCandidateBit, 1> {
2307 }; 2318 };
2308 2319
2309 // Update guarded class id and nullability of the field to reflect assignment 2320 // Update guarded cid and guarded length for this field. Returns true, if
2310 // of the value with the given class id to this field. Returns true, if
2311 // deoptimization of dependent code is required. 2321 // deoptimization of dependent code is required.
2312 bool UpdateCid(intptr_t cid) const; 2322 bool UpdateGuardedCidAndLength(const Object& value) const;
2313
2314 // Update guarded class length of the field to reflect assignment of the
2315 // value with the given length. Returns true if deoptimization of dependent
2316 // code is required.
2317 bool UpdateLength(intptr_t length) const;
2318 2323
2319 void set_name(const String& value) const; 2324 void set_name(const String& value) const;
2320 void set_is_static(bool is_static) const { 2325 void set_is_static(bool is_static) const {
2321 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); 2326 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_));
2322 } 2327 }
2323 void set_is_final(bool is_final) const { 2328 void set_is_final(bool is_final) const {
2324 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); 2329 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_));
2325 } 2330 }
2326 void set_is_const(bool value) const { 2331 void set_is_const(bool value) const {
2327 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); 2332 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_));
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after
4152 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; 4157 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const;
4153 4158
4154 // Returns true if all fields are OK for canonicalization. 4159 // Returns true if all fields are OK for canonicalization.
4155 virtual bool CheckAndCanonicalizeFields(const char** error_str) const; 4160 virtual bool CheckAndCanonicalizeFields(const char** error_str) const;
4156 4161
4157 RawObject* GetField(const Field& field) const { 4162 RawObject* GetField(const Field& field) const {
4158 return *FieldAddr(field); 4163 return *FieldAddr(field);
4159 } 4164 }
4160 4165
4161 void SetField(const Field& field, const Object& value) const { 4166 void SetField(const Field& field, const Object& value) const {
4162 field.UpdateGuardedCidAndLength(value); 4167 field.RecordStore(value);
4163 StorePointer(FieldAddr(field), value.raw()); 4168 StorePointer(FieldAddr(field), value.raw());
4164 } 4169 }
4165 4170
4166 RawType* GetType() const; 4171 RawType* GetType() const;
4167 4172
4168 virtual RawTypeArguments* GetTypeArguments() const; 4173 virtual RawTypeArguments* GetTypeArguments() const;
4169 virtual void SetTypeArguments(const TypeArguments& value) const; 4174 virtual void SetTypeArguments(const TypeArguments& value) const;
4170 4175
4171 // Check if the type of this instance is a subtype of the given type. 4176 // Check if the type of this instance is a subtype of the given type.
4172 bool IsInstanceOf(const AbstractType& type, 4177 bool IsInstanceOf(const AbstractType& type,
(...skipping 2897 matching lines...) Expand 10 before | Expand all | Expand 10 after
7070 7075
7071 7076
7072 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7077 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7073 intptr_t index) { 7078 intptr_t index) {
7074 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7079 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7075 } 7080 }
7076 7081
7077 } // namespace dart 7082 } // namespace dart
7078 7083
7079 #endif // VM_OBJECT_H_ 7084 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698