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 3522008: This is a little experiment to move Failure to a superclass above Object... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 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
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 BUILTIN(ArrayCodeGeneric) { 182 BUILTIN(ArrayCodeGeneric) {
183 Counters::array_function_runtime.Increment(); 183 Counters::array_function_runtime.Increment();
184 184
185 JSArray* array; 185 JSArray* array;
186 if (CalledAsConstructor()) { 186 if (CalledAsConstructor()) {
187 array = JSArray::cast(*args.receiver()); 187 array = JSArray::cast(*args.receiver());
188 } else { 188 } else {
189 // Allocate the JS Array 189 // Allocate the JS Array
190 JSFunction* constructor = 190 JSFunction* constructor =
191 Object* obj;
192 { TryAllocation t = Heap::AllocateJSObject(constructor);
193 if (!t->ToObject(&obj)) return t;
194 }
191 Top::context()->global_context()->array_function(); 195 Top::context()->global_context()->array_function();
192 Object* obj = Heap::AllocateJSObject(constructor);
193 if (obj->IsFailure()) return obj;
194 array = JSArray::cast(obj); 196 array = JSArray::cast(obj);
195 } 197 }
196 198
197 // 'array' now contains the JSArray we should initialize. 199 // 'array' now contains the JSArray we should initialize.
198 ASSERT(array->HasFastElements()); 200 ASSERT(array->HasFastElements());
199 201
200 // Optimize the case where there is one argument and the argument is a 202 // Optimize the case where there is one argument and the argument is a
201 // small smi. 203 // small smi.
202 if (args.length() == 2) { 204 if (args.length() == 2) {
203 Object* obj = args[1]; 205 Object* obj = args[1];
204 if (obj->IsSmi()) { 206 if (obj->IsSmi()) {
205 int len = Smi::cast(obj)->value(); 207 int len = Smi::cast(obj)->value();
208 Object* obj;
209 { TryAllocation t = Heap::AllocateFixedArrayWithHoles(len);
210 if (!t->ToObject(&obj)) return t;
211 }
206 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) { 212 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
207 Object* obj = Heap::AllocateFixedArrayWithHoles(len);
208 if (obj->IsFailure()) return obj;
209 array->SetContent(FixedArray::cast(obj)); 213 array->SetContent(FixedArray::cast(obj));
210 return array; 214 return array;
211 } 215 }
212 } 216 }
217 { TryAllocation t = array->Initialize(0);
218 if (!t->ToObject(&obj)) return t;
219 }
213 // Take the argument as the length. 220 // Take the argument as the length.
214 obj = array->Initialize(0);
215 if (obj->IsFailure()) return obj;
216 return array->SetElementsLength(args[1]); 221 return array->SetElementsLength(args[1]);
217 } 222 }
218 223
219 // Optimize the case where there are no parameters passed. 224 // Optimize the case where there are no parameters passed.
220 if (args.length() == 1) { 225 if (args.length() == 1) {
221 return array->Initialize(JSArray::kPreallocatedArrayElements); 226 return array->Initialize(JSArray::kPreallocatedArrayElements);
222 } 227 }
223 228
224 // Take the arguments as elements. 229 // Take the arguments as elements.
225 int number_of_elements = args.length() - 1; 230 int number_of_elements = args.length() - 1;
231 Object* obj;
232 { TryAllocation t = Heap::AllocateFixedArrayWithHoles(len->value());
233 if (!t->ToObject(&obj)) return t;
234 }
226 Smi* len = Smi::FromInt(number_of_elements); 235 Smi* len = Smi::FromInt(number_of_elements);
227 Object* obj = Heap::AllocateFixedArrayWithHoles(len->value());
228 if (obj->IsFailure()) return obj;
229 236
230 AssertNoAllocation no_gc; 237 AssertNoAllocation no_gc;
231 FixedArray* elms = FixedArray::cast(obj); 238 FixedArray* elms = FixedArray::cast(obj);
232 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 239 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
233 // Fill in the content 240 // Fill in the content
234 for (int index = 0; index < number_of_elements; index++) { 241 for (int index = 0; index < number_of_elements; index++) {
235 elms->set(index, args[index+1], mode); 242 elms->set(index, args[index+1], mode);
236 } 243 }
237 244
238 // Set length and elements on the array. 245 // Set length and elements on the array.
239 array->set_elements(FixedArray::cast(obj)); 246 array->set_elements(FixedArray::cast(obj));
240 array->set_length(len); 247 array->set_length(len);
241 248
242 return array; 249 return array;
243 } 250 }
244 251
245 252
246 MUST_USE_RESULT static Object* AllocateJSArray() { 253 MUST_USE_RESULT static Object* AllocateJSArray() {
247 JSFunction* array_function = 254 JSFunction* array_function =
255 Object* result;
256 { TryAllocation t = Heap::AllocateJSObject(array_function);
257 if (!t->ToObject(&result)) return t;
258 }
248 Top::context()->global_context()->array_function(); 259 Top::context()->global_context()->array_function();
249 Object* result = Heap::AllocateJSObject(array_function);
250 if (result->IsFailure()) return result;
251 return result; 260 return result;
252 } 261 }
253 262
254 263
264 Object* result;
265 { TryAllocation t = AllocateJSArray();
266 if (!t->ToObject(&result)) return t;
267 }
255 MUST_USE_RESULT static Object* AllocateEmptyJSArray() { 268 MUST_USE_RESULT static Object* AllocateEmptyJSArray() {
256 Object* result = AllocateJSArray();
257 if (result->IsFailure()) return result;
258 JSArray* result_array = JSArray::cast(result); 269 JSArray* result_array = JSArray::cast(result);
259 result_array->set_length(Smi::FromInt(0)); 270 result_array->set_length(Smi::FromInt(0));
260 result_array->set_elements(Heap::empty_fixed_array()); 271 result_array->set_elements(Heap::empty_fixed_array());
261 return result_array; 272 return result_array;
262 } 273 }
263 274
264 275
265 static void CopyElements(AssertNoAllocation* no_gc, 276 static void CopyElements(AssertNoAllocation* no_gc,
266 FixedArray* dst, 277 FixedArray* dst,
267 int dst_index, 278 int dst_index,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return Smi::FromInt(len); 431 return Smi::FromInt(len);
421 } 432 }
422 // Currently fixed arrays cannot grow too big, so 433 // Currently fixed arrays cannot grow too big, so
423 // we should never hit this case. 434 // we should never hit this case.
424 ASSERT(to_add <= (Smi::kMaxValue - len)); 435 ASSERT(to_add <= (Smi::kMaxValue - len));
425 436
426 int new_length = len + to_add; 437 int new_length = len + to_add;
427 438
428 if (new_length > elms->length()) { 439 if (new_length > elms->length()) {
429 // New backing storage is needed. 440 // New backing storage is needed.
441 Object* obj;
442 { TryAllocation t = Heap::AllocateUninitializedFixedArray(capacity);
443 if (!t->ToObject(&obj)) return t;
444 }
430 int capacity = new_length + (new_length >> 1) + 16; 445 int capacity = new_length + (new_length >> 1) + 16;
431 Object* obj = Heap::AllocateUninitializedFixedArray(capacity);
432 if (obj->IsFailure()) return obj;
433 FixedArray* new_elms = FixedArray::cast(obj); 446 FixedArray* new_elms = FixedArray::cast(obj);
434 447
435 AssertNoAllocation no_gc; 448 AssertNoAllocation no_gc;
436 if (len > 0) { 449 if (len > 0) {
437 CopyElements(&no_gc, new_elms, 0, elms, 0, len); 450 CopyElements(&no_gc, new_elms, 0, elms, 0, len);
438 } 451 }
439 FillWithHoles(new_elms, new_length, capacity); 452 FillWithHoles(new_elms, new_length, capacity);
440 453
441 elms = new_elms; 454 elms = new_elms;
442 array->set_elements(elms); 455 array->set_elements(elms);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return top; 491 return top;
479 } 492 }
480 493
481 top = array->GetPrototype()->GetElement(len - 1); 494 top = array->GetPrototype()->GetElement(len - 1);
482 495
483 return top; 496 return top;
484 } 497 }
485 498
486 499
487 BUILTIN(ArrayShift) { 500 BUILTIN(ArrayShift) {
501 Object* elms_obj;
502 { TryAllocation t = EnsureJSArrayWithWritableFastElements(receiver);
503 if (!t->ToObject(&elms_obj)) return t;
504 }
488 Object* receiver = *args.receiver(); 505 Object* receiver = *args.receiver();
489 Object* elms_obj = EnsureJSArrayWithWritableFastElements(receiver);
490 if (elms_obj->IsFailure()) return elms_obj;
491 if (elms_obj == NULL || 506 if (elms_obj == NULL ||
492 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) { 507 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
493 return CallJsBuiltin("ArrayShift", args); 508 return CallJsBuiltin("ArrayShift", args);
494 } 509 }
495 FixedArray* elms = FixedArray::cast(elms_obj); 510 FixedArray* elms = FixedArray::cast(elms_obj);
496 JSArray* array = JSArray::cast(receiver); 511 JSArray* array = JSArray::cast(receiver);
497 ASSERT(array->HasFastElements()); 512 ASSERT(array->HasFastElements());
498 513
499 int len = Smi::cast(array->length())->value(); 514 int len = Smi::cast(array->length())->value();
500 if (len == 0) return Heap::undefined_value(); 515 if (len == 0) return Heap::undefined_value();
(...skipping 16 matching lines...) Expand all
517 } 532 }
518 533
519 // Set the length. 534 // Set the length.
520 array->set_length(Smi::FromInt(len - 1)); 535 array->set_length(Smi::FromInt(len - 1));
521 536
522 return first; 537 return first;
523 } 538 }
524 539
525 540
526 BUILTIN(ArrayUnshift) { 541 BUILTIN(ArrayUnshift) {
542 Object* elms_obj;
543 { TryAllocation t = EnsureJSArrayWithWritableFastElements(receiver);
544 if (!t->ToObject(&elms_obj)) return t;
545 }
527 Object* receiver = *args.receiver(); 546 Object* receiver = *args.receiver();
528 Object* elms_obj = EnsureJSArrayWithWritableFastElements(receiver);
529 if (elms_obj->IsFailure()) return elms_obj;
530 if (elms_obj == NULL || 547 if (elms_obj == NULL ||
531 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) { 548 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
532 return CallJsBuiltin("ArrayUnshift", args); 549 return CallJsBuiltin("ArrayUnshift", args);
533 } 550 }
534 FixedArray* elms = FixedArray::cast(elms_obj); 551 FixedArray* elms = FixedArray::cast(elms_obj);
535 JSArray* array = JSArray::cast(receiver); 552 JSArray* array = JSArray::cast(receiver);
536 ASSERT(array->HasFastElements()); 553 ASSERT(array->HasFastElements());
537 554
538 int len = Smi::cast(array->length())->value(); 555 int len = Smi::cast(array->length())->value();
539 int to_add = args.length() - 1; 556 int to_add = args.length() - 1;
540 int new_length = len + to_add; 557 int new_length = len + to_add;
541 // Currently fixed arrays cannot grow too big, so 558 // Currently fixed arrays cannot grow too big, so
542 // we should never hit this case. 559 // we should never hit this case.
543 ASSERT(to_add <= (Smi::kMaxValue - len)); 560 ASSERT(to_add <= (Smi::kMaxValue - len));
544 561
545 if (new_length > elms->length()) { 562 if (new_length > elms->length()) {
546 // New backing storage is needed. 563 // New backing storage is needed.
564 Object* obj;
565 { TryAllocation t = Heap::AllocateUninitializedFixedArray(capacity);
566 if (!t->ToObject(&obj)) return t;
567 }
547 int capacity = new_length + (new_length >> 1) + 16; 568 int capacity = new_length + (new_length >> 1) + 16;
548 Object* obj = Heap::AllocateUninitializedFixedArray(capacity);
549 if (obj->IsFailure()) return obj;
550 FixedArray* new_elms = FixedArray::cast(obj); 569 FixedArray* new_elms = FixedArray::cast(obj);
551 570
552 AssertNoAllocation no_gc; 571 AssertNoAllocation no_gc;
553 if (len > 0) { 572 if (len > 0) {
554 CopyElements(&no_gc, new_elms, to_add, elms, 0, len); 573 CopyElements(&no_gc, new_elms, to_add, elms, 0, len);
555 } 574 }
556 FillWithHoles(new_elms, new_length, capacity); 575 FillWithHoles(new_elms, new_length, capacity);
557 576
558 elms = new_elms; 577 elms = new_elms;
559 array->set_elements(elms); 578 array->set_elements(elms);
560 } else { 579 } else {
561 AssertNoAllocation no_gc; 580 AssertNoAllocation no_gc;
562 MoveElements(&no_gc, elms, to_add, elms, 0, len); 581 MoveElements(&no_gc, elms, to_add, elms, 0, len);
563 } 582 }
564 583
565 // Add the provided values. 584 // Add the provided values.
566 AssertNoAllocation no_gc; 585 AssertNoAllocation no_gc;
567 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 586 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
568 for (int i = 0; i < to_add; i++) { 587 for (int i = 0; i < to_add; i++) {
569 elms->set(i, args[i + 1], mode); 588 elms->set(i, args[i + 1], mode);
570 } 589 }
571 590
572 // Set the length. 591 // Set the length.
573 array->set_length(Smi::FromInt(new_length)); 592 array->set_length(Smi::FromInt(new_length));
574 return Smi::FromInt(new_length); 593 return Smi::FromInt(new_length);
575 } 594 }
576 595
577 596
578 BUILTIN(ArraySlice) { 597 BUILTIN(ArraySlice) {
598 Object* elms_obj;
599 { TryAllocation t = EnsureJSArrayWithWritableFastElements(receiver);
600 if (!t->ToObject(&elms_obj)) return t;
601 }
579 Object* receiver = *args.receiver(); 602 Object* receiver = *args.receiver();
580 Object* elms_obj = EnsureJSArrayWithWritableFastElements(receiver);
581 if (elms_obj->IsFailure()) return elms_obj;
582 if (elms_obj == NULL || 603 if (elms_obj == NULL ||
583 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) { 604 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
584 return CallJsBuiltin("ArraySlice", args); 605 return CallJsBuiltin("ArraySlice", args);
585 } 606 }
586 FixedArray* elms = FixedArray::cast(elms_obj); 607 FixedArray* elms = FixedArray::cast(elms_obj);
587 JSArray* array = JSArray::cast(receiver); 608 JSArray* array = JSArray::cast(receiver);
588 ASSERT(array->HasFastElements()); 609 ASSERT(array->HasFastElements());
589 610
590 int len = Smi::cast(array->length())->value(); 611 int len = Smi::cast(array->length())->value();
591 612
(...skipping 27 matching lines...) Expand all
619 640
620 // ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 8. 641 // ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 8.
621 int final = (relative_end < 0) ? Max(len + relative_end, 0) 642 int final = (relative_end < 0) ? Max(len + relative_end, 0)
622 : Min(relative_end, len); 643 : Min(relative_end, len);
623 644
624 // Calculate the length of result array. 645 // Calculate the length of result array.
625 int result_len = final - k; 646 int result_len = final - k;
626 if (result_len <= 0) { 647 if (result_len <= 0) {
627 return AllocateEmptyJSArray(); 648 return AllocateEmptyJSArray();
628 } 649 }
650 Object* result;
651 { TryAllocation t = AllocateJSArray();
652 if (!t->ToObject(&result)) return t;
653 }
629 654
630 Object* result = AllocateJSArray();
631 if (result->IsFailure()) return result;
632 JSArray* result_array = JSArray::cast(result); 655 JSArray* result_array = JSArray::cast(result);
656 { TryAllocation t = Heap::AllocateUninitializedFixedArray(result_len);
657 if (!t->ToObject(&result)) return t;
658 }
633 659
634 result = Heap::AllocateUninitializedFixedArray(result_len);
635 if (result->IsFailure()) return result;
636 FixedArray* result_elms = FixedArray::cast(result); 660 FixedArray* result_elms = FixedArray::cast(result);
637 661
638 AssertNoAllocation no_gc; 662 AssertNoAllocation no_gc;
639 CopyElements(&no_gc, result_elms, 0, elms, k, result_len); 663 CopyElements(&no_gc, result_elms, 0, elms, k, result_len);
640 664
641 // Set elements. 665 // Set elements.
642 result_array->set_elements(result_elms); 666 result_array->set_elements(result_elms);
643 667
644 // Set the length. 668 // Set the length.
645 result_array->set_length(Smi::FromInt(result_len)); 669 result_array->set_length(Smi::FromInt(result_len));
646 return result_array; 670 return result_array;
647 } 671 }
648 672
649 673
650 BUILTIN(ArraySplice) { 674 BUILTIN(ArraySplice) {
675 Object* elms_obj;
676 { TryAllocation t = EnsureJSArrayWithWritableFastElements(receiver);
677 if (!t->ToObject(&elms_obj)) return t;
678 }
651 Object* receiver = *args.receiver(); 679 Object* receiver = *args.receiver();
652 Object* elms_obj = EnsureJSArrayWithWritableFastElements(receiver);
653 if (elms_obj->IsFailure()) return elms_obj;
654 if (elms_obj == NULL || 680 if (elms_obj == NULL ||
655 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) { 681 !IsJSArrayFastElementMovingAllowed(JSArray::cast(receiver))) {
656 return CallJsBuiltin("ArraySplice", args); 682 return CallJsBuiltin("ArraySplice", args);
657 } 683 }
658 FixedArray* elms = FixedArray::cast(elms_obj); 684 FixedArray* elms = FixedArray::cast(elms_obj);
659 JSArray* array = JSArray::cast(receiver); 685 JSArray* array = JSArray::cast(receiver);
660 ASSERT(array->HasFastElements()); 686 ASSERT(array->HasFastElements());
661 687
662 int len = Smi::cast(array->length())->value(); 688 int len = Smi::cast(array->length())->value();
663 689
(...skipping 23 matching lines...) Expand all
687 Object* arg2 = args[2]; 713 Object* arg2 = args[2];
688 if (arg2->IsSmi()) { 714 if (arg2->IsSmi()) {
689 delete_count = Smi::cast(arg2)->value(); 715 delete_count = Smi::cast(arg2)->value();
690 } else { 716 } else {
691 return CallJsBuiltin("ArraySplice", args); 717 return CallJsBuiltin("ArraySplice", args);
692 } 718 }
693 } 719 }
694 int actual_delete_count = Min(Max(delete_count, 0), len - actual_start); 720 int actual_delete_count = Min(Max(delete_count, 0), len - actual_start);
695 721
696 JSArray* result_array = NULL; 722 JSArray* result_array = NULL;
723 Object* result;
724 { TryAllocation t = AllocateEmptyJSArray();
725 if (!t->ToObject(&result)) return t;
726 }
697 if (actual_delete_count == 0) { 727 if (actual_delete_count == 0) {
698 Object* result = AllocateEmptyJSArray();
699 if (result->IsFailure()) return result;
700 result_array = JSArray::cast(result); 728 result_array = JSArray::cast(result);
701 } else { 729 } else {
730 Object* result;
731 { TryAllocation t = AllocateJSArray();
732 if (!t->ToObject(&result)) return t;
733 }
702 // Allocate result array. 734 // Allocate result array.
703 Object* result = AllocateJSArray();
704 if (result->IsFailure()) return result;
705 result_array = JSArray::cast(result); 735 result_array = JSArray::cast(result);
736 { TryAllocation t =
737 Heap::AllocateUninitializedFixedArray(actual_delete_count);
738 if (!t->ToObject(&result)) return t;
739 }
706 740
707 result = Heap::AllocateUninitializedFixedArray(actual_delete_count);
708 if (result->IsFailure()) return result;
709 FixedArray* result_elms = FixedArray::cast(result); 741 FixedArray* result_elms = FixedArray::cast(result);
710 742
711 AssertNoAllocation no_gc; 743 AssertNoAllocation no_gc;
712 // Fill newly created array. 744 // Fill newly created array.
713 CopyElements(&no_gc, 745 CopyElements(&no_gc,
714 result_elms, 0, 746 result_elms, 0,
715 elms, actual_start, 747 elms, actual_start,
716 actual_delete_count); 748 actual_delete_count);
717 749
718 // Set elements. 750 // Set elements.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 FillWithHoles(elms, new_length, len); 782 FillWithHoles(elms, new_length, len);
751 } 783 }
752 } else if (item_count > actual_delete_count) { 784 } else if (item_count > actual_delete_count) {
753 // Currently fixed arrays cannot grow too big, so 785 // Currently fixed arrays cannot grow too big, so
754 // we should never hit this case. 786 // we should never hit this case.
755 ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len)); 787 ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len));
756 788
757 // Check if array need to grow. 789 // Check if array need to grow.
758 if (new_length > elms->length()) { 790 if (new_length > elms->length()) {
759 // New backing storage is needed. 791 // New backing storage is needed.
792 Object* obj;
793 { TryAllocation t = Heap::AllocateUninitializedFixedArray(capacity);
794 if (!t->ToObject(&obj)) return t;
795 }
760 int capacity = new_length + (new_length >> 1) + 16; 796 int capacity = new_length + (new_length >> 1) + 16;
761 Object* obj = Heap::AllocateUninitializedFixedArray(capacity);
762 if (obj->IsFailure()) return obj;
763 FixedArray* new_elms = FixedArray::cast(obj); 797 FixedArray* new_elms = FixedArray::cast(obj);
764 798
765 AssertNoAllocation no_gc; 799 AssertNoAllocation no_gc;
766 // Copy the part before actual_start as is. 800 // Copy the part before actual_start as is.
767 if (actual_start > 0) { 801 if (actual_start > 0) {
768 CopyElements(&no_gc, new_elms, 0, elms, 0, actual_start); 802 CopyElements(&no_gc, new_elms, 0, elms, 0, actual_start);
769 } 803 }
770 const int to_copy = len - actual_delete_count - actual_start; 804 const int to_copy = len - actual_delete_count - actual_start;
771 if (to_copy > 0) { 805 if (to_copy > 0) {
772 CopyElements(&no_gc, 806 CopyElements(&no_gc,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 864
831 if (result_len > FixedArray::kMaxLength) { 865 if (result_len > FixedArray::kMaxLength) {
832 return CallJsBuiltin("ArrayConcat", args); 866 return CallJsBuiltin("ArrayConcat", args);
833 } 867 }
834 } 868 }
835 869
836 if (result_len == 0) { 870 if (result_len == 0) {
837 return AllocateEmptyJSArray(); 871 return AllocateEmptyJSArray();
838 } 872 }
839 873
874 Object* result;
875 { TryAllocation t = AllocateJSArray();
876 if (!t->ToObject(&result)) return t;
877 }
840 // Allocate result. 878 // Allocate result.
841 Object* result = AllocateJSArray();
842 if (result->IsFailure()) return result;
843 JSArray* result_array = JSArray::cast(result); 879 JSArray* result_array = JSArray::cast(result);
880 { TryAllocation t = Heap::AllocateUninitializedFixedArray(result_len);
881 if (!t->ToObject(&result)) return t;
882 }
844 883
845 result = Heap::AllocateUninitializedFixedArray(result_len);
846 if (result->IsFailure()) return result;
847 FixedArray* result_elms = FixedArray::cast(result); 884 FixedArray* result_elms = FixedArray::cast(result);
848 885
849 // Copy data. 886 // Copy data.
850 AssertNoAllocation no_gc; 887 AssertNoAllocation no_gc;
851 int start_pos = 0; 888 int start_pos = 0;
852 for (int i = 0; i < n_arguments; i++) { 889 for (int i = 0; i < n_arguments; i++) {
853 JSArray* array = JSArray::cast(args[i]); 890 JSArray* array = JSArray::cast(args[i]);
854 int len = Smi::cast(array->length())->value(); 891 int len = Smi::cast(array->length())->value();
855 if (len > 0) { 892 if (len > 0) {
856 FixedArray* elms = FixedArray::cast(array->elements()); 893 FixedArray* elms = FixedArray::cast(array->elements());
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 if (entry->contains(pc)) { 1568 if (entry->contains(pc)) {
1532 return names_[i]; 1569 return names_[i];
1533 } 1570 }
1534 } 1571 }
1535 } 1572 }
1536 return NULL; 1573 return NULL;
1537 } 1574 }
1538 1575
1539 1576
1540 } } // namespace v8::internal 1577 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698