Commit 161cc3cd authored by rafaelw@chromium.org's avatar rafaelw@chromium.org

Handlify JSObject::SetElement & brethren

Because SetElement & co are interdependent, this patch handlfies all of JSObject::
-SetElement
-SetFastElement
-SetDictionaryElement
-SetFastDoubleElement
-SetElementWithInterceptor
-SetElementWithoutInterceptor
-SetElementWithCallbackSetterInPrototype

R=mstarzinger@chromium.org
LOG=N

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17757 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6befb8d5
......@@ -451,6 +451,15 @@ Handle<Struct> Factory::NewStruct(InstanceType type) {
}
Handle<AliasedArgumentsEntry> Factory::NewAliasedArgumentsEntry(
int aliased_context_slot) {
Handle<AliasedArgumentsEntry> entry = Handle<AliasedArgumentsEntry>::cast(
NewStruct(ALIASED_ARGUMENTS_ENTRY_TYPE));
entry->set_aliased_context_slot(aliased_context_slot);
return entry;
}
Handle<DeclaredAccessorDescriptor> Factory::NewDeclaredAccessorDescriptor() {
return Handle<DeclaredAccessorDescriptor>::cast(
NewStruct(DECLARED_ACCESSOR_DESCRIPTOR_TYPE));
......
......@@ -224,6 +224,9 @@ class Factory {
// the old generation).
Handle<Struct> NewStruct(InstanceType type);
Handle<AliasedArgumentsEntry> NewAliasedArgumentsEntry(
int aliased_context_slot);
Handle<DeclaredAccessorDescriptor> NewDeclaredAccessorDescriptor();
Handle<DeclaredAccessorInfo> NewDeclaredAccessorInfo();
......
This diff is collapsed.
This diff is collapsed.
......@@ -9821,22 +9821,22 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldDataSpace) {
// array. Returns true if the element was pushed on the stack and
// false otherwise.
RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) {
SealHandleScope shs(isolate);
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSArray, array, 0);
CONVERT_ARG_CHECKED(JSReceiver, element, 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1);
RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
int length = Smi::cast(array->length())->value();
FixedArray* elements = FixedArray::cast(array->elements());
for (int i = 0; i < length; i++) {
if (elements->get(i) == element) return isolate->heap()->false_value();
if (elements->get(i) == *element) return isolate->heap()->false_value();
}
Object* obj;
// Strict not needed. Used for cycle detection in Array join implementation.
{ MaybeObject* maybe_obj =
array->SetFastElement(length, element, kNonStrictMode, true);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length,
element,
kNonStrictMode,
true));
return isolate->heap()->true_value();
}
......
......@@ -760,7 +760,7 @@ TEST(JSArray) {
CHECK(array->HasFastSmiOrObjectElements());
// array[length] = name.
array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked();
JSReceiver::SetElement(array, 0, name, NONE, kNonStrictMode);
CHECK_EQ(Smi::FromInt(1), array->length());
CHECK_EQ(array->GetElement(isolate, 0), *name);
......@@ -775,7 +775,7 @@ TEST(JSArray) {
CHECK(array->HasDictionaryElements()); // Must be in slow mode.
// array[length] = name.
array->SetElement(int_length, *name, NONE, kNonStrictMode)->ToObjectChecked();
JSReceiver::SetElement(array, int_length, name, NONE, kNonStrictMode);
uint32_t new_int_length = 0;
CHECK(array->length()->ToArrayIndex(&new_int_length));
CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
......@@ -805,8 +805,8 @@ TEST(JSObjectCopy) {
JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode);
JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode);
obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked();
obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked();
JSReceiver::SetElement(obj, 0, first, NONE, kNonStrictMode);
JSReceiver::SetElement(obj, 1, second, NONE, kNonStrictMode);
// Make the clone.
Handle<JSObject> clone = JSObject::Copy(obj);
......@@ -822,8 +822,8 @@ TEST(JSObjectCopy) {
JSReceiver::SetProperty(clone, first, two, NONE, kNonStrictMode);
JSReceiver::SetProperty(clone, second, one, NONE, kNonStrictMode);
clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked();
clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked();
JSReceiver::SetElement(clone, 0, second, NONE, kNonStrictMode);
JSReceiver::SetElement(clone, 1, first, NONE, kNonStrictMode);
CHECK_EQ(obj->GetElement(isolate, 1), clone->GetElement(isolate, 0));
CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 1));
......
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