OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 #include "src/interface-descriptors.h" | 8 #include "src/interface-descriptors.h" |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 assembler->Branch( | 166 assembler->Branch( |
167 assembler->IntPtrLessThanOrEqual(length, assembler->IntPtrConstant(0)), | 167 assembler->IntPtrLessThanOrEqual(length, assembler->IntPtrConstant(0)), |
168 &if_empty, &if_notempty); | 168 &if_empty, &if_notempty); |
169 | 169 |
170 assembler->Bind(&if_empty); | 170 assembler->Bind(&if_empty); |
171 assembler->Return(assembler->EmptyFixedArrayConstant()); | 171 assembler->Return(assembler->EmptyFixedArrayConstant()); |
172 | 172 |
173 assembler->Bind(&if_notempty); | 173 assembler->Bind(&if_notempty); |
174 { | 174 { |
175 // Allocate a FixedArray in new space. | 175 // Allocate a FixedArray in new space. |
176 Node* result = assembler->AllocateFixedArray( | 176 Node* result = assembler->AllocateFixedArray(kind, length); |
177 kind, length, CodeStubAssembler::INTPTR_PARAMETERS); | |
178 | 177 |
179 // Compute the effective {offset} into the {frame}. | 178 // Compute the effective {offset} into the {frame}. |
180 Node* offset = assembler->IntPtrAdd(length, assembler->IntPtrConstant(1)); | 179 Node* offset = assembler->IntPtrAdd(length, assembler->IntPtrConstant(1)); |
181 | 180 |
182 // Copy the parameters from {frame} (starting at {offset}) to {result}. | 181 // Copy the parameters from {frame} (starting at {offset}) to {result}. |
183 Variable var_index(assembler, MachineType::PointerRepresentation()); | 182 Variable var_index(assembler, MachineType::PointerRepresentation()); |
184 Label loop(assembler, &var_index), done_loop(assembler); | 183 Label loop(assembler, &var_index), done_loop(assembler); |
185 var_index.Bind(assembler->IntPtrConstant(0)); | 184 var_index.Bind(assembler->IntPtrConstant(0)); |
186 assembler->Goto(&loop); | 185 assembler->Goto(&loop); |
187 assembler->Bind(&loop); | 186 assembler->Bind(&loop); |
188 { | 187 { |
189 // Load the current {index}. | 188 // Load the current {index}. |
190 Node* index = var_index.value(); | 189 Node* index = var_index.value(); |
191 | 190 |
192 // Check if we are done. | 191 // Check if we are done. |
193 assembler->GotoIf(assembler->WordEqual(index, length), &done_loop); | 192 assembler->GotoIf(assembler->WordEqual(index, length), &done_loop); |
194 | 193 |
195 // Load the parameter at the given {index}. | 194 // Load the parameter at the given {index}. |
196 Node* value = assembler->Load( | 195 Node* value = assembler->Load( |
197 MachineType::AnyTagged(), frame, | 196 MachineType::AnyTagged(), frame, |
198 assembler->WordShl(assembler->IntPtrSub(offset, index), | 197 assembler->WordShl(assembler->IntPtrSub(offset, index), |
199 assembler->IntPtrConstant(kPointerSizeLog2))); | 198 assembler->IntPtrConstant(kPointerSizeLog2))); |
200 | 199 |
201 // Store the {value} into the {result}. | 200 // Store the {value} into the {result}. |
202 assembler->StoreFixedArrayElement(result, index, value, | 201 assembler->StoreFixedArrayElement(result, index, value, |
203 SKIP_WRITE_BARRIER, 0, | 202 SKIP_WRITE_BARRIER); |
204 CodeStubAssembler::INTPTR_PARAMETERS); | |
205 | 203 |
206 // Continue with next {index}. | 204 // Continue with next {index}. |
207 var_index.Bind( | 205 var_index.Bind( |
208 assembler->IntPtrAdd(index, assembler->IntPtrConstant(1))); | 206 assembler->IntPtrAdd(index, assembler->IntPtrConstant(1))); |
209 assembler->Goto(&loop); | 207 assembler->Goto(&loop); |
210 } | 208 } |
211 | 209 |
212 assembler->Bind(&done_loop); | 210 assembler->Bind(&done_loop); |
213 assembler->Return(result); | 211 assembler->Return(result); |
214 } | 212 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // Allocate the actual FixedArray for the elements. | 304 // Allocate the actual FixedArray for the elements. |
307 Generate_NewArgumentsElements(&assembler, frame, length); | 305 Generate_NewArgumentsElements(&assembler, frame, length); |
308 | 306 |
309 // No rest parameters, return an empty FixedArray. | 307 // No rest parameters, return an empty FixedArray. |
310 assembler.Bind(&if_empty); | 308 assembler.Bind(&if_empty); |
311 assembler.Return(assembler.EmptyFixedArrayConstant()); | 309 assembler.Return(assembler.EmptyFixedArrayConstant()); |
312 } | 310 } |
313 | 311 |
314 } // namespace internal | 312 } // namespace internal |
315 } // namespace v8 | 313 } // namespace v8 |
OLD | NEW |