| Index: src/builtins.cc
|
| ===================================================================
|
| --- src/builtins.cc (revision 7006)
|
| +++ src/builtins.cc (working copy)
|
| @@ -373,7 +373,9 @@
|
| array_proto = JSObject::cast(array_proto->GetPrototype());
|
| ASSERT(array_proto->elements() == heap->empty_fixed_array());
|
| // Object.prototype
|
| - array_proto = JSObject::cast(array_proto->GetPrototype());
|
| + Object* proto = array_proto->GetPrototype();
|
| + if (proto == heap->null_value()) return false;
|
| + array_proto = JSObject::cast(proto);
|
| if (array_proto != global_context->initial_object_prototype()) return false;
|
| if (array_proto->elements() != heap->empty_fixed_array()) return false;
|
| ASSERT(array_proto->GetPrototype()->IsNull());
|
| @@ -753,35 +755,39 @@
|
|
|
| int n_arguments = args.length() - 1;
|
|
|
| - // Return empty array when no arguments are supplied.
|
| - if (n_arguments == 0) {
|
| - return AllocateEmptyJSArray(heap);
|
| - }
|
| -
|
| int relative_start = 0;
|
| - Object* arg1 = args[1];
|
| - if (arg1->IsSmi()) {
|
| - relative_start = Smi::cast(arg1)->value();
|
| - } else if (!arg1->IsUndefined()) {
|
| - return CallJsBuiltin(isolate, "ArraySplice", args);
|
| + if (n_arguments > 0) {
|
| + Object* arg1 = args[1];
|
| + if (arg1->IsSmi()) {
|
| + relative_start = Smi::cast(arg1)->value();
|
| + } else if (!arg1->IsUndefined()) {
|
| + return CallJsBuiltin(isolate, "ArraySplice", args);
|
| + }
|
| }
|
| int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
|
| : Min(relative_start, len);
|
|
|
| // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is
|
| - // given differently from when an undefined delete count is given.
|
| + // given as a request to delete all the elements from the start.
|
| + // And it differs from the case of undefined delete count.
|
| // This does not follow ECMA-262, but we do the same for
|
| // compatibility.
|
| - int delete_count = len;
|
| - if (n_arguments > 1) {
|
| - Object* arg2 = args[2];
|
| - if (arg2->IsSmi()) {
|
| - delete_count = Smi::cast(arg2)->value();
|
| - } else {
|
| - return CallJsBuiltin(isolate, "ArraySplice", args);
|
| + int actual_delete_count;
|
| + if (n_arguments == 1) {
|
| + ASSERT(len - actual_start >= 0);
|
| + actual_delete_count = len - actual_start;
|
| + } else {
|
| + int value = 0; // ToInteger(undefined) == 0
|
| + if (n_arguments > 1) {
|
| + Object* arg2 = args[2];
|
| + if (arg2->IsSmi()) {
|
| + value = Smi::cast(arg2)->value();
|
| + } else {
|
| + return CallJsBuiltin(isolate, "ArraySplice", args);
|
| + }
|
| }
|
| + actual_delete_count = Min(Max(value, 0), len - actual_start);
|
| }
|
| - int actual_delete_count = Min(Max(delete_count, 0), len - actual_start);
|
|
|
| JSArray* result_array = NULL;
|
| if (actual_delete_count == 0) {
|
|
|