Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/builtins.cc

Issue 7901016: Basic support for tracking smi-only arrays on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ready to land Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 JSFunction* constructor = 196 JSFunction* constructor =
197 isolate->context()->global_context()->array_function(); 197 isolate->context()->global_context()->array_function();
198 Object* obj; 198 Object* obj;
199 { MaybeObject* maybe_obj = heap->AllocateJSObject(constructor); 199 { MaybeObject* maybe_obj = heap->AllocateJSObject(constructor);
200 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 200 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
201 } 201 }
202 array = JSArray::cast(obj); 202 array = JSArray::cast(obj);
203 } 203 }
204 204
205 // 'array' now contains the JSArray we should initialize. 205 // 'array' now contains the JSArray we should initialize.
206 ASSERT(array->HasFastElements()); 206 ASSERT(array->HasFastTypeElements());
207 207
208 // Optimize the case where there is one argument and the argument is a 208 // Optimize the case where there is one argument and the argument is a
209 // small smi. 209 // small smi.
210 if (args.length() == 2) { 210 if (args.length() == 2) {
211 Object* obj = args[1]; 211 Object* obj = args[1];
212 if (obj->IsSmi()) { 212 if (obj->IsSmi()) {
213 int len = Smi::cast(obj)->value(); 213 int len = Smi::cast(obj)->value();
214 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) { 214 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
215 Object* obj; 215 Object* obj;
216 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len); 216 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len);
217 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 217 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
218 } 218 }
219 array->SetContent(FixedArray::cast(obj)); 219 MaybeObject* maybe_obj = array->SetContent(FixedArray::cast(obj));
220 if (maybe_obj->IsFailure()) return maybe_obj;
220 return array; 221 return array;
221 } 222 }
222 } 223 }
223 // Take the argument as the length. 224 // Take the argument as the length.
224 { MaybeObject* maybe_obj = array->Initialize(0); 225 { MaybeObject* maybe_obj = array->Initialize(0);
225 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 226 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
226 } 227 }
227 return array->SetElementsLength(args[1]); 228 return array->SetElementsLength(args[1]);
228 } 229 }
229 230
230 // Optimize the case where there are no parameters passed. 231 // Optimize the case where there are no parameters passed.
231 if (args.length() == 1) { 232 if (args.length() == 1) {
232 return array->Initialize(JSArray::kPreallocatedArrayElements); 233 return array->Initialize(JSArray::kPreallocatedArrayElements);
233 } 234 }
234 235
235 // Take the arguments as elements. 236 // Take the arguments as elements.
236 int number_of_elements = args.length() - 1; 237 int number_of_elements = args.length() - 1;
237 Smi* len = Smi::FromInt(number_of_elements); 238 Smi* len = Smi::FromInt(number_of_elements);
238 Object* obj; 239 Object* obj;
239 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len->value()); 240 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len->value());
240 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 241 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
241 } 242 }
242 243
244 // Set length and elements on the array.
245 if (FLAG_smi_only_arrays) {
246 MaybeObject* maybe_object =
247 array->EnsureCanContainElements(FixedArray::cast(obj));
248 if (maybe_object->IsFailure()) return maybe_object;
249 }
250
243 AssertNoAllocation no_gc; 251 AssertNoAllocation no_gc;
244 FixedArray* elms = FixedArray::cast(obj); 252 FixedArray* elms = FixedArray::cast(obj);
245 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 253 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
246 // Fill in the content 254 // Fill in the content
247 for (int index = 0; index < number_of_elements; index++) { 255 for (int index = 0; index < number_of_elements; index++) {
248 elms->set(index, args[index+1], mode); 256 elms->set(index, args[index+1], mode);
249 } 257 }
250 258
251 // Set length and elements on the array.
252 array->set_elements(FixedArray::cast(obj)); 259 array->set_elements(FixedArray::cast(obj));
253 array->set_length(len); 260 array->set_length(len);
254 261
255 return array; 262 return array;
256 } 263 }
257 264
258 265
259 MUST_USE_RESULT static MaybeObject* AllocateJSArray(Heap* heap) { 266 MUST_USE_RESULT static MaybeObject* AllocateJSArray(Heap* heap) {
260 JSFunction* array_function = 267 JSFunction* array_function =
261 heap->isolate()->context()->global_context()->array_function(); 268 heap->isolate()->context()->global_context()->array_function();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 486 }
480 FixedArray* new_elms = FixedArray::cast(obj); 487 FixedArray* new_elms = FixedArray::cast(obj);
481 488
482 AssertNoAllocation no_gc; 489 AssertNoAllocation no_gc;
483 if (len > 0) { 490 if (len > 0) {
484 CopyElements(heap, &no_gc, new_elms, 0, elms, 0, len); 491 CopyElements(heap, &no_gc, new_elms, 0, elms, 0, len);
485 } 492 }
486 FillWithHoles(heap, new_elms, new_length, capacity); 493 FillWithHoles(heap, new_elms, new_length, capacity);
487 494
488 elms = new_elms; 495 elms = new_elms;
489 array->set_elements(elms);
490 } 496 }
491 497
498 MaybeObject* maybe = array->EnsureCanContainElements(&args, 1, to_add);
499 if (maybe->IsFailure()) return maybe;
500
492 // Add the provided values. 501 // Add the provided values.
493 AssertNoAllocation no_gc; 502 AssertNoAllocation no_gc;
494 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 503 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
495 for (int index = 0; index < to_add; index++) { 504 for (int index = 0; index < to_add; index++) {
496 elms->set(index + len, args[index + 1], mode); 505 elms->set(index + len, args[index + 1], mode);
497 } 506 }
498 507
508 if (elms != array->elements()) {
509 array->set_elements(elms);
510 }
511
499 // Set the length. 512 // Set the length.
500 array->set_length(Smi::FromInt(new_length)); 513 array->set_length(Smi::FromInt(new_length));
501 return Smi::FromInt(new_length); 514 return Smi::FromInt(new_length);
502 } 515 }
503 516
504 517
505 BUILTIN(ArrayPop) { 518 BUILTIN(ArrayPop) {
506 Heap* heap = isolate->heap(); 519 Heap* heap = isolate->heap();
507 Object* receiver = *args.receiver(); 520 Object* receiver = *args.receiver();
508 Object* elms_obj; 521 Object* elms_obj;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 EnsureJSArrayWithWritableFastElements(heap, receiver); 556 EnsureJSArrayWithWritableFastElements(heap, receiver);
544 if (maybe_elms_obj == NULL) 557 if (maybe_elms_obj == NULL)
545 return CallJsBuiltin(isolate, "ArrayShift", args); 558 return CallJsBuiltin(isolate, "ArrayShift", args);
546 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; 559 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
547 } 560 }
548 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { 561 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) {
549 return CallJsBuiltin(isolate, "ArrayShift", args); 562 return CallJsBuiltin(isolate, "ArrayShift", args);
550 } 563 }
551 FixedArray* elms = FixedArray::cast(elms_obj); 564 FixedArray* elms = FixedArray::cast(elms_obj);
552 JSArray* array = JSArray::cast(receiver); 565 JSArray* array = JSArray::cast(receiver);
553 ASSERT(array->HasFastElements()); 566 ASSERT(array->HasFastTypeElements());
554 567
555 int len = Smi::cast(array->length())->value(); 568 int len = Smi::cast(array->length())->value();
556 if (len == 0) return heap->undefined_value(); 569 if (len == 0) return heap->undefined_value();
557 570
558 // Get first element 571 // Get first element
559 Object* first = elms->get(0); 572 Object* first = elms->get(0);
560 if (first->IsTheHole()) { 573 if (first->IsTheHole()) {
561 first = heap->undefined_value(); 574 first = heap->undefined_value();
562 } 575 }
563 576
(...skipping 21 matching lines...) Expand all
585 EnsureJSArrayWithWritableFastElements(heap, receiver); 598 EnsureJSArrayWithWritableFastElements(heap, receiver);
586 if (maybe_elms_obj == NULL) 599 if (maybe_elms_obj == NULL)
587 return CallJsBuiltin(isolate, "ArrayUnshift", args); 600 return CallJsBuiltin(isolate, "ArrayUnshift", args);
588 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; 601 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
589 } 602 }
590 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { 603 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) {
591 return CallJsBuiltin(isolate, "ArrayUnshift", args); 604 return CallJsBuiltin(isolate, "ArrayUnshift", args);
592 } 605 }
593 FixedArray* elms = FixedArray::cast(elms_obj); 606 FixedArray* elms = FixedArray::cast(elms_obj);
594 JSArray* array = JSArray::cast(receiver); 607 JSArray* array = JSArray::cast(receiver);
595 ASSERT(array->HasFastElements()); 608 ASSERT(array->HasFastTypeElements());
596 609
597 int len = Smi::cast(array->length())->value(); 610 int len = Smi::cast(array->length())->value();
598 int to_add = args.length() - 1; 611 int to_add = args.length() - 1;
599 int new_length = len + to_add; 612 int new_length = len + to_add;
600 // Currently fixed arrays cannot grow too big, so 613 // Currently fixed arrays cannot grow too big, so
601 // we should never hit this case. 614 // we should never hit this case.
602 ASSERT(to_add <= (Smi::kMaxValue - len)); 615 ASSERT(to_add <= (Smi::kMaxValue - len));
603 616
617 if (FLAG_smi_only_arrays) {
618 MaybeObject* maybe_object =
619 array->EnsureCanContainElements(&args, 1, to_add);
620 if (maybe_object->IsFailure()) return maybe_object;
621 }
622
604 if (new_length > elms->length()) { 623 if (new_length > elms->length()) {
605 // New backing storage is needed. 624 // New backing storage is needed.
606 int capacity = new_length + (new_length >> 1) + 16; 625 int capacity = new_length + (new_length >> 1) + 16;
607 Object* obj; 626 Object* obj;
608 { MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity); 627 { MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity);
609 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 628 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
610 } 629 }
611 FixedArray* new_elms = FixedArray::cast(obj); 630 FixedArray* new_elms = FixedArray::cast(obj);
612
613 AssertNoAllocation no_gc; 631 AssertNoAllocation no_gc;
614 if (len > 0) { 632 if (len > 0) {
615 CopyElements(heap, &no_gc, new_elms, to_add, elms, 0, len); 633 CopyElements(heap, &no_gc, new_elms, to_add, elms, 0, len);
616 } 634 }
617 FillWithHoles(heap, new_elms, new_length, capacity); 635 FillWithHoles(heap, new_elms, new_length, capacity);
618
619 elms = new_elms; 636 elms = new_elms;
620 array->set_elements(elms); 637 array->set_elements(elms);
621 } else { 638 } else {
622 AssertNoAllocation no_gc; 639 AssertNoAllocation no_gc;
623 MoveElements(heap, &no_gc, elms, to_add, elms, 0, len); 640 MoveElements(heap, &no_gc, elms, to_add, elms, 0, len);
624 } 641 }
625 642
626 // Add the provided values. 643 // Add the provided values.
627 AssertNoAllocation no_gc; 644 AssertNoAllocation no_gc;
628 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 645 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 if (!maybe_result->ToObject(&result)) return maybe_result; 740 if (!maybe_result->ToObject(&result)) return maybe_result;
724 } 741 }
725 JSArray* result_array = JSArray::cast(result); 742 JSArray* result_array = JSArray::cast(result);
726 743
727 { MaybeObject* maybe_result = 744 { MaybeObject* maybe_result =
728 heap->AllocateUninitializedFixedArray(result_len); 745 heap->AllocateUninitializedFixedArray(result_len);
729 if (!maybe_result->ToObject(&result)) return maybe_result; 746 if (!maybe_result->ToObject(&result)) return maybe_result;
730 } 747 }
731 FixedArray* result_elms = FixedArray::cast(result); 748 FixedArray* result_elms = FixedArray::cast(result);
732 749
750 if (FLAG_smi_only_arrays) {
751 MaybeObject* maybe_object =
752 result_array->EnsureCanContainElements(result_elms);
753 if (maybe_object->IsFailure()) return maybe_object;
754 }
755
733 AssertNoAllocation no_gc; 756 AssertNoAllocation no_gc;
734 CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len); 757 CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len);
735 758
736 // Set elements. 759 // Set elements.
737 result_array->set_elements(result_elms); 760 result_array->set_elements(result_elms);
738 761
739 // Set the length. 762 // Set the length.
740 result_array->set_length(Smi::FromInt(result_len)); 763 result_array->set_length(Smi::FromInt(result_len));
741 return result_array; 764 return result_array;
742 } 765 }
743 766
744 767
745 BUILTIN(ArraySplice) { 768 BUILTIN(ArraySplice) {
746 Heap* heap = isolate->heap(); 769 Heap* heap = isolate->heap();
747 Object* receiver = *args.receiver(); 770 Object* receiver = *args.receiver();
748 Object* elms_obj; 771 Object* elms_obj;
749 { MaybeObject* maybe_elms_obj = 772 { MaybeObject* maybe_elms_obj =
750 EnsureJSArrayWithWritableFastElements(heap, receiver); 773 EnsureJSArrayWithWritableFastElements(heap, receiver);
751 if (maybe_elms_obj == NULL) 774 if (maybe_elms_obj == NULL)
752 return CallJsBuiltin(isolate, "ArraySplice", args); 775 return CallJsBuiltin(isolate, "ArraySplice", args);
753 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj; 776 if (!maybe_elms_obj->ToObject(&elms_obj)) return maybe_elms_obj;
754 } 777 }
755 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) { 778 if (!IsJSArrayFastElementMovingAllowed(heap, JSArray::cast(receiver))) {
756 return CallJsBuiltin(isolate, "ArraySplice", args); 779 return CallJsBuiltin(isolate, "ArraySplice", args);
757 } 780 }
758 FixedArray* elms = FixedArray::cast(elms_obj); 781 FixedArray* elms = FixedArray::cast(elms_obj);
759 JSArray* array = JSArray::cast(receiver); 782 JSArray* array = JSArray::cast(receiver);
760 ASSERT(array->HasFastElements()); 783 ASSERT(array->HasFastTypeElements());
761 784
762 int len = Smi::cast(array->length())->value(); 785 int len = Smi::cast(array->length())->value();
763 786
764 int n_arguments = args.length() - 1; 787 int n_arguments = args.length() - 1;
765 788
766 int relative_start = 0; 789 int relative_start = 0;
767 if (n_arguments > 0) { 790 if (n_arguments > 0) {
768 Object* arg1 = args[1]; 791 Object* arg1 = args[1];
769 if (arg1->IsSmi()) { 792 if (arg1->IsSmi()) {
770 relative_start = Smi::cast(arg1)->value(); 793 relative_start = Smi::cast(arg1)->value();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 851
829 // Set elements. 852 // Set elements.
830 result_array->set_elements(result_elms); 853 result_array->set_elements(result_elms);
831 854
832 // Set the length. 855 // Set the length.
833 result_array->set_length(Smi::FromInt(actual_delete_count)); 856 result_array->set_length(Smi::FromInt(actual_delete_count));
834 } 857 }
835 858
836 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0; 859 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0;
837 860
861 if (FLAG_smi_only_arrays) {
862 MaybeObject* maybe = array->EnsureCanContainElements(&args, 3, item_count);
863 if (maybe->IsFailure()) return maybe;
864 }
865
838 int new_length = len - actual_delete_count + item_count; 866 int new_length = len - actual_delete_count + item_count;
839 867
868 bool elms_changed = false;
840 if (item_count < actual_delete_count) { 869 if (item_count < actual_delete_count) {
841 // Shrink the array. 870 // Shrink the array.
842 const bool trim_array = !heap->lo_space()->Contains(elms) && 871 const bool trim_array = !heap->lo_space()->Contains(elms) &&
843 ((actual_start + item_count) < 872 ((actual_start + item_count) <
844 (len - actual_delete_count - actual_start)); 873 (len - actual_delete_count - actual_start));
845 if (trim_array) { 874 if (trim_array) {
846 const int delta = actual_delete_count - item_count; 875 const int delta = actual_delete_count - item_count;
847 876
848 if (actual_start > 0) { 877 if (actual_start > 0) {
849 AssertNoAllocation no_gc; 878 AssertNoAllocation no_gc;
850 MoveElements(heap, &no_gc, elms, delta, elms, 0, actual_start); 879 MoveElements(heap, &no_gc, elms, delta, elms, 0, actual_start);
851 } 880 }
852 881
853 elms = LeftTrimFixedArray(heap, elms, delta); 882 elms = LeftTrimFixedArray(heap, elms, delta);
854 array->set_elements(elms); 883
884 elms_changed = true;
855 } else { 885 } else {
856 AssertNoAllocation no_gc; 886 AssertNoAllocation no_gc;
857 MoveElements(heap, &no_gc, 887 MoveElements(heap, &no_gc,
858 elms, actual_start + item_count, 888 elms, actual_start + item_count,
859 elms, actual_start + actual_delete_count, 889 elms, actual_start + actual_delete_count,
860 (len - actual_delete_count - actual_start)); 890 (len - actual_delete_count - actual_start));
861 FillWithHoles(heap, elms, new_length, len); 891 FillWithHoles(heap, elms, new_length, len);
862 } 892 }
863 } else if (item_count > actual_delete_count) { 893 } else if (item_count > actual_delete_count) {
864 // Currently fixed arrays cannot grow too big, so 894 // Currently fixed arrays cannot grow too big, so
(...skipping 19 matching lines...) Expand all
884 const int to_copy = len - actual_delete_count - actual_start; 914 const int to_copy = len - actual_delete_count - actual_start;
885 if (to_copy > 0) { 915 if (to_copy > 0) {
886 CopyElements(heap, &no_gc, 916 CopyElements(heap, &no_gc,
887 new_elms, actual_start + item_count, 917 new_elms, actual_start + item_count,
888 elms, actual_start + actual_delete_count, 918 elms, actual_start + actual_delete_count,
889 to_copy); 919 to_copy);
890 } 920 }
891 FillWithHoles(heap, new_elms, new_length, capacity); 921 FillWithHoles(heap, new_elms, new_length, capacity);
892 922
893 elms = new_elms; 923 elms = new_elms;
894 array->set_elements(elms); 924 elms_changed = true;
895 } else { 925 } else {
896 AssertNoAllocation no_gc; 926 AssertNoAllocation no_gc;
897 MoveElements(heap, &no_gc, 927 MoveElements(heap, &no_gc,
898 elms, actual_start + item_count, 928 elms, actual_start + item_count,
899 elms, actual_start + actual_delete_count, 929 elms, actual_start + actual_delete_count,
900 (len - actual_delete_count - actual_start)); 930 (len - actual_delete_count - actual_start));
901 } 931 }
902 } 932 }
903 933
904 AssertNoAllocation no_gc; 934 AssertNoAllocation no_gc;
905 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 935 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
906 for (int k = actual_start; k < actual_start + item_count; k++) { 936 for (int k = actual_start; k < actual_start + item_count; k++) {
907 elms->set(k, args[3 + k - actual_start], mode); 937 elms->set(k, args[3 + k - actual_start], mode);
908 } 938 }
909 939
940 if (elms_changed) {
941 array->set_elements(elms);
942 }
943
910 // Set the length. 944 // Set the length.
911 array->set_length(Smi::FromInt(new_length)); 945 array->set_length(Smi::FromInt(new_length));
912 946
913 return result_array; 947 return result_array;
914 } 948 }
915 949
916 950
917 BUILTIN(ArrayConcat) { 951 BUILTIN(ArrayConcat) {
918 Heap* heap = isolate->heap(); 952 Heap* heap = isolate->heap();
919 Context* global_context = isolate->context()->global_context(); 953 Context* global_context = isolate->context()->global_context();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 if (!maybe_result->ToObject(&result)) return maybe_result; 992 if (!maybe_result->ToObject(&result)) return maybe_result;
959 } 993 }
960 JSArray* result_array = JSArray::cast(result); 994 JSArray* result_array = JSArray::cast(result);
961 995
962 { MaybeObject* maybe_result = 996 { MaybeObject* maybe_result =
963 heap->AllocateUninitializedFixedArray(result_len); 997 heap->AllocateUninitializedFixedArray(result_len);
964 if (!maybe_result->ToObject(&result)) return maybe_result; 998 if (!maybe_result->ToObject(&result)) return maybe_result;
965 } 999 }
966 FixedArray* result_elms = FixedArray::cast(result); 1000 FixedArray* result_elms = FixedArray::cast(result);
967 1001
1002 if (FLAG_smi_only_arrays) {
1003 for (int i = 0; i < n_arguments; i++) {
1004 JSArray* array = JSArray::cast(args[i]);
1005 int len = Smi::cast(array->length())->value();
1006 if (len > 0) {
1007 FixedArray* elms = FixedArray::cast(array->elements());
1008 MaybeObject* maybe_object =
1009 result_array->EnsureCanContainElements(elms);
1010 if (maybe_object->IsFailure()) return maybe_object;
1011 }
1012 }
1013 }
1014
968 // Copy data. 1015 // Copy data.
969 AssertNoAllocation no_gc; 1016 AssertNoAllocation no_gc;
970 int start_pos = 0; 1017 int start_pos = 0;
971 for (int i = 0; i < n_arguments; i++) { 1018 for (int i = 0; i < n_arguments; i++) {
972 JSArray* array = JSArray::cast(args[i]); 1019 JSArray* array = JSArray::cast(args[i]);
973 int len = Smi::cast(array->length())->value(); 1020 int len = Smi::cast(array->length())->value();
974 if (len > 0) { 1021 if (len > 0) {
975 FixedArray* elms = FixedArray::cast(array->elements()); 1022 FixedArray* elms = FixedArray::cast(array->elements());
976 CopyElements(heap, &no_gc, result_elms, start_pos, elms, 0, len); 1023 CopyElements(heap, &no_gc, result_elms, start_pos, elms, 0, len);
977 start_pos += len; 1024 start_pos += len;
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 return Handle<Code>(code_address); \ 1761 return Handle<Code>(code_address); \
1715 } 1762 }
1716 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1763 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1717 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1764 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1718 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1765 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1719 #undef DEFINE_BUILTIN_ACCESSOR_C 1766 #undef DEFINE_BUILTIN_ACCESSOR_C
1720 #undef DEFINE_BUILTIN_ACCESSOR_A 1767 #undef DEFINE_BUILTIN_ACCESSOR_A
1721 1768
1722 1769
1723 } } // namespace v8::internal 1770 } } // namespace v8::internal
OLDNEW
« src/bootstrapper.cc ('K') | « src/bootstrapper.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698