| 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 // -- r4 : called function (only guaranteed when | 24 // (only guaranteed when the called function |
| 25 // extra_args requires it) | 25 // is not marked as DontAdaptArguments) |
| 26 // -- r4 : called function |
| 26 // -- sp[0] : last argument | 27 // -- sp[0] : last argument |
| 27 // -- ... | 28 // -- ... |
| 28 // -- sp[4 * (argc - 1)] : first argument (argc == r0) | 29 // -- sp[4 * (argc - 1)] : first argument |
| 29 // -- sp[4 * argc] : receiver | 30 // -- sp[4 * argc] : receiver |
| 30 // ----------------------------------- | 31 // ----------------------------------- |
| 31 __ AssertFunction(r4); | 32 __ AssertFunction(r4); |
| 32 | 33 |
| 33 // Make sure we operate in the context of the called function (for example | 34 // Make sure we operate in the context of the called function (for example |
| 34 // ConstructStubs implemented in C++ will be run in the context of the caller | 35 // ConstructStubs implemented in C++ will be run in the context of the caller |
| 35 // instead of the callee, due to the way that [[Construct]] is defined for | 36 // instead of the callee, due to the way that [[Construct]] is defined for |
| 36 // ordinary functions). | 37 // ordinary functions). |
| 37 // TODO(bmeurer): Can we make this more robust? | 38 // TODO(bmeurer): Can we make this more robust? |
| 38 __ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset)); | 39 __ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset)); |
| 39 | 40 |
| 40 // Insert extra arguments. | 41 // Insert extra arguments. |
| 41 int num_extra_args = 0; | 42 int num_extra_args = 0; |
| 42 if (extra_args == NEEDS_CALLED_FUNCTION) { | 43 if (extra_args == NEEDS_CALLED_FUNCTION) { |
| 43 num_extra_args = 1; | 44 num_extra_args = 1; |
| 44 __ push(r4); | 45 __ push(r4); |
| 45 } else { | 46 } else { |
| 46 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 47 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
| 47 } | 48 } |
| 48 | 49 |
| 49 // JumpToExternalReference expects r0 to contain the number of arguments | 50 // JumpToExternalReference expects r3 to contain the number of arguments |
| 50 // including the receiver and the extra arguments. | 51 // including the receiver and the extra arguments. But r3 is only valid |
| 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 } |
| 51 __ addi(r3, r3, Operand(num_extra_args + 1)); | 69 __ addi(r3, r3, Operand(num_extra_args + 1)); |
| 70 |
| 52 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 71 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 53 } | 72 } |
| 54 | 73 |
| 55 | 74 |
| 56 // Load the built-in InternalArray function from the current context. | 75 // Load the built-in InternalArray function from the current context. |
| 57 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 76 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
| 58 Register result) { | 77 Register result) { |
| 59 // Load the native context. | 78 // Load the native context. |
| 60 | 79 |
| 61 __ LoadP(result, | 80 __ LoadP(result, |
| (...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 __ bkpt(0); | 1921 __ bkpt(0); |
| 1903 } | 1922 } |
| 1904 } | 1923 } |
| 1905 | 1924 |
| 1906 | 1925 |
| 1907 #undef __ | 1926 #undef __ |
| 1908 } // namespace internal | 1927 } // namespace internal |
| 1909 } // namespace v8 | 1928 } // namespace v8 |
| 1910 | 1929 |
| 1911 #endif // V8_TARGET_ARCH_PPC | 1930 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |