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/counters.h" | 8 #include "src/counters.h" |
9 #include "src/interface-descriptors.h" | 9 #include "src/interface-descriptors.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 assembler->TailCallRuntime( | 220 assembler->TailCallRuntime( |
221 Runtime::kNewArgumentsElements, assembler->NoContextConstant(), | 221 Runtime::kNewArgumentsElements, assembler->NoContextConstant(), |
222 assembler->BitcastWordToTagged(frame), assembler->SmiFromWord(length)); | 222 assembler->BitcastWordToTagged(frame), assembler->SmiFromWord(length)); |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 } // namespace | 226 } // namespace |
227 | 227 |
228 void Builtins::Generate_NewUnmappedArgumentsElements( | 228 void Builtins::Generate_NewUnmappedArgumentsElements( |
229 compiler::CodeAssemblerState* state) { | 229 compiler::CodeAssemblerState* state) { |
230 typedef CodeStubAssembler::Label Label; | |
231 typedef CodeStubAssembler::Variable Variable; | |
232 typedef compiler::Node Node; | 230 typedef compiler::Node Node; |
233 typedef NewArgumentsElementsDescriptor Descriptor; | 231 typedef NewArgumentsElementsDescriptor Descriptor; |
234 CodeStubAssembler assembler(state); | 232 CodeStubAssembler assembler(state); |
235 | 233 |
236 Node* formal_parameter_count = | 234 Node* frame = assembler.Parameter(Descriptor::kFrame); |
237 assembler.Parameter(Descriptor::kFormalParameterCount); | 235 Node* length = assembler.Parameter(Descriptor::kLength); |
238 | 236 Generate_NewArgumentsElements(&assembler, frame, assembler.SmiToWord(length)); |
239 // Determine the frame that holds the parameters. | |
240 Label done(&assembler); | |
241 Variable var_frame(&assembler, MachineType::PointerRepresentation()), | |
242 var_length(&assembler, MachineType::PointerRepresentation()); | |
243 var_frame.Bind(assembler.LoadParentFramePointer()); | |
244 var_length.Bind(formal_parameter_count); | |
245 Node* parent_frame = assembler.Load( | |
246 MachineType::Pointer(), var_frame.value(), | |
247 assembler.IntPtrConstant(StandardFrameConstants::kCallerFPOffset)); | |
248 Node* parent_frame_type = | |
249 assembler.Load(MachineType::AnyTagged(), parent_frame, | |
250 assembler.IntPtrConstant( | |
251 CommonFrameConstants::kContextOrFrameTypeOffset)); | |
252 assembler.GotoIfNot(assembler.MarkerIsFrameType( | |
253 parent_frame_type, StackFrame::ARGUMENTS_ADAPTOR), | |
254 &done); | |
255 { | |
256 // Determine the length from the ArgumentsAdaptorFrame. | |
257 Node* length = assembler.LoadAndUntagSmi( | |
258 parent_frame, ArgumentsAdaptorFrameConstants::kLengthOffset); | |
259 | |
260 // Take the arguments from the ArgumentsAdaptorFrame. | |
261 var_frame.Bind(parent_frame); | |
262 var_length.Bind(length); | |
263 } | |
264 assembler.Goto(&done); | |
265 | |
266 // Allocate the actual FixedArray for the elements. | |
267 assembler.Bind(&done); | |
268 Generate_NewArgumentsElements(&assembler, var_frame.value(), | |
269 var_length.value()); | |
270 } | |
271 | |
272 void Builtins::Generate_NewRestParameterElements( | |
273 compiler::CodeAssemblerState* state) { | |
274 typedef CodeStubAssembler::Label Label; | |
275 typedef compiler::Node Node; | |
276 typedef NewArgumentsElementsDescriptor Descriptor; | |
277 CodeStubAssembler assembler(state); | |
278 | |
279 Node* formal_parameter_count = | |
280 assembler.Parameter(Descriptor::kFormalParameterCount); | |
281 | |
282 // Check if we have an ArgumentsAdaptorFrame, as we will only have rest | |
283 // parameters in that case. | |
284 Label if_empty(&assembler); | |
285 Node* frame = assembler.Load( | |
286 MachineType::Pointer(), assembler.LoadParentFramePointer(), | |
287 assembler.IntPtrConstant(StandardFrameConstants::kCallerFPOffset)); | |
288 Node* frame_type = | |
289 assembler.Load(MachineType::AnyTagged(), frame, | |
290 assembler.IntPtrConstant( | |
291 CommonFrameConstants::kContextOrFrameTypeOffset)); | |
292 assembler.GotoIfNot( | |
293 assembler.MarkerIsFrameType(frame_type, StackFrame::ARGUMENTS_ADAPTOR), | |
294 &if_empty); | |
295 | |
296 // Determine the length from the ArgumentsAdaptorFrame. | |
297 Node* frame_length = assembler.LoadAndUntagSmi( | |
298 frame, ArgumentsAdaptorFrameConstants::kLengthOffset); | |
299 | |
300 // Compute the actual rest parameter length (may be negative). | |
301 Node* length = assembler.IntPtrSub(frame_length, formal_parameter_count); | |
302 | |
303 // Allocate the actual FixedArray for the elements. | |
304 Generate_NewArgumentsElements(&assembler, frame, length); | |
305 | |
306 // No rest parameters, return an empty FixedArray. | |
307 assembler.Bind(&if_empty); | |
308 assembler.Return(assembler.EmptyFixedArrayConstant()); | |
309 } | 237 } |
310 | 238 |
311 void Builtins::Generate_ReturnReceiver(compiler::CodeAssemblerState* state) { | 239 void Builtins::Generate_ReturnReceiver(compiler::CodeAssemblerState* state) { |
312 CodeStubAssembler assembler(state); | 240 CodeStubAssembler assembler(state); |
313 assembler.Return(assembler.Parameter(0)); | 241 assembler.Return(assembler.Parameter(0)); |
314 } | 242 } |
315 | 243 |
316 } // namespace internal | 244 } // namespace internal |
317 } // namespace v8 | 245 } // namespace v8 |
OLD | NEW |