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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 int len = Smi::cast(array->length())->value(); | 364 int len = Smi::cast(array->length())->value(); |
365 if (push_size == 0) { | 365 if (push_size == 0) { |
366 return Smi::FromInt(len); | 366 return Smi::FromInt(len); |
367 } | 367 } |
368 if (push_size > 0 && | 368 if (push_size > 0 && |
369 JSArray::WouldChangeReadOnlyLength(array, len + push_size)) { | 369 JSArray::WouldChangeReadOnlyLength(array, len + push_size)) { |
370 return CallJsIntrinsic(isolate, isolate->array_push(), args); | 370 return CallJsIntrinsic(isolate, isolate->array_push(), args); |
371 } | 371 } |
372 DCHECK(!array->map()->is_observed()); | 372 DCHECK(!array->map()->is_observed()); |
373 ElementsAccessor* accessor = array->GetElementsAccessor(); | 373 ElementsAccessor* accessor = array->GetElementsAccessor(); |
374 int new_length = accessor->Push(array, elms_obj, &args[1], push_size, | 374 int new_length = accessor->Push(array, elms_obj, &args, push_size); |
375 ElementsAccessor::kDirectionReverse); | |
376 return Smi::FromInt(new_length); | 375 return Smi::FromInt(new_length); |
377 } | 376 } |
378 | 377 |
379 | 378 |
380 BUILTIN(ArrayPop) { | 379 BUILTIN(ArrayPop) { |
381 HandleScope scope(isolate); | 380 HandleScope scope(isolate); |
382 Handle<Object> receiver = args.receiver(); | 381 Handle<Object> receiver = args.receiver(); |
383 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 382 MaybeHandle<FixedArrayBase> maybe_elms_obj = |
384 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); | 383 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); |
385 Handle<FixedArrayBase> elms_obj; | 384 Handle<FixedArrayBase> elms_obj; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 614 |
616 int add_count = (argument_count > 1) ? (argument_count - 2) : 0; | 615 int add_count = (argument_count > 1) ? (argument_count - 2) : 0; |
617 int new_length = len - actual_delete_count + add_count; | 616 int new_length = len - actual_delete_count + add_count; |
618 | 617 |
619 if (new_length != len && JSArray::HasReadOnlyLength(array)) { | 618 if (new_length != len && JSArray::HasReadOnlyLength(array)) { |
620 AllowHeapAllocation allow_allocation; | 619 AllowHeapAllocation allow_allocation; |
621 return CallJsIntrinsic(isolate, isolate->array_splice(), args); | 620 return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
622 } | 621 } |
623 ElementsAccessor* accessor = array->GetElementsAccessor(); | 622 ElementsAccessor* accessor = array->GetElementsAccessor(); |
624 Handle<JSArray> result_array = accessor->Splice( | 623 Handle<JSArray> result_array = accessor->Splice( |
625 array, elms_obj, actual_start, actual_delete_count, args, add_count); | 624 array, elms_obj, actual_start, actual_delete_count, &args, add_count); |
626 return *result_array; | 625 return *result_array; |
627 } | 626 } |
628 | 627 |
629 | 628 |
630 BUILTIN(ArrayConcat) { | 629 BUILTIN(ArrayConcat) { |
631 HandleScope scope(isolate); | 630 HandleScope scope(isolate); |
632 | 631 |
633 int n_arguments = args.length(); | 632 int n_arguments = args.length(); |
634 int result_len = 0; | 633 int result_len = 0; |
635 ElementsKind elements_kind = GetInitialFastElementsKind(); | 634 ElementsKind elements_kind = GetInitialFastElementsKind(); |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1335 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1337 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1336 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1338 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1337 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
1339 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1338 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1340 #undef DEFINE_BUILTIN_ACCESSOR_C | 1339 #undef DEFINE_BUILTIN_ACCESSOR_C |
1341 #undef DEFINE_BUILTIN_ACCESSOR_A | 1340 #undef DEFINE_BUILTIN_ACCESSOR_A |
1342 | 1341 |
1343 | 1342 |
1344 } // namespace internal | 1343 } // namespace internal |
1345 } // namespace v8 | 1344 } // namespace v8 |
OLD | NEW |