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" |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 // The function is a "classConstructor", need to raise an exception. | 1874 // The function is a "classConstructor", need to raise an exception. |
1875 __ bind(&class_constructor); | 1875 __ bind(&class_constructor); |
1876 { | 1876 { |
1877 FrameScope frame(masm, StackFrame::INTERNAL); | 1877 FrameScope frame(masm, StackFrame::INTERNAL); |
1878 __ Push(x1); | 1878 __ Push(x1); |
1879 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 1); | 1879 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 1); |
1880 } | 1880 } |
1881 } | 1881 } |
1882 | 1882 |
1883 | 1883 |
| 1884 namespace { |
| 1885 |
| 1886 void Generate_PushBoundArguments(MacroAssembler* masm) { |
| 1887 // ----------- S t a t e ------------- |
| 1888 // -- x0 : the number of arguments (not including the receiver) |
| 1889 // -- x1 : target (checked to be a JSBoundFunction) |
| 1890 // -- x3 : new.target (only in case of [[Construct]]) |
| 1891 // ----------------------------------- |
| 1892 |
| 1893 // Load [[BoundArguments]] into x2 and length of that into x4. |
| 1894 Label no_bound_arguments; |
| 1895 __ Ldr(x2, FieldMemOperand(x1, JSBoundFunction::kBoundArgumentsOffset)); |
| 1896 __ Ldrsw(x4, UntagSmiFieldMemOperand(x2, FixedArray::kLengthOffset)); |
| 1897 __ Cmp(x4, 0); |
| 1898 __ B(eq, &no_bound_arguments); |
| 1899 { |
| 1900 // ----------- S t a t e ------------- |
| 1901 // -- x0 : the number of arguments (not including the receiver) |
| 1902 // -- x1 : target (checked to be a JSBoundFunction) |
| 1903 // -- x2 : the [[BoundArguments]] (implemented as FixedArray) |
| 1904 // -- x3 : new.target (only in case of [[Construct]]) |
| 1905 // -- x4 : the number of [[BoundArguments]] |
| 1906 // ----------------------------------- |
| 1907 |
| 1908 // Reserve stack space for the [[BoundArguments]]. |
| 1909 { |
| 1910 Label done; |
| 1911 __ Claim(x4); |
| 1912 // Check the stack for overflow. We are not trying to catch interruptions |
| 1913 // (i.e. debug break and preemption) here, so check the "real stack |
| 1914 // limit". |
| 1915 __ CompareRoot(jssp, Heap::kRealStackLimitRootIndex); |
| 1916 __ B(gt, &done); // Signed comparison. |
| 1917 // Restore the stack pointer. |
| 1918 __ Drop(x4); |
| 1919 { |
| 1920 FrameScope scope(masm, StackFrame::MANUAL); |
| 1921 __ EnterFrame(StackFrame::INTERNAL); |
| 1922 __ CallRuntime(Runtime::kThrowStackOverflow, 0); |
| 1923 } |
| 1924 __ Bind(&done); |
| 1925 } |
| 1926 |
| 1927 // Relocate arguments down the stack. |
| 1928 { |
| 1929 Label loop, done_loop; |
| 1930 __ Mov(x5, 0); |
| 1931 __ Bind(&loop); |
| 1932 __ Cmp(x5, x0); |
| 1933 __ B(gt, &done_loop); |
| 1934 __ Peek(x10, Operand(x4, LSL, kPointerSizeLog2)); |
| 1935 __ Poke(x10, Operand(x5, LSL, kPointerSizeLog2)); |
| 1936 __ Add(x4, x4, 1); |
| 1937 __ Add(x5, x5, 1); |
| 1938 __ B(&loop); |
| 1939 __ Bind(&done_loop); |
| 1940 } |
| 1941 |
| 1942 // Copy [[BoundArguments]] to the stack (below the arguments). |
| 1943 { |
| 1944 Label loop; |
| 1945 __ Ldrsw(x4, UntagSmiFieldMemOperand(x2, FixedArray::kLengthOffset)); |
| 1946 __ Add(x2, x2, FixedArray::kHeaderSize - kHeapObjectTag); |
| 1947 __ Bind(&loop); |
| 1948 __ Sub(x4, x4, 1); |
| 1949 __ Ldr(x10, MemOperand(x2, x4, LSL, kPointerSizeLog2)); |
| 1950 __ Poke(x10, Operand(x0, LSL, kPointerSizeLog2)); |
| 1951 __ Add(x0, x0, 1); |
| 1952 __ Cmp(x4, 0); |
| 1953 __ B(gt, &loop); |
| 1954 } |
| 1955 } |
| 1956 __ Bind(&no_bound_arguments); |
| 1957 } |
| 1958 |
| 1959 } // namespace |
| 1960 |
| 1961 |
| 1962 // static |
| 1963 void Builtins::Generate_CallBoundFunction(MacroAssembler* masm) { |
| 1964 // ----------- S t a t e ------------- |
| 1965 // -- x0 : the number of arguments (not including the receiver) |
| 1966 // -- x1 : the function to call (checked to be a JSBoundFunction) |
| 1967 // ----------------------------------- |
| 1968 __ AssertBoundFunction(x1); |
| 1969 |
| 1970 // Patch the receiver to [[BoundThis]]. |
| 1971 __ Ldr(x10, FieldMemOperand(x1, JSBoundFunction::kBoundThisOffset)); |
| 1972 __ Poke(x10, Operand(x0, LSL, kPointerSizeLog2)); |
| 1973 |
| 1974 // Push the [[BoundArguments]] onto the stack. |
| 1975 Generate_PushBoundArguments(masm); |
| 1976 |
| 1977 // Call the [[BoundTargetFunction]] via the Call builtin. |
| 1978 __ Ldr(x1, FieldMemOperand(x1, JSBoundFunction::kBoundTargetFunctionOffset)); |
| 1979 __ Mov(x10, |
| 1980 ExternalReference(Builtins::kCall_ReceiverIsAny, masm->isolate())); |
| 1981 __ Ldr(x11, MemOperand(x10)); |
| 1982 __ Add(x12, x11, Code::kHeaderSize - kHeapObjectTag); |
| 1983 __ Br(x12); |
| 1984 } |
| 1985 |
| 1986 |
1884 // static | 1987 // static |
1885 void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { | 1988 void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { |
1886 // ----------- S t a t e ------------- | 1989 // ----------- S t a t e ------------- |
1887 // -- x0 : the number of arguments (not including the receiver) | 1990 // -- x0 : the number of arguments (not including the receiver) |
1888 // -- x1 : the target to call (can be any Object). | 1991 // -- x1 : the target to call (can be any Object). |
1889 // ----------------------------------- | 1992 // ----------------------------------- |
1890 | 1993 |
1891 Label non_callable, non_function, non_smi; | 1994 Label non_callable, non_function, non_smi; |
1892 __ JumpIfSmi(x1, &non_callable); | 1995 __ JumpIfSmi(x1, &non_callable); |
1893 __ Bind(&non_smi); | 1996 __ Bind(&non_smi); |
1894 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); | 1997 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); |
1895 __ Jump(masm->isolate()->builtins()->CallFunction(mode), | 1998 __ Jump(masm->isolate()->builtins()->CallFunction(mode), |
1896 RelocInfo::CODE_TARGET, eq); | 1999 RelocInfo::CODE_TARGET, eq); |
| 2000 __ Cmp(x5, JS_BOUND_FUNCTION_TYPE); |
| 2001 __ Jump(masm->isolate()->builtins()->CallBoundFunction(), |
| 2002 RelocInfo::CODE_TARGET, eq); |
1897 __ Cmp(x5, JS_PROXY_TYPE); | 2003 __ Cmp(x5, JS_PROXY_TYPE); |
1898 __ B(ne, &non_function); | 2004 __ B(ne, &non_function); |
1899 | 2005 |
1900 // 1. Runtime fallback for Proxy [[Call]]. | 2006 // 1. Runtime fallback for Proxy [[Call]]. |
1901 __ Push(x1); | 2007 __ Push(x1); |
1902 // Increase the arguments size to include the pushed function and the | 2008 // Increase the arguments size to include the pushed function and the |
1903 // existing receiver on the stack. | 2009 // existing receiver on the stack. |
1904 __ Add(x0, x0, Operand(2)); | 2010 __ Add(x0, x0, Operand(2)); |
1905 // Tail-call to the runtime. | 2011 // Tail-call to the runtime. |
1906 __ JumpToExternalReference( | 2012 __ JumpToExternalReference( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 // Tail call to the function-specific construct stub (still in the caller | 2052 // Tail call to the function-specific construct stub (still in the caller |
1947 // context at this point). | 2053 // context at this point). |
1948 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 2054 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
1949 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); | 2055 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); |
1950 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); | 2056 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); |
1951 __ Br(x4); | 2057 __ Br(x4); |
1952 } | 2058 } |
1953 | 2059 |
1954 | 2060 |
1955 // static | 2061 // static |
| 2062 void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { |
| 2063 // ----------- S t a t e ------------- |
| 2064 // -- x0 : the number of arguments (not including the receiver) |
| 2065 // -- x1 : the function to call (checked to be a JSBoundFunction) |
| 2066 // -- x3 : the new target (checked to be a constructor) |
| 2067 // ----------------------------------- |
| 2068 __ AssertBoundFunction(x1); |
| 2069 |
| 2070 // Push the [[BoundArguments]] onto the stack. |
| 2071 Generate_PushBoundArguments(masm); |
| 2072 |
| 2073 // Patch new.target to [[BoundTargetFunction]] if new.target equals target. |
| 2074 { |
| 2075 Label done; |
| 2076 __ Cmp(x1, x3); |
| 2077 __ B(ne, &done); |
| 2078 __ Ldr(x3, |
| 2079 FieldMemOperand(x1, JSBoundFunction::kBoundTargetFunctionOffset)); |
| 2080 __ Bind(&done); |
| 2081 } |
| 2082 |
| 2083 // Construct the [[BoundTargetFunction]] via the Construct builtin. |
| 2084 __ Ldr(x1, FieldMemOperand(x1, JSBoundFunction::kBoundTargetFunctionOffset)); |
| 2085 __ Mov(x10, ExternalReference(Builtins::kConstruct, masm->isolate())); |
| 2086 __ Ldr(x11, MemOperand(x10)); |
| 2087 __ Add(x12, x11, Code::kHeaderSize - kHeapObjectTag); |
| 2088 __ Br(x12); |
| 2089 } |
| 2090 |
| 2091 |
| 2092 // static |
1956 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 2093 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
1957 // ----------- S t a t e ------------- | 2094 // ----------- S t a t e ------------- |
1958 // -- x0 : the number of arguments (not including the receiver) | 2095 // -- x0 : the number of arguments (not including the receiver) |
1959 // -- x1 : the constructor to call (checked to be a JSProxy) | 2096 // -- x1 : the constructor to call (checked to be a JSProxy) |
1960 // -- x3 : the new target (either the same as the constructor or | 2097 // -- x3 : the new target (either the same as the constructor or |
1961 // the JSFunction on which new was invoked initially) | 2098 // the JSFunction on which new was invoked initially) |
1962 // ----------------------------------- | 2099 // ----------------------------------- |
1963 | 2100 |
1964 // Call into the Runtime for Proxy [[Construct]]. | 2101 // Call into the Runtime for Proxy [[Construct]]. |
1965 __ Push(x1); | 2102 __ Push(x1); |
(...skipping 21 matching lines...) Expand all Loading... |
1987 | 2124 |
1988 // Dispatch based on instance type. | 2125 // Dispatch based on instance type. |
1989 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); | 2126 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); |
1990 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 2127 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
1991 RelocInfo::CODE_TARGET, eq); | 2128 RelocInfo::CODE_TARGET, eq); |
1992 | 2129 |
1993 // Check if target has a [[Construct]] internal method. | 2130 // Check if target has a [[Construct]] internal method. |
1994 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset)); | 2131 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset)); |
1995 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor); | 2132 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor); |
1996 | 2133 |
| 2134 // Only dispatch to bound functions after checking whether they are |
| 2135 // constructors. |
| 2136 __ Cmp(x5, JS_BOUND_FUNCTION_TYPE); |
| 2137 __ Jump(masm->isolate()->builtins()->ConstructBoundFunction(), |
| 2138 RelocInfo::CODE_TARGET, eq); |
| 2139 |
1997 // Only dispatch to proxies after checking whether they are constructors. | 2140 // Only dispatch to proxies after checking whether they are constructors. |
1998 __ Cmp(x5, JS_PROXY_TYPE); | 2141 __ Cmp(x5, JS_PROXY_TYPE); |
1999 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, | 2142 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
2000 eq); | 2143 eq); |
2001 | 2144 |
2002 // Called Construct on an exotic Object with a [[Construct]] internal method. | 2145 // Called Construct on an exotic Object with a [[Construct]] internal method. |
2003 { | 2146 { |
2004 // Overwrite the original receiver with the (original) target. | 2147 // Overwrite the original receiver with the (original) target. |
2005 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); | 2148 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); |
2006 // Let the "call_as_constructor_delegate" take care of the rest. | 2149 // Let the "call_as_constructor_delegate" take care of the rest. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 } | 2399 } |
2257 } | 2400 } |
2258 | 2401 |
2259 | 2402 |
2260 #undef __ | 2403 #undef __ |
2261 | 2404 |
2262 } // namespace internal | 2405 } // namespace internal |
2263 } // namespace v8 | 2406 } // namespace v8 |
2264 | 2407 |
2265 #endif // V8_TARGET_ARCH_ARM | 2408 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |