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" |
11 #include "src/runtime/runtime.h" | 11 #include "src/runtime/runtime.h" |
12 | 12 |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 | 17 |
18 #define __ ACCESS_MASM(masm) | 18 #define __ ACCESS_MASM(masm) |
19 | 19 |
20 | 20 |
21 void Builtins::Generate_Adaptor(MacroAssembler* masm, | 21 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
22 CFunctionId id, | 22 CFunctionId id, |
23 BuiltinExtraArguments extra_args) { | 23 BuiltinExtraArguments extra_args) { |
24 // ----------- S t a t e ------------- | 24 // ----------- S t a t e ------------- |
25 // -- a0 : number of arguments excluding receiver | 25 // -- a0 : number of arguments excluding receiver |
26 // (only guaranteed when the called function | |
27 // is not marked as DontAdaptArguments) | |
28 // -- a1 : called function | 26 // -- a1 : called function |
29 // -- sp[0] : last argument | 27 // -- sp[0] : last argument |
30 // -- ... | 28 // -- ... |
31 // -- sp[4 * (argc - 1)] : first argument | 29 // -- sp[4 * (argc - 1)] : first argument |
32 // -- sp[4 * agrc] : receiver | 30 // -- sp[4 * agrc] : receiver |
33 // ----------------------------------- | 31 // ----------------------------------- |
34 __ AssertFunction(a1); | 32 __ AssertFunction(a1); |
35 | 33 |
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. | 34 // Insert extra arguments. |
44 int num_extra_args = 0; | 35 int num_extra_args = 0; |
45 if (extra_args == NEEDS_CALLED_FUNCTION) { | 36 if (extra_args == NEEDS_CALLED_FUNCTION) { |
46 num_extra_args = 1; | 37 num_extra_args = 1; |
47 __ push(a1); | 38 __ push(a1); |
48 } else { | 39 } else { |
49 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 40 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
50 } | 41 } |
51 | 42 |
52 // JumpToExternalReference expects a0 to contain the number of arguments | 43 // JumpToExternalReference expects a0 to contain the number of arguments |
53 // including the receiver and the extra arguments. But a0 is only valid | 44 // 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); | 45 __ Addu(a0, a0, num_extra_args + 1); |
67 __ bind(&done_argc); | |
68 | 46 |
69 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 47 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
70 } | 48 } |
71 | 49 |
72 | 50 |
73 // Load the built-in InternalArray function from the current context. | 51 // Load the built-in InternalArray function from the current context. |
74 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 52 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
75 Register result) { | 53 Register result) { |
76 // Load the InternalArray function from the native context. | 54 // Load the InternalArray function from the native context. |
77 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); | 55 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); |
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 } | 1963 } |
1986 } | 1964 } |
1987 | 1965 |
1988 | 1966 |
1989 #undef __ | 1967 #undef __ |
1990 | 1968 |
1991 } // namespace internal | 1969 } // namespace internal |
1992 } // namespace v8 | 1970 } // namespace v8 |
1993 | 1971 |
1994 #endif // V8_TARGET_ARCH_MIPS | 1972 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |