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 2902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2913 __ bind(&miss); | 2913 __ bind(&miss); |
2914 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 2914 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
2915 | 2915 |
2916 // Return the generated code. | 2916 // Return the generated code. |
2917 return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); | 2917 return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); |
2918 } | 2918 } |
2919 | 2919 |
2920 | 2920 |
2921 // Specialized stub for constructing objects from functions which only have only | 2921 // Specialized stub for constructing objects from functions which only have only |
2922 // simple assignments of the form this.x = ...; in their body. | 2922 // simple assignments of the form this.x = ...; in their body. |
2923 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { | 2923 Handle<Code> ConstructStubCompiler::CompileConstructStub( |
| 2924 Handle<JSFunction> function) { |
2924 // ----------- S t a t e ------------- | 2925 // ----------- S t a t e ------------- |
2925 // -- rax : argc | 2926 // -- rax : argc |
2926 // -- rdi : constructor | 2927 // -- rdi : constructor |
2927 // -- rsp[0] : return address | 2928 // -- rsp[0] : return address |
2928 // -- rsp[4] : last argument | 2929 // -- rsp[4] : last argument |
2929 // ----------------------------------- | 2930 // ----------------------------------- |
2930 Label generic_stub_call; | 2931 Label generic_stub_call; |
2931 | 2932 |
2932 // Use r8 for holding undefined which is used in several places below. | 2933 // Use r8 for holding undefined which is used in several places below. |
2933 __ Move(r8, factory()->undefined_value()); | 2934 __ Move(r8, factory()->undefined_value()); |
(...skipping 22 matching lines...) Expand all Loading... |
2956 // rbx: initial map | 2957 // rbx: initial map |
2957 __ CmpInstanceType(rbx, JS_FUNCTION_TYPE); | 2958 __ CmpInstanceType(rbx, JS_FUNCTION_TYPE); |
2958 __ Assert(not_equal, "Function constructed by construct stub."); | 2959 __ Assert(not_equal, "Function constructed by construct stub."); |
2959 #endif | 2960 #endif |
2960 | 2961 |
2961 // Now allocate the JSObject in new space. | 2962 // Now allocate the JSObject in new space. |
2962 // rdi: constructor | 2963 // rdi: constructor |
2963 // rbx: initial map | 2964 // rbx: initial map |
2964 __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset)); | 2965 __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset)); |
2965 __ shl(rcx, Immediate(kPointerSizeLog2)); | 2966 __ shl(rcx, Immediate(kPointerSizeLog2)); |
2966 __ AllocateInNewSpace(rcx, | 2967 __ AllocateInNewSpace(rcx, rdx, rcx, no_reg, |
2967 rdx, | 2968 &generic_stub_call, NO_ALLOCATION_FLAGS); |
2968 rcx, | |
2969 no_reg, | |
2970 &generic_stub_call, | |
2971 NO_ALLOCATION_FLAGS); | |
2972 | 2969 |
2973 // Allocated the JSObject, now initialize the fields and add the heap tag. | 2970 // Allocated the JSObject, now initialize the fields and add the heap tag. |
2974 // rbx: initial map | 2971 // rbx: initial map |
2975 // rdx: JSObject (untagged) | 2972 // rdx: JSObject (untagged) |
2976 __ movq(Operand(rdx, JSObject::kMapOffset), rbx); | 2973 __ movq(Operand(rdx, JSObject::kMapOffset), rbx); |
2977 __ Move(rbx, factory()->empty_fixed_array()); | 2974 __ Move(rbx, factory()->empty_fixed_array()); |
2978 __ movq(Operand(rdx, JSObject::kPropertiesOffset), rbx); | 2975 __ movq(Operand(rdx, JSObject::kPropertiesOffset), rbx); |
2979 __ movq(Operand(rdx, JSObject::kElementsOffset), rbx); | 2976 __ movq(Operand(rdx, JSObject::kElementsOffset), rbx); |
2980 | 2977 |
2981 // rax: argc | 2978 // rax: argc |
2982 // rdx: JSObject (untagged) | 2979 // rdx: JSObject (untagged) |
2983 // Load the address of the first in-object property into r9. | 2980 // Load the address of the first in-object property into r9. |
2984 __ lea(r9, Operand(rdx, JSObject::kHeaderSize)); | 2981 __ lea(r9, Operand(rdx, JSObject::kHeaderSize)); |
2985 // Calculate the location of the first argument. The stack contains only the | 2982 // Calculate the location of the first argument. The stack contains only the |
2986 // return address on top of the argc arguments. | 2983 // return address on top of the argc arguments. |
2987 __ lea(rcx, Operand(rsp, rax, times_pointer_size, 0)); | 2984 __ lea(rcx, Operand(rsp, rax, times_pointer_size, 0)); |
2988 | 2985 |
2989 // rax: argc | 2986 // rax: argc |
2990 // rcx: first argument | 2987 // rcx: first argument |
2991 // rdx: JSObject (untagged) | 2988 // rdx: JSObject (untagged) |
2992 // r8: undefined | 2989 // r8: undefined |
2993 // r9: first in-object property of the JSObject | 2990 // r9: first in-object property of the JSObject |
2994 // Fill the initialized properties with a constant value or a passed argument | 2991 // Fill the initialized properties with a constant value or a passed argument |
2995 // depending on the this.x = ...; assignment in the function. | 2992 // depending on the this.x = ...; assignment in the function. |
2996 SharedFunctionInfo* shared = function->shared(); | 2993 Handle<SharedFunctionInfo> shared(function->shared()); |
2997 for (int i = 0; i < shared->this_property_assignments_count(); i++) { | 2994 for (int i = 0; i < shared->this_property_assignments_count(); i++) { |
2998 if (shared->IsThisPropertyAssignmentArgument(i)) { | 2995 if (shared->IsThisPropertyAssignmentArgument(i)) { |
2999 // Check if the argument assigned to the property is actually passed. | 2996 // Check if the argument assigned to the property is actually passed. |
3000 // If argument is not passed the property is set to undefined, | 2997 // If argument is not passed the property is set to undefined, |
3001 // otherwise find it on the stack. | 2998 // otherwise find it on the stack. |
3002 int arg_number = shared->GetThisPropertyAssignmentArgument(i); | 2999 int arg_number = shared->GetThisPropertyAssignmentArgument(i); |
3003 __ movq(rbx, r8); | 3000 __ movq(rbx, r8); |
3004 __ cmpq(rax, Immediate(arg_number)); | 3001 __ cmpq(rax, Immediate(arg_number)); |
3005 __ cmovq(above, rbx, Operand(rcx, arg_number * -kPointerSize)); | 3002 __ cmovq(above, rbx, Operand(rcx, arg_number * -kPointerSize)); |
3006 // Store value in the property. | 3003 // Store value in the property. |
(...skipping 27 matching lines...) Expand all Loading... |
3034 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize)); | 3031 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize)); |
3035 __ push(rcx); | 3032 __ push(rcx); |
3036 Counters* counters = isolate()->counters(); | 3033 Counters* counters = isolate()->counters(); |
3037 __ IncrementCounter(counters->constructed_objects(), 1); | 3034 __ IncrementCounter(counters->constructed_objects(), 1); |
3038 __ IncrementCounter(counters->constructed_objects_stub(), 1); | 3035 __ IncrementCounter(counters->constructed_objects_stub(), 1); |
3039 __ ret(0); | 3036 __ ret(0); |
3040 | 3037 |
3041 // Jump to the generic stub in case the specialized code cannot handle the | 3038 // Jump to the generic stub in case the specialized code cannot handle the |
3042 // construction. | 3039 // construction. |
3043 __ bind(&generic_stub_call); | 3040 __ bind(&generic_stub_call); |
3044 Code* code = | 3041 Handle<Code> code = isolate()->builtins()->JSConstructStubGeneric(); |
3045 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); | 3042 __ Jump(code, RelocInfo::CODE_TARGET); |
3046 Handle<Code> generic_construct_stub(code); | |
3047 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | |
3048 | 3043 |
3049 // Return the generated code. | 3044 // Return the generated code. |
3050 return GetCode(); | 3045 return GetCode(); |
3051 } | 3046 } |
3052 | 3047 |
3053 | 3048 |
3054 #undef __ | 3049 #undef __ |
3055 #define __ ACCESS_MASM(masm) | 3050 #define __ ACCESS_MASM(masm) |
3056 | 3051 |
3057 | 3052 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); | 3618 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); |
3624 __ jmp(ic_miss, RelocInfo::CODE_TARGET); | 3619 __ jmp(ic_miss, RelocInfo::CODE_TARGET); |
3625 } | 3620 } |
3626 | 3621 |
3627 | 3622 |
3628 #undef __ | 3623 #undef __ |
3629 | 3624 |
3630 } } // namespace v8::internal | 3625 } } // namespace v8::internal |
3631 | 3626 |
3632 #endif // V8_TARGET_ARCH_X64 | 3627 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |