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

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

Issue 209012: Minor changes to the native array construct code... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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
« 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 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
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // Initialize the FixedArray and fill it with holes. FixedArray length is not 733 // Initialize the FixedArray and fill it with holes. FixedArray length is not
734 // stored as a smi. 734 // stored as a smi.
735 // result: JSObject 735 // result: JSObject
736 // scratch1: elements array 736 // scratch1: elements array
737 // scratch2: start of next object 737 // scratch2: start of next object
738 __ mov(FieldOperand(scratch1, JSObject::kMapOffset), 738 __ mov(FieldOperand(scratch1, JSObject::kMapOffset),
739 Factory::fixed_array_map()); 739 Factory::fixed_array_map());
740 __ mov(FieldOperand(scratch1, Array::kLengthOffset), Immediate(holes)); 740 __ mov(FieldOperand(scratch1, Array::kLengthOffset), Immediate(holes));
741 741
742 // Fill the FixedArray with the hole value. Inline the code if short. 742 // Fill the FixedArray with the hole value. Inline the code if short.
743 if (holes <= 4) { 743 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed.
744 static const int kLoopUnfoldLimit = 4;
745 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit);
746 if (holes <= kLoopUnfoldLimit) {
744 // Use a scratch register here to have only one reloc info when unfolding 747 // Use a scratch register here to have only one reloc info when unfolding
745 // the loop. 748 // the loop.
746 __ mov(scratch3, Factory::the_hole_value()); 749 __ mov(scratch3, Factory::the_hole_value());
747 for (int i = 0; i < holes; i++) { 750 for (int i = 0; i < holes; i++) {
748 __ mov(FieldOperand(scratch1, 751 __ mov(FieldOperand(scratch1,
749 FixedArray::kHeaderSize + i * kPointerSize), 752 FixedArray::kHeaderSize + i * kPointerSize),
750 scratch3); 753 scratch3);
751 } 754 }
752 } else { 755 } else {
753 Label loop, entry; 756 Label loop, entry;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size); 832 __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size);
830 833
831 // Calculate the location of the elements array and set elements array member 834 // Calculate the location of the elements array and set elements array member
832 // of the JSArray. 835 // of the JSArray.
833 // result: JSObject 836 // result: JSObject
834 // elements_array_end: start of next object 837 // elements_array_end: start of next object
835 // array_size: size of array (smi) 838 // array_size: size of array (smi)
836 __ lea(elements_array, Operand(result, JSArray::kSize)); 839 __ lea(elements_array, Operand(result, JSArray::kSize));
837 __ mov(FieldOperand(result, JSArray::kElementsOffset), elements_array); 840 __ mov(FieldOperand(result, JSArray::kElementsOffset), elements_array);
838 841
839 // Initialize the fixed array and fill it with holes. FixedArray length is not 842 // Initialize the fixed array. FixedArray length is not stored as a smi.
840 // stored as a smi.
841 // result: JSObject 843 // result: JSObject
842 // elements_array: elements array 844 // elements_array: elements array
843 // elements_array_end: start of next object 845 // elements_array_end: start of next object
844 // array_size: size of array (smi) 846 // array_size: size of array (smi)
845 ASSERT(kSmiTag == 0); 847 ASSERT(kSmiTag == 0);
846 __ shr(array_size, kSmiTagSize); // Convert from smi to value. 848 __ shr(array_size, kSmiTagSize); // Convert from smi to value.
847 __ mov(FieldOperand(elements_array, JSObject::kMapOffset), 849 __ mov(FieldOperand(elements_array, JSObject::kMapOffset),
848 Factory::fixed_array_map()); 850 Factory::fixed_array_map());
849 Label not_empty_2, fill_array; 851 Label not_empty_2, fill_array;
850 __ test(array_size, Operand(array_size)); 852 __ test(array_size, Operand(array_size));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 // Push the constructor and argc. No need to tag argc as a smi, as there will 904 // Push the constructor and argc. No need to tag argc as a smi, as there will
903 // be no garbage collection with this on the stack. 905 // be no garbage collection with this on the stack.
904 int push_count = 0; 906 int push_count = 0;
905 if (construct_call) { 907 if (construct_call) {
906 push_count++; 908 push_count++;
907 __ push(edi); 909 __ push(edi);
908 } 910 }
909 push_count++; 911 push_count++;
910 __ push(eax); 912 __ push(eax);
911 913
912 // Check for array construction with zero arguments or one. 914 // Check for array construction with zero arguments.
913 __ test(eax, Operand(eax)); 915 __ test(eax, Operand(eax));
914 __ j(not_zero, &argc_one_or_more); 916 __ j(not_zero, &argc_one_or_more);
915 917
916 // Handle construction of an empty array. 918 // Handle construction of an empty array.
917 AllocateEmptyJSArray(masm, 919 AllocateEmptyJSArray(masm,
918 edi, 920 edi,
919 eax, 921 eax,
920 ebx, 922 ebx,
921 ecx, 923 ecx,
922 edi, 924 edi,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 // eax: JSArray 1000 // eax: JSArray
999 // ebx: argc 1001 // ebx: argc
1000 // edx: elements_array_end (untagged) 1002 // edx: elements_array_end (untagged)
1001 // esp[0]: JSArray 1003 // esp[0]: JSArray
1002 // esp[4]: return address 1004 // esp[4]: return address
1003 // esp[8]: last argument 1005 // esp[8]: last argument
1004 1006
1005 // Location of the last argument 1007 // Location of the last argument
1006 __ lea(edi, Operand(esp, 2 * kPointerSize)); 1008 __ lea(edi, Operand(esp, 2 * kPointerSize));
1007 1009
1008 // Location of the first array element (fill_with_holes is false, so the 1010 // Location of the first array element (Parameter fill_with_holes to
1009 // FixedArray is returned). 1011 // AllocateJSArrayis false, so the FixedArray is returned in ecx).
1010 __ lea(edx, Operand(ecx, FixedArray::kHeaderSize - kHeapObjectTag)); 1012 __ lea(edx, Operand(ecx, FixedArray::kHeaderSize - kHeapObjectTag));
1011 1013
1012 // ebx: argc 1014 // ebx: argc
1013 // edx: location of the first array element 1015 // edx: location of the first array element
1014 // edi: location of the last argument 1016 // edi: location of the last argument
1015 // esp[0]: JSArray 1017 // esp[0]: JSArray
1016 // esp[4]: return address 1018 // esp[4]: return address
1017 // esp[8]: last argument 1019 // esp[8]: last argument
1018 Label loop, entry; 1020 Label loop, entry;
1019 __ mov(ecx, ebx); 1021 __ mov(ecx, ebx);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 if (FLAG_debug_code) { 1063 if (FLAG_debug_code) {
1062 // Initial map for the builtin Array function shoud be a map. 1064 // Initial map for the builtin Array function shoud be a map.
1063 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); 1065 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
1064 // Will both indicate a NULL and a Smi. 1066 // Will both indicate a NULL and a Smi.
1065 __ test(ebx, Immediate(kSmiTagMask)); 1067 __ test(ebx, Immediate(kSmiTagMask));
1066 __ Assert(not_zero, "Unexpected initial map for Array function"); 1068 __ Assert(not_zero, "Unexpected initial map for Array function");
1067 __ CmpObjectType(ebx, MAP_TYPE, ecx); 1069 __ CmpObjectType(ebx, MAP_TYPE, ecx);
1068 __ Assert(equal, "Unexpected initial map for Array function"); 1070 __ Assert(equal, "Unexpected initial map for Array function");
1069 } 1071 }
1070 1072
1071 // Run the native code for the Array function called as constructor. 1073 // Run the native code for the Array function called as a normal function.
1072 ArrayNativeCode(masm, false, &generic_array_code); 1074 ArrayNativeCode(masm, false, &generic_array_code);
1073 1075
1074 // Jump to the generic array code in case the specialized code cannot handle 1076 // Jump to the generic array code in case the specialized code cannot handle
1075 // the construction. 1077 // the construction.
1076 __ bind(&generic_array_code); 1078 __ bind(&generic_array_code);
1077 Code* code = Builtins::builtin(Builtins::ArrayCodeGeneric); 1079 Code* code = Builtins::builtin(Builtins::ArrayCodeGeneric);
1078 Handle<Code> array_code(code); 1080 Handle<Code> array_code(code);
1079 __ jmp(array_code, RelocInfo::CODE_TARGET); 1081 __ jmp(array_code, RelocInfo::CODE_TARGET);
1080 } 1082 }
1081 1083
(...skipping 16 matching lines...) Expand all
1098 // Initial map for the builtin Array function should be a map. 1100 // Initial map for the builtin Array function should be a map.
1099 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); 1101 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
1100 // Will both indicate a NULL and a Smi. 1102 // Will both indicate a NULL and a Smi.
1101 __ test(ebx, Immediate(kSmiTagMask)); 1103 __ test(ebx, Immediate(kSmiTagMask));
1102 __ Assert(not_zero, "Unexpected initial map for Array function"); 1104 __ Assert(not_zero, "Unexpected initial map for Array function");
1103 __ CmpObjectType(ebx, MAP_TYPE, ecx); 1105 __ CmpObjectType(ebx, MAP_TYPE, ecx);
1104 __ Assert(equal, "Unexpected initial map for Array function"); 1106 __ Assert(equal, "Unexpected initial map for Array function");
1105 } 1107 }
1106 1108
1107 // Run the native code for the Array function called as constructor. 1109 // Run the native code for the Array function called as constructor.
1108 ArrayNativeCode(masm, false, &generic_constructor); 1110 ArrayNativeCode(masm, true, &generic_constructor);
1109 1111
1110 // Jump to the generic construct code in case the specialized code cannot 1112 // Jump to the generic construct code in case the specialized code cannot
1111 // handle the construction. 1113 // handle the construction.
1112 __ bind(&generic_constructor); 1114 __ bind(&generic_constructor);
1113 GenerateLoadArrayFunction(masm, edi);
1114 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); 1115 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric);
1115 Handle<Code> generic_construct_stub(code); 1116 Handle<Code> generic_construct_stub(code);
1116 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); 1117 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
1117 } 1118 }
1118 1119
1119 1120
1120 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { 1121 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
1121 __ push(ebp); 1122 __ push(ebp);
1122 __ mov(ebp, Operand(esp)); 1123 __ mov(ebp, Operand(esp));
1123 1124
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // Dont adapt arguments. 1228 // Dont adapt arguments.
1228 // ------------------------------------------- 1229 // -------------------------------------------
1229 __ bind(&dont_adapt_arguments); 1230 __ bind(&dont_adapt_arguments);
1230 __ jmp(Operand(edx)); 1231 __ jmp(Operand(edx));
1231 } 1232 }
1232 1233
1233 1234
1234 #undef __ 1235 #undef __
1235 1236
1236 } } // namespace v8::internal 1237 } } // 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