Commit ca7feba7 authored by verwaest's avatar verwaest Committed by Commit bot

Index -> Entry and Key -> Index in elements.[cc|h]

BUG=v8:4137
LOG=n

Review URL: https://codereview.chromium.org/1224643004

Cr-Commit-Position: refs/heads/master@{#29514}
parent 3e966abc
This diff is collapsed.
......@@ -26,32 +26,28 @@ class ElementsAccessor {
// is found.
virtual void Validate(Handle<JSObject> obj) = 0;
// Returns true if a holder contains an element with the specified key
// Returns true if a holder contains an element with the specified index
// without iterating up the prototype chain. The caller can optionally pass
// in the backing store to use for the check, which must be compatible with
// the ElementsKind of the ElementsAccessor. If backing_store is NULL, the
// holder->elements() is used as the backing store.
virtual bool HasElement(
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) = 0;
inline bool HasElement(
Handle<JSObject> holder,
uint32_t key) {
return HasElement(holder, key, handle(holder->elements()));
virtual bool HasElement(Handle<JSObject> holder, uint32_t index,
Handle<FixedArrayBase> backing_store) = 0;
inline bool HasElement(Handle<JSObject> holder, uint32_t index) {
return HasElement(holder, index, handle(holder->elements()));
}
// Returns the element with the specified key or undefined if there is no such
// element. This method doesn't iterate up the prototype chain. The caller
// can optionally pass in the backing store to use for the check, which must
// be compatible with the ElementsKind of the ElementsAccessor. If
// Returns the element with the specified index or undefined if there is no
// such element. This method doesn't iterate up the prototype chain. The
// caller can optionally pass in the backing store to use for the check, which
// must be compatible with the ElementsKind of the ElementsAccessor. If
// backing_store is NULL, the holder->elements() is used as the backing store.
virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key,
virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t index,
Handle<FixedArrayBase> backing_store) = 0;
inline Handle<Object> Get(Handle<JSObject> holder, uint32_t key) {
return Get(holder, key, handle(holder->elements()));
inline Handle<Object> Get(Handle<JSObject> holder, uint32_t index) {
return Get(holder, index, handle(holder->elements()));
}
// Modifies the length data property as specified for JSArrays and resizes the
......@@ -62,7 +58,7 @@ class ElementsAccessor {
virtual void SetLength(Handle<JSArray> holder, uint32_t new_length) = 0;
// Deletes an element in an object.
virtual void Delete(Handle<JSObject> holder, uint32_t index) = 0;
virtual void Delete(Handle<JSObject> holder, uint32_t entry) = 0;
// If kCopyToEnd is specified as the copy_size to CopyElements, it copies all
// of elements from source after source_start to the destination array.
......@@ -123,13 +119,13 @@ class ElementsAccessor {
static void InitializeOncePerProcess();
static void TearDown();
virtual void Set(FixedArrayBase* backing_store, uint32_t key,
virtual void Set(FixedArrayBase* backing_store, uint32_t index,
Object* value) = 0;
virtual void Reconfigure(Handle<JSObject> object,
Handle<FixedArrayBase> backing_store, uint32_t index,
Handle<FixedArrayBase> backing_store, uint32_t entry,
Handle<Object> value,
PropertyAttributes attributes) = 0;
virtual void Add(Handle<JSObject> object, uint32_t index,
virtual void Add(Handle<JSObject> object, uint32_t entry,
Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) = 0;
......@@ -141,22 +137,19 @@ class ElementsAccessor {
virtual uint32_t GetCapacity(JSObject* holder,
FixedArrayBase* backing_store) = 0;
// Element handlers distinguish between indexes and keys when they manipulate
// elements. Indexes refer to elements in terms of their location in the
// underlying storage's backing store representation, and are between 0 and
// GetCapacity. Keys refer to elements in terms of the value that would be
// specified in JavaScript to access the element. In most implementations,
// keys are equivalent to indexes, and GetKeyForIndex returns the same value
// it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps
// the index to a key using the KeyAt method on the NumberDictionary.
virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
uint32_t index) = 0;
virtual uint32_t GetIndexForKey(JSObject* holder,
FixedArrayBase* backing_store,
uint32_t key) = 0;
// Element handlers distinguish between entries and indices when they
// manipulate elements. Entries refer to elements in terms of their location
// in the underlying storage's backing store representation, and are between 0
// and GetCapacity. Indices refer to elements in terms of the value that would
// be specified in JavaScript to access the element. In most implementations,
// indices are equivalent to entries. In the NumberDictionary
// ElementsAccessor, entries are mapped to an index using the KeyAt method on
// the NumberDictionary.
virtual uint32_t GetEntryForIndex(JSObject* holder,
FixedArrayBase* backing_store,
uint32_t index) = 0;
virtual PropertyDetails GetDetails(FixedArrayBase* backing_store,
uint32_t index) = 0;
virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t key) = 0;
uint32_t entry) = 0;
private:
static ElementsAccessor** elements_accessors_;
......@@ -165,7 +158,7 @@ class ElementsAccessor {
DISALLOW_COPY_AND_ASSIGN(ElementsAccessor);
};
void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key,
void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index,
bool allow_appending = false);
MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements(
......
......@@ -74,7 +74,8 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* const map,
ElementsAccessor* accessor = js_object->GetElementsAccessor();
FixedArrayBase* backing_store = js_object->elements();
number_ = accessor->GetIndexForKey(js_object, backing_store, index_);
number_ =
accessor->GetEntryForIndex(js_object, backing_store, index_);
if (number_ == kMaxUInt32) return NOT_FOUND;
property_details_ = accessor->GetDetails(backing_store, number_);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment