Revision: 20616
Author: [email protected]
Date: Wed Apr 9 12:56:24 2014 UTC
Log: Reland of r20606: Further ElementsAccessor handlification
(GetKeyForIndex(), GetCapacity(), GetType() and GetAttributes()).
It was not related to test failures.
[email protected]
Review URL: https://codereview.chromium.org/230373007
http://code.google.com/p/v8/source/detail?r=20616
Modified:
/branches/bleeding_edge/src/elements.cc
/branches/bleeding_edge/src/elements.h
=======================================
--- /branches/bleeding_edge/src/elements.cc Wed Apr 9 10:58:17 2014 UTC
+++ /branches/bleeding_edge/src/elements.cc Wed Apr 9 12:56:24 2014 UTC
@@ -146,7 +146,9 @@
ElementsAccessor** ElementsAccessor::elements_accessors_;
-static bool HasKey(FixedArray* array, Object* key) {
+static bool HasKey(Handle<FixedArray> array, Handle<Object> key_handle) {
+ DisallowHeapAllocation no_gc;
+ Object* key = *key_handle;
int len0 = array->length();
for (int i = 0; i < len0; i++) {
Object* element = array->get(i);
@@ -621,7 +623,7 @@
uint32_t key,
Handle<FixedArrayBase> backing_store) {
return ElementsAccessorSubclass::GetAttributesImpl(
- *receiver, *holder, key, *backing_store) != ABSENT;
+ receiver, holder, key, backing_store) != ABSENT;
}
virtual bool HasElement(
@@ -657,7 +659,7 @@
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
- if (key < ElementsAccessorSubclass::GetCapacityImpl(*backing_store)) {
+ if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
return BackingStore::get(Handle<BackingStore>::cast(backing_store),
key);
} else {
return backing_store->GetIsolate()->factory()->the_hole_value();
@@ -670,28 +672,20 @@
uint32_t key,
Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE {
return ElementsAccessorSubclass::GetAttributesImpl(
- *receiver, *holder, key, *backing_store);
- }
-
- // TODO(ishell): To be removed once elements.cc is handlified.
- MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
- Object* receiver,
- JSObject* holder,
- uint32_t key,
- FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE {
- return ElementsAccessorSubclass::GetAttributesImpl(
receiver, holder, key, backing_store);
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* backing_store) {
+ Handle<FixedArrayBase> backing_store) {
if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
return ABSENT;
}
- return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT :
NONE;
+ return
+ Handle<BackingStore>::cast(backing_store)->is_the_hole(key)
+ ? ABSENT : NONE;
}
MUST_USE_RESULT virtual PropertyType GetType(
@@ -700,29 +694,20 @@
uint32_t key,
Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE {
return ElementsAccessorSubclass::GetTypeImpl(
- *receiver, *holder, key, *backing_store);
- }
-
- // TODO(ishell): To be removed once elements.cc is handlified.
- MUST_USE_RESULT virtual PropertyType GetType(
- Object* receiver,
- JSObject* holder,
- uint32_t key,
- FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE {
- return ElementsAccessorSubclass::GetTypeImpl(
receiver, holder, key, backing_store);
}
MUST_USE_RESULT static PropertyType GetTypeImpl(
- Object* receiver,
- JSObject* obj,
- uint32_t key,
- FixedArrayBase* backing_store) {
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
+ uint32_t key,
+ Handle<FixedArrayBase> backing_store) {
if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
return NONEXISTENT;
}
- return BackingStore::cast(backing_store)->is_the_hole(key)
- ? NONEXISTENT : FIELD;
+ return
+ Handle<BackingStore>::cast(backing_store)->is_the_hole(key)
+ ? NONEXISTENT : FIELD;
}
MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair(
@@ -835,20 +820,20 @@
// Optimize if 'other' is empty.
// We cannot optimize if 'this' is empty, as other may have holes.
- uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(*from);
+ uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from);
if (len1 == 0) return to;
// Compute how many elements are not in other.
uint32_t extra = 0;
for (uint32_t y = 0; y < len1; y++) {
- uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(*from,
y);
+ uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
if (ElementsAccessorSubclass::HasElementImpl(
receiver, holder, key, from)) {
Handle<Object> value =
ElementsAccessorSubclass::GetImpl(receiver, holder, key, from);
ASSERT(!value->IsTheHole());
- if (!HasKey(*to, *value)) {
+ if (!HasKey(to, value)) {
extra++;
}
}
@@ -874,12 +859,12 @@
uint32_t index = 0;
for (uint32_t y = 0; y < len1; y++) {
uint32_t key =
- ElementsAccessorSubclass::GetKeyForIndexImpl(*from, y);
+ ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
if (ElementsAccessorSubclass::HasElementImpl(
receiver, holder, key, from)) {
Handle<Object> value =
ElementsAccessorSubclass::GetImpl(receiver, holder, key, from);
- if (!value->IsTheHole() && !HasKey(*to, *value)) {
+ if (!value->IsTheHole() && !HasKey(to, value)) {
result->set(len0 + index, *value);
index++;
}
@@ -890,23 +875,23 @@
}
protected:
- static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) {
+ static uint32_t GetCapacityImpl(Handle<FixedArrayBase> backing_store) {
return backing_store->length();
}
- virtual uint32_t GetCapacity(FixedArrayBase* backing_store)
+ virtual uint32_t GetCapacity(Handle<FixedArrayBase> backing_store)
V8_FINAL V8_OVERRIDE {
return ElementsAccessorSubclass::GetCapacityImpl(backing_store);
}
- static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store,
+ static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> backing_store,
uint32_t index) {
return index;
}
virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store,
uint32_t index) V8_FINAL V8_OVERRIDE {
- return ElementsAccessorSubclass::GetKeyForIndexImpl(*backing_store,
index);
+ return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store,
index);
}
private:
@@ -1094,7 +1079,7 @@
};
-static inline ElementsKind ElementsKindForArray(FixedArrayBase* array) {
+static inline ElementsKind ElementsKindForArray(Handle<FixedArrayBase>
array) {
switch (array->map()->instance_type()) {
case FIXED_ARRAY_TYPE:
if (array->IsDictionary()) {
@@ -1165,7 +1150,7 @@
Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(from);
Handle<FixedArrayBase> arguments(
FixedArrayBase::cast(parameter_map->get(1)));
- ElementsKind from_kind = ElementsKindForArray(*arguments);
+ ElementsKind from_kind = ElementsKindForArray(arguments);
CopyElementsImpl(arguments, from_start, to, from_kind,
to_start, packed_size, copy_size);
break;
@@ -1352,7 +1337,7 @@
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
- if (key < AccessorClass::GetCapacityImpl(*backing_store)) {
+ if (key < AccessorClass::GetCapacityImpl(backing_store)) {
return BackingStore::get(Handle<BackingStore>::cast(backing_store),
key);
} else {
return backing_store->GetIsolate()->factory()->undefined_value();
@@ -1360,20 +1345,20 @@
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* backing_store) {
+ Handle<FixedArrayBase> backing_store) {
return
key < AccessorClass::GetCapacityImpl(backing_store)
? NONE : ABSENT;
}
MUST_USE_RESULT static PropertyType GetTypeImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* backing_store) {
+ Handle<FixedArrayBase> backing_store) {
return
key < AccessorClass::GetCapacityImpl(backing_store)
? FIELD : NONEXISTENT;
@@ -1401,7 +1386,7 @@
uint32_t key,
Handle<FixedArrayBase> backing_store) {
uint32_t capacity =
- AccessorClass::GetCapacityImpl(*backing_store);
+ AccessorClass::GetCapacityImpl(backing_store);
return key < capacity;
}
};
@@ -1603,12 +1588,12 @@
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* backing_store) {
- SeededNumberDictionary* dictionary =
- SeededNumberDictionary::cast(backing_store);
+ Handle<FixedArrayBase> backing_store) {
+ Handle<SeededNumberDictionary> dictionary =
+ Handle<SeededNumberDictionary>::cast(backing_store);
int entry = dictionary->FindEntry(key);
if (entry != SeededNumberDictionary::kNotFound) {
return dictionary->DetailsAt(entry).attributes();
@@ -1617,11 +1602,12 @@
}
MUST_USE_RESULT static PropertyType GetTypeImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* store) {
- SeededNumberDictionary* backing_store =
SeededNumberDictionary::cast(store);
+ Handle<FixedArrayBase> store) {
+ Handle<SeededNumberDictionary> backing_store =
+ Handle<SeededNumberDictionary>::cast(store);
int entry = backing_store->FindEntry(key);
if (entry != SeededNumberDictionary::kNotFound) {
return backing_store->DetailsAt(entry).type();
@@ -1654,10 +1640,11 @@
return backing_store->FindEntry(key) !=
SeededNumberDictionary::kNotFound;
}
- // TODO(ishell): Handlify when all callers are handlified.
- static uint32_t GetKeyForIndexImpl(FixedArrayBase* store,
+ static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> store,
uint32_t index) {
- SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
+ DisallowHeapAllocation no_gc;
+ Handle<SeededNumberDictionary> dict =
+ Handle<SeededNumberDictionary>::cast(store);
Object* key = dict->KeyAt(index);
return Smi::cast(key)->value();
}
@@ -1712,34 +1699,34 @@
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* backing_store) {
- FixedArray* parameter_map = FixedArray::cast(backing_store);
- Object* probe = GetParameterMapArg(obj, parameter_map, key);
+ Handle<FixedArrayBase> backing_store) {
+ Handle<FixedArray> parameter_map =
Handle<FixedArray>::cast(backing_store);
+ Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
if (!probe->IsTheHole()) {
return NONE;
} else {
// If not aliased, check the arguments.
- FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
+ Handle<FixedArray>
arguments(FixedArray::cast(parameter_map->get(1)));
return ElementsAccessor::ForArray(arguments)->GetAttributes(
receiver, obj, key, arguments);
}
}
MUST_USE_RESULT static PropertyType GetTypeImpl(
- Object* receiver,
- JSObject* obj,
+ Handle<Object> receiver,
+ Handle<JSObject> obj,
uint32_t key,
- FixedArrayBase* parameters) {
- FixedArray* parameter_map = FixedArray::cast(parameters);
- Object* probe = GetParameterMapArg(obj, parameter_map, key);
+ Handle<FixedArrayBase> parameters) {
+ Handle<FixedArray> parameter_map =
Handle<FixedArray>::cast(parameters);
+ Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
if (!probe->IsTheHole()) {
return FIELD;
} else {
// If not aliased, check the arguments.
- FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
+ Handle<FixedArray>
arguments(FixedArray::cast(parameter_map->get(1)));
return ElementsAccessor::ForArray(arguments)->GetType(
receiver, obj, key, arguments);
}
@@ -1808,15 +1795,15 @@
UNREACHABLE();
}
- static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) {
- FixedArray* parameter_map = FixedArray::cast(backing_store);
- FixedArrayBase* arguments =
FixedArrayBase::cast(parameter_map->get(1));
+ static uint32_t GetCapacityImpl(Handle<FixedArrayBase> backing_store) {
+ Handle<FixedArray> parameter_map =
Handle<FixedArray>::cast(backing_store);
+ Handle<FixedArrayBase> arguments(
+ FixedArrayBase::cast(parameter_map->get(1)));
return Max(static_cast<uint32_t>(parameter_map->length() - 2),
ForArray(arguments)->GetCapacity(arguments));
}
- // TODO(ishell): Handlify when all callers are handlified.
- static uint32_t GetKeyForIndexImpl(FixedArrayBase* dict,
+ static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> dict,
uint32_t index) {
return index;
}
@@ -1838,18 +1825,6 @@
}
private:
- // TODO(ishell): remove when all usages are handlified.
- static Object* GetParameterMapArg(JSObject* holder,
- FixedArray* parameter_map,
- uint32_t key) {
- uint32_t length = holder->IsJSArray()
- ? Smi::cast(JSArray::cast(holder)->length())->value()
- : parameter_map->length();
- return key < (length - 2)
- ? parameter_map->get(key + 2)
- : parameter_map->GetHeap()->the_hole_value();
- }
-
static Handle<Object> GetParameterMapArg(Handle<JSObject> holder,
Handle<FixedArray>
parameter_map,
uint32_t key) {
@@ -1864,7 +1839,7 @@
};
-ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) {
+ElementsAccessor* ElementsAccessor::ForArray(Handle<FixedArrayBase> array)
{
return elements_accessors_[ElementsKindForArray(array)];
}
=======================================
--- /branches/bleeding_edge/src/elements.h Wed Apr 9 10:58:17 2014 UTC
+++ /branches/bleeding_edge/src/elements.h Wed Apr 9 12:56:24 2014 UTC
@@ -226,11 +226,7 @@
return elements_accessors_[elements_kind];
}
- // TODO(ishell): Temporary wrapper until handlified.
- inline static ElementsAccessor* ForArray(Handle<FixedArrayBase> array) {
- return ForArray(*array);
- }
- static ElementsAccessor* ForArray(FixedArrayBase* array);
+ static ElementsAccessor* ForArray(Handle<FixedArrayBase> array);
static void InitializeOncePerProcess();
static void TearDown();
@@ -238,7 +234,7 @@
protected:
friend class SloppyArgumentsElementsAccessor;
- virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0;
+ virtual uint32_t GetCapacity(Handle<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
@@ -251,20 +247,6 @@
virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store,
uint32_t index) = 0;
- // TODO(ishell): Non-handlified versions, used only by accessors'
- // implementations. To be removed once elements.cc is handlified.
- MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
- Object* receiver,
- JSObject* holder,
- uint32_t key,
- FixedArrayBase* backing_store) = 0;
-
- MUST_USE_RESULT virtual PropertyType GetType(
- Object* receiver,
- JSObject* holder,
- uint32_t key,
- FixedArrayBase* backing_store) = 0;
-
private:
static ElementsAccessor** elements_accessors_;
const char* name_;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.