OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 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 |
20 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, | 20 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, |
21 BuiltinExtraArguments extra_args) { | 21 BuiltinExtraArguments extra_args) { |
22 // ----------- S t a t e ------------- | 22 // ----------- S t a t e ------------- |
23 // -- r3 : number of arguments excluding receiver | 23 // -- r3 : number of arguments excluding receiver |
24 // (only guaranteed when the called function | |
25 // is not marked as DontAdaptArguments) | |
26 // -- r4 : called function | 24 // -- r4 : called function |
27 // -- sp[0] : last argument | 25 // -- sp[0] : last argument |
28 // -- ... | 26 // -- ... |
29 // -- sp[4 * (argc - 1)] : first argument | 27 // -- sp[4 * (argc - 1)] : first argument |
30 // -- sp[4 * argc] : receiver | 28 // -- sp[4 * argc] : receiver |
31 // ----------------------------------- | 29 // ----------------------------------- |
32 __ AssertFunction(r4); | 30 __ AssertFunction(r4); |
33 | 31 |
34 // Make sure we operate in the context of the called function (for example | |
35 // ConstructStubs implemented in C++ will be run in the context of the caller | |
36 // instead of the callee, due to the way that [[Construct]] is defined for | |
37 // ordinary functions). | |
38 // TODO(bmeurer): Can we make this more robust? | |
39 __ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset)); | |
40 | |
41 // Insert extra arguments. | 32 // Insert extra arguments. |
42 int num_extra_args = 0; | 33 int num_extra_args = 0; |
43 if (extra_args == NEEDS_CALLED_FUNCTION) { | 34 if (extra_args == NEEDS_CALLED_FUNCTION) { |
44 num_extra_args = 1; | 35 num_extra_args = 1; |
45 __ push(r4); | 36 __ push(r4); |
46 } else { | 37 } else { |
47 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 38 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
48 } | 39 } |
49 | 40 |
50 // JumpToExternalReference expects r3 to contain the number of arguments | 41 // JumpToExternalReference expects r3 to contain the number of arguments |
51 // including the receiver and the extra arguments. But r3 is only valid | 42 // including the receiver and the extra arguments. |
52 // if the called function is marked as DontAdaptArguments, otherwise we | |
53 // need to load the argument count from the SharedFunctionInfo. | |
54 __ LoadP(r5, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | |
55 __ LoadWordArith( | |
56 r5, FieldMemOperand(r5, SharedFunctionInfo::kFormalParameterCountOffset)); | |
57 #if !V8_TARGET_ARCH_PPC64 | |
58 __ SmiUntag(r5); | |
59 #endif | |
60 __ cmpi(r5, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | |
61 if (CpuFeatures::IsSupported(ISELECT)) { | |
62 __ isel(ne, r3, r5, r3); | |
63 } else { | |
64 Label skip; | |
65 __ beq(&skip); | |
66 __ mr(r3, r5); | |
67 __ bind(&skip); | |
68 } | |
69 __ addi(r3, r3, Operand(num_extra_args + 1)); | 43 __ addi(r3, r3, Operand(num_extra_args + 1)); |
70 | 44 |
71 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 45 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
72 } | 46 } |
73 | 47 |
74 | 48 |
75 // Load the built-in InternalArray function from the current context. | 49 // Load the built-in InternalArray function from the current context. |
76 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 50 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
77 Register result) { | 51 Register result) { |
78 // Load the InternalArray function from the current native context. | 52 // Load the InternalArray function from the current native context. |
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 __ bkpt(0); | 1968 __ bkpt(0); |
1995 } | 1969 } |
1996 } | 1970 } |
1997 | 1971 |
1998 | 1972 |
1999 #undef __ | 1973 #undef __ |
2000 } // namespace internal | 1974 } // namespace internal |
2001 } // namespace v8 | 1975 } // namespace v8 |
2002 | 1976 |
2003 #endif // V8_TARGET_ARCH_PPC | 1977 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |