OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
11 #include "src/ia32/frames-ia32.h" | 11 #include "src/ia32/frames-ia32.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 | 16 |
17 #define __ ACCESS_MASM(masm) | 17 #define __ ACCESS_MASM(masm) |
18 | 18 |
19 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, | 19 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) { |
20 ExitFrameType exit_frame_type) { | |
21 // ----------- S t a t e ------------- | 20 // ----------- S t a t e ------------- |
22 // -- eax : number of arguments excluding receiver | 21 // -- eax : number of arguments excluding receiver |
23 // -- edi : target | 22 // -- edi : target |
24 // -- edx : new.target | 23 // -- edx : new.target |
25 // -- esp[0] : return address | 24 // -- esp[0] : return address |
26 // -- esp[4] : last argument | 25 // -- esp[4] : last argument |
27 // -- ... | 26 // -- ... |
28 // -- esp[4 * argc] : first argument | 27 // -- esp[4 * argc] : first argument |
29 // -- esp[4 * (argc +1)] : receiver | 28 // -- esp[4 * (argc +1)] : receiver |
30 // ----------------------------------- | 29 // ----------------------------------- |
31 __ AssertFunction(edi); | 30 __ AssertFunction(edi); |
32 | 31 |
33 // Make sure we operate in the context of the called function (for example | 32 // Make sure we operate in the context of the called function (for example |
34 // ConstructStubs implemented in C++ will be run in the context of the caller | 33 // ConstructStubs implemented in C++ will be run in the context of the caller |
35 // instead of the callee, due to the way that [[Construct]] is defined for | 34 // instead of the callee, due to the way that [[Construct]] is defined for |
36 // ordinary functions). | 35 // ordinary functions). |
37 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 36 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
38 | 37 |
39 // Insert extra arguments. | 38 // Insert extra arguments. |
40 const int num_extra_args = 2; | 39 const int num_extra_args = 2; |
41 __ PopReturnAddressTo(ecx); | 40 __ PopReturnAddressTo(ecx); |
42 __ Push(edi); | 41 __ Push(edi); |
43 __ Push(edx); | 42 __ Push(edx); |
44 __ PushReturnAddressFrom(ecx); | 43 __ PushReturnAddressFrom(ecx); |
45 | 44 |
46 // JumpToExternalReference expects eax to contain the number of arguments | 45 // JumpToExternalReference expects eax to contain the number of arguments |
47 // including the receiver and the extra arguments. | 46 // including the receiver and the extra arguments. |
48 __ add(eax, Immediate(num_extra_args + 1)); | 47 __ add(eax, Immediate(num_extra_args + 1)); |
49 | 48 |
50 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), | 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
51 exit_frame_type == BUILTIN_EXIT); | |
52 } | 50 } |
53 | 51 |
54 static void GenerateTailCallToReturnedCode(MacroAssembler* masm, | 52 static void GenerateTailCallToReturnedCode(MacroAssembler* masm, |
55 Runtime::FunctionId function_id) { | 53 Runtime::FunctionId function_id) { |
56 // ----------- S t a t e ------------- | 54 // ----------- S t a t e ------------- |
57 // -- eax : argument count (preserved for callee) | 55 // -- eax : argument count (preserved for callee) |
58 // -- edx : new target (preserved for callee) | 56 // -- edx : new target (preserved for callee) |
59 // -- edi : target function (preserved for callee) | 57 // -- edi : target function (preserved for callee) |
60 // ----------------------------------- | 58 // ----------------------------------- |
61 { | 59 { |
(...skipping 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 // And "return" to the OSR entry point of the function. | 2979 // And "return" to the OSR entry point of the function. |
2982 __ ret(0); | 2980 __ ret(0); |
2983 } | 2981 } |
2984 | 2982 |
2985 | 2983 |
2986 #undef __ | 2984 #undef __ |
2987 } // namespace internal | 2985 } // namespace internal |
2988 } // namespace v8 | 2986 } // namespace v8 |
2989 | 2987 |
2990 #endif // V8_TARGET_ARCH_IA32 | 2988 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |