Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1952 // Slow-case: Handle non-smi or out-of-bounds access to arguments | 1952 // Slow-case: Handle non-smi or out-of-bounds access to arguments |
| 1953 // by calling the runtime system. | 1953 // by calling the runtime system. |
| 1954 __ bind(&slow); | 1954 __ bind(&slow); |
| 1955 __ pop(rbx); // Return address. | 1955 __ pop(rbx); // Return address. |
| 1956 __ push(rdx); | 1956 __ push(rdx); |
| 1957 __ push(rbx); | 1957 __ push(rbx); |
| 1958 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); | 1958 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); |
| 1959 } | 1959 } |
| 1960 | 1960 |
| 1961 | 1961 |
| 1962 void ArgumentsAccessStub::GenerateNewNonStrictFast(MacroAssembler* masm) { | |
| 1963 // rsp[0] : return address | |
| 1964 // rsp[8] : number of parameters (tagged) | |
| 1965 // rsp[16] : receiver displacement | |
| 1966 // rsp[24] : function | |
| 1967 | |
| 1968 Factory* factory = masm->isolate()->factory(); | |
| 1969 | |
| 1970 __ SmiToInteger64(rbx, Operand(rsp, 1 * kPointerSize)); | |
| 1971 // rbx = parameter count (untagged) | |
| 1972 | |
| 1973 // Check if the calling frame is an arguments adaptor frame. | |
| 1974 Label runtime; | |
| 1975 Label adaptor_frame, try_allocate; | |
| 1976 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | |
| 1977 __ movq(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); | |
| 1978 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | |
| 1979 __ j(equal, &adaptor_frame); | |
| 1980 | |
| 1981 // No adaptor, parameter count = argument count. | |
| 1982 __ movq(rcx, rbx); | |
| 1983 __ jmp(&try_allocate, Label::kNear); | |
| 1984 | |
| 1985 // We have an adaptor frame. Patch the parameters pointer. | |
| 1986 __ bind(&adaptor_frame); | |
| 1987 __ SmiToInteger64(rcx, | |
| 1988 Operand(rdx, | |
| 1989 ArgumentsAdaptorFrameConstants::kLengthOffset)); | |
| 1990 __ lea(rdx, Operand(rdx, rcx, times_pointer_size, | |
| 1991 StandardFrameConstants::kCallerSPOffset)); | |
| 1992 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | |
| 1993 | |
| 1994 // rbx = parameter count (untagged) | |
| 1995 // rcx = argument count (untagged) | |
| 1996 // rsp[8] = parameter count (tagged) | |
| 1997 // rsp[16] = address of receiver argument | |
| 1998 // Compute the mapped parameter count = min(rbx, rcx) in rbx. | |
| 1999 __ cmpq(rbx, rcx); | |
| 2000 __ j(less_equal, &try_allocate, Label::kNear); | |
| 2001 __ movq(rbx, rcx); | |
| 2002 | |
| 2003 __ bind(&try_allocate); | |
| 2004 | |
| 2005 // Save mapped parameter count. | |
| 2006 __ push(rbx); | |
|
Kevin Millikin (Chromium)
2011/06/10 11:51:52
I don't know what the register story on x64 is (Bi
Lasse Reichstein
2011/06/10 12:15:23
Unless the stub uses them for something else (and
Karl Klose
2011/06/14 12:56:28
I have removed the push instructions, the code is
| |
| 2007 | |
| 2008 // Compute the sizes of backing store, parameter map, and arguments object. | |
| 2009 // 1. Parameter map, has 2 extra words containing context and backing store. | |
| 2010 const int kParameterMapHeaderSize = | |
| 2011 FixedArray::kHeaderSize + 2 * kPointerSize; | |
| 2012 Label no_parameter_map; | |
| 2013 __ testq(rbx, rbx); | |
| 2014 __ j(zero, &no_parameter_map, Label::kNear); | |
| 2015 __ lea(rbx, Operand(rbx, times_pointer_size, kParameterMapHeaderSize)); | |
| 2016 __ bind(&no_parameter_map); | |
| 2017 | |
| 2018 // 2. Backing store. | |
| 2019 __ lea(rbx, Operand(rbx, rcx, times_pointer_size, FixedArray::kHeaderSize)); | |
| 2020 | |
| 2021 // 3. Arguments object. | |
| 2022 __ addq(rbx, Immediate(Heap::kArgumentsObjectSize)); | |
| 2023 | |
| 2024 // Do the allocation of all three objects in one go. | |
| 2025 __ AllocateInNewSpace(rbx, rax, rdx, rdi, &runtime, TAG_OBJECT); | |
| 2026 | |
| 2027 // rax = address of new object(s) (tagged) | |
| 2028 // rcx = argument count (untagged) | |
| 2029 // rsp[0] = mapped parameter count (tagged) | |
| 2030 // rsp[16] = parameter count (tagged) | |
| 2031 // rsp[24] = address of receiver argument | |
| 2032 // Get the arguments boilerplate from the current (global) context into rdi. | |
| 2033 Label has_mapped_parameters, copy; | |
| 2034 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | |
| 2035 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | |
| 2036 __ SmiToInteger64(rbx, Operand(rsp, 0 * kPointerSize)); | |
| 2037 __ testq(rbx, rbx); | |
| 2038 __ j(not_zero, &has_mapped_parameters, Label::kNear); | |
| 2039 | |
| 2040 const int kIndex = Context::ARGUMENTS_BOILERPLATE_INDEX; | |
| 2041 __ movq(rdi, Operand(rdi, Context::SlotOffset(kIndex))); | |
| 2042 __ jmp(©, Label::kNear); | |
| 2043 | |
| 2044 const int kAliasedIndex = Context::ALIASED_ARGUMENTS_BOILERPLATE_INDEX; | |
| 2045 __ bind(&has_mapped_parameters); | |
| 2046 __ movq(rdi, Operand(rdi, Context::SlotOffset(kAliasedIndex))); | |
| 2047 __ bind(©); | |
| 2048 | |
| 2049 // rax = address of new object (tagged) | |
| 2050 // rbx = mapped parameter count (untagged) | |
| 2051 // rcx = argument count (untagged) | |
| 2052 // rdi = address of boilerplate object (tagged) | |
| 2053 // rsp[0] = mapped parameter count (tagged) | |
| 2054 // rsp[16] = parameter count (tagged) | |
| 2055 // rsp[24] = address of receiver argument | |
| 2056 // Copy the JS object part. | |
| 2057 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { | |
| 2058 __ movq(rdx, FieldOperand(rdi, i)); | |
| 2059 __ movq(FieldOperand(rax, i), rdx); | |
| 2060 } | |
| 2061 | |
| 2062 // Setup the callee in-object property. | |
| 2063 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); | |
| 2064 __ movq(rdx, Operand(rsp, 4 * kPointerSize)); | |
| 2065 __ movq(FieldOperand(rax, JSObject::kHeaderSize + | |
| 2066 Heap::kArgumentsCalleeIndex * kPointerSize), | |
| 2067 rdx); | |
| 2068 | |
| 2069 // Use the length (smi tagged) and set that as an in-object property too. | |
| 2070 // Note: rcx is tagged from here on. | |
| 2071 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | |
| 2072 __ Integer32ToSmi(rcx, rcx); | |
| 2073 __ movq(FieldOperand(rax, JSObject::kHeaderSize + | |
| 2074 Heap::kArgumentsLengthIndex * kPointerSize), | |
| 2075 rcx); | |
| 2076 | |
| 2077 // Setup the elements pointer in the allocated arguments object. | |
| 2078 // If we allocated a parameter map, edi will point there, otherwise to the | |
| 2079 // backing store. | |
| 2080 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSize)); | |
| 2081 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | |
| 2082 | |
| 2083 // rax = address of new object (tagged) | |
| 2084 // rbx = mapped parameter count (untagged) | |
| 2085 // rcx = argument count (tagged) | |
| 2086 // rdi = address of parameter map or backing store (tagged) | |
| 2087 // rsp[0] = mapped parameter count (tagged) | |
| 2088 // rsp[16] = parameter count (tagged) | |
| 2089 // rsp[24] = address of receiver argument | |
| 2090 // Free a register. | |
| 2091 __ push(rax); | |
|
Kevin Millikin (Chromium)
2011/06/10 11:51:52
May be able to avoid this push.
Karl Klose
2011/06/14 12:56:28
Done.
| |
| 2092 | |
| 2093 // Initialize parameter map. If there are no mapped arguments, we're done. | |
| 2094 Label skip_parameter_map; | |
| 2095 __ testq(rbx, rbx); | |
| 2096 __ j(zero, &skip_parameter_map); | |
| 2097 | |
| 2098 __ LoadRoot(kScratchRegister, Heap::kNonStrictArgumentsElementsMapRootIndex); | |
| 2099 // rbx contains the untagged argument count. Add 2 and tag to write. | |
| 2100 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | |
| 2101 __ Integer64PlusConstantToSmi(rax, rbx, 2); | |
| 2102 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rax); | |
| 2103 __ movq(FieldOperand(rdi, FixedArray::kHeaderSize + 0 * kPointerSize), rsi); | |
| 2104 __ lea(rax, Operand(rdi, rbx, times_pointer_size, kParameterMapHeaderSize)); | |
| 2105 __ movq(FieldOperand(rdi, FixedArray::kHeaderSize + 1 * kPointerSize), rax); | |
| 2106 | |
| 2107 // Copy the parameter slots and the holes in the arguments. | |
| 2108 // We need to fill in mapped_parameter_count slots. They index the context, | |
| 2109 // where parameters are stored in reverse order, at | |
| 2110 // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1 | |
| 2111 // The mapped parameter thus need to get indices | |
| 2112 // MIN_CONTEXT_SLOTS+parameter_count-1 .. | |
| 2113 // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count | |
| 2114 // We loop from right to left. | |
| 2115 Label parameters_loop, parameters_test; | |
| 2116 __ push(rcx); | |
|
Kevin Millikin (Chromium)
2011/06/10 11:51:52
Also here.
Karl Klose
2011/06/14 12:56:28
Done.
| |
| 2117 // Load tagged parameter count into rax. | |
| 2118 __ movq(rax, Operand(rsp, 2 * kPointerSize)); | |
| 2119 __ Move(rbx, Smi::FromInt(Context::MIN_CONTEXT_SLOTS)); | |
| 2120 __ addq(rbx, Operand(rsp, 4 * kPointerSize)); | |
| 2121 __ subq(rbx, rax); | |
| 2122 __ Move(rcx, factory->the_hole_value()); | |
| 2123 __ movq(rdx, rdi); | |
| 2124 __ SmiToInteger64(kScratchRegister, rax); | |
| 2125 __ lea(rdi, Operand(rdi, kScratchRegister, | |
| 2126 times_pointer_size, | |
| 2127 kParameterMapHeaderSize)); | |
| 2128 // rax = loop variable (tagged) | |
| 2129 // rbx = mapping index (tagged) | |
| 2130 // rcx = the hole value | |
| 2131 // rdx = address of parameter map (tagged) | |
| 2132 // rdi = address of backing store (tagged) | |
| 2133 // rsp[0] = argument count (tagged) | |
| 2134 // rsp[8] = address of new object (tagged) | |
| 2135 // rsp[16] = mapped parameter count (tagged) | |
| 2136 // rsp[32] = parameter count (tagged) | |
| 2137 // rsp[40] = address of receiver argument | |
| 2138 __ jmp(¶meters_test, Label::kNear); | |
| 2139 | |
| 2140 __ bind(¶meters_loop); | |
| 2141 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | |
| 2142 __ SmiToInteger64(kScratchRegister, rax); | |
| 2143 __ movq(FieldOperand(rdx, kScratchRegister, | |
| 2144 times_pointer_size, | |
| 2145 kParameterMapHeaderSize), | |
| 2146 rbx); | |
| 2147 __ movq(FieldOperand(rdi, kScratchRegister, | |
| 2148 times_pointer_size, | |
| 2149 FixedArray::kHeaderSize), | |
| 2150 rcx); | |
| 2151 __ SmiAddConstant(rbx, rbx, Smi::FromInt(1)); | |
| 2152 __ bind(¶meters_test); | |
| 2153 __ SmiTest(rax); | |
| 2154 __ j(not_zero, ¶meters_loop, Label::kNear); | |
| 2155 __ pop(rcx); | |
| 2156 | |
| 2157 __ bind(&skip_parameter_map); | |
| 2158 | |
| 2159 // rcx = argument count (tagged) | |
| 2160 // rdi = address of backing store (tagged) | |
| 2161 // rsp[0] = address of new object (tagged) | |
| 2162 // rsp[8] = mapped parameter count (tagged) | |
| 2163 // rsp[24] = parameter count (tagged) | |
| 2164 // rsp[32] = address of receiver argument | |
| 2165 // Copy arguments header and remaining slots (if there are any). | |
| 2166 __ Move(FieldOperand(rdi, FixedArray::kMapOffset), | |
| 2167 factory->fixed_array_map()); | |
| 2168 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | |
| 2169 | |
| 2170 Label arguments_loop, arguments_test; | |
| 2171 __ movq(rbx, Operand(rsp, 1 * kPointerSize)); | |
| 2172 __ movq(rdx, Operand(rsp, 4 * kPointerSize)); | |
| 2173 // Untag rcx and rbx for the loop below. | |
| 2174 __ SmiToInteger64(rcx, rcx); | |
| 2175 __ SmiToInteger64(rbx, rbx); | |
| 2176 __ lea(kScratchRegister, Operand(rbx, times_pointer_size, 0)); | |
| 2177 __ subq(rdx, kScratchRegister); | |
| 2178 __ jmp(&arguments_test, Label::kNear); | |
| 2179 | |
| 2180 __ bind(&arguments_loop); | |
| 2181 __ subq(rdx, Immediate(kPointerSize)); | |
| 2182 __ movq(rax, Operand(rdx, 0)); | |
| 2183 __ movq(FieldOperand(rdi, rbx, | |
| 2184 times_pointer_size, | |
| 2185 FixedArray::kHeaderSize), | |
| 2186 rax); | |
| 2187 __ addq(rbx, Immediate(1)); | |
| 2188 | |
| 2189 __ bind(&arguments_test); | |
| 2190 __ cmpq(rbx, rcx); | |
| 2191 __ j(less, &arguments_loop, Label::kNear); | |
| 2192 | |
| 2193 // Restore. | |
| 2194 __ pop(rax); // Address of arguments object. | |
| 2195 __ pop(rbx); // Parameter count. | |
| 2196 | |
| 2197 // Return and remove the on-stack parameters. | |
| 2198 __ ret(3 * kPointerSize); | |
| 2199 | |
| 2200 // Do the runtime call to allocate the arguments object. | |
| 2201 // rcx = argument count (untagged) | |
| 2202 __ bind(&runtime); | |
| 2203 __ pop(rax); // Remove saved parameter count. | |
| 2204 __ Integer32ToSmi(rcx, rcx); | |
| 2205 __ movq(Operand(rsp, 1 * kPointerSize), rcx); // Patch argument count. | |
| 2206 __ TailCallRuntime(Runtime::kNewStrictArgumentsFast, 3, 1); | |
| 2207 } | |
| 2208 | |
| 2209 | |
| 2210 void ArgumentsAccessStub::GenerateNewNonStrictSlow(MacroAssembler* masm) { | |
| 2211 // esp[0] : return address | |
| 2212 // esp[8] : number of parameters | |
| 2213 // esp[16] : receiver displacement | |
| 2214 // esp[24] : function | |
| 2215 | |
| 2216 // Check if the calling frame is an arguments adaptor frame. | |
| 2217 Label runtime; | |
| 2218 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | |
| 2219 __ movq(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); | |
| 2220 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | |
| 2221 __ j(not_equal, &runtime); | |
| 2222 | |
| 2223 // Patch the arguments.length and the parameters pointer. | |
| 2224 __ movq(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | |
| 2225 __ movq(Operand(rsp, 1 * kPointerSize), rcx); | |
| 2226 __ SmiToInteger64(rcx, rcx); | |
| 2227 __ lea(rdx, Operand(rdx, rcx, times_pointer_size, | |
| 2228 StandardFrameConstants::kCallerSPOffset)); | |
| 2229 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | |
| 2230 | |
| 2231 __ bind(&runtime); | |
| 2232 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1); | |
| 2233 } | |
| 2234 | |
| 2235 | |
| 1962 void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { | 2236 void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { |
| 1963 UNIMPLEMENTED(); | |
| 1964 } | |
| 1965 | |
| 1966 | |
| 1967 void ArgumentsAccessStub::GenerateNewNonStrictFast(MacroAssembler* masm) { | |
| 1968 UNIMPLEMENTED(); | |
| 1969 } | |
| 1970 | |
| 1971 | |
| 1972 void ArgumentsAccessStub::GenerateNewNonStrictSlow(MacroAssembler* masm) { | |
| 1973 // rsp[0] : return address | 2237 // rsp[0] : return address |
| 1974 // rsp[8] : number of parameters | 2238 // rsp[8] : number of parameters |
| 1975 // rsp[16] : receiver displacement | 2239 // rsp[16] : receiver displacement |
| 1976 // rsp[24] : function | 2240 // rsp[24] : function |
| 1977 | 2241 |
| 1978 // The displacement is used for skipping the return address and the | |
| 1979 // frame pointer on the stack. It is the offset of the last | |
| 1980 // parameter (if any) relative to the frame pointer. | |
| 1981 static const int kDisplacement = 2 * kPointerSize; | |
| 1982 | |
| 1983 // Check if the calling frame is an arguments adaptor frame. | 2242 // Check if the calling frame is an arguments adaptor frame. |
| 1984 Label adaptor_frame, try_allocate, runtime; | 2243 Label adaptor_frame, try_allocate, runtime; |
| 1985 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 2244 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 1986 __ Cmp(Operand(rdx, StandardFrameConstants::kContextOffset), | 2245 __ movq(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); |
| 1987 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 2246 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 1988 __ j(equal, &adaptor_frame); | 2247 __ j(equal, &adaptor_frame); |
| 1989 | 2248 |
| 1990 // Get the length from the frame. | 2249 // Get the length from the frame. |
| 1991 __ SmiToInteger32(rcx, Operand(rsp, 1 * kPointerSize)); | 2250 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); |
| 2251 __ SmiToInteger64(rcx, rcx); | |
| 1992 __ jmp(&try_allocate); | 2252 __ jmp(&try_allocate); |
| 1993 | 2253 |
| 1994 // Patch the arguments.length and the parameters pointer. | 2254 // Patch the arguments.length and the parameters pointer. |
| 1995 __ bind(&adaptor_frame); | 2255 __ bind(&adaptor_frame); |
| 1996 __ SmiToInteger32(rcx, | 2256 __ movq(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1997 Operand(rdx, | 2257 __ movq(Operand(rsp, 1 * kPointerSize), rcx); |
| 1998 ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2258 __ SmiToInteger64(rcx, rcx); |
| 1999 // Space on stack must already hold a smi. | 2259 __ lea(rdx, Operand(rdx, rcx, times_pointer_size, |
| 2000 __ Integer32ToSmiField(Operand(rsp, 1 * kPointerSize), rcx); | 2260 StandardFrameConstants::kCallerSPOffset)); |
| 2001 // Do not clobber the length index for the indexing operation since | |
| 2002 // it is used compute the size for allocation later. | |
| 2003 __ lea(rdx, Operand(rdx, rcx, times_pointer_size, kDisplacement)); | |
| 2004 __ movq(Operand(rsp, 2 * kPointerSize), rdx); | 2261 __ movq(Operand(rsp, 2 * kPointerSize), rdx); |
| 2005 | 2262 |
| 2006 // Try the new space allocation. Start out with computing the size of | 2263 // Try the new space allocation. Start out with computing the size of |
| 2007 // the arguments object and the elements array. | 2264 // the arguments object and the elements array. |
| 2008 Label add_arguments_object; | 2265 Label add_arguments_object; |
| 2009 __ bind(&try_allocate); | 2266 __ bind(&try_allocate); |
| 2010 if (type_ == NEW_NON_STRICT_SLOW || type_ == NEW_NON_STRICT_FAST) { | 2267 __ testq(rcx, rcx); |
| 2011 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1); | 2268 __ j(zero, &add_arguments_object, Label::kNear); |
| 2012 } else { | 2269 __ lea(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); |
| 2013 __ testl(rcx, rcx); | 2270 __ bind(&add_arguments_object); |
| 2014 __ j(zero, &add_arguments_object); | 2271 __ addq(rcx, Immediate(Heap::kArgumentsObjectSizeStrict)); |
| 2015 __ leal(rcx, Operand(rcx, times_pointer_size, FixedArray::kHeaderSize)); | 2272 |
| 2016 __ bind(&add_arguments_object); | 2273 // Do the allocation of both objects in one go. |
| 2017 __ addl(rcx, Immediate(Heap::kArgumentsObjectSize)); | 2274 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); |
| 2018 | 2275 |
| 2019 // Do the allocation of both objects in one go. | 2276 // Get the arguments boilerplate from the current (global) context. |
| 2020 __ AllocateInNewSpace(rcx, rax, rdx, rbx, &runtime, TAG_OBJECT); | 2277 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2021 | 2278 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); |
| 2022 // Get the arguments boilerplate from the current (global) context. | 2279 const int offset = |
| 2023 __ movq(rdi, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2280 Context::SlotOffset(Context::STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX); |
| 2024 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); | 2281 __ movq(rdi, Operand(rdi, offset)); |
| 2025 __ movq(rdi, Operand(rdi, Context::SlotOffset( | 2282 |
| 2026 Context::STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX))); | 2283 // Copy the JS object part. |
| 2027 | 2284 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { |
| 2028 // Copy the JS object part. | 2285 __ movq(rbx, FieldOperand(rdi, i)); |
| 2029 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 2286 __ movq(FieldOperand(rax, i), rbx); |
| 2030 __ movq(kScratchRegister, FieldOperand(rdi, 0 * kPointerSize)); | |
| 2031 __ movq(rdx, FieldOperand(rdi, 1 * kPointerSize)); | |
| 2032 __ movq(rbx, FieldOperand(rdi, 2 * kPointerSize)); | |
| 2033 __ movq(FieldOperand(rax, 0 * kPointerSize), kScratchRegister); | |
| 2034 __ movq(FieldOperand(rax, 1 * kPointerSize), rdx); | |
| 2035 __ movq(FieldOperand(rax, 2 * kPointerSize), rbx); | |
| 2036 | |
| 2037 if (type_ == NEW_NON_STRICT_SLOW || type_ == NEW_NON_STRICT_FAST) { | |
| 2038 // Setup the callee in-object property. | |
| 2039 ASSERT(Heap::kArgumentsCalleeIndex == 1); | |
| 2040 __ movq(kScratchRegister, Operand(rsp, 3 * kPointerSize)); | |
| 2041 __ movq(FieldOperand(rax, JSObject::kHeaderSize + | |
| 2042 Heap::kArgumentsCalleeIndex * kPointerSize), | |
| 2043 kScratchRegister); | |
| 2044 } | |
| 2045 | |
| 2046 // Get the length (smi tagged) and set that as an in-object property too. | |
| 2047 ASSERT(Heap::kArgumentsLengthIndex == 0); | |
| 2048 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | |
| 2049 __ movq(FieldOperand(rax, JSObject::kHeaderSize + | |
| 2050 Heap::kArgumentsLengthIndex * kPointerSize), | |
| 2051 rcx); | |
| 2052 | |
| 2053 // If there are no actual arguments, we're done. | |
| 2054 Label done; | |
| 2055 __ SmiTest(rcx); | |
| 2056 __ j(zero, &done); | |
| 2057 | |
| 2058 // Get the parameters pointer from the stack and untag the length. | |
| 2059 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | |
| 2060 | |
| 2061 // Setup the elements pointer in the allocated arguments object and | |
| 2062 // initialize the header in the elements fixed array. | |
| 2063 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSize)); | |
| 2064 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | |
| 2065 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); | |
| 2066 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | |
| 2067 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | |
| 2068 __ SmiToInteger32(rcx, rcx); // Untag length for the loop below. | |
| 2069 | |
| 2070 // Copy the fixed array slots. | |
| 2071 Label loop; | |
| 2072 __ bind(&loop); | |
| 2073 // -1 ~ skip the receiver. | |
| 2074 __ movq(kScratchRegister, Operand(rdx, -1 * kPointerSize)); | |
| 2075 __ movq(FieldOperand(rdi, FixedArray::kHeaderSize), kScratchRegister); | |
| 2076 __ addq(rdi, Immediate(kPointerSize)); | |
| 2077 __ subq(rdx, Immediate(kPointerSize)); | |
| 2078 __ decl(rcx); | |
| 2079 __ j(not_zero, &loop); | |
| 2080 | |
| 2081 // Return and remove the on-stack parameters. | |
| 2082 __ bind(&done); | |
| 2083 __ ret(3 * kPointerSize); | |
| 2084 | |
| 2085 // Do the runtime call to allocate the arguments object. | |
| 2086 __ bind(&runtime); | |
| 2087 __ TailCallRuntime(Runtime::kNewStrictArgumentsFast, 3, 1); | |
| 2088 } | 2287 } |
| 2288 | |
| 2289 // Get the length (smi tagged) and set that as an in-object property too. | |
| 2290 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | |
| 2291 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); | |
| 2292 __ movq(FieldOperand(rax, JSObject::kHeaderSize + | |
| 2293 Heap::kArgumentsLengthIndex * kPointerSize), | |
| 2294 rcx); | |
| 2295 | |
| 2296 // If there are no actual arguments, we're done. | |
| 2297 Label done; | |
| 2298 __ testq(rcx, rcx); | |
| 2299 __ j(zero, &done); | |
| 2300 | |
| 2301 // Get the parameters pointer from the stack. | |
| 2302 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | |
| 2303 | |
| 2304 // Setup the elements pointer in the allocated arguments object and | |
| 2305 // initialize the header in the elements fixed array. | |
| 2306 __ lea(rdi, Operand(rax, Heap::kArgumentsObjectSizeStrict)); | |
| 2307 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rdi); | |
| 2308 __ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex); | |
| 2309 __ movq(FieldOperand(rdi, FixedArray::kMapOffset), kScratchRegister); | |
| 2310 | |
| 2311 | |
| 2312 __ movq(FieldOperand(rdi, FixedArray::kLengthOffset), rcx); | |
| 2313 // Untag the length for the loop below. | |
| 2314 __ SmiToInteger64(rcx, rcx); | |
| 2315 | |
| 2316 // Copy the fixed array slots. | |
| 2317 Label loop; | |
| 2318 __ bind(&loop); | |
| 2319 __ movq(rbx, Operand(rdx, -1 * kPointerSize)); // Skip receiver. | |
| 2320 __ movq(FieldOperand(rdi, FixedArray::kHeaderSize), rbx); | |
| 2321 __ addq(rdi, Immediate(kPointerSize)); | |
| 2322 __ subq(rdx, Immediate(kPointerSize)); | |
| 2323 __ decq(rcx); | |
| 2324 __ j(not_zero, &loop); | |
| 2325 | |
| 2326 // Return and remove the on-stack parameters. | |
| 2327 __ bind(&done); | |
| 2328 __ ret(3 * kPointerSize); | |
| 2329 | |
| 2330 // Do the runtime call to allocate the arguments object. | |
| 2331 __ bind(&runtime); | |
| 2332 __ TailCallRuntime(Runtime::kNewStrictArgumentsFast, 3, 1); | |
| 2089 } | 2333 } |
| 2090 | 2334 |
| 2091 | 2335 |
| 2092 void RegExpExecStub::Generate(MacroAssembler* masm) { | 2336 void RegExpExecStub::Generate(MacroAssembler* masm) { |
| 2093 // Just jump directly to runtime if native RegExp is not selected at compile | 2337 // Just jump directly to runtime if native RegExp is not selected at compile |
| 2094 // time or if regexp entry in generated code is turned off runtime switch or | 2338 // time or if regexp entry in generated code is turned off runtime switch or |
| 2095 // at compilation. | 2339 // at compilation. |
| 2096 #ifdef V8_INTERPRETED_REGEXP | 2340 #ifdef V8_INTERPRETED_REGEXP |
| 2097 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); | 2341 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
| 2098 #else // V8_INTERPRETED_REGEXP | 2342 #else // V8_INTERPRETED_REGEXP |
| (...skipping 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5142 __ Drop(1); | 5386 __ Drop(1); |
| 5143 __ ret(2 * kPointerSize); | 5387 __ ret(2 * kPointerSize); |
| 5144 } | 5388 } |
| 5145 | 5389 |
| 5146 | 5390 |
| 5147 #undef __ | 5391 #undef __ |
| 5148 | 5392 |
| 5149 } } // namespace v8::internal | 5393 } } // namespace v8::internal |
| 5150 | 5394 |
| 5151 #endif // V8_TARGET_ARCH_X64 | 5395 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |