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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // is not marked as DontAdaptArguments) | 26 // is not marked as DontAdaptArguments) |
27 // -- edi : called function | 27 // -- edi : called function |
28 // -- esp[0] : return address | 28 // -- esp[0] : return address |
29 // -- esp[4] : last argument | 29 // -- esp[4] : last argument |
30 // -- ... | 30 // -- ... |
31 // -- esp[4 * argc] : first argument | 31 // -- esp[4 * argc] : first argument |
32 // -- esp[4 * (argc +1)] : receiver | 32 // -- esp[4 * (argc +1)] : receiver |
33 // ----------------------------------- | 33 // ----------------------------------- |
34 __ AssertFunction(edi); | 34 __ AssertFunction(edi); |
35 | 35 |
36 // Make sure we operate in the context of the called function (for example | |
37 // ConstructStubs implemented in C++ will be run in the context of the caller | |
38 // instead of the callee, due to the way that [[Construct]] is defined for | |
39 // ordinary functions). | |
40 // TODO(bmeurer): Can we make this more robust? | |
41 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | |
42 | |
43 // Insert extra arguments. | 36 // Insert extra arguments. |
44 int num_extra_args = 0; | 37 int num_extra_args = 0; |
45 if (extra_args == NEEDS_CALLED_FUNCTION) { | 38 if (extra_args == NEEDS_CALLED_FUNCTION) { |
46 num_extra_args = 1; | 39 num_extra_args = 1; |
47 Register scratch = ebx; | 40 Register scratch = ebx; |
48 __ pop(scratch); // Save return address. | 41 __ pop(scratch); // Save return address. |
49 __ push(edi); | 42 __ push(edi); |
50 __ push(scratch); // Restore return address. | 43 __ push(scratch); // Restore return address. |
51 } else { | 44 } else { |
52 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 45 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
53 } | 46 } |
54 | 47 |
55 // JumpToExternalReference expects eax to contain the number of arguments | 48 // JumpToExternalReference expects eax to contain the number of arguments |
56 // including the receiver and the extra arguments. But eax is only valid | 49 // including the receiver and the extra arguments. |
57 // if the called function is marked as DontAdaptArguments, otherwise we | |
58 // need to load the argument count from the SharedFunctionInfo. | |
59 Label argc, done_argc; | |
60 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | |
61 __ mov(ebx, | |
62 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | |
63 __ SmiUntag(ebx); | |
64 __ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
65 __ j(equal, &argc, Label::kNear); | |
66 __ lea(eax, Operand(ebx, num_extra_args + 1)); | |
67 __ jmp(&done_argc, Label::kNear); | |
68 __ bind(&argc); | |
69 __ add(eax, Immediate(num_extra_args + 1)); | 50 __ add(eax, Immediate(num_extra_args + 1)); |
70 __ bind(&done_argc); | |
71 | 51 |
72 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 52 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
73 } | 53 } |
74 | 54 |
75 | 55 |
76 static void CallRuntimePassFunction( | 56 static void CallRuntimePassFunction( |
77 MacroAssembler* masm, Runtime::FunctionId function_id) { | 57 MacroAssembler* masm, Runtime::FunctionId function_id) { |
78 // ----------- S t a t e ------------- | 58 // ----------- S t a t e ------------- |
79 // -- edx : new target (preserved for callee) | 59 // -- edx : new target (preserved for callee) |
80 // -- edi : target function (preserved for callee) | 60 // -- edi : target function (preserved for callee) |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 | 1973 |
1994 __ bind(&ok); | 1974 __ bind(&ok); |
1995 __ ret(0); | 1975 __ ret(0); |
1996 } | 1976 } |
1997 | 1977 |
1998 #undef __ | 1978 #undef __ |
1999 } // namespace internal | 1979 } // namespace internal |
2000 } // namespace v8 | 1980 } // namespace v8 |
2001 | 1981 |
2002 #endif // V8_TARGET_ARCH_IA32 | 1982 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |