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

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

Issue 16780009: When canonicalize instances check if all fields are canonical. If a field is a non-canonical number… (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
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 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error); 3510 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error);
3511 friend class Class; 3511 friend class Class;
3512 }; 3512 };
3513 3513
3514 3514
3515 // Instance is the base class for all instance objects (aka the Object class 3515 // Instance is the base class for all instance objects (aka the Object class
3516 // in Dart source code. 3516 // in Dart source code.
3517 class Instance : public Object { 3517 class Instance : public Object {
3518 public: 3518 public:
3519 virtual bool Equals(const Instance& other) const; 3519 virtual bool Equals(const Instance& other) const;
3520 virtual RawInstance* Canonicalize() const; 3520 // Returns Instance::null() if instance cannot be canonicalized.
3521 // Any non-canonical number of string will be canonicalized here.
3522 // An instance cannot be canonicalized if it still contains non-canonical
3523 // instances in its fields.
3524 // Returns error in error_str, pass NULL if an error cannot occur.
3525 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const;
3521 3526
3522 RawObject* GetField(const Field& field) const { 3527 RawObject* GetField(const Field& field) const {
3523 return *FieldAddr(field); 3528 return *FieldAddr(field);
3524 } 3529 }
3525 3530
3526 void SetField(const Field& field, const Object& value) const { 3531 void SetField(const Field& field, const Object& value) const {
3527 StorePointer(FieldAddr(field), value.raw()); 3532 StorePointer(FieldAddr(field), value.raw());
3528 } 3533 }
3529 3534
3530 RawType* GetType() const; 3535 RawType* GetType() const;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3601 virtual bool IsInstantiated() const; 3606 virtual bool IsInstantiated() const;
3602 virtual bool Equals(const Instance& other) const; 3607 virtual bool Equals(const Instance& other) const;
3603 3608
3604 // Instantiate this type using the given type argument vector. 3609 // Instantiate this type using the given type argument vector.
3605 // Return a new type, or return 'this' if it is already instantiated. 3610 // Return a new type, or return 'this' if it is already instantiated.
3606 // If malformed_error is not NULL, it may be set to reflect a bound error. 3611 // If malformed_error is not NULL, it may be set to reflect a bound error.
3607 virtual RawAbstractType* InstantiateFrom( 3612 virtual RawAbstractType* InstantiateFrom(
3608 const AbstractTypeArguments& instantiator_type_arguments, 3613 const AbstractTypeArguments& instantiator_type_arguments,
3609 Error* malformed_error) const; 3614 Error* malformed_error) const;
3610 3615
3616 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const {
3617 return Canonicalize();
3618 }
3619
3611 // Return the canonical version of this type. 3620 // Return the canonical version of this type.
3612 virtual RawAbstractType* Canonicalize() const; 3621 virtual RawAbstractType* Canonicalize() const;
3613 3622
3614 // The name of this type, including the names of its type arguments, if any. 3623 // The name of this type, including the names of its type arguments, if any.
3615 virtual RawString* Name() const { 3624 virtual RawString* Name() const {
3616 return BuildName(kInternalName); 3625 return BuildName(kInternalName);
3617 } 3626 }
3618 3627
3619 // The name of this type, including the names of its type arguments, if any. 3628 // The name of this type, including the names of its type arguments, if any.
3620 // Names of internal classes are mapped to their public interfaces. 3629 // Names of internal classes are mapped to their public interfaces.
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 static const intptr_t kMinValue = kSmiMin; 4063 static const intptr_t kMinValue = kSmiMin;
4055 4064
4056 intptr_t Value() const { 4065 intptr_t Value() const {
4057 return ValueFromRaw(raw_value()); 4066 return ValueFromRaw(raw_value());
4058 } 4067 }
4059 4068
4060 virtual bool Equals(const Instance& other) const; 4069 virtual bool Equals(const Instance& other) const;
4061 virtual bool IsZero() const { return Value() == 0; } 4070 virtual bool IsZero() const { return Value() == 0; }
4062 virtual bool IsNegative() const { return Value() < 0; } 4071 virtual bool IsNegative() const { return Value() < 0; }
4063 // Smi values are implicitly canonicalized. 4072 // Smi values are implicitly canonicalized.
4064 virtual RawInstance* Canonicalize() const { 4073 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const {
4065 return reinterpret_cast<RawSmi*>(raw_value()); 4074 return reinterpret_cast<RawSmi*>(raw_value());
4066 } 4075 }
4067 4076
4068 virtual double AsDoubleValue() const; 4077 virtual double AsDoubleValue() const;
4069 virtual int64_t AsInt64Value() const; 4078 virtual int64_t AsInt64Value() const;
4070 4079
4071 virtual int CompareWith(const Integer& other) const; 4080 virtual int CompareWith(const Integer& other) const;
4072 4081
4073 static intptr_t InstanceSize() { return 0; } 4082 static intptr_t InstanceSize() { return 0; }
4074 4083
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
4384 4393
4385 // Compares to an array of UTF-32 encoded characters. 4394 // Compares to an array of UTF-32 encoded characters.
4386 bool Equals(const int32_t* characters, intptr_t len) const; 4395 bool Equals(const int32_t* characters, intptr_t len) const;
4387 4396
4388 virtual bool Equals(const Instance& other) const; 4397 virtual bool Equals(const Instance& other) const;
4389 4398
4390 intptr_t CompareTo(const String& other) const; 4399 intptr_t CompareTo(const String& other) const;
4391 4400
4392 bool StartsWith(const String& other) const; 4401 bool StartsWith(const String& other) const;
4393 4402
4394 virtual RawInstance* Canonicalize() const; 4403 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const;
4395 4404
4396 bool IsSymbol() const { return raw()->IsCanonical(); } 4405 bool IsSymbol() const { return raw()->IsCanonical(); }
4397 4406
4398 bool IsOneByteString() const { 4407 bool IsOneByteString() const {
4399 return raw()->GetClassId() == kOneByteStringCid; 4408 return raw()->GetClassId() == kOneByteStringCid;
4400 } 4409 }
4401 4410
4402 bool IsTwoByteString() const { 4411 bool IsTwoByteString() const {
4403 return raw()->GetClassId() == kTwoByteStringCid; 4412 return raw()->GetClassId() == kTwoByteStringCid;
4404 } 4413 }
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
5867 5876
5868 5877
5869 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 5878 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
5870 intptr_t index) { 5879 intptr_t index) {
5871 return array.At((index * kEntryLength) + kTargetFunctionIndex); 5880 return array.At((index * kEntryLength) + kTargetFunctionIndex);
5872 } 5881 }
5873 5882
5874 } // namespace dart 5883 } // namespace dart
5875 5884
5876 #endif // VM_OBJECT_H_ 5885 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698