| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 | 162 |
| 163 static void InitializeArrayConstructorDescriptor( | 163 static void InitializeArrayConstructorDescriptor( |
| 164 Isolate* isolate, | 164 Isolate* isolate, |
| 165 CodeStubInterfaceDescriptor* descriptor, | 165 CodeStubInterfaceDescriptor* descriptor, |
| 166 int constant_stack_parameter_count) { | 166 int constant_stack_parameter_count) { |
| 167 // register state | 167 // register state |
| 168 // eax -- number of arguments | 168 // eax -- number of arguments |
| 169 // edi -- function | 169 // edi -- function |
| 170 // ebx -- type info cell with elements kind | 170 // ebx -- type info cell with elements kind |
| 171 static Register registers[] = { edi, ebx }; | 171 static Register registers_variable_args[] = { edi, ebx, eax }; |
| 172 descriptor->register_param_count_ = 2; | 172 static Register registers_no_args[] = { edi, ebx }; |
| 173 | 173 |
| 174 if (constant_stack_parameter_count != 0) { | 174 if (constant_stack_parameter_count == 0) { |
| 175 descriptor->register_param_count_ = 2; |
| 176 descriptor->register_params_ = registers_no_args; |
| 177 } else { |
| 175 // stack param count needs (constructor pointer, and single argument) | 178 // stack param count needs (constructor pointer, and single argument) |
| 179 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; |
| 176 descriptor->stack_parameter_count_ = eax; | 180 descriptor->stack_parameter_count_ = eax; |
| 181 descriptor->register_param_count_ = 3; |
| 182 descriptor->register_params_ = registers_variable_args; |
| 177 } | 183 } |
| 184 |
| 178 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; | 185 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; |
| 179 descriptor->register_params_ = registers; | |
| 180 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; | 186 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; |
| 181 descriptor->deoptimization_handler_ = | 187 descriptor->deoptimization_handler_ = |
| 182 Runtime::FunctionForId(Runtime::kArrayConstructor)->entry; | 188 Runtime::FunctionForId(Runtime::kArrayConstructor)->entry; |
| 183 } | 189 } |
| 184 | 190 |
| 185 | 191 |
| 186 static void InitializeInternalArrayConstructorDescriptor( | 192 static void InitializeInternalArrayConstructorDescriptor( |
| 187 Isolate* isolate, | 193 Isolate* isolate, |
| 188 CodeStubInterfaceDescriptor* descriptor, | 194 CodeStubInterfaceDescriptor* descriptor, |
| 189 int constant_stack_parameter_count) { | 195 int constant_stack_parameter_count) { |
| 190 // register state | 196 // register state |
| 191 // eax -- number of arguments | 197 // eax -- number of arguments |
| 192 // edi -- constructor function | 198 // edi -- constructor function |
| 193 static Register registers[] = { edi }; | 199 static Register registers_variable_args[] = { edi, eax }; |
| 194 descriptor->register_param_count_ = 1; | 200 static Register registers_no_args[] = { edi }; |
| 195 | 201 |
| 196 if (constant_stack_parameter_count != 0) { | 202 if (constant_stack_parameter_count == 0) { |
| 203 descriptor->register_param_count_ = 1; |
| 204 descriptor->register_params_ = registers_no_args; |
| 205 } else { |
| 197 // stack param count needs (constructor pointer, and single argument) | 206 // stack param count needs (constructor pointer, and single argument) |
| 207 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; |
| 198 descriptor->stack_parameter_count_ = eax; | 208 descriptor->stack_parameter_count_ = eax; |
| 209 descriptor->register_param_count_ = 2; |
| 210 descriptor->register_params_ = registers_variable_args; |
| 199 } | 211 } |
| 212 |
| 200 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; | 213 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; |
| 201 descriptor->register_params_ = registers; | |
| 202 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; | 214 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; |
| 203 descriptor->deoptimization_handler_ = | 215 descriptor->deoptimization_handler_ = |
| 204 Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry; | 216 Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry; |
| 205 } | 217 } |
| 206 | 218 |
| 207 | 219 |
| 208 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 220 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 209 Isolate* isolate, | 221 Isolate* isolate, |
| 210 CodeStubInterfaceDescriptor* descriptor) { | 222 CodeStubInterfaceDescriptor* descriptor) { |
| 211 InitializeArrayConstructorDescriptor(isolate, descriptor, 0); | 223 InitializeArrayConstructorDescriptor(isolate, descriptor, 0); |
| (...skipping 5707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5919 MacroAssembler* masm, ElementsKind kind) { | 5931 MacroAssembler* masm, ElementsKind kind) { |
| 5920 Label not_zero_case, not_one_case; | 5932 Label not_zero_case, not_one_case; |
| 5921 Label normal_sequence; | 5933 Label normal_sequence; |
| 5922 | 5934 |
| 5923 __ test(eax, eax); | 5935 __ test(eax, eax); |
| 5924 __ j(not_zero, ¬_zero_case); | 5936 __ j(not_zero, ¬_zero_case); |
| 5925 InternalArrayNoArgumentConstructorStub stub0(kind); | 5937 InternalArrayNoArgumentConstructorStub stub0(kind); |
| 5926 __ TailCallStub(&stub0); | 5938 __ TailCallStub(&stub0); |
| 5927 | 5939 |
| 5928 __ bind(¬_zero_case); | 5940 __ bind(¬_zero_case); |
| 5929 __ cmp(eax, 1); | 5941 __ cmp(eax, Immediate(1)); |
| 5930 __ j(greater, ¬_one_case); | 5942 __ j(greater, ¬_one_case); |
| 5931 | 5943 |
| 5932 if (IsFastPackedElementsKind(kind)) { | 5944 if (IsFastPackedElementsKind(kind)) { |
| 5933 // We might need to create a holey array | 5945 // We might need to create a holey array |
| 5934 // look at the first argument | 5946 // look at the first argument |
| 5935 __ mov(ecx, Operand(esp, kPointerSize)); | 5947 __ mov(ecx, Operand(esp, kPointerSize)); |
| 5936 __ test(ecx, ecx); | 5948 __ test(ecx, ecx); |
| 5937 __ j(zero, &normal_sequence); | 5949 __ j(zero, &normal_sequence); |
| 5938 | 5950 |
| 5939 InternalArraySingleArgumentConstructorStub | 5951 InternalArraySingleArgumentConstructorStub |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5952 | 5964 |
| 5953 | 5965 |
| 5954 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { | 5966 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
| 5955 // ----------- S t a t e ------------- | 5967 // ----------- S t a t e ------------- |
| 5956 // -- eax : argc | 5968 // -- eax : argc |
| 5957 // -- ebx : type info cell | 5969 // -- ebx : type info cell |
| 5958 // -- edi : constructor | 5970 // -- edi : constructor |
| 5959 // -- esp[0] : return address | 5971 // -- esp[0] : return address |
| 5960 // -- esp[4] : last argument | 5972 // -- esp[4] : last argument |
| 5961 // ----------------------------------- | 5973 // ----------------------------------- |
| 5962 | |
| 5963 if (FLAG_debug_code) { | 5974 if (FLAG_debug_code) { |
| 5964 // The array construct code is only set for the global and natives | 5975 // The array construct code is only set for the global and natives |
| 5965 // builtin Array functions which always have maps. | 5976 // builtin Array functions which always have maps. |
| 5966 | 5977 |
| 5967 // Initial map for the builtin Array function should be a map. | 5978 // Initial map for the builtin Array function should be a map. |
| 5968 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 5979 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
| 5969 // Will both indicate a NULL and a Smi. | 5980 // Will both indicate a NULL and a Smi. |
| 5970 __ test(ecx, Immediate(kSmiTagMask)); | 5981 __ test(ecx, Immediate(kSmiTagMask)); |
| 5971 __ Assert(not_zero, kUnexpectedInitialMapForArrayFunction); | 5982 __ Assert(not_zero, kUnexpectedInitialMapForArrayFunction); |
| 5972 __ CmpObjectType(ecx, MAP_TYPE, ecx); | 5983 __ CmpObjectType(ecx, MAP_TYPE, ecx); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6001 __ bind(&fast_elements_case); | 6012 __ bind(&fast_elements_case); |
| 6002 GenerateCase(masm, FAST_ELEMENTS); | 6013 GenerateCase(masm, FAST_ELEMENTS); |
| 6003 } | 6014 } |
| 6004 | 6015 |
| 6005 | 6016 |
| 6006 #undef __ | 6017 #undef __ |
| 6007 | 6018 |
| 6008 } } // namespace v8::internal | 6019 } } // namespace v8::internal |
| 6009 | 6020 |
| 6010 #endif // V8_TARGET_ARCH_IA32 | 6021 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |