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

Side by Side Diff: src/builtins.cc

Issue 8054007: Smi element fixes in Builtins. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 653 }
654 654
655 655
656 BUILTIN(ArraySlice) { 656 BUILTIN(ArraySlice) {
657 Heap* heap = isolate->heap(); 657 Heap* heap = isolate->heap();
658 Object* receiver = *args.receiver(); 658 Object* receiver = *args.receiver();
659 FixedArray* elms; 659 FixedArray* elms;
660 int len = -1; 660 int len = -1;
661 if (receiver->IsJSArray()) { 661 if (receiver->IsJSArray()) {
662 JSArray* array = JSArray::cast(receiver); 662 JSArray* array = JSArray::cast(receiver);
663 if (!array->HasFastElements() || 663 if (!array->HasFastTypeElements() ||
664 !IsJSArrayFastElementMovingAllowed(heap, array)) { 664 !IsJSArrayFastElementMovingAllowed(heap, array)) {
665 return CallJsBuiltin(isolate, "ArraySlice", args); 665 return CallJsBuiltin(isolate, "ArraySlice", args);
666 } 666 }
667 667
668 elms = FixedArray::cast(array->elements()); 668 elms = FixedArray::cast(array->elements());
669 len = Smi::cast(array->length())->value(); 669 len = Smi::cast(array->length())->value();
670 } else { 670 } else {
671 // Array.slice(arguments, ...) is quite a common idiom (notably more 671 // Array.slice(arguments, ...) is quite a common idiom (notably more
672 // than 50% of invocations in Web apps). Treat it in C++ as well. 672 // than 50% of invocations in Web apps). Treat it in C++ as well.
673 Map* arguments_map = 673 Map* arguments_map =
674 isolate->context()->global_context()->arguments_boilerplate()->map(); 674 isolate->context()->global_context()->arguments_boilerplate()->map();
675 675
676 bool is_arguments_object_with_fast_elements = 676 bool is_arguments_object_with_fast_elements =
677 receiver->IsJSObject() 677 receiver->IsJSObject()
678 && JSObject::cast(receiver)->map() == arguments_map 678 && JSObject::cast(receiver)->map() == arguments_map
679 && JSObject::cast(receiver)->HasFastElements(); 679 && JSObject::cast(receiver)->HasFastTypeElements();
680 if (!is_arguments_object_with_fast_elements) { 680 if (!is_arguments_object_with_fast_elements) {
681 return CallJsBuiltin(isolate, "ArraySlice", args); 681 return CallJsBuiltin(isolate, "ArraySlice", args);
682 } 682 }
683 elms = FixedArray::cast(JSObject::cast(receiver)->elements()); 683 elms = FixedArray::cast(JSObject::cast(receiver)->elements());
684 Object* len_obj = JSObject::cast(receiver) 684 Object* len_obj = JSObject::cast(receiver)
685 ->InObjectPropertyAt(Heap::kArgumentsLengthIndex); 685 ->InObjectPropertyAt(Heap::kArgumentsLengthIndex);
686 if (!len_obj->IsSmi()) { 686 if (!len_obj->IsSmi()) {
687 return CallJsBuiltin(isolate, "ArraySlice", args); 687 return CallJsBuiltin(isolate, "ArraySlice", args);
688 } 688 }
689 len = Smi::cast(len_obj)->value(); 689 len = Smi::cast(len_obj)->value();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 if (!ArrayPrototypeHasNoElements(heap, global_context, array_proto)) { 956 if (!ArrayPrototypeHasNoElements(heap, global_context, array_proto)) {
957 return CallJsBuiltin(isolate, "ArrayConcat", args); 957 return CallJsBuiltin(isolate, "ArrayConcat", args);
958 } 958 }
959 959
960 // Iterate through all the arguments performing checks 960 // Iterate through all the arguments performing checks
961 // and calculating total length. 961 // and calculating total length.
962 int n_arguments = args.length(); 962 int n_arguments = args.length();
963 int result_len = 0; 963 int result_len = 0;
964 for (int i = 0; i < n_arguments; i++) { 964 for (int i = 0; i < n_arguments; i++) {
965 Object* arg = args[i]; 965 Object* arg = args[i];
966 if (!arg->IsJSArray() || !JSArray::cast(arg)->HasFastElements() 966 if (!arg->IsJSArray() || !JSArray::cast(arg)->HasFastTypeElements()
967 || JSArray::cast(arg)->GetPrototype() != array_proto) { 967 || JSArray::cast(arg)->GetPrototype() != array_proto) {
968 return CallJsBuiltin(isolate, "ArrayConcat", args); 968 return CallJsBuiltin(isolate, "ArrayConcat", args);
969 } 969 }
970 970
971 int len = Smi::cast(JSArray::cast(arg)->length())->value(); 971 int len = Smi::cast(JSArray::cast(arg)->length())->value();
972 972
973 // We shouldn't overflow when adding another len. 973 // We shouldn't overflow when adding another len.
974 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); 974 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
975 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); 975 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt);
976 USE(kHalfOfMaxInt); 976 USE(kHalfOfMaxInt);
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 return Handle<Code>(code_address); \ 1761 return Handle<Code>(code_address); \
1762 } 1762 }
1763 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1763 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1764 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1764 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1765 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1765 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1766 #undef DEFINE_BUILTIN_ACCESSOR_C 1766 #undef DEFINE_BUILTIN_ACCESSOR_C
1767 #undef DEFINE_BUILTIN_ACCESSOR_A 1767 #undef DEFINE_BUILTIN_ACCESSOR_A
1768 1768
1769 1769
1770 } } // namespace v8::internal 1770 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698