| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| 11 #include "src/full-codegen/full-codegen.h" | 11 #include "src/full-codegen/full-codegen.h" |
| 12 #include "src/runtime/runtime.h" | 12 #include "src/runtime/runtime.h" |
| 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 // Load the built-in Array function from the current context. | 21 // Load the built-in Array function from the current context. |
| 22 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { | 22 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { |
| 23 // Load the native context. |
| 24 __ Ldr(result, GlobalObjectMemOperand()); |
| 25 __ Ldr(result, FieldMemOperand(result, JSGlobalObject::kNativeContextOffset)); |
| 23 // Load the InternalArray function from the native context. | 26 // Load the InternalArray function from the native context. |
| 24 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); | 27 __ Ldr(result, |
| 28 MemOperand(result, |
| 29 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
| 25 } | 30 } |
| 26 | 31 |
| 27 | 32 |
| 28 // Load the built-in InternalArray function from the current context. | 33 // Load the built-in InternalArray function from the current context. |
| 29 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 34 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
| 30 Register result) { | 35 Register result) { |
| 36 // Load the native context. |
| 37 __ Ldr(result, GlobalObjectMemOperand()); |
| 38 __ Ldr(result, FieldMemOperand(result, JSGlobalObject::kNativeContextOffset)); |
| 31 // Load the InternalArray function from the native context. | 39 // Load the InternalArray function from the native context. |
| 32 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); | 40 __ Ldr(result, ContextMemOperand(result, |
| 41 Context::INTERNAL_ARRAY_FUNCTION_INDEX)); |
| 33 } | 42 } |
| 34 | 43 |
| 35 | 44 |
| 36 void Builtins::Generate_Adaptor(MacroAssembler* masm, | 45 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
| 37 CFunctionId id, | 46 CFunctionId id, |
| 38 BuiltinExtraArguments extra_args) { | 47 BuiltinExtraArguments extra_args) { |
| 39 // ----------- S t a t e ------------- | 48 // ----------- S t a t e ------------- |
| 40 // -- x0 : number of arguments excluding receiver | 49 // -- x0 : number of arguments excluding receiver |
| 41 // (only guaranteed when the called function | 50 // (only guaranteed when the called function |
| 42 // is not marked as DontAdaptArguments) | 51 // is not marked as DontAdaptArguments) |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 CompatibleReceiverCheck(masm, x2, x3, x4, x5, x6, &receiver_check_failed); | 1215 CompatibleReceiverCheck(masm, x2, x3, x4, x5, x6, &receiver_check_failed); |
| 1207 | 1216 |
| 1208 // Get the callback offset from the FunctionTemplateInfo, and jump to the | 1217 // Get the callback offset from the FunctionTemplateInfo, and jump to the |
| 1209 // beginning of the code. | 1218 // beginning of the code. |
| 1210 __ Ldr(x4, FieldMemOperand(x3, FunctionTemplateInfo::kCallCodeOffset)); | 1219 __ Ldr(x4, FieldMemOperand(x3, FunctionTemplateInfo::kCallCodeOffset)); |
| 1211 __ Ldr(x4, FieldMemOperand(x4, CallHandlerInfo::kFastHandlerOffset)); | 1220 __ Ldr(x4, FieldMemOperand(x4, CallHandlerInfo::kFastHandlerOffset)); |
| 1212 __ Add(x4, x4, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1221 __ Add(x4, x4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1213 __ Jump(x4); | 1222 __ Jump(x4); |
| 1214 | 1223 |
| 1215 __ Bind(&set_global_proxy); | 1224 __ Bind(&set_global_proxy); |
| 1216 __ LoadGlobalProxy(x2); | 1225 __ Ldr(x2, GlobalObjectMemOperand()); |
| 1226 __ Ldr(x2, FieldMemOperand(x2, JSGlobalObject::kGlobalProxyOffset)); |
| 1217 __ Str(x2, MemOperand(jssp, x0, LSL, kPointerSizeLog2)); | 1227 __ Str(x2, MemOperand(jssp, x0, LSL, kPointerSizeLog2)); |
| 1218 __ B(&valid_receiver); | 1228 __ B(&valid_receiver); |
| 1219 | 1229 |
| 1220 // Compatible receiver check failed: throw an Illegal Invocation exception. | 1230 // Compatible receiver check failed: throw an Illegal Invocation exception. |
| 1221 __ Bind(&receiver_check_failed); | 1231 __ Bind(&receiver_check_failed); |
| 1222 // Drop the arguments (including the receiver) | 1232 // Drop the arguments (including the receiver) |
| 1223 __ add(x0, x0, Operand(1)); | 1233 __ add(x0, x0, Operand(1)); |
| 1224 __ Drop(x0); | 1234 __ Drop(x0); |
| 1225 __ TailCallRuntime(Runtime::kThrowIllegalInvocation, 0, 1); | 1235 __ TailCallRuntime(Runtime::kThrowIllegalInvocation, 0, 1); |
| 1226 } | 1236 } |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 | 1713 |
| 1704 // 2. Call to something else, which might have a [[Call]] internal method (if | 1714 // 2. Call to something else, which might have a [[Call]] internal method (if |
| 1705 // not we raise an exception). | 1715 // not we raise an exception). |
| 1706 __ Bind(&non_function); | 1716 __ Bind(&non_function); |
| 1707 // Check if target has a [[Call]] internal method. | 1717 // Check if target has a [[Call]] internal method. |
| 1708 __ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset)); | 1718 __ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset)); |
| 1709 __ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &non_callable); | 1719 __ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &non_callable); |
| 1710 // Overwrite the original receiver with the (original) target. | 1720 // Overwrite the original receiver with the (original) target. |
| 1711 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); | 1721 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); |
| 1712 // Let the "call_as_function_delegate" take care of the rest. | 1722 // Let the "call_as_function_delegate" take care of the rest. |
| 1713 __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, x1); | 1723 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, x1); |
| 1714 __ Jump(masm->isolate()->builtins()->CallFunction( | 1724 __ Jump(masm->isolate()->builtins()->CallFunction( |
| 1715 ConvertReceiverMode::kNotNullOrUndefined), | 1725 ConvertReceiverMode::kNotNullOrUndefined), |
| 1716 RelocInfo::CODE_TARGET); | 1726 RelocInfo::CODE_TARGET); |
| 1717 | 1727 |
| 1718 // 3. Call to something that is not callable. | 1728 // 3. Call to something that is not callable. |
| 1719 __ bind(&non_callable); | 1729 __ bind(&non_callable); |
| 1720 { | 1730 { |
| 1721 FrameScope scope(masm, StackFrame::INTERNAL); | 1731 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1722 __ Push(x1); | 1732 __ Push(x1); |
| 1723 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1733 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 | 1796 |
| 1787 // Check if target has a [[Construct]] internal method. | 1797 // Check if target has a [[Construct]] internal method. |
| 1788 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset)); | 1798 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset)); |
| 1789 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor); | 1799 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor); |
| 1790 | 1800 |
| 1791 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1801 // Called Construct on an exotic Object with a [[Construct]] internal method. |
| 1792 { | 1802 { |
| 1793 // Overwrite the original receiver with the (original) target. | 1803 // Overwrite the original receiver with the (original) target. |
| 1794 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); | 1804 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); |
| 1795 // Let the "call_as_constructor_delegate" take care of the rest. | 1805 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1796 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1); | 1806 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1); |
| 1797 __ Jump(masm->isolate()->builtins()->CallFunction(), | 1807 __ Jump(masm->isolate()->builtins()->CallFunction(), |
| 1798 RelocInfo::CODE_TARGET); | 1808 RelocInfo::CODE_TARGET); |
| 1799 } | 1809 } |
| 1800 | 1810 |
| 1801 // Called Construct on an Object that doesn't have a [[Construct]] internal | 1811 // Called Construct on an Object that doesn't have a [[Construct]] internal |
| 1802 // method. | 1812 // method. |
| 1803 __ bind(&non_constructor); | 1813 __ bind(&non_constructor); |
| 1804 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), | 1814 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), |
| 1805 RelocInfo::CODE_TARGET); | 1815 RelocInfo::CODE_TARGET); |
| 1806 } | 1816 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 } | 2055 } |
| 2046 } | 2056 } |
| 2047 | 2057 |
| 2048 | 2058 |
| 2049 #undef __ | 2059 #undef __ |
| 2050 | 2060 |
| 2051 } // namespace internal | 2061 } // namespace internal |
| 2052 } // namespace v8 | 2062 } // namespace v8 |
| 2053 | 2063 |
| 2054 #endif // V8_TARGET_ARCH_ARM | 2064 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |