| OLD | NEW |
| 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 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3072 __ bind(&miss); | 3072 __ bind(&miss); |
| 3073 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 3073 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 3074 | 3074 |
| 3075 // Return the generated code. | 3075 // Return the generated code. |
| 3076 return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); | 3076 return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); |
| 3077 } | 3077 } |
| 3078 | 3078 |
| 3079 | 3079 |
| 3080 // Specialized stub for constructing objects from functions which only have only | 3080 // Specialized stub for constructing objects from functions which only have only |
| 3081 // simple assignments of the form this.x = ...; in their body. | 3081 // simple assignments of the form this.x = ...; in their body. |
| 3082 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { | 3082 Handle<Code> ConstructStubCompiler::CompileConstructStub( |
| 3083 Handle<JSFunction> function) { |
| 3083 // ----------- S t a t e ------------- | 3084 // ----------- S t a t e ------------- |
| 3084 // -- eax : argc | 3085 // -- eax : argc |
| 3085 // -- edi : constructor | 3086 // -- edi : constructor |
| 3086 // -- esp[0] : return address | 3087 // -- esp[0] : return address |
| 3087 // -- esp[4] : last argument | 3088 // -- esp[4] : last argument |
| 3088 // ----------------------------------- | 3089 // ----------------------------------- |
| 3089 Label generic_stub_call; | 3090 Label generic_stub_call; |
| 3090 #ifdef ENABLE_DEBUGGER_SUPPORT | 3091 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 3091 // Check to see whether there are any break points in the function code. If | 3092 // Check to see whether there are any break points in the function code. If |
| 3092 // there are jump to the generic constructor stub which calls the actual | 3093 // there are jump to the generic constructor stub which calls the actual |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3111 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); | 3112 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); |
| 3112 __ Assert(not_equal, "Function constructed by construct stub."); | 3113 __ Assert(not_equal, "Function constructed by construct stub."); |
| 3113 #endif | 3114 #endif |
| 3114 | 3115 |
| 3115 // Now allocate the JSObject on the heap by moving the new space allocation | 3116 // Now allocate the JSObject on the heap by moving the new space allocation |
| 3116 // top forward. | 3117 // top forward. |
| 3117 // edi: constructor | 3118 // edi: constructor |
| 3118 // ebx: initial map | 3119 // ebx: initial map |
| 3119 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); | 3120 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); |
| 3120 __ shl(ecx, kPointerSizeLog2); | 3121 __ shl(ecx, kPointerSizeLog2); |
| 3121 __ AllocateInNewSpace(ecx, | 3122 __ AllocateInNewSpace(ecx, edx, ecx, no_reg, |
| 3122 edx, | 3123 &generic_stub_call, NO_ALLOCATION_FLAGS); |
| 3123 ecx, | |
| 3124 no_reg, | |
| 3125 &generic_stub_call, | |
| 3126 NO_ALLOCATION_FLAGS); | |
| 3127 | 3124 |
| 3128 // Allocated the JSObject, now initialize the fields and add the heap tag. | 3125 // Allocated the JSObject, now initialize the fields and add the heap tag. |
| 3129 // ebx: initial map | 3126 // ebx: initial map |
| 3130 // edx: JSObject (untagged) | 3127 // edx: JSObject (untagged) |
| 3131 __ mov(Operand(edx, JSObject::kMapOffset), ebx); | 3128 __ mov(Operand(edx, JSObject::kMapOffset), ebx); |
| 3132 __ mov(ebx, factory()->empty_fixed_array()); | 3129 __ mov(ebx, factory()->empty_fixed_array()); |
| 3133 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx); | 3130 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx); |
| 3134 __ mov(Operand(edx, JSObject::kElementsOffset), ebx); | 3131 __ mov(Operand(edx, JSObject::kElementsOffset), ebx); |
| 3135 | 3132 |
| 3136 // Push the allocated object to the stack. This is the object that will be | 3133 // Push the allocated object to the stack. This is the object that will be |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3147 | 3144 |
| 3148 // Use edi for holding undefined which is used in several places below. | 3145 // Use edi for holding undefined which is used in several places below. |
| 3149 __ mov(edi, factory()->undefined_value()); | 3146 __ mov(edi, factory()->undefined_value()); |
| 3150 | 3147 |
| 3151 // eax: argc | 3148 // eax: argc |
| 3152 // ecx: first argument | 3149 // ecx: first argument |
| 3153 // edx: first in-object property of the JSObject | 3150 // edx: first in-object property of the JSObject |
| 3154 // edi: undefined | 3151 // edi: undefined |
| 3155 // Fill the initialized properties with a constant value or a passed argument | 3152 // Fill the initialized properties with a constant value or a passed argument |
| 3156 // depending on the this.x = ...; assignment in the function. | 3153 // depending on the this.x = ...; assignment in the function. |
| 3157 SharedFunctionInfo* shared = function->shared(); | 3154 Handle<SharedFunctionInfo> shared(function->shared()); |
| 3158 for (int i = 0; i < shared->this_property_assignments_count(); i++) { | 3155 for (int i = 0; i < shared->this_property_assignments_count(); i++) { |
| 3159 if (shared->IsThisPropertyAssignmentArgument(i)) { | 3156 if (shared->IsThisPropertyAssignmentArgument(i)) { |
| 3160 // Check if the argument assigned to the property is actually passed. | 3157 // Check if the argument assigned to the property is actually passed. |
| 3161 // If argument is not passed the property is set to undefined, | 3158 // If argument is not passed the property is set to undefined, |
| 3162 // otherwise find it on the stack. | 3159 // otherwise find it on the stack. |
| 3163 int arg_number = shared->GetThisPropertyAssignmentArgument(i); | 3160 int arg_number = shared->GetThisPropertyAssignmentArgument(i); |
| 3164 __ mov(ebx, edi); | 3161 __ mov(ebx, edi); |
| 3165 __ cmp(eax, arg_number); | 3162 __ cmp(eax, arg_number); |
| 3166 if (CpuFeatures::IsSupported(CMOV)) { | 3163 if (CpuFeatures::IsSupported(CMOV)) { |
| 3167 CpuFeatures::Scope use_cmov(CMOV); | 3164 CpuFeatures::Scope use_cmov(CMOV); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3199 __ lea(esp, Operand(esp, ebx, times_pointer_size, 1 * kPointerSize)); | 3196 __ lea(esp, Operand(esp, ebx, times_pointer_size, 1 * kPointerSize)); |
| 3200 __ push(ecx); | 3197 __ push(ecx); |
| 3201 Counters* counters = isolate()->counters(); | 3198 Counters* counters = isolate()->counters(); |
| 3202 __ IncrementCounter(counters->constructed_objects(), 1); | 3199 __ IncrementCounter(counters->constructed_objects(), 1); |
| 3203 __ IncrementCounter(counters->constructed_objects_stub(), 1); | 3200 __ IncrementCounter(counters->constructed_objects_stub(), 1); |
| 3204 __ ret(0); | 3201 __ ret(0); |
| 3205 | 3202 |
| 3206 // Jump to the generic stub in case the specialized code cannot handle the | 3203 // Jump to the generic stub in case the specialized code cannot handle the |
| 3207 // construction. | 3204 // construction. |
| 3208 __ bind(&generic_stub_call); | 3205 __ bind(&generic_stub_call); |
| 3209 Handle<Code> generic_construct_stub = | 3206 Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric(); |
| 3210 isolate()->builtins()->JSConstructStubGeneric(); | 3207 __ jmp(code, RelocInfo::CODE_TARGET); |
| 3211 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | |
| 3212 | 3208 |
| 3213 // Return the generated code. | 3209 // Return the generated code. |
| 3214 return GetCode(); | 3210 return GetCode(); |
| 3215 } | 3211 } |
| 3216 | 3212 |
| 3217 | 3213 |
| 3218 #undef __ | 3214 #undef __ |
| 3219 #define __ ACCESS_MASM(masm) | 3215 #define __ ACCESS_MASM(masm) |
| 3220 | 3216 |
| 3221 | 3217 |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3855 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); | 3851 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); |
| 3856 __ jmp(ic_miss, RelocInfo::CODE_TARGET); | 3852 __ jmp(ic_miss, RelocInfo::CODE_TARGET); |
| 3857 } | 3853 } |
| 3858 | 3854 |
| 3859 | 3855 |
| 3860 #undef __ | 3856 #undef __ |
| 3861 | 3857 |
| 3862 } } // namespace v8::internal | 3858 } } // namespace v8::internal |
| 3863 | 3859 |
| 3864 #endif // V8_TARGET_ARCH_IA32 | 3860 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |