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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 2084017: Version 2.2.11... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 7 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/ia32/assembler-ia32-inl.h ('k') | src/ia32/codegen-ia32.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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #if defined(V8_TARGET_ARCH_IA32)
31
30 #include "codegen-inl.h" 32 #include "codegen-inl.h"
31 33
32 namespace v8 { 34 namespace v8 {
33 namespace internal { 35 namespace internal {
34 36
35 37
36 #define __ ACCESS_MASM(masm) 38 #define __ ACCESS_MASM(masm)
37 39
38 40
39 void Builtins::Generate_Adaptor(MacroAssembler* masm, 41 void Builtins::Generate_Adaptor(MacroAssembler* masm,
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 Register array_function, // Array function. 801 Register array_function, // Array function.
800 Register array_size, // As a smi, cannot be 0. 802 Register array_size, // As a smi, cannot be 0.
801 Register result, 803 Register result,
802 Register elements_array, 804 Register elements_array,
803 Register elements_array_end, 805 Register elements_array_end,
804 Register scratch, 806 Register scratch,
805 bool fill_with_hole, 807 bool fill_with_hole,
806 Label* gc_required) { 808 Label* gc_required) {
807 ASSERT(scratch.is(edi)); // rep stos destination 809 ASSERT(scratch.is(edi)); // rep stos destination
808 ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count 810 ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count
811 ASSERT(!fill_with_hole || !result.is(eax)); // result is never eax
809 812
810 // Load the initial map from the array function. 813 // Load the initial map from the array function.
811 __ mov(elements_array, 814 __ mov(elements_array,
812 FieldOperand(array_function, 815 FieldOperand(array_function,
813 JSFunction::kPrototypeOrInitialMapOffset)); 816 JSFunction::kPrototypeOrInitialMapOffset));
814 817
815 // Allocate the JSArray object together with space for a FixedArray with the 818 // Allocate the JSArray object together with space for a FixedArray with the
816 // requested elements. 819 // requested elements.
817 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 820 ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
818 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, 821 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // For non-empty JSArrays the length of the FixedArray and the JSArray is the 859 // For non-empty JSArrays the length of the FixedArray and the JSArray is the
857 // same. 860 // same.
858 __ mov(FieldOperand(elements_array, Array::kLengthOffset), array_size); 861 __ mov(FieldOperand(elements_array, Array::kLengthOffset), array_size);
859 862
860 // Fill the allocated FixedArray with the hole value if requested. 863 // Fill the allocated FixedArray with the hole value if requested.
861 // result: JSObject 864 // result: JSObject
862 // elements_array: elements array 865 // elements_array: elements array
863 if (fill_with_hole) { 866 if (fill_with_hole) {
864 __ lea(edi, Operand(elements_array, 867 __ lea(edi, Operand(elements_array,
865 FixedArray::kHeaderSize - kHeapObjectTag)); 868 FixedArray::kHeaderSize - kHeapObjectTag));
866
867 __ push(eax);
868 __ mov(eax, Factory::the_hole_value()); 869 __ mov(eax, Factory::the_hole_value());
869
870 __ cld(); 870 __ cld();
871 // Do not use rep stos when filling less than kRepStosThreshold
872 // words.
873 const int kRepStosThreshold = 16;
874 Label loop, entry, done;
875 __ cmp(ecx, kRepStosThreshold);
876 __ j(below, &loop); // Note: ecx > 0.
871 __ rep_stos(); 877 __ rep_stos();
872 878 __ jmp(&done);
873 // Restore saved registers. 879 __ bind(&loop);
874 __ pop(eax); 880 __ stos();
881 __ bind(&entry);
882 __ cmp(edi, Operand(elements_array_end));
883 __ j(below, &loop);
884 __ bind(&done);
875 } 885 }
876 } 886 }
877 887
878 888
879 // Create a new array for the built-in Array function. This function allocates 889 // Create a new array for the built-in Array function. This function allocates
880 // the JSArray object and the FixedArray elements array and initializes these. 890 // the JSArray object and the FixedArray elements array and initializes these.
881 // If the Array cannot be constructed in native code the runtime is called. This 891 // If the Array cannot be constructed in native code the runtime is called. This
882 // function assumes the following state: 892 // function assumes the following state:
883 // edi: constructor (built-in Array function) 893 // edi: constructor (built-in Array function)
884 // eax: argc 894 // eax: argc
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 973
964 // edx: array_size (smi) 974 // edx: array_size (smi)
965 // edi: constructor 975 // edi: constructor
966 // esp[0]: argc (cannot be 0 here) 976 // esp[0]: argc (cannot be 0 here)
967 // esp[4]: constructor (only if construct_call) 977 // esp[4]: constructor (only if construct_call)
968 // esp[8]: return address 978 // esp[8]: return address
969 // esp[C]: argument 979 // esp[C]: argument
970 AllocateJSArray(masm, 980 AllocateJSArray(masm,
971 edi, 981 edi,
972 ecx, 982 ecx,
983 ebx,
973 eax, 984 eax,
974 ebx,
975 edx, 985 edx,
976 edi, 986 edi,
977 true, 987 true,
978 &prepare_generic_code_call); 988 &prepare_generic_code_call);
979 __ IncrementCounter(&Counters::array_function_native, 1); 989 __ IncrementCounter(&Counters::array_function_native, 1);
990 __ mov(eax, ebx);
980 __ pop(ebx); 991 __ pop(ebx);
981 if (construct_call) { 992 if (construct_call) {
982 __ pop(edi); 993 __ pop(edi);
983 } 994 }
984 __ ret(2 * kPointerSize); 995 __ ret(2 * kPointerSize);
985 996
986 // Handle construction of an array from a list of arguments. 997 // Handle construction of an array from a list of arguments.
987 __ bind(&argc_two_or_more); 998 __ bind(&argc_two_or_more);
988 ASSERT(kSmiTag == 0); 999 ASSERT(kSmiTag == 0);
989 __ SmiTag(eax); // Convet argc to a smi. 1000 __ SmiTag(eax); // Convet argc to a smi.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 // Dont adapt arguments. 1251 // Dont adapt arguments.
1241 // ------------------------------------------- 1252 // -------------------------------------------
1242 __ bind(&dont_adapt_arguments); 1253 __ bind(&dont_adapt_arguments);
1243 __ jmp(Operand(edx)); 1254 __ jmp(Operand(edx));
1244 } 1255 }
1245 1256
1246 1257
1247 #undef __ 1258 #undef __
1248 1259
1249 } } // namespace v8::internal 1260 } } // namespace v8::internal
1261
1262 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32-inl.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698