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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 4367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4378 } | 4378 } |
4379 | 4379 |
4380 case Yield::kFinal: { | 4380 case Yield::kFinal: { |
4381 // Pop value from top-of-stack slot, box result into result register. | 4381 // Pop value from top-of-stack slot, box result into result register. |
4382 EmitCreateIteratorResult(true); | 4382 EmitCreateIteratorResult(true); |
4383 EmitUnwindBeforeReturn(); | 4383 EmitUnwindBeforeReturn(); |
4384 EmitReturnSequence(); | 4384 EmitReturnSequence(); |
4385 break; | 4385 break; |
4386 } | 4386 } |
4387 | 4387 |
4388 case Yield::kDelegating: { | 4388 case Yield::kDelegating: |
4389 VisitForStackValue(expr->generator_object()); | 4389 UNREACHABLE(); |
4390 | |
4391 // Initial stack layout is as follows: | |
4392 // [sp + 1 * kPointerSize] iter | |
4393 // [sp + 0 * kPointerSize] g | |
4394 | |
4395 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | |
4396 Label l_next, l_call, l_loop; | |
4397 Register load_receiver = LoadDescriptor::ReceiverRegister(); | |
4398 Register load_name = LoadDescriptor::NameRegister(); | |
4399 | |
4400 // Initial send value is undefined. | |
4401 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); | |
4402 __ B(&l_next); | |
4403 | |
4404 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | |
4405 __ Bind(&l_catch); | |
4406 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" | |
4407 __ Peek(x3, 1 * kPointerSize); // iter | |
4408 __ Push(load_name, x3, x0); // "throw", iter, except | |
4409 __ B(&l_call); | |
4410 | |
4411 // try { received = %yield result } | |
4412 // Shuffle the received result above a try handler and yield it without | |
4413 // re-boxing. | |
4414 __ Bind(&l_try); | |
4415 __ Pop(x0); // result | |
4416 int handler_index = NewHandlerTableEntry(); | |
4417 EnterTryBlock(handler_index, &l_catch); | |
4418 const int try_block_size = TryCatch::kElementCount * kPointerSize; | |
4419 __ Push(x0); // result | |
4420 | |
4421 __ B(&l_suspend); | |
4422 // TODO(jbramley): This label is bound here because the following code | |
4423 // looks at its pos(). Is it possible to do something more efficient here, | |
4424 // perhaps using Adr? | |
4425 __ Bind(&l_continuation); | |
4426 __ RecordGeneratorContinuation(); | |
4427 __ B(&l_resume); | |
4428 | |
4429 __ Bind(&l_suspend); | |
4430 const int generator_object_depth = kPointerSize + try_block_size; | |
4431 __ Peek(x0, generator_object_depth); | |
4432 __ Push(x0); // g | |
4433 __ Push(Smi::FromInt(handler_index)); // handler-index | |
4434 DCHECK((l_continuation.pos() > 0) && Smi::IsValid(l_continuation.pos())); | |
4435 __ Mov(x1, Smi::FromInt(l_continuation.pos())); | |
4436 __ Str(x1, FieldMemOperand(x0, JSGeneratorObject::kContinuationOffset)); | |
4437 __ Str(cp, FieldMemOperand(x0, JSGeneratorObject::kContextOffset)); | |
4438 __ Mov(x1, cp); | |
4439 __ RecordWriteField(x0, JSGeneratorObject::kContextOffset, x1, x2, | |
4440 kLRHasBeenSaved, kDontSaveFPRegs); | |
4441 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); | |
4442 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
4443 __ Pop(x0); // result | |
4444 EmitReturnSequence(); | |
4445 __ Bind(&l_resume); // received in x0 | |
4446 ExitTryBlock(handler_index); | |
4447 | |
4448 // receiver = iter; f = 'next'; arg = received; | |
4449 __ Bind(&l_next); | |
4450 | |
4451 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | |
4452 __ Peek(x3, 1 * kPointerSize); // iter | |
4453 __ Push(load_name, x3, x0); // "next", iter, received | |
4454 | |
4455 // result = receiver[f](arg); | |
4456 __ Bind(&l_call); | |
4457 __ Peek(load_receiver, 1 * kPointerSize); | |
4458 __ Peek(load_name, 2 * kPointerSize); | |
4459 __ Mov(LoadDescriptor::SlotRegister(), | |
4460 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | |
4461 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | |
4462 CallIC(ic, TypeFeedbackId::None()); | |
4463 __ Mov(x1, x0); | |
4464 __ Poke(x1, 2 * kPointerSize); | |
4465 SetCallPosition(expr); | |
4466 __ Mov(x0, 1); | |
4467 __ Call( | |
4468 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), | |
4469 RelocInfo::CODE_TARGET); | |
4470 | |
4471 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
4472 __ Drop(1); // The function is still on the stack; drop it. | |
4473 | |
4474 // if (!result.done) goto l_try; | |
4475 __ Bind(&l_loop); | |
4476 __ Move(load_receiver, x0); | |
4477 | |
4478 __ Push(load_receiver); // save result | |
4479 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | |
4480 __ Mov(LoadDescriptor::SlotRegister(), | |
4481 SmiFromSlot(expr->DoneFeedbackSlot())); | |
4482 CallLoadIC(NOT_INSIDE_TYPEOF); // x0=result.done | |
4483 // The ToBooleanStub argument (result.done) is in x0. | |
4484 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | |
4485 CallIC(bool_ic); | |
4486 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex); | |
4487 __ B(ne, &l_try); | |
4488 | |
4489 // result.value | |
4490 __ Pop(load_receiver); // result | |
4491 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | |
4492 __ Mov(LoadDescriptor::SlotRegister(), | |
4493 SmiFromSlot(expr->ValueFeedbackSlot())); | |
4494 CallLoadIC(NOT_INSIDE_TYPEOF); // x0=result.value | |
4495 context()->DropAndPlug(2, x0); // drop iter and g | |
4496 break; | |
4497 } | |
4498 } | 4390 } |
4499 } | 4391 } |
4500 | 4392 |
4501 | 4393 |
4502 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 4394 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
4503 Expression *value, | 4395 Expression *value, |
4504 JSGeneratorObject::ResumeMode resume_mode) { | 4396 JSGeneratorObject::ResumeMode resume_mode) { |
4505 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume"); | 4397 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume"); |
4506 Register generator_object = x1; | 4398 Register generator_object = x1; |
4507 Register the_hole = x2; | 4399 Register the_hole = x2; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4835 } | 4727 } |
4836 | 4728 |
4837 return INTERRUPT; | 4729 return INTERRUPT; |
4838 } | 4730 } |
4839 | 4731 |
4840 | 4732 |
4841 } // namespace internal | 4733 } // namespace internal |
4842 } // namespace v8 | 4734 } // namespace v8 |
4843 | 4735 |
4844 #endif // V8_TARGET_ARCH_ARM64 | 4736 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |