OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // runtime JavaScript code that use InternalArrays and don't care about | 59 // runtime JavaScript code that use InternalArrays and don't care about |
60 // EcmaScript 5.1 semantics. | 60 // EcmaScript 5.1 semantics. |
61 virtual MaybeObject* SetCapacityAndLength(JSArray* array, | 61 virtual MaybeObject* SetCapacityAndLength(JSArray* array, |
62 int capacity, | 62 int capacity, |
63 int length) = 0; | 63 int length) = 0; |
64 | 64 |
65 virtual MaybeObject* Delete(JSObject* holder, | 65 virtual MaybeObject* Delete(JSObject* holder, |
66 uint32_t key, | 66 uint32_t key, |
67 JSReceiver::DeleteMode mode) = 0; | 67 JSReceiver::DeleteMode mode) = 0; |
68 | 68 |
| 69 virtual bool HasElement(FixedArrayBase* backing_store, |
| 70 uint32_t key, |
| 71 JSObject* holder, |
| 72 Object* receiver) = 0; |
| 73 |
69 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, | 74 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, |
70 FixedArray* to, | 75 FixedArray* to, |
71 JSObject* holder, | 76 JSObject* holder, |
72 Object* receiver) = 0; | 77 Object* receiver) = 0; |
73 | 78 |
74 // Returns a shared ElementsAccessor for the specified ElementsKind. | 79 // Returns a shared ElementsAccessor for the specified ElementsKind. |
75 static ElementsAccessor* ForKind(ElementsKind elements_kind) { | 80 static ElementsAccessor* ForKind(ElementsKind elements_kind) { |
76 ASSERT(elements_kind < kElementsKindCount); | 81 ASSERT(elements_kind < kElementsKindCount); |
77 return elements_accessors_[elements_kind]; | 82 return elements_accessors_[elements_kind]; |
78 } | 83 } |
79 | 84 |
80 static ElementsAccessor* ForArray(FixedArrayBase* array); | 85 static ElementsAccessor* ForArray(FixedArrayBase* array); |
81 | 86 |
82 static void InitializeOncePerProcess(); | 87 static void InitializeOncePerProcess(); |
83 | 88 |
84 protected: | 89 protected: |
85 friend class NonStrictArgumentsElementsAccessor; | 90 friend class NonStrictArgumentsElementsAccessor; |
86 | 91 |
87 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; | 92 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; |
88 | 93 |
89 virtual bool HasElementAtIndex(FixedArrayBase* backing_store, | 94 // Element handlers distinguish between indexes and keys when they manipulate |
90 uint32_t index, | |
91 JSObject* holder, | |
92 Object* receiver) = 0; | |
93 | |
94 // Element handlers distinguish between indexes and keys when the manipulate | |
95 // elements. Indexes refer to elements in terms of their location in the | 95 // elements. Indexes refer to elements in terms of their location in the |
96 // underlying storage's backing store representation, and are between 0 | 96 // underlying storage's backing store representation, and are between 0 and |
97 // GetCapacity. Keys refer to elements in terms of the value that would be | 97 // GetCapacity. Keys refer to elements in terms of the value that would be |
98 // specific in JavaScript to access the element. In most implementations, keys | 98 // specified in JavaScript to access the element. In most implementations, |
99 // are equivalent to indexes, and GetKeyForIndex returns the same value it is | 99 // keys are equivalent to indexes, and GetKeyForIndex returns the same value |
100 // passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the | 100 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps |
101 // index to a key using the KeyAt method on the NumberDictionary. | 101 // the index to a key using the KeyAt method on the NumberDictionary. |
102 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 102 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
103 uint32_t index) = 0; | 103 uint32_t index) = 0; |
104 | 104 |
105 private: | 105 private: |
106 static ElementsAccessor** elements_accessors_; | 106 static ElementsAccessor** elements_accessors_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 108 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
109 }; | 109 }; |
110 | 110 |
111 } } // namespace v8::internal | 111 } } // namespace v8::internal |
112 | 112 |
113 #endif // V8_ELEMENTS_H_ | 113 #endif // V8_ELEMENTS_H_ |
OLD | NEW |