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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 // (only guaranteed when the called function | 26 // (only guaranteed when the called function |
27 // is not marked as DontAdaptArguments) | 27 // is not marked as DontAdaptArguments) |
28 // -- a1 : called function | 28 // -- a1 : called function |
29 // -- sp[0] : last argument | 29 // -- sp[0] : last argument |
30 // -- ... | 30 // -- ... |
31 // -- sp[4 * (argc - 1)] : first argument | 31 // -- sp[4 * (argc - 1)] : first argument |
32 // -- sp[4 * agrc] : receiver | 32 // -- sp[4 * agrc] : receiver |
33 // ----------------------------------- | 33 // ----------------------------------- |
34 __ AssertFunction(a1); | 34 __ AssertFunction(a1); |
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 __ lw(cp, FieldMemOperand(a1, 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 __ push(a1); | 40 __ push(a1); |
48 } else { | 41 } else { |
49 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 42 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
50 } | 43 } |
51 | 44 |
52 // JumpToExternalReference expects a0 to contain the number of arguments | 45 // JumpToExternalReference expects a0 to contain the number of arguments |
53 // including the receiver and the extra arguments. But a0 is only valid | 46 // including the receiver and the extra arguments. |
54 // if the called function is marked as DontAdaptArguments, otherwise we | |
55 // need to load the argument count from the SharedFunctionInfo. | |
56 Label argc, done_argc; | |
57 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | |
58 __ lw(a2, | |
59 FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset)); | |
60 __ SmiUntag(a2); | |
61 __ Branch(&argc, eq, a2, | |
62 Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | |
63 __ Addu(a0, a2, num_extra_args + 1); | |
64 __ jmp(&done_argc); | |
65 __ bind(&argc); | |
66 __ Addu(a0, a0, num_extra_args + 1); | 47 __ Addu(a0, a0, num_extra_args + 1); |
67 __ bind(&done_argc); | |
68 | 48 |
69 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
70 } | 50 } |
71 | 51 |
72 | 52 |
73 // Load the built-in InternalArray function from the current context. | 53 // Load the built-in InternalArray function from the current context. |
74 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 54 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
75 Register result) { | 55 Register result) { |
76 // Load the InternalArray function from the native context. | 56 // Load the InternalArray function from the native context. |
77 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); | 57 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); |
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 } | 1965 } |
1986 } | 1966 } |
1987 | 1967 |
1988 | 1968 |
1989 #undef __ | 1969 #undef __ |
1990 | 1970 |
1991 } // namespace internal | 1971 } // namespace internal |
1992 } // namespace v8 | 1972 } // namespace v8 |
1993 | 1973 |
1994 #endif // V8_TARGET_ARCH_MIPS | 1974 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |