| 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 // -- a1 : called function (only guaranteed when | 26 // (only guaranteed when the called function |
| 27 // -- extra_args requires it) | 27 // is not marked as DontAdaptArguments) |
| 28 // -- a1 : called function |
| 28 // -- sp[0] : last argument | 29 // -- sp[0] : last argument |
| 29 // -- ... | 30 // -- ... |
| 30 // -- sp[4 * (argc - 1)] : first argument | 31 // -- sp[4 * (argc - 1)] : first argument |
| 31 // -- sp[4 * agrc] : receiver | 32 // -- sp[4 * agrc] : receiver |
| 32 // ----------------------------------- | 33 // ----------------------------------- |
| 33 __ AssertFunction(a1); | 34 __ AssertFunction(a1); |
| 34 | 35 |
| 35 // Make sure we operate in the context of the called function (for example | 36 // 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 // 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 // instead of the callee, due to the way that [[Construct]] is defined for |
| 38 // ordinary functions). | 39 // ordinary functions). |
| 39 // TODO(bmeurer): Can we make this more robust? | 40 // TODO(bmeurer): Can we make this more robust? |
| 40 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 41 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 41 | 42 |
| 42 // Insert extra arguments. | 43 // Insert extra arguments. |
| 43 int num_extra_args = 0; | 44 int num_extra_args = 0; |
| 44 if (extra_args == NEEDS_CALLED_FUNCTION) { | 45 if (extra_args == NEEDS_CALLED_FUNCTION) { |
| 45 num_extra_args = 1; | 46 num_extra_args = 1; |
| 46 __ push(a1); | 47 __ push(a1); |
| 47 } else { | 48 } else { |
| 48 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 49 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
| 49 } | 50 } |
| 50 | 51 |
| 51 // JumpToExternalReference expects a0 to contain the number of arguments | 52 // JumpToExternalReference expects a0 to contain the number of arguments |
| 52 // including the receiver and the extra arguments. | 53 // including the receiver and the extra arguments. But a0 is only valid |
| 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, ne, a2, |
| 62 Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
| 63 __ Addu(a0, a2, num_extra_args + 1); |
| 64 __ jmp(&done_argc); |
| 65 __ bind(&argc); |
| 53 __ Addu(a0, a0, num_extra_args + 1); | 66 __ Addu(a0, a0, num_extra_args + 1); |
| 67 __ bind(&done_argc); |
| 68 |
| 54 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 69 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 55 } | 70 } |
| 56 | 71 |
| 57 | 72 |
| 58 // Load the built-in InternalArray function from the current context. | 73 // Load the built-in InternalArray function from the current context. |
| 59 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 74 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
| 60 Register result) { | 75 Register result) { |
| 61 // Load the native context. | 76 // Load the native context. |
| 62 | 77 |
| 63 __ lw(result, | 78 __ lw(result, |
| (...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 } | 1906 } |
| 1892 } | 1907 } |
| 1893 | 1908 |
| 1894 | 1909 |
| 1895 #undef __ | 1910 #undef __ |
| 1896 | 1911 |
| 1897 } // namespace internal | 1912 } // namespace internal |
| 1898 } // namespace v8 | 1913 } // namespace v8 |
| 1899 | 1914 |
| 1900 #endif // V8_TARGET_ARCH_MIPS | 1915 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |