Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 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 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 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 explicit ElementsAccessor(const char* name) : name_(name) { } | 40 explicit ElementsAccessor(const char* name) : name_(name) { } |
| 41 virtual ~ElementsAccessor() { } | 41 virtual ~ElementsAccessor() { } |
| 42 | 42 |
| 43 virtual const char* name() const { return name_; } | 43 virtual const char* name() const { return name_; } |
| 44 | 44 |
| 45 virtual MaybeObject* Get(FixedArrayBase* backing_store, | 45 // Returns true if a holder contains an element with the specified key |
| 46 // without iterating up the prototype chain. The caller can optionally pass | |
| 47 // in the backing store to use for the check, which must be compatible with | |
| 48 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the | |
| 49 // holder->elements() is used as the backing store. | |
| 50 virtual bool HasElement(Object* receiver, | |
| 51 JSObject* holder, | |
| 52 uint32_t key, | |
| 53 FixedArrayBase* backing_store = NULL) = 0; | |
| 54 | |
| 55 // Returns the element with the specified key or undefined if there is no such | |
| 56 // element. This method doesn't iterate up the prototype chain. The caller | |
| 57 // can optionally pass in the backing store to use for the check, which must | |
| 58 // be compatible with the ElementsKind of the ElementsAccessor. If | |
| 59 // backing_store is NULL, the holder->elements() is used as the backing store. | |
| 60 virtual MaybeObject* Get(Object* receiver, | |
| 61 JSObject* holder, | |
| 46 uint32_t key, | 62 uint32_t key, |
| 47 JSObject* holder, | 63 FixedArrayBase* backing_store = NULL) = 0; |
| 48 Object* receiver) = 0; | |
| 49 | 64 |
| 50 // Modifies the length data property as specified for JSArrays and resizes the | 65 // Modifies the length data property as specified for JSArrays and resizes the |
| 51 // underlying backing store accordingly. The method honors the semantics of | 66 // underlying backing store accordingly. The method honors the semantics of |
| 52 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that | 67 // changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that |
| 53 // have non-deletable elements can only be shrunk to the size of highest | 68 // have non-deletable elements can only be shrunk to the size of highest |
| 54 // element that is non-deletable. | 69 // element that is non-deletable. |
| 55 virtual MaybeObject* SetLength(JSObject* holder, | 70 virtual MaybeObject* SetLength(JSArray* holder, |
| 56 Object* new_length) = 0; | 71 Object* new_length) = 0; |
| 57 | 72 |
| 58 // Modifies both the length and capacity of a JSArray, resizing the underlying | 73 // Modifies both the length and capacity of a JSArray, resizing the underlying |
| 59 // backing store as necessary. This method does NOT honor the semantics of | 74 // backing store as necessary. This method does NOT honor the semantics of |
| 60 // EcmaScript 5.1 15.4.5.2, arrays can be shrunk beyond non-deletable | 75 // EcmaScript 5.1 15.4.5.2, arrays can be shrunk beyond non-deletable |
| 61 // elements. This method should only be called for array expansion OR by | 76 // elements. This method should only be called for array expansion OR by |
| 62 // runtime JavaScript code that use InternalArrays and don't care about | 77 // runtime JavaScript code that use InternalArrays and don't care about |
| 63 // EcmaScript 5.1 semantics. | 78 // EcmaScript 5.1 semantics. |
| 64 virtual MaybeObject* SetCapacityAndLength(JSArray* array, | 79 virtual MaybeObject* SetCapacityAndLength(JSArray* array, |
| 65 int capacity, | 80 int capacity, |
| 66 int length) = 0; | 81 int length) = 0; |
| 67 | 82 |
| 83 // Deleted an element in an object, returning a new elements backing store. | |
|
Jakob Kummerow
2012/03/06 11:57:43
s/Deleted/Deletes/
danno
2012/03/06 12:21:54
Done.
| |
| 68 virtual MaybeObject* Delete(JSObject* holder, | 84 virtual MaybeObject* Delete(JSObject* holder, |
| 69 uint32_t key, | 85 uint32_t key, |
| 70 JSReceiver::DeleteMode mode) = 0; | 86 JSReceiver::DeleteMode mode) = 0; |
| 71 | 87 |
| 72 virtual bool HasElement(FixedArrayBase* backing_store, | 88 virtual MaybeObject* AddElementsToFixedArray(Object* receiver, |
| 73 uint32_t key, | 89 JSObject* holder, |
| 74 JSObject* holder, | |
| 75 Object* receiver) = 0; | |
| 76 | |
| 77 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, | |
| 78 FixedArray* to, | 90 FixedArray* to, |
| 79 JSObject* holder, | 91 FixedArrayBase* from = NULL) = 0; |
| 80 Object* receiver) = 0; | |
| 81 | 92 |
| 82 // Returns a shared ElementsAccessor for the specified ElementsKind. | 93 // Returns a shared ElementsAccessor for the specified ElementsKind. |
| 83 static ElementsAccessor* ForKind(ElementsKind elements_kind) { | 94 static ElementsAccessor* ForKind(ElementsKind elements_kind) { |
| 84 ASSERT(elements_kind < kElementsKindCount); | 95 ASSERT(elements_kind < kElementsKindCount); |
| 85 return elements_accessors_[elements_kind]; | 96 return elements_accessors_[elements_kind]; |
| 86 } | 97 } |
| 87 | 98 |
| 88 static ElementsAccessor* ForArray(FixedArrayBase* array); | 99 static ElementsAccessor* ForArray(FixedArrayBase* array); |
| 89 | 100 |
| 90 static void InitializeOncePerProcess(); | 101 static void InitializeOncePerProcess(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 108 private: | 119 private: |
| 109 static ElementsAccessor** elements_accessors_; | 120 static ElementsAccessor** elements_accessors_; |
| 110 const char* name_; | 121 const char* name_; |
| 111 | 122 |
| 112 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 123 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
| 113 }; | 124 }; |
| 114 | 125 |
| 115 } } // namespace v8::internal | 126 } } // namespace v8::internal |
| 116 | 127 |
| 117 #endif // V8_ELEMENTS_H_ | 128 #endif // V8_ELEMENTS_H_ |
| OLD | NEW |