OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2883 scratch1, scratch2, scratch3, name, miss); | 2883 scratch1, scratch2, scratch3, name, miss); |
2884 | 2884 |
2885 // Return the constant value. | 2885 // Return the constant value. |
2886 __ Move(rax, Handle<Object>(value)); | 2886 __ Move(rax, Handle<Object>(value)); |
2887 __ ret(0); | 2887 __ ret(0); |
2888 } | 2888 } |
2889 | 2889 |
2890 | 2890 |
2891 // Specialized stub for constructing objects from functions which only have only | 2891 // Specialized stub for constructing objects from functions which only have only |
2892 // simple assignments of the form this.x = ...; in their body. | 2892 // simple assignments of the form this.x = ...; in their body. |
2893 MaybeObject* ConstructStubCompiler::CompileConstructStub( | 2893 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { |
2894 SharedFunctionInfo* shared) { | |
2895 // ----------- S t a t e ------------- | 2894 // ----------- S t a t e ------------- |
2896 // -- rax : argc | 2895 // -- rax : argc |
2897 // -- rdi : constructor | 2896 // -- rdi : constructor |
2898 // -- rsp[0] : return address | 2897 // -- rsp[0] : return address |
2899 // -- rsp[4] : last argument | 2898 // -- rsp[4] : last argument |
2900 // ----------------------------------- | 2899 // ----------------------------------- |
2901 Label generic_stub_call; | 2900 Label generic_stub_call; |
2902 | 2901 |
2903 // Use r8 for holding undefined which is used in several places below. | 2902 // Use r8 for holding undefined which is used in several places below. |
2904 __ Move(r8, Factory::undefined_value()); | 2903 __ Move(r8, Factory::undefined_value()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 // return address on top of the argc arguments. | 2956 // return address on top of the argc arguments. |
2958 __ lea(rcx, Operand(rsp, rax, times_pointer_size, 0)); | 2957 __ lea(rcx, Operand(rsp, rax, times_pointer_size, 0)); |
2959 | 2958 |
2960 // rax: argc | 2959 // rax: argc |
2961 // rcx: first argument | 2960 // rcx: first argument |
2962 // rdx: JSObject (untagged) | 2961 // rdx: JSObject (untagged) |
2963 // r8: undefined | 2962 // r8: undefined |
2964 // r9: first in-object property of the JSObject | 2963 // r9: first in-object property of the JSObject |
2965 // Fill the initialized properties with a constant value or a passed argument | 2964 // Fill the initialized properties with a constant value or a passed argument |
2966 // depending on the this.x = ...; assignment in the function. | 2965 // depending on the this.x = ...; assignment in the function. |
| 2966 SharedFunctionInfo* shared = function->shared(); |
2967 for (int i = 0; i < shared->this_property_assignments_count(); i++) { | 2967 for (int i = 0; i < shared->this_property_assignments_count(); i++) { |
2968 if (shared->IsThisPropertyAssignmentArgument(i)) { | 2968 if (shared->IsThisPropertyAssignmentArgument(i)) { |
2969 // Check if the argument assigned to the property is actually passed. | 2969 // Check if the argument assigned to the property is actually passed. |
2970 // If argument is not passed the property is set to undefined, | 2970 // If argument is not passed the property is set to undefined, |
2971 // otherwise find it on the stack. | 2971 // otherwise find it on the stack. |
2972 int arg_number = shared->GetThisPropertyAssignmentArgument(i); | 2972 int arg_number = shared->GetThisPropertyAssignmentArgument(i); |
2973 __ movq(rbx, r8); | 2973 __ movq(rbx, r8); |
2974 __ cmpq(rax, Immediate(arg_number)); | 2974 __ cmpq(rax, Immediate(arg_number)); |
2975 __ cmovq(above, rbx, Operand(rcx, arg_number * -kPointerSize)); | 2975 __ cmovq(above, rbx, Operand(rcx, arg_number * -kPointerSize)); |
2976 // Store value in the property. | 2976 // Store value in the property. |
2977 __ movq(Operand(r9, i * kPointerSize), rbx); | 2977 __ movq(Operand(r9, i * kPointerSize), rbx); |
2978 } else { | 2978 } else { |
2979 // Set the property to the constant value. | 2979 // Set the property to the constant value. |
2980 Handle<Object> constant(shared->GetThisPropertyAssignmentConstant(i)); | 2980 Handle<Object> constant(shared->GetThisPropertyAssignmentConstant(i)); |
2981 __ Move(Operand(r9, i * kPointerSize), constant); | 2981 __ Move(Operand(r9, i * kPointerSize), constant); |
2982 } | 2982 } |
2983 } | 2983 } |
2984 | 2984 |
2985 // Fill the unused in-object property fields with undefined. | 2985 // Fill the unused in-object property fields with undefined. |
| 2986 ASSERT(function->has_initial_map()); |
2986 for (int i = shared->this_property_assignments_count(); | 2987 for (int i = shared->this_property_assignments_count(); |
2987 i < shared->CalculateInObjectProperties(); | 2988 i < function->initial_map()->inobject_properties(); |
2988 i++) { | 2989 i++) { |
2989 __ movq(Operand(r9, i * kPointerSize), r8); | 2990 __ movq(Operand(r9, i * kPointerSize), r8); |
2990 } | 2991 } |
2991 | 2992 |
2992 // rax: argc | 2993 // rax: argc |
2993 // rdx: JSObject (untagged) | 2994 // rdx: JSObject (untagged) |
2994 // Move argc to rbx and the JSObject to return to rax and tag it. | 2995 // Move argc to rbx and the JSObject to return to rax and tag it. |
2995 __ movq(rbx, rax); | 2996 __ movq(rbx, rax); |
2996 __ movq(rax, rdx); | 2997 __ movq(rax, rdx); |
2997 __ or_(rax, Immediate(kHeapObjectTag)); | 2998 __ or_(rax, Immediate(kHeapObjectTag)); |
(...skipping 18 matching lines...) Expand all Loading... |
3016 // Return the generated code. | 3017 // Return the generated code. |
3017 return GetCode(); | 3018 return GetCode(); |
3018 } | 3019 } |
3019 | 3020 |
3020 | 3021 |
3021 #undef __ | 3022 #undef __ |
3022 | 3023 |
3023 } } // namespace v8::internal | 3024 } } // namespace v8::internal |
3024 | 3025 |
3025 #endif // V8_TARGET_ARCH_X64 | 3026 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |