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

Side by Side Diff: src/elements.h

Issue 7655030: Unify GetElement handlers in ElementsAccessor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge with latest Created 9 years, 4 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
« no previous file with comments | « no previous file | src/elements.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 21 matching lines...) Expand all
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 // Abstract base class for handles that can operate on objects with differing 36 // Abstract base class for handles that can operate on objects with differing
37 // ElementsKinds. 37 // ElementsKinds.
38 class ElementsAccessor { 38 class ElementsAccessor {
39 public: 39 public:
40 ElementsAccessor() { } 40 ElementsAccessor() { }
41 virtual ~ElementsAccessor() { } 41 virtual ~ElementsAccessor() { }
42 virtual MaybeObject* GetWithReceiver(JSObject* obj, 42 virtual MaybeObject* Get(FixedArrayBase* backing_store,
43 Object* receiver, 43 uint32_t key,
44 uint32_t key) = 0; 44 JSObject* holder,
45 Object* receiver) = 0;
45 46
46 virtual MaybeObject* Delete(JSObject* obj, 47 virtual MaybeObject* Delete(JSObject* holder,
47 uint32_t key, 48 uint32_t key,
48 JSReceiver::DeleteMode mode) = 0; 49 JSReceiver::DeleteMode mode) = 0;
49 50
50 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, 51 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from,
51 FixedArray* to) = 0; 52 FixedArray* to,
53 JSObject* holder,
54 Object* receiver) = 0;
52 55
53 // Returns a shared ElementsAccessor for the specified ElementsKind. 56 // Returns a shared ElementsAccessor for the specified ElementsKind.
54 static ElementsAccessor* ForKind(JSObject::ElementsKind elements_kind) { 57 static ElementsAccessor* ForKind(JSObject::ElementsKind elements_kind) {
55 ASSERT(elements_kind < JSObject::kElementsKindCount); 58 ASSERT(elements_kind < JSObject::kElementsKindCount);
56 return elements_accessors_[elements_kind]; 59 return elements_accessors_[elements_kind];
57 } 60 }
58 61
59 static ElementsAccessor* ForArray(FixedArrayBase* array); 62 static ElementsAccessor* ForArray(FixedArrayBase* array);
60 63
61 static void InitializeOncePerProcess(); 64 static void InitializeOncePerProcess();
62 65
63 protected: 66 protected:
64 friend class NonStrictArgumentsElementsAccessor; 67 friend class NonStrictArgumentsElementsAccessor;
65 68
66 // TODO(danno): GetElement should be merged with GetWithReceiver.
67 virtual MaybeObject* GetElement(FixedArrayBase* backing_store,
68 uint32_t key) = 0;
69
70 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; 69 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0;
71 70
72 virtual bool HasElementAtIndex(FixedArrayBase* backing_store, 71 virtual bool HasElementAtIndex(FixedArrayBase* backing_store,
73 uint32_t index) = 0; 72 uint32_t index,
73 JSObject* holder,
74 Object* receiver) = 0;
74 75
75 // Element handlers distinguish between indexes and keys when the manipulate 76 // Element handlers distinguish between indexes and keys when the manipulate
76 // elements. Indexes refer to elements in terms of their location in the 77 // elements. Indexes refer to elements in terms of their location in the
77 // underlying storage's backing store representation, and are between 0 78 // underlying storage's backing store representation, and are between 0
78 // GetCapacity. Keys refer to elements in terms of the value that would be 79 // GetCapacity. Keys refer to elements in terms of the value that would be
79 // specific in JavaScript to access the element. In most implementations, keys 80 // specific in JavaScript to access the element. In most implementations, keys
80 // are equivalent to indexes, and GetKeyForIndex returns the same value it is 81 // are equivalent to indexes, and GetKeyForIndex returns the same value it is
81 // passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the 82 // passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the
82 // index to a key using the KeyAt method on the NumberDictionary. 83 // index to a key using the KeyAt method on the NumberDictionary.
83 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, 84 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
84 uint32_t index) = 0; 85 uint32_t index) = 0;
85 86
86 private: 87 private:
87 static ElementsAccessor** elements_accessors_; 88 static ElementsAccessor** elements_accessors_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); 90 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
90 }; 91 };
91 92
92 } } // namespace v8::internal 93 } } // namespace v8::internal
93 94
94 #endif // V8_ELEMENTS_H_ 95 #endif // V8_ELEMENTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698