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

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

Issue 1151523002: VM-internalize the default Map implementation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix fingerprints. Created 5 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
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | 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 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_ACCESSORS) 2290 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_ACCESSORS)
2291 #undef DEFINE_ACCESSORS 2291 #undef DEFINE_ACCESSORS
2292 2292
2293 private: 2293 private:
2294 void set_ic_data_array(const Array& value) const; 2294 void set_ic_data_array(const Array& value) const;
2295 2295
2296 enum KindTagBits { 2296 enum KindTagBits {
2297 kKindTagPos = 0, 2297 kKindTagPos = 0,
2298 kKindTagSize = 4, 2298 kKindTagSize = 4,
2299 kRecognizedTagPos = kKindTagPos + kKindTagSize, 2299 kRecognizedTagPos = kKindTagPos + kKindTagSize,
2300 kRecognizedTagSize = 8, 2300 kRecognizedTagSize = 9,
2301 kModifierPos = kRecognizedTagPos + kRecognizedTagSize, 2301 kModifierPos = kRecognizedTagPos + kRecognizedTagSize,
2302 kModifierSize = 2, 2302 kModifierSize = 2,
2303 kLastModifierBitPos = kModifierPos + (kModifierSize - 1), 2303 kLastModifierBitPos = kModifierPos + (kModifierSize - 1),
2304 // Single bit sized fields start here. 2304 // Single bit sized fields start here.
2305 #define DECLARE_BIT(name, _) k##name##Bit, 2305 #define DECLARE_BIT(name, _) k##name##Bit,
2306 FOR_EACH_FUNCTION_KIND_BIT(DECLARE_BIT) 2306 FOR_EACH_FUNCTION_KIND_BIT(DECLARE_BIT)
2307 #undef DECLARE_BIT 2307 #undef DECLARE_BIT
2308 kNumTagBits 2308 kNumTagBits
2309 }; 2309 };
2310 2310
(...skipping 4360 matching lines...) Expand 10 before | Expand all | Expand 10 after
6671 } 6671 }
6672 6672
6673 static const int kDefaultInitialCapacity = 4; 6673 static const int kDefaultInitialCapacity = 4;
6674 6674
6675 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 6675 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
6676 friend class Array; 6676 friend class Array;
6677 friend class Class; 6677 friend class Class;
6678 }; 6678 };
6679 6679
6680 6680
6681 // Corresponds to
6682 // - "new Map()",
6683 // - non-const map literals, and
6684 // - the default constructor of LinkedHashMap in dart:collection.
6685 class LinkedHashMap : public Instance {
6686 public:
6687 intptr_t Length() const;
6688 RawObject* LookUp(const Object& key) const;
6689 void InsertOrUpdate(const Object& key, const Object& value) const;
6690 bool Contains(const Object& key) const;
6691 RawObject* Remove(const Object& key) const;
6692 void Clear() const;
6693 // List of key, value pairs in iteration (i.e., key insertion) order.
6694 RawArray* ToArray() const;
6695
6696 static intptr_t InstanceSize() {
6697 return RoundedAllocationSize(sizeof(RawLinkedHashMap));
6698 }
6699
6700 static RawLinkedHashMap* New(Heap::Space space = Heap::kNew);
6701
6702 virtual RawTypeArguments* GetTypeArguments() const {
6703 return raw_ptr()->type_arguments_;
6704 }
6705 virtual void SetTypeArguments(const TypeArguments& value) const {
6706 ASSERT(value.IsNull() || ((value.Length() >= 2) && value.IsInstantiated()));
6707 StorePointer(&raw_ptr()->type_arguments_, value.raw());
6708 }
6709 static intptr_t type_arguments_offset() {
6710 return OFFSET_OF(RawLinkedHashMap, type_arguments_);
6711 }
6712
6713 // Called whenever the set of keys changes.
6714 void SetModified() const;
6715 RawInstance* GetModificationMark(bool create) const;
6716
6717 private:
6718 RawArray* data() const { return raw_ptr()->data_; }
6719 void SetData(const Array& value) const {
6720 StorePointer(&raw_ptr()->data_, value.raw());
6721 }
6722
6723 FINAL_HEAP_OBJECT_IMPLEMENTATION(LinkedHashMap, Instance);
6724 friend class Class;
6725 };
6726
6727
6728 class Float32x4 : public Instance { 6681 class Float32x4 : public Instance {
6729 public: 6682 public:
6730 static RawFloat32x4* New(float value0, float value1, float value2, 6683 static RawFloat32x4* New(float value0, float value1, float value2,
6731 float value3, Heap::Space space = Heap::kNew); 6684 float value3, Heap::Space space = Heap::kNew);
6732 static RawFloat32x4* New(simd128_value_t value, 6685 static RawFloat32x4* New(simd128_value_t value,
6733 Heap::Space space = Heap::kNew); 6686 Heap::Space space = Heap::kNew);
6734 6687
6735 float x() const; 6688 float x() const;
6736 float y() const; 6689 float y() const;
6737 float z() const; 6690 float z() const;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
7188 return kWordSize * kDataOffset; 7141 return kWordSize * kDataOffset;
7189 } 7142 }
7190 7143
7191 private: 7144 private:
7192 enum { 7145 enum {
7193 kDataOffset = 1, 7146 kDataOffset = 1,
7194 }; 7147 };
7195 }; 7148 };
7196 7149
7197 7150
7151 // Corresponds to
7152 // - "new Map()",
7153 // - non-const map literals, and
7154 // - the default constructor of LinkedHashMap in dart:collection.
7155 class LinkedHashMap : public Instance {
7156 public:
7157 static intptr_t InstanceSize() {
7158 return RoundedAllocationSize(sizeof(RawLinkedHashMap));
7159 }
7160
7161 // Allocates a map with some default capacity, just like "new Map()".
7162 static RawLinkedHashMap* NewDefault(Heap::Space space = Heap::kNew);
7163 static RawLinkedHashMap* New(const Array& data,
7164 const TypedData& index,
7165 intptr_t hash_mask,
7166 intptr_t used_data,
7167 intptr_t deleted_keys,
7168 Heap::Space space = Heap::kNew);
7169
7170 virtual RawTypeArguments* GetTypeArguments() const {
7171 return raw_ptr()->type_arguments_;
7172 }
7173 virtual void SetTypeArguments(const TypeArguments& value) const {
7174 ASSERT(value.IsNull() || ((value.Length() >= 2) && value.IsInstantiated()));
7175 StorePointer(&raw_ptr()->type_arguments_, value.raw());
7176 }
7177 static intptr_t type_arguments_offset() {
7178 return OFFSET_OF(RawLinkedHashMap, type_arguments_);
7179 }
7180
7181 RawTypedData* index() const {
7182 return raw_ptr()->index_;
7183 }
7184 void SetIndex(const TypedData& value) const {
7185 StorePointer(&raw_ptr()->index_, value.raw());
7186 }
7187 static intptr_t index_offset() {
7188 return OFFSET_OF(RawLinkedHashMap, index_);
7189 }
7190
7191 RawArray* data() const {
7192 return raw_ptr()->data_;
7193 }
7194 void SetData(const Array& value) const {
7195 StorePointer(&raw_ptr()->data_, value.raw());
7196 }
7197 static intptr_t data_offset() {
7198 return OFFSET_OF(RawLinkedHashMap, data_);
7199 }
7200
7201 RawSmi* hash_mask() const {
7202 return raw_ptr()->hash_mask_;
7203 }
7204 void SetHashMask(intptr_t value) const {
7205 StoreSmi(&raw_ptr()->hash_mask_, Smi::New(value));
7206 }
7207 static intptr_t hash_mask_offset() {
7208 return OFFSET_OF(RawLinkedHashMap, hash_mask_);
7209 }
7210
7211 RawSmi* used_data() const {
7212 return raw_ptr()->used_data_;
7213 }
7214 void SetUsedData(intptr_t value) const {
7215 StoreSmi(&raw_ptr()->used_data_, Smi::New(value));
7216 }
7217 static intptr_t used_data_offset() {
7218 return OFFSET_OF(RawLinkedHashMap, used_data_);
7219 }
7220
7221 RawSmi* deleted_keys() const {
7222 return raw_ptr()->deleted_keys_;
7223 }
7224 void SetDeletedKeys(intptr_t value) const {
7225 StoreSmi(&raw_ptr()->deleted_keys_, Smi::New(value));
7226 }
7227 static intptr_t deleted_keys_offset() {
7228 return OFFSET_OF(RawLinkedHashMap, deleted_keys_);
7229 }
7230
7231 private:
7232 FINAL_HEAP_OBJECT_IMPLEMENTATION(LinkedHashMap, Instance);
7233
7234 // Allocate a map, but leave all fields set to null.
7235 // Used during deserialization (since map might contain itself as key/value).
7236 static RawLinkedHashMap* NewUninitialized(Heap::Space space = Heap::kNew);
7237
7238 friend class Class;
7239 };
7240
7241
7198 class Closure : public AllStatic { 7242 class Closure : public AllStatic {
7199 public: 7243 public:
7200 static RawFunction* function(const Instance& closure) { 7244 static RawFunction* function(const Instance& closure) {
7201 return *FunctionAddr(closure); 7245 return *FunctionAddr(closure);
7202 } 7246 }
7203 static intptr_t function_offset() { 7247 static intptr_t function_offset() {
7204 return static_cast<intptr_t>(kFunctionOffset * kWordSize); 7248 return static_cast<intptr_t>(kFunctionOffset * kWordSize);
7205 } 7249 }
7206 7250
7207 static RawContext* context(const Instance& closure) { 7251 static RawContext* context(const Instance& closure) {
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
7743 7787
7744 7788
7745 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7789 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7746 intptr_t index) { 7790 intptr_t index) {
7747 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7791 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7748 } 7792 }
7749 7793
7750 } // namespace dart 7794 } // namespace dart
7751 7795
7752 #endif // VM_OBJECT_H_ 7796 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698