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

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

Issue 380333002: Add VM class for Map/LinkedHashMap. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 <limits> 8 #include <limits>
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 6202 matching lines...) Expand 10 before | Expand all | Expand 10 after
6213 } 6213 }
6214 6214
6215 static const int kDefaultInitialCapacity = 4; 6215 static const int kDefaultInitialCapacity = 4;
6216 6216
6217 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 6217 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
6218 friend class Array; 6218 friend class Array;
6219 friend class Class; 6219 friend class Class;
6220 }; 6220 };
6221 6221
6222 6222
6223 // Corresponds to
6224 // - "new Map()",
6225 // - non-const map literals, and
6226 // - the default constructor of LinkedHashMap in dart:collection.
6227 class LinkedHashMap : public Instance {
6228 public:
6229 intptr_t Length() const;
6230 RawObject* LookUp(const Object& key) const;
6231 void InsertOrUpdate(const Object& key, const Object& value) const;
6232 bool Contains(const Object& key) const;
6233 RawObject* Remove(const Object& key) const;
6234 void Clear() const;
6235 // List of key, value pairs in iteration (i.e., key insertion) order.
6236 RawArray* ToArray() const;
6237
6238 static intptr_t InstanceSize() {
6239 return RoundedAllocationSize(sizeof(RawLinkedHashMap));
6240 }
6241
6242 static RawLinkedHashMap* New(Heap::Space space = Heap::kNew);
6243
6244 virtual RawTypeArguments* GetTypeArguments() const {
6245 return raw_ptr()->type_arguments_;
6246 }
6247 virtual void SetTypeArguments(const TypeArguments& value) const {
6248 ASSERT(value.IsNull() || ((value.Length() >= 2) && value.IsInstantiated()));
6249 StorePointer(&raw_ptr()->type_arguments_, value.raw());
6250 }
6251 static intptr_t type_arguments_offset() {
6252 return OFFSET_OF(RawLinkedHashMap, type_arguments_);
6253 }
6254
6255 // Called whenever the set of keys changes.
6256 void SetModified() const;
6257 RawInstance* GetModificationMark(bool create) const;
6258
6259 private:
6260 RawArray* data() const { return raw_ptr()->data_; }
6261 void SetData(const Array& value) const {
6262 StorePointer(&raw_ptr()->data_, value.raw());
6263 }
6264
6265 FINAL_HEAP_OBJECT_IMPLEMENTATION(LinkedHashMap, Instance);
6266 friend class Class;
6267 };
6268
6269
6223 class Float32x4 : public Instance { 6270 class Float32x4 : public Instance {
6224 public: 6271 public:
6225 static RawFloat32x4* New(float value0, float value1, float value2, 6272 static RawFloat32x4* New(float value0, float value1, float value2,
6226 float value3, Heap::Space space = Heap::kNew); 6273 float value3, Heap::Space space = Heap::kNew);
6227 static RawFloat32x4* New(simd128_value_t value, 6274 static RawFloat32x4* New(simd128_value_t value,
6228 Heap::Space space = Heap::kNew); 6275 Heap::Space space = Heap::kNew);
6229 6276
6230 float x() const; 6277 float x() const;
6231 float y() const; 6278 float y() const;
6232 float z() const; 6279 float z() const;
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
7148 7195
7149 7196
7150 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7197 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7151 intptr_t index) { 7198 intptr_t index) {
7152 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7199 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7153 } 7200 }
7154 7201
7155 } // namespace dart 7202 } // namespace dart
7156 7203
7157 #endif // VM_OBJECT_H_ 7204 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698