Chromium Code Reviews| Index: src/ia32/builtins-ia32.cc |
| diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc |
| index c689afb28a605c0b2ad346211763bef1241af308..7dacc24cc6914e5e14b486294ecce15bb4c184c2 100644 |
| --- a/src/ia32/builtins-ia32.cc |
| +++ b/src/ia32/builtins-ia32.cc |
| @@ -1475,6 +1475,70 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
| void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
| // ----------- S t a t e ------------- |
| // -- eax : argc |
| + // -- ebx : type info cell |
| + // -- edi : constructor |
| + // -- esp[0] : return address |
| + // -- esp[4] : last argument |
| + // ----------------------------------- |
| + if (FLAG_debug_code) { |
| + // The array construct code is only set for the global and natives |
| + // builtin Array functions which always have maps. |
| + |
| + // Initial map for the builtin Array function should be a map. |
| + __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
| + // Will both indicate a NULL and a Smi. |
| + __ test(ecx, Immediate(kSmiTagMask)); |
| + __ Assert(not_zero, "Unexpected initial map for Array function"); |
| + __ CmpObjectType(ecx, MAP_TYPE, ecx); |
| + __ Assert(equal, "Unexpected initial map for Array function"); |
| + |
| + // We should either have undefined in ebx or a valid jsglobalpropertycell |
| + Label okay_here; |
| + Handle<Object> undefined_sentinel( |
| + masm->isolate()->heap()->undefined_value()); |
| + Handle<Map> global_property_cell_map( |
| + masm->isolate()->heap()->global_property_cell_map()); |
| + __ cmp(ebx, Immediate(undefined_sentinel)); |
| + __ j(equal, &okay_here); |
| + __ cmp(FieldOperand(ebx, 0), Immediate(global_property_cell_map)); |
| + __ Assert(equal, "Expected property cell in register ebx"); |
| + __ bind(&okay_here); |
| + } |
| + |
| + if (FLAG_optimize_constructed_arrays) { |
|
Toon Verwaest
2013/02/13 15:14:51
Given that the 2 blocks of code are entirely indep
mvstanton
2013/02/19 11:04:08
Actually I'd like to keep it this way because in t
|
| + Label not_zero_case, not_one_case; |
| + __ test(eax, eax); |
| + __ j(not_zero, ¬_zero_case); |
| + ArrayNoArgumentConstructorStub no_argument_stub; |
| + __ TailCallStub(&no_argument_stub); |
| + |
| + __ bind(¬_zero_case); |
| + __ cmp(eax, 1); |
| + __ j(greater, ¬_one_case); |
| + ArraySingleArgumentConstructorStub single_argument_stub; |
| + __ TailCallStub(&single_argument_stub); |
| + |
| + __ bind(¬_one_case); |
| + ArrayNArgumentsConstructorStub n_argument_stub; |
| + __ TailCallStub(&n_argument_stub); |
| + } else { |
| + Label generic_constructor; |
| + // Run the native code for the Array function called as constructor. |
| + ArrayNativeCode(masm, true, &generic_constructor); |
| + |
| + // Jump to the generic construct code in case the specialized code cannot |
| + // handle the construction. |
| + __ bind(&generic_constructor); |
| + Handle<Code> generic_construct_stub = |
| + masm->isolate()->builtins()->JSConstructStubGeneric(); |
| + __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
| + } |
| +} |
| + |
| + |
| +void Builtins::Generate_InternalArrayConstructCode(MacroAssembler* masm) { |
| + // ----------- S t a t e ------------- |
| + // -- eax : argc |
| // -- edi : constructor |
| // -- esp[0] : return address |
| // -- esp[4] : last argument |