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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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/x87/frames-x87.h" | 11 #include "src/x87/frames-x87.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 | 19 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) { |
20 void Builtins::Generate_Adaptor(MacroAssembler* masm, | |
21 CFunctionId id, | |
22 BuiltinExtraArguments extra_args) { | |
23 // ----------- S t a t e ------------- | 20 // ----------- S t a t e ------------- |
24 // -- eax : number of arguments excluding receiver | 21 // -- eax : number of arguments excluding receiver |
25 // -- edi : target | 22 // -- edi : target |
26 // -- edx : new.target | 23 // -- edx : new.target |
27 // -- esp[0] : return address | 24 // -- esp[0] : return address |
28 // -- esp[4] : last argument | 25 // -- esp[4] : last argument |
29 // -- ... | 26 // -- ... |
30 // -- esp[4 * argc] : first argument | 27 // -- esp[4 * argc] : first argument |
31 // -- esp[4 * (argc +1)] : receiver | 28 // -- esp[4 * (argc +1)] : receiver |
32 // ----------------------------------- | 29 // ----------------------------------- |
33 __ AssertFunction(edi); | 30 __ AssertFunction(edi); |
34 | 31 |
35 // 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 |
36 // 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 |
37 // 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 |
38 // ordinary functions). | 35 // ordinary functions). |
39 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 36 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
40 | 37 |
41 // Insert extra arguments. | 38 // Insert extra arguments. |
42 int num_extra_args = 0; | 39 const int num_extra_args = 2; |
43 if (extra_args != BuiltinExtraArguments::kNone) { | 40 __ PopReturnAddressTo(ecx); |
44 __ PopReturnAddressTo(ecx); | 41 __ Push(edi); |
45 if (extra_args & BuiltinExtraArguments::kTarget) { | 42 __ Push(edx); |
46 ++num_extra_args; | 43 __ PushReturnAddressFrom(ecx); |
47 __ Push(edi); | |
48 } | |
49 if (extra_args & BuiltinExtraArguments::kNewTarget) { | |
50 ++num_extra_args; | |
51 __ Push(edx); | |
52 } | |
53 __ PushReturnAddressFrom(ecx); | |
54 } | |
55 | 44 |
56 // JumpToExternalReference expects eax to contain the number of arguments | 45 // JumpToExternalReference expects eax to contain the number of arguments |
57 // including the receiver and the extra arguments. | 46 // including the receiver and the extra arguments. |
58 __ add(eax, Immediate(num_extra_args + 1)); | 47 __ add(eax, Immediate(num_extra_args + 1)); |
59 | 48 |
60 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
61 } | 50 } |
62 | 51 |
63 static void GenerateTailCallToReturnedCode(MacroAssembler* masm, | 52 static void GenerateTailCallToReturnedCode(MacroAssembler* masm, |
64 Runtime::FunctionId function_id) { | 53 Runtime::FunctionId function_id) { |
(...skipping 2941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 // And "return" to the OSR entry point of the function. | 2995 // And "return" to the OSR entry point of the function. |
3007 __ ret(0); | 2996 __ ret(0); |
3008 } | 2997 } |
3009 | 2998 |
3010 | 2999 |
3011 #undef __ | 3000 #undef __ |
3012 } // namespace internal | 3001 } // namespace internal |
3013 } // namespace v8 | 3002 } // namespace v8 |
3014 | 3003 |
3015 #endif // V8_TARGET_ARCH_X87 | 3004 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |