OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/builtins.h" | 5 #include "src/builtins.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 BUILTIN(ArraySlice) { | 451 BUILTIN(ArraySlice) { |
452 HandleScope scope(isolate); | 452 HandleScope scope(isolate); |
453 Handle<Object> receiver = args.receiver(); | 453 Handle<Object> receiver = args.receiver(); |
454 Handle<JSObject> object; | 454 Handle<JSObject> object; |
455 Handle<FixedArrayBase> elms_obj; | 455 Handle<FixedArrayBase> elms_obj; |
456 int len = -1; | 456 int len = -1; |
457 int relative_start = 0; | 457 int relative_start = 0; |
458 int relative_end = 0; | 458 int relative_end = 0; |
459 bool is_sloppy_arguments = false; | 459 bool is_sloppy_arguments = false; |
460 | 460 |
| 461 // TODO(littledan): Look up @@species only once, not once here and |
| 462 // again in the JS builtin. Pass the species out? |
| 463 Handle<Object> species; |
| 464 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 465 isolate, species, Object::ArraySpeciesConstructor(isolate, receiver)); |
| 466 if (*species != isolate->context()->native_context()->array_function()) { |
| 467 return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
| 468 } |
461 if (receiver->IsJSArray()) { | 469 if (receiver->IsJSArray()) { |
462 DisallowHeapAllocation no_gc; | 470 DisallowHeapAllocation no_gc; |
463 JSArray* array = JSArray::cast(*receiver); | 471 JSArray* array = JSArray::cast(*receiver); |
464 if (!array->HasFastElements() || | 472 if (!array->HasFastElements() || |
465 !IsJSArrayFastElementMovingAllowed(isolate, array)) { | 473 !IsJSArrayFastElementMovingAllowed(isolate, array)) { |
466 AllowHeapAllocation allow_allocation; | 474 AllowHeapAllocation allow_allocation; |
467 return CallJsIntrinsic(isolate, isolate->array_slice(), args); | 475 return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
468 } | 476 } |
469 len = Smi::cast(array->length())->value(); | 477 len = Smi::cast(array->length())->value(); |
470 object = Handle<JSObject>::cast(receiver); | 478 object = Handle<JSObject>::cast(receiver); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 544 |
537 BUILTIN(ArraySplice) { | 545 BUILTIN(ArraySplice) { |
538 HandleScope scope(isolate); | 546 HandleScope scope(isolate); |
539 Handle<Object> receiver = args.receiver(); | 547 Handle<Object> receiver = args.receiver(); |
540 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 548 MaybeHandle<FixedArrayBase> maybe_elms_obj = |
541 EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3); | 549 EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3); |
542 Handle<FixedArrayBase> elms_obj; | 550 Handle<FixedArrayBase> elms_obj; |
543 if (!maybe_elms_obj.ToHandle(&elms_obj)) { | 551 if (!maybe_elms_obj.ToHandle(&elms_obj)) { |
544 return CallJsIntrinsic(isolate, isolate->array_splice(), args); | 552 return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
545 } | 553 } |
| 554 // TODO(littledan): Look up @@species only once, not once here and |
| 555 // again in the JS builtin. Pass the species out? |
| 556 Handle<Object> species; |
| 557 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 558 isolate, species, Object::ArraySpeciesConstructor(isolate, receiver)); |
| 559 if (*species != isolate->context()->native_context()->array_function()) { |
| 560 return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
| 561 } |
546 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 562 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
547 DCHECK(!array->map()->is_observed()); | 563 DCHECK(!array->map()->is_observed()); |
548 | 564 |
549 int argument_count = args.length() - 1; | 565 int argument_count = args.length() - 1; |
550 int relative_start = 0; | 566 int relative_start = 0; |
551 if (argument_count > 0) { | 567 if (argument_count > 0) { |
552 DisallowHeapAllocation no_gc; | 568 DisallowHeapAllocation no_gc; |
553 if (!ClampedToInteger(args[1], &relative_start)) { | 569 if (!ClampedToInteger(args[1], &relative_start)) { |
554 AllowHeapAllocation allow_allocation; | 570 AllowHeapAllocation allow_allocation; |
555 return CallJsIntrinsic(isolate, isolate->array_splice(), args); | 571 return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 3309 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
3294 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 3310 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
3295 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 3311 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
3296 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 3312 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
3297 #undef DEFINE_BUILTIN_ACCESSOR_C | 3313 #undef DEFINE_BUILTIN_ACCESSOR_C |
3298 #undef DEFINE_BUILTIN_ACCESSOR_A | 3314 #undef DEFINE_BUILTIN_ACCESSOR_A |
3299 | 3315 |
3300 | 3316 |
3301 } // namespace internal | 3317 } // namespace internal |
3302 } // namespace v8 | 3318 } // namespace v8 |
OLD | NEW |