OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 // Take the arguments as elements. | 236 // Take the arguments as elements. |
237 int number_of_elements = args.length() - 1; | 237 int number_of_elements = args.length() - 1; |
238 Smi* len = Smi::FromInt(number_of_elements); | 238 Smi* len = Smi::FromInt(number_of_elements); |
239 Object* obj; | 239 Object* obj; |
240 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len->value()); | 240 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len->value()); |
241 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 241 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
242 } | 242 } |
243 | 243 |
244 // Set length and elements on the array. | 244 // Set length and elements on the array. |
245 if (FLAG_smi_only_arrays) { | 245 MaybeObject* maybe_object = |
246 MaybeObject* maybe_object = | 246 array->EnsureCanContainElements(FixedArray::cast(obj)); |
247 array->EnsureCanContainElements(FixedArray::cast(obj)); | 247 if (maybe_object->IsFailure()) return maybe_object; |
248 if (maybe_object->IsFailure()) return maybe_object; | |
249 } | |
250 | 248 |
251 AssertNoAllocation no_gc; | 249 AssertNoAllocation no_gc; |
252 FixedArray* elms = FixedArray::cast(obj); | 250 FixedArray* elms = FixedArray::cast(obj); |
253 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); | 251 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); |
254 // Fill in the content | 252 // Fill in the content |
255 for (int index = 0; index < number_of_elements; index++) { | 253 for (int index = 0; index < number_of_elements; index++) { |
256 elms->set(index, args[index+1], mode); | 254 elms->set(index, args[index+1], mode); |
257 } | 255 } |
258 | 256 |
259 array->set_elements(FixedArray::cast(obj)); | 257 array->set_elements(FixedArray::cast(obj)); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 if (proto == heap->null_value()) return false; | 393 if (proto == heap->null_value()) return false; |
396 array_proto = JSObject::cast(proto); | 394 array_proto = JSObject::cast(proto); |
397 if (array_proto != global_context->initial_object_prototype()) return false; | 395 if (array_proto != global_context->initial_object_prototype()) return false; |
398 if (array_proto->elements() != heap->empty_fixed_array()) return false; | 396 if (array_proto->elements() != heap->empty_fixed_array()) return false; |
399 return array_proto->GetPrototype()->IsNull(); | 397 return array_proto->GetPrototype()->IsNull(); |
400 } | 398 } |
401 | 399 |
402 | 400 |
403 MUST_USE_RESULT | 401 MUST_USE_RESULT |
404 static inline MaybeObject* EnsureJSArrayWithWritableFastElements( | 402 static inline MaybeObject* EnsureJSArrayWithWritableFastElements( |
405 Heap* heap, Object* receiver) { | 403 Heap* heap, Object* receiver, Arguments* args, int first_added_arg) { |
406 if (!receiver->IsJSArray()) return NULL; | 404 if (!receiver->IsJSArray()) return NULL; |
407 JSArray* array = JSArray::cast(receiver); | 405 JSArray* array = JSArray::cast(receiver); |
408 HeapObject* elms = array->elements(); | 406 HeapObject* elms = array->elements(); |
409 if (elms->map() == heap->fixed_array_map()) return elms; | 407 Map* map = elms->map(); |
410 if (elms->map() == heap->fixed_cow_array_map()) { | 408 if (map == heap->fixed_array_map()) { |
411 return array->EnsureWritableFastElements(); | 409 if (args == NULL || !array->HasFastSmiOnlyElements()) { |
| 410 return elms; |
| 411 } |
| 412 } else if (map == heap->fixed_cow_array_map()) { |
| 413 MaybeObject* maybe_writable_result = array->EnsureWritableFastElements(); |
| 414 if (args == NULL || !array->HasFastSmiOnlyElements() || |
| 415 maybe_writable_result->IsFailure()) { |
| 416 return maybe_writable_result; |
| 417 } |
| 418 } else { |
| 419 return NULL; |
412 } | 420 } |
413 return NULL; | 421 |
| 422 // Need to ensure that the arguments passed in args can be contained in |
| 423 // the array. |
| 424 int args_length = args->length(); |
| 425 if (first_added_arg >= args_length) return array->elements(); |
| 426 |
| 427 MaybeObject* maybe_array = array->EnsureCanContainElements( |
| 428 args, |
| 429 first_added_arg, |
| 430 args_length - first_added_arg); |
| 431 if (maybe_array->IsFailure()) return maybe_array; |
| 432 return array->elements(); |
414 } | 433 } |
415 | 434 |
416 | 435 |
417 static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap, | 436 static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap, |
418 JSArray* receiver) { | 437 JSArray* receiver) { |
419 Context* global_context = heap->isolate()->context()->global_context(); | 438 Context* global_context = heap->isolate()->context()->global_context(); |
420 JSObject* array_proto = | 439 JSObject* array_proto = |
421 JSObject::cast(global_context->array_function()->prototype()); | 440 JSObject::cast(global_context->array_function()->prototype()); |
422 return receiver->GetPrototype() == array_proto && | 441 return receiver->GetPrototype() == array_proto && |
423 ArrayPrototypeHasNoElements(heap, global_context, array_proto); | 442 ArrayPrototypeHasNoElements(heap, global_context, array_proto); |
(...skipping 26 matching lines...) Expand all Loading... |
450 if (pending_exception) return Failure::Exception(); | 469 if (pending_exception) return Failure::Exception(); |
451 return *result; | 470 return *result; |
452 } | 471 } |
453 | 472 |
454 | 473 |
455 BUILTIN(ArrayPush) { | 474 BUILTIN(ArrayPush) { |
456 Heap* heap = isolate->heap(); | 475 Heap* heap = isolate->heap(); |
457 Object* receiver = *args.receiver(); | 476 Object* receiver = *args.receiver(); |
458 Object* elms_obj; | 477 Object* elms_obj; |
459 { MaybeObject* maybe_elms_obj = | 478 { MaybeObject* maybe_elms_obj = |
460 EnsureJSArrayWithWritableFastElements(heap, receiver); | 479 EnsureJSArrayWithWritableFastElements(heap, receiver, &args, 1); |
461 if (maybe_elms_obj == NULL) { | 480 if (maybe_elms_obj == NULL) { |
462 return CallJsBuiltin(isolate, "ArrayPush", args); | 481 return CallJsBuiltin(isolate, "ArrayPush", args); |
463 } | 482 } |
464 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 483 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
465 } | 484 } |
466 FixedArray* elms = FixedArray::cast(elms_obj); | 485 FixedArray* elms = FixedArray::cast(elms_obj); |
467 JSArray* array = JSArray::cast(receiver); | 486 JSArray* array = JSArray::cast(receiver); |
468 | 487 |
469 int len = Smi::cast(array->length())->value(); | 488 int len = Smi::cast(array->length())->value(); |
470 int to_add = args.length() - 1; | 489 int to_add = args.length() - 1; |
(...skipping 17 matching lines...) Expand all Loading... |
488 | 507 |
489 AssertNoAllocation no_gc; | 508 AssertNoAllocation no_gc; |
490 if (len > 0) { | 509 if (len > 0) { |
491 CopyElements(heap, &no_gc, new_elms, 0, elms, 0, len); | 510 CopyElements(heap, &no_gc, new_elms, 0, elms, 0, len); |
492 } | 511 } |
493 FillWithHoles(heap, new_elms, new_length, capacity); | 512 FillWithHoles(heap, new_elms, new_length, capacity); |
494 | 513 |
495 elms = new_elms; | 514 elms = new_elms; |
496 } | 515 } |
497 | 516 |
498 MaybeObject* maybe = array->EnsureCanContainElements(&args, 1, to_add); | |
499 if (maybe->IsFailure()) return maybe; | |
500 | |
501 // Add the provided values. | 517 // Add the provided values. |
502 AssertNoAllocation no_gc; | 518 AssertNoAllocation no_gc; |
503 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); | 519 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); |
504 for (int index = 0; index < to_add; index++) { | 520 for (int index = 0; index < to_add; index++) { |
505 elms->set(index + len, args[index + 1], mode); | 521 elms->set(index + len, args[index + 1], mode); |
506 } | 522 } |
507 | 523 |
508 if (elms != array->elements()) { | 524 if (elms != array->elements()) { |
509 array->set_elements(elms); | 525 array->set_elements(elms); |
510 } | 526 } |
511 | 527 |
512 // Set the length. | 528 // Set the length. |
513 array->set_length(Smi::FromInt(new_length)); | 529 array->set_length(Smi::FromInt(new_length)); |
514 return Smi::FromInt(new_length); | 530 return Smi::FromInt(new_length); |
515 } | 531 } |
516 | 532 |
517 | 533 |
518 BUILTIN(ArrayPop) { | 534 BUILTIN(ArrayPop) { |
519 Heap* heap = isolate->heap(); | 535 Heap* heap = isolate->heap(); |
520 Object* receiver = *args.receiver(); | 536 Object* receiver = *args.receiver(); |
521 Object* elms_obj; | 537 Object* elms_obj; |
522 { MaybeObject* maybe_elms_obj = | 538 { MaybeObject* maybe_elms_obj = |
523 EnsureJSArrayWithWritableFastElements(heap, receiver); | 539 EnsureJSArrayWithWritableFastElements(heap, receiver, NULL, 0); |
524 if (maybe_elms_obj == NULL) return CallJsBuiltin(isolate, "ArrayPop", args); | 540 if (maybe_elms_obj == NULL) return CallJsBuiltin(isolate, "ArrayPop", args); |
525 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 541 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
526 } | 542 } |
527 FixedArray* elms = FixedArray::cast(elms_obj); | 543 FixedArray* elms = FixedArray::cast(elms_obj); |
528 JSArray* array = JSArray::cast(receiver); | 544 JSArray* array = JSArray::cast(receiver); |
529 | 545 |
530 int len = Smi::cast(array->length())->value(); | 546 int len = Smi::cast(array->length())->value(); |
531 if (len == 0) return heap->undefined_value(); | 547 if (len == 0) return heap->undefined_value(); |
532 | 548 |
533 // Get top element | 549 // Get top element |
(...skipping 12 matching lines...) Expand all Loading... |
546 | 562 |
547 return top; | 563 return top; |
548 } | 564 } |
549 | 565 |
550 | 566 |
551 BUILTIN(ArrayShift) { | 567 BUILTIN(ArrayShift) { |
552 Heap* heap = isolate->heap(); | 568 Heap* heap = isolate->heap(); |
553 Object* receiver = *args.receiver(); | 569 Object* receiver = *args.receiver(); |
554 Object* elms_obj; | 570 Object* elms_obj; |
555 { MaybeObject* maybe_elms_obj = | 571 { MaybeObject* maybe_elms_obj = |
556 EnsureJSArrayWithWritableFastElements(heap, receiver); | 572 EnsureJSArrayWithWritableFastElements(heap, receiver, NULL, 0); |
557 if (maybe_elms_obj == NULL) | 573 if (maybe_elms_obj == NULL) |
558 return CallJsBuiltin(isolate, "ArrayShift", args); | 574 return CallJsBuiltin(isolate, "ArrayShift", args); |
559 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 575 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
560 } | 576 } |
561 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { | 577 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { |
562 return CallJsBuiltin(isolate, "ArrayShift", args); | 578 return CallJsBuiltin(isolate, "ArrayShift", args); |
563 } | 579 } |
564 FixedArray* elms = FixedArray::cast(elms_obj); | 580 FixedArray* elms = FixedArray::cast(elms_obj); |
565 JSArray* array = JSArray::cast(receiver); | 581 JSArray* array = JSArray::cast(receiver); |
566 ASSERT(array->HasFastTypeElements()); | 582 ASSERT(array->HasFastTypeElements()); |
(...skipping 21 matching lines...) Expand all Loading... |
588 | 604 |
589 return first; | 605 return first; |
590 } | 606 } |
591 | 607 |
592 | 608 |
593 BUILTIN(ArrayUnshift) { | 609 BUILTIN(ArrayUnshift) { |
594 Heap* heap = isolate->heap(); | 610 Heap* heap = isolate->heap(); |
595 Object* receiver = *args.receiver(); | 611 Object* receiver = *args.receiver(); |
596 Object* elms_obj; | 612 Object* elms_obj; |
597 { MaybeObject* maybe_elms_obj = | 613 { MaybeObject* maybe_elms_obj = |
598 EnsureJSArrayWithWritableFastElements(heap, receiver); | 614 EnsureJSArrayWithWritableFastElements(heap, receiver, NULL, 0); |
599 if (maybe_elms_obj == NULL) | 615 if (maybe_elms_obj == NULL) |
600 return CallJsBuiltin(isolate, "ArrayUnshift", args); | 616 return CallJsBuiltin(isolate, "ArrayUnshift", args); |
601 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 617 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
602 } | 618 } |
603 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { | 619 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { |
604 return CallJsBuiltin(isolate, "ArrayUnshift", args); | 620 return CallJsBuiltin(isolate, "ArrayUnshift", args); |
605 } | 621 } |
606 FixedArray* elms = FixedArray::cast(elms_obj); | 622 FixedArray* elms = FixedArray::cast(elms_obj); |
607 JSArray* array = JSArray::cast(receiver); | 623 JSArray* array = JSArray::cast(receiver); |
608 ASSERT(array->HasFastTypeElements()); | 624 ASSERT(array->HasFastTypeElements()); |
609 | 625 |
610 int len = Smi::cast(array->length())->value(); | 626 int len = Smi::cast(array->length())->value(); |
611 int to_add = args.length() - 1; | 627 int to_add = args.length() - 1; |
612 int new_length = len + to_add; | 628 int new_length = len + to_add; |
613 // Currently fixed arrays cannot grow too big, so | 629 // Currently fixed arrays cannot grow too big, so |
614 // we should never hit this case. | 630 // we should never hit this case. |
615 ASSERT(to_add <= (Smi::kMaxValue - len)); | 631 ASSERT(to_add <= (Smi::kMaxValue - len)); |
616 | 632 |
617 if (FLAG_smi_only_arrays) { | 633 MaybeObject* maybe_object = |
618 MaybeObject* maybe_object = | 634 array->EnsureCanContainElements(&args, 1, to_add); |
619 array->EnsureCanContainElements(&args, 1, to_add); | 635 if (maybe_object->IsFailure()) return maybe_object; |
620 if (maybe_object->IsFailure()) return maybe_object; | |
621 } | |
622 | 636 |
623 if (new_length > elms->length()) { | 637 if (new_length > elms->length()) { |
624 // New backing storage is needed. | 638 // New backing storage is needed. |
625 int capacity = new_length + (new_length >> 1) + 16; | 639 int capacity = new_length + (new_length >> 1) + 16; |
626 Object* obj; | 640 Object* obj; |
627 { MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity); | 641 { MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity); |
628 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 642 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
629 } | 643 } |
630 FixedArray* new_elms = FixedArray::cast(obj); | 644 FixedArray* new_elms = FixedArray::cast(obj); |
631 AssertNoAllocation no_gc; | 645 AssertNoAllocation no_gc; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 if (!maybe_result->ToObject(&result)) return maybe_result; | 754 if (!maybe_result->ToObject(&result)) return maybe_result; |
741 } | 755 } |
742 JSArray* result_array = JSArray::cast(result); | 756 JSArray* result_array = JSArray::cast(result); |
743 | 757 |
744 { MaybeObject* maybe_result = | 758 { MaybeObject* maybe_result = |
745 heap->AllocateUninitializedFixedArray(result_len); | 759 heap->AllocateUninitializedFixedArray(result_len); |
746 if (!maybe_result->ToObject(&result)) return maybe_result; | 760 if (!maybe_result->ToObject(&result)) return maybe_result; |
747 } | 761 } |
748 FixedArray* result_elms = FixedArray::cast(result); | 762 FixedArray* result_elms = FixedArray::cast(result); |
749 | 763 |
750 if (FLAG_smi_only_arrays) { | 764 MaybeObject* maybe_object = |
751 MaybeObject* maybe_object = | 765 result_array->EnsureCanContainElements(result_elms); |
752 result_array->EnsureCanContainElements(result_elms); | 766 if (maybe_object->IsFailure()) return maybe_object; |
753 if (maybe_object->IsFailure()) return maybe_object; | |
754 } | |
755 | 767 |
756 AssertNoAllocation no_gc; | 768 AssertNoAllocation no_gc; |
757 CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len); | 769 CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len); |
758 | 770 |
759 // Set elements. | 771 // Set elements. |
760 result_array->set_elements(result_elms); | 772 result_array->set_elements(result_elms); |
761 | 773 |
762 // Set the length. | 774 // Set the length. |
763 result_array->set_length(Smi::FromInt(result_len)); | 775 result_array->set_length(Smi::FromInt(result_len)); |
764 return result_array; | 776 return result_array; |
765 } | 777 } |
766 | 778 |
767 | 779 |
768 BUILTIN(ArraySplice) { | 780 BUILTIN(ArraySplice) { |
769 Heap* heap = isolate->heap(); | 781 Heap* heap = isolate->heap(); |
770 Object* receiver = *args.receiver(); | 782 Object* receiver = *args.receiver(); |
771 Object* elms_obj; | 783 Object* elms_obj; |
772 { MaybeObject* maybe_elms_obj = | 784 { MaybeObject* maybe_elms_obj = |
773 EnsureJSArrayWithWritableFastElements(heap, receiver); | 785 EnsureJSArrayWithWritableFastElements(heap, receiver, &args, 3); |
774 if (maybe_elms_obj == NULL) | 786 if (maybe_elms_obj == NULL) |
775 return CallJsBuiltin(isolate, "ArraySplice", args); | 787 return CallJsBuiltin(isolate, "ArraySplice", args); |
776 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; | 788 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; |
777 } | 789 } |
778 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { | 790 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { |
779 return CallJsBuiltin(isolate, "ArraySplice", args); | 791 return CallJsBuiltin(isolate, "ArraySplice", args); |
780 } | 792 } |
781 FixedArray* elms = FixedArray::cast(elms_obj); | 793 FixedArray* elms = FixedArray::cast(elms_obj); |
782 JSArray* array = JSArray::cast(receiver); | 794 JSArray* array = JSArray::cast(receiver); |
783 ASSERT(array->HasFastTypeElements()); | 795 ASSERT(array->HasFastTypeElements()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 actual_delete_count); | 862 actual_delete_count); |
851 | 863 |
852 // Set elements. | 864 // Set elements. |
853 result_array->set_elements(result_elms); | 865 result_array->set_elements(result_elms); |
854 | 866 |
855 // Set the length. | 867 // Set the length. |
856 result_array->set_length(Smi::FromInt(actual_delete_count)); | 868 result_array->set_length(Smi::FromInt(actual_delete_count)); |
857 } | 869 } |
858 | 870 |
859 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0; | 871 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0; |
860 | |
861 if (FLAG_smi_only_arrays) { | |
862 MaybeObject* maybe = array->EnsureCanContainElements(&args, 3, item_count); | |
863 if (maybe->IsFailure()) return maybe; | |
864 } | |
865 | |
866 int new_length = len - actual_delete_count + item_count; | 872 int new_length = len - actual_delete_count + item_count; |
867 | 873 |
868 bool elms_changed = false; | 874 bool elms_changed = false; |
869 if (item_count < actual_delete_count) { | 875 if (item_count < actual_delete_count) { |
870 // Shrink the array. | 876 // Shrink the array. |
871 const bool trim_array = !heap->lo_space()->Contains(elms) && | 877 const bool trim_array = !heap->lo_space()->Contains(elms) && |
872 ((actual_start + item_count) < | 878 ((actual_start + item_count) < |
873 (len - actual_delete_count - actual_start)); | 879 (len - actual_delete_count - actual_start)); |
874 if (trim_array) { | 880 if (trim_array) { |
875 const int delta = actual_delete_count - item_count; | 881 const int delta = actual_delete_count - item_count; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 if (!maybe_result->ToObject(&result)) return maybe_result; | 998 if (!maybe_result->ToObject(&result)) return maybe_result; |
993 } | 999 } |
994 JSArray* result_array = JSArray::cast(result); | 1000 JSArray* result_array = JSArray::cast(result); |
995 | 1001 |
996 { MaybeObject* maybe_result = | 1002 { MaybeObject* maybe_result = |
997 heap->AllocateUninitializedFixedArray(result_len); | 1003 heap->AllocateUninitializedFixedArray(result_len); |
998 if (!maybe_result->ToObject(&result)) return maybe_result; | 1004 if (!maybe_result->ToObject(&result)) return maybe_result; |
999 } | 1005 } |
1000 FixedArray* result_elms = FixedArray::cast(result); | 1006 FixedArray* result_elms = FixedArray::cast(result); |
1001 | 1007 |
1002 if (FLAG_smi_only_arrays) { | 1008 // Ensure element type transitions happen before copying elements in. |
| 1009 if (result_array->HasFastSmiOnlyElements()) { |
1003 for (int i = 0; i < n_arguments; i++) { | 1010 for (int i = 0; i < n_arguments; i++) { |
1004 JSArray* array = JSArray::cast(args[i]); | 1011 JSArray* array = JSArray::cast(args[i]); |
1005 int len = Smi::cast(array->length())->value(); | 1012 if (!array->HasFastSmiOnlyElements()) { |
1006 if (len > 0) { | 1013 result_array->EnsureCanContainNonSmiElements(); |
1007 FixedArray* elms = FixedArray::cast(array->elements()); | 1014 break; |
1008 MaybeObject* maybe_object = | |
1009 result_array->EnsureCanContainElements(elms); | |
1010 if (maybe_object->IsFailure()) return maybe_object; | |
1011 } | 1015 } |
1012 } | 1016 } |
1013 } | 1017 } |
1014 | 1018 |
1015 // Copy data. | 1019 // Copy data. |
1016 AssertNoAllocation no_gc; | 1020 AssertNoAllocation no_gc; |
1017 int start_pos = 0; | 1021 int start_pos = 0; |
1018 for (int i = 0; i < n_arguments; i++) { | 1022 for (int i = 0; i < n_arguments; i++) { |
1019 JSArray* array = JSArray::cast(args[i]); | 1023 JSArray* array = JSArray::cast(args[i]); |
1020 int len = Smi::cast(array->length())->value(); | 1024 int len = Smi::cast(array->length())->value(); |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 return Handle<Code>(code_address); \ | 1765 return Handle<Code>(code_address); \ |
1762 } | 1766 } |
1763 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1767 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1764 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1768 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1765 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1769 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1766 #undef DEFINE_BUILTIN_ACCESSOR_C | 1770 #undef DEFINE_BUILTIN_ACCESSOR_C |
1767 #undef DEFINE_BUILTIN_ACCESSOR_A | 1771 #undef DEFINE_BUILTIN_ACCESSOR_A |
1768 | 1772 |
1769 | 1773 |
1770 } } // namespace v8::internal | 1774 } } // namespace v8::internal |
OLD | NEW |