OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 info->AddNoFrameRange(0, masm_->pc_offset()); | 176 info->AddNoFrameRange(0, masm_->pc_offset()); |
177 | 177 |
178 // Reserve space on the stack for locals. | 178 // Reserve space on the stack for locals. |
179 { Comment cmnt(masm_, "[ Allocate locals"); | 179 { Comment cmnt(masm_, "[ Allocate locals"); |
180 int locals_count = info->scope()->num_stack_slots(); | 180 int locals_count = info->scope()->num_stack_slots(); |
181 // Generators allocate locals, if any, in context slots. | 181 // Generators allocate locals, if any, in context slots. |
182 ASSERT(!info->function()->is_generator() || locals_count == 0); | 182 ASSERT(!info->function()->is_generator() || locals_count == 0); |
183 | 183 |
184 if (locals_count > 0) { | 184 if (locals_count > 0) { |
185 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); | 185 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); |
186 __ PushMultipleTimes(locals_count, x10); | 186 __ PushMultipleTimes(x10, locals_count); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 bool function_in_register_x1 = true; | 190 bool function_in_register_x1 = true; |
191 | 191 |
192 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 192 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
193 if (heap_slots > 0) { | 193 if (heap_slots > 0) { |
194 // Argument to NewContext is the function, which is still in x1. | 194 // Argument to NewContext is the function, which is still in x1. |
195 Comment cmnt(masm_, "[ Allocate context"); | 195 Comment cmnt(masm_, "[ Allocate context"); |
196 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 196 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
(...skipping 4418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4615 // Push holes for the rest of the arguments to the generator function. | 4615 // Push holes for the rest of the arguments to the generator function. |
4616 __ Ldr(x10, FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 4616 __ Ldr(x10, FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
4617 | 4617 |
4618 // The number of arguments is stored as an int32_t, and -1 is a marker | 4618 // The number of arguments is stored as an int32_t, and -1 is a marker |
4619 // (SharedFunctionInfo::kDontAdaptArgumentsSentinel), so we need sign | 4619 // (SharedFunctionInfo::kDontAdaptArgumentsSentinel), so we need sign |
4620 // extension to correctly handle it. However, in this case, we operate on | 4620 // extension to correctly handle it. However, in this case, we operate on |
4621 // 32-bit W registers, so extension isn't required. | 4621 // 32-bit W registers, so extension isn't required. |
4622 __ Ldr(w10, FieldMemOperand(x10, | 4622 __ Ldr(w10, FieldMemOperand(x10, |
4623 SharedFunctionInfo::kFormalParameterCountOffset)); | 4623 SharedFunctionInfo::kFormalParameterCountOffset)); |
4624 __ LoadRoot(the_hole, Heap::kTheHoleValueRootIndex); | 4624 __ LoadRoot(the_hole, Heap::kTheHoleValueRootIndex); |
4625 | 4625 __ PushMultipleTimes(the_hole, w10); |
4626 // TODO(jbramley): Write a variant of PushMultipleTimes which takes a register | |
4627 // instead of a constant count, and use it to replace this loop. | |
4628 Label push_argument_holes, push_frame; | |
4629 __ Bind(&push_argument_holes); | |
4630 __ Subs(w10, w10, 1); | |
4631 __ B(mi, &push_frame); | |
4632 __ Push(the_hole); | |
4633 __ B(&push_argument_holes); | |
4634 | 4626 |
4635 // Enter a new JavaScript frame, and initialize its slots as they were when | 4627 // Enter a new JavaScript frame, and initialize its slots as they were when |
4636 // the generator was suspended. | 4628 // the generator was suspended. |
4637 Label resume_frame; | 4629 Label resume_frame; |
4638 __ Bind(&push_frame); | |
4639 __ Bl(&resume_frame); | 4630 __ Bl(&resume_frame); |
4640 __ B(&done); | 4631 __ B(&done); |
4641 | 4632 |
4642 __ Bind(&resume_frame); | 4633 __ Bind(&resume_frame); |
4643 __ Push(lr, // Return address. | 4634 __ Push(lr, // Return address. |
4644 fp, // Caller's frame pointer. | 4635 fp, // Caller's frame pointer. |
4645 cp, // Callee's context. | 4636 cp, // Callee's context. |
4646 function); // Callee's JS Function. | 4637 function); // Callee's JS Function. |
4647 __ Add(fp, __ StackPointer(), kPointerSize * 2); | 4638 __ Add(fp, __ StackPointer(), kPointerSize * 2); |
4648 | 4639 |
(...skipping 16 matching lines...) Expand all Loading... |
4665 __ Mov(x12, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 4656 __ Mov(x12, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
4666 __ Str(x12, FieldMemOperand(generator_object, | 4657 __ Str(x12, FieldMemOperand(generator_object, |
4667 JSGeneratorObject::kContinuationOffset)); | 4658 JSGeneratorObject::kContinuationOffset)); |
4668 __ Br(x10); | 4659 __ Br(x10); |
4669 | 4660 |
4670 __ Bind(&slow_resume); | 4661 __ Bind(&slow_resume); |
4671 } | 4662 } |
4672 | 4663 |
4673 // Otherwise, we push holes for the operand stack and call the runtime to fix | 4664 // Otherwise, we push holes for the operand stack and call the runtime to fix |
4674 // up the stack and the handlers. | 4665 // up the stack and the handlers. |
4675 // TODO(jbramley): Write a variant of PushMultipleTimes which takes a register | 4666 __ PushMultipleTimes(the_hole, operand_stack_size); |
4676 // instead of a constant count, and use it to replace this loop. | |
4677 Label push_operand_holes, call_resume; | |
4678 __ Bind(&push_operand_holes); | |
4679 __ Subs(operand_stack_size, operand_stack_size, 1); | |
4680 __ B(mi, &call_resume); | |
4681 __ Push(the_hole); | |
4682 __ B(&push_operand_holes); | |
4683 | 4667 |
4684 __ Bind(&call_resume); | |
4685 __ Mov(x10, Operand(Smi::FromInt(resume_mode))); | 4668 __ Mov(x10, Operand(Smi::FromInt(resume_mode))); |
4686 __ Push(generator_object, result_register(), x10); | 4669 __ Push(generator_object, result_register(), x10); |
4687 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); | 4670 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); |
4688 // Not reached: the runtime call returns elsewhere. | 4671 // Not reached: the runtime call returns elsewhere. |
4689 __ Unreachable(); | 4672 __ Unreachable(); |
4690 | 4673 |
4691 // Reach here when generator is closed. | 4674 // Reach here when generator is closed. |
4692 __ Bind(&closed_state); | 4675 __ Bind(&closed_state); |
4693 if (resume_mode == JSGeneratorObject::NEXT) { | 4676 if (resume_mode == JSGeneratorObject::NEXT) { |
4694 // Return completed iterator result when generator is closed. | 4677 // Return completed iterator result when generator is closed. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5001 return previous_; | 4984 return previous_; |
5002 } | 4985 } |
5003 | 4986 |
5004 | 4987 |
5005 #undef __ | 4988 #undef __ |
5006 | 4989 |
5007 | 4990 |
5008 } } // namespace v8::internal | 4991 } } // namespace v8::internal |
5009 | 4992 |
5010 #endif // V8_TARGET_ARCH_A64 | 4993 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |