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

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

Issue 1556113002: Use the fast canonical type cache for non-generic classes, even if their (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')
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 6811 matching lines...) Expand 10 before | Expand all | Expand 10 after
6822 return raw()->GetClassId() == kImmutableArrayCid; 6822 return raw()->GetClassId() == kImmutableArrayCid;
6823 } 6823 }
6824 6824
6825 virtual RawTypeArguments* GetTypeArguments() const { 6825 virtual RawTypeArguments* GetTypeArguments() const {
6826 return raw_ptr()->type_arguments_; 6826 return raw_ptr()->type_arguments_;
6827 } 6827 }
6828 virtual void SetTypeArguments(const TypeArguments& value) const { 6828 virtual void SetTypeArguments(const TypeArguments& value) const {
6829 // An Array is raw or takes one type argument. However, its type argument 6829 // An Array is raw or takes one type argument. However, its type argument
6830 // vector may be longer than 1 due to a type optimization reusing the type 6830 // vector may be longer than 1 due to a type optimization reusing the type
6831 // argument vector of the instantiator. 6831 // argument vector of the instantiator.
6832 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated())); 6832 ASSERT(value.IsNull() ||
6833 ((value.Length() >= 1) &&
6834 value.IsInstantiated() &&
6835 value.IsCanonical()));
6833 StorePointer(&raw_ptr()->type_arguments_, value.raw()); 6836 StorePointer(&raw_ptr()->type_arguments_, value.raw());
6834 } 6837 }
6835 6838
6836 virtual bool CanonicalizeEquals(const Instance& other) const; 6839 virtual bool CanonicalizeEquals(const Instance& other) const;
6837 6840
6838 static const intptr_t kBytesPerElement = kWordSize; 6841 static const intptr_t kBytesPerElement = kWordSize;
6839 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 6842 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
6840 6843
6841 static intptr_t type_arguments_offset() { 6844 static intptr_t type_arguments_offset() {
6842 return OFFSET_OF(RawArray, type_arguments_); 6845 return OFFSET_OF(RawArray, type_arguments_);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
6985 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; 6988 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const;
6986 RawObject* RemoveLast() const; 6989 RawObject* RemoveLast() const;
6987 6990
6988 virtual RawTypeArguments* GetTypeArguments() const { 6991 virtual RawTypeArguments* GetTypeArguments() const {
6989 return raw_ptr()->type_arguments_; 6992 return raw_ptr()->type_arguments_;
6990 } 6993 }
6991 virtual void SetTypeArguments(const TypeArguments& value) const { 6994 virtual void SetTypeArguments(const TypeArguments& value) const {
6992 // A GrowableObjectArray is raw or takes one type argument. However, its 6995 // A GrowableObjectArray is raw or takes one type argument. However, its
6993 // type argument vector may be longer than 1 due to a type optimization 6996 // type argument vector may be longer than 1 due to a type optimization
6994 // reusing the type argument vector of the instantiator. 6997 // reusing the type argument vector of the instantiator.
6995 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated())); 6998 ASSERT(value.IsNull() ||
6999 ((value.Length() >= 1) &&
7000 value.IsInstantiated() &&
7001 value.IsCanonical()));
6996 const Array& contents = Array::Handle(data()); 7002 const Array& contents = Array::Handle(data());
6997 contents.SetTypeArguments(value); 7003 contents.SetTypeArguments(value);
6998 StorePointer(&raw_ptr()->type_arguments_, value.raw()); 7004 StorePointer(&raw_ptr()->type_arguments_, value.raw());
6999 } 7005 }
7000 7006
7001 virtual bool CanonicalizeEquals(const Instance& other) const; 7007 virtual bool CanonicalizeEquals(const Instance& other) const;
7002 7008
7003 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { 7009 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const {
7004 UNREACHABLE(); 7010 UNREACHABLE();
7005 return Instance::null(); 7011 return Instance::null();
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
7533 const TypedData& index, 7539 const TypedData& index,
7534 intptr_t hash_mask, 7540 intptr_t hash_mask,
7535 intptr_t used_data, 7541 intptr_t used_data,
7536 intptr_t deleted_keys, 7542 intptr_t deleted_keys,
7537 Heap::Space space = Heap::kNew); 7543 Heap::Space space = Heap::kNew);
7538 7544
7539 virtual RawTypeArguments* GetTypeArguments() const { 7545 virtual RawTypeArguments* GetTypeArguments() const {
7540 return raw_ptr()->type_arguments_; 7546 return raw_ptr()->type_arguments_;
7541 } 7547 }
7542 virtual void SetTypeArguments(const TypeArguments& value) const { 7548 virtual void SetTypeArguments(const TypeArguments& value) const {
7543 ASSERT(value.IsNull() || ((value.Length() >= 2) && value.IsInstantiated())); 7549 ASSERT(value.IsNull() ||
7550 ((value.Length() >= 2) &&
7551 value.IsInstantiated() &&
7552 value.IsCanonical()));
7544 StorePointer(&raw_ptr()->type_arguments_, value.raw()); 7553 StorePointer(&raw_ptr()->type_arguments_, value.raw());
7545 } 7554 }
7546 static intptr_t type_arguments_offset() { 7555 static intptr_t type_arguments_offset() {
7547 return OFFSET_OF(RawLinkedHashMap, type_arguments_); 7556 return OFFSET_OF(RawLinkedHashMap, type_arguments_);
7548 } 7557 }
7549 7558
7550 RawTypedData* index() const { 7559 RawTypedData* index() const {
7551 return raw_ptr()->index_; 7560 return raw_ptr()->index_;
7552 } 7561 }
7553 void SetIndex(const TypedData& value) const { 7562 void SetIndex(const TypedData& value) const {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
7674 } 7683 }
7675 static intptr_t context_offset() { 7684 static intptr_t context_offset() {
7676 return static_cast<intptr_t>(kContextOffset * kWordSize); 7685 return static_cast<intptr_t>(kContextOffset * kWordSize);
7677 } 7686 }
7678 7687
7679 static RawTypeArguments* GetTypeArguments(const Instance& closure) { 7688 static RawTypeArguments* GetTypeArguments(const Instance& closure) {
7680 return *TypeArgumentsAddr(closure); 7689 return *TypeArgumentsAddr(closure);
7681 } 7690 }
7682 static void SetTypeArguments(const Instance& closure, 7691 static void SetTypeArguments(const Instance& closure,
7683 const TypeArguments& value) { 7692 const TypeArguments& value) {
7693 ASSERT(value.IsNull() || value.IsCanonical());
7684 closure.StorePointer(TypeArgumentsAddr(closure), value.raw()); 7694 closure.StorePointer(TypeArgumentsAddr(closure), value.raw());
7685 } 7695 }
7686 static intptr_t type_arguments_offset() { 7696 static intptr_t type_arguments_offset() {
7687 return static_cast<intptr_t>(kTypeArgumentsOffset * kWordSize); 7697 return static_cast<intptr_t>(kTypeArgumentsOffset * kWordSize);
7688 } 7698 }
7689 7699
7690 static const char* ToCString(const Instance& closure); 7700 static const char* ToCString(const Instance& closure);
7691 7701
7692 static intptr_t InstanceSize() { 7702 static intptr_t InstanceSize() {
7693 intptr_t size = sizeof(RawInstance) + (kNumFields * kWordSize); 7703 intptr_t size = sizeof(RawInstance) + (kNumFields * kWordSize);
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
8235 8245
8236 8246
8237 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8247 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8238 intptr_t index) { 8248 intptr_t index) {
8239 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8249 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8240 } 8250 }
8241 8251
8242 } // namespace dart 8252 } // namespace dart
8243 8253
8244 #endif // VM_OBJECT_H_ 8254 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698