| 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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
| 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, | 20 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
| 21 CFunctionId id, | 21 CFunctionId id, |
| 22 BuiltinExtraArguments extra_args) { | 22 BuiltinExtraArguments extra_args) { |
| 23 // ----------- S t a t e ------------- | 23 // ----------- S t a t e ------------- |
| 24 // -- a0 : number of arguments excluding receiver | 24 // -- a0 : number of arguments excluding receiver |
| 25 // (only guaranteed when the called function | |
| 26 // is not marked as DontAdaptArguments) | |
| 27 // -- a1 : called function | 25 // -- a1 : called function |
| 28 // -- sp[0] : last argument | 26 // -- sp[0] : last argument |
| 29 // -- ... | 27 // -- ... |
| 30 // -- sp[8 * (argc - 1)] : first argument | 28 // -- sp[8 * (argc - 1)] : first argument |
| 31 // -- sp[8 * agrc] : receiver | 29 // -- sp[8 * agrc] : receiver |
| 32 // ----------------------------------- | 30 // ----------------------------------- |
| 33 __ AssertFunction(a1); | 31 __ AssertFunction(a1); |
| 34 | 32 |
| 35 // Make sure we operate in the context of the called function (for example | |
| 36 // ConstructStubs implemented in C++ will be run in the context of the caller | |
| 37 // instead of the callee, due to the way that [[Construct]] is defined for | |
| 38 // ordinary functions). | |
| 39 // TODO(bmeurer): Can we make this more robust? | |
| 40 __ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | |
| 41 | |
| 42 // Insert extra arguments. | 33 // Insert extra arguments. |
| 43 int num_extra_args = 0; | 34 int num_extra_args = 0; |
| 44 if (extra_args == NEEDS_CALLED_FUNCTION) { | 35 if (extra_args == NEEDS_CALLED_FUNCTION) { |
| 45 num_extra_args = 1; | 36 num_extra_args = 1; |
| 46 __ push(a1); | 37 __ push(a1); |
| 47 } else { | 38 } else { |
| 48 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 39 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
| 49 } | 40 } |
| 50 | 41 |
| 51 // JumpToExternalReference expects a0 to contain the number of arguments | 42 // JumpToExternalReference expects a0 to contain the number of arguments |
| 52 // including the receiver and the extra arguments. But a0 is only valid | 43 // including the receiver and the extra arguments. |
| 53 // if the called function is marked as DontAdaptArguments, otherwise we | |
| 54 // need to load the argument count from the SharedFunctionInfo. | |
| 55 Label argc, done_argc; | |
| 56 __ ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | |
| 57 __ lw(a2, | |
| 58 FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset)); | |
| 59 __ Branch(&argc, eq, a2, | |
| 60 Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | |
| 61 __ Daddu(a0, a2, num_extra_args + 1); | |
| 62 __ jmp(&done_argc); | |
| 63 __ bind(&argc); | |
| 64 __ Daddu(a0, a0, num_extra_args + 1); | 44 __ Daddu(a0, a0, num_extra_args + 1); |
| 65 __ bind(&done_argc); | |
| 66 | 45 |
| 67 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 46 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 68 } | 47 } |
| 69 | 48 |
| 70 | 49 |
| 71 // Load the built-in InternalArray function from the current context. | 50 // Load the built-in InternalArray function from the current context. |
| 72 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 51 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
| 73 Register result) { | 52 Register result) { |
| 74 // Load the InternalArray function from the native context. | 53 // Load the InternalArray function from the native context. |
| 75 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); | 54 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); |
| (...skipping 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 } | 1957 } |
| 1979 } | 1958 } |
| 1980 | 1959 |
| 1981 | 1960 |
| 1982 #undef __ | 1961 #undef __ |
| 1983 | 1962 |
| 1984 } // namespace internal | 1963 } // namespace internal |
| 1985 } // namespace v8 | 1964 } // namespace v8 |
| 1986 | 1965 |
| 1987 #endif // V8_TARGET_ARCH_MIPS64 | 1966 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |