| 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_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 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 // -- r0 : number of arguments excluding receiver | 24 // -- r0 : number of arguments excluding receiver |
| 25 // -- r1 : called function (only guaranteed when | 25 // (only guaranteed when the called function |
| 26 // extra_args requires it) | 26 // is not marked as DontAdaptArguments) |
| 27 // -- r1 : called function |
| 27 // -- sp[0] : last argument | 28 // -- sp[0] : last argument |
| 28 // -- ... | 29 // -- ... |
| 29 // -- sp[4 * (argc - 1)] : first argument (argc == r0) | 30 // -- sp[4 * (argc - 1)] : first argument |
| 30 // -- sp[4 * argc] : receiver | 31 // -- sp[4 * argc] : receiver |
| 31 // ----------------------------------- | 32 // ----------------------------------- |
| 32 __ AssertFunction(r1); | 33 __ AssertFunction(r1); |
| 33 | 34 |
| 34 // Make sure we operate in the context of the called function (for example | 35 // 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 // 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 // instead of the callee, due to the way that [[Construct]] is defined for |
| 37 // ordinary functions). | 38 // ordinary functions). |
| 38 // TODO(bmeurer): Can we make this more robust? | 39 // TODO(bmeurer): Can we make this more robust? |
| 39 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 40 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 40 | 41 |
| 41 // Insert extra arguments. | 42 // Insert extra arguments. |
| 42 int num_extra_args = 0; | 43 int num_extra_args = 0; |
| 43 if (extra_args == NEEDS_CALLED_FUNCTION) { | 44 if (extra_args == NEEDS_CALLED_FUNCTION) { |
| 44 num_extra_args = 1; | 45 num_extra_args = 1; |
| 45 __ push(r1); | 46 __ push(r1); |
| 46 } else { | 47 } else { |
| 47 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 48 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
| 48 } | 49 } |
| 49 | 50 |
| 50 // JumpToExternalReference expects r0 to contain the number of arguments | 51 // JumpToExternalReference expects r0 to contain the number of arguments |
| 51 // including the receiver and the extra arguments. | 52 // including the receiver and the extra arguments. But r0 is only valid |
| 53 // if the called function is marked as DontAdaptArguments, otherwise we |
| 54 // need to load the argument count from the SharedFunctionInfo. |
| 55 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 56 __ ldr(r2, |
| 57 FieldMemOperand(r2, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 58 __ SmiUntag(r2); |
| 59 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
| 60 __ mov(r0, r2, LeaveCC, ne); |
| 52 __ add(r0, r0, Operand(num_extra_args + 1)); | 61 __ add(r0, r0, Operand(num_extra_args + 1)); |
| 62 |
| 53 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 63 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 54 } | 64 } |
| 55 | 65 |
| 56 | 66 |
| 57 // Load the built-in InternalArray function from the current context. | 67 // Load the built-in InternalArray function from the current context. |
| 58 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 68 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
| 59 Register result) { | 69 Register result) { |
| 60 // Load the native context. | 70 // Load the native context. |
| 61 | 71 |
| 62 __ ldr(result, | 72 __ ldr(result, |
| (...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 } | 1878 } |
| 1869 } | 1879 } |
| 1870 | 1880 |
| 1871 | 1881 |
| 1872 #undef __ | 1882 #undef __ |
| 1873 | 1883 |
| 1874 } // namespace internal | 1884 } // namespace internal |
| 1875 } // namespace v8 | 1885 } // namespace v8 |
| 1876 | 1886 |
| 1877 #endif // V8_TARGET_ARCH_ARM | 1887 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |