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 #include "src/crankshaft/arm64/lithium-codegen-arm64.h" | 5 #include "src/crankshaft/arm64/lithium-codegen-arm64.h" |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // Allocate a local context if needed. | 644 // Allocate a local context if needed. |
645 if (info()->num_heap_slots() > 0) { | 645 if (info()->num_heap_slots() > 0) { |
646 Comment(";;; Allocate local context"); | 646 Comment(";;; Allocate local context"); |
647 bool need_write_barrier = true; | 647 bool need_write_barrier = true; |
648 // Argument to NewContext is the function, which is in x1. | 648 // Argument to NewContext is the function, which is in x1. |
649 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 649 int slots = info()->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
650 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; | 650 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
651 if (info()->scope()->is_script_scope()) { | 651 if (info()->scope()->is_script_scope()) { |
652 __ Mov(x10, Operand(info()->scope()->GetScopeInfo(info()->isolate()))); | 652 __ Mov(x10, Operand(info()->scope()->GetScopeInfo(info()->isolate()))); |
653 __ Push(x1, x10); | 653 __ Push(x1, x10); |
654 __ CallRuntime(Runtime::kNewScriptContext, 2); | 654 __ CallRuntime(Runtime::kNewScriptContext); |
655 deopt_mode = Safepoint::kLazyDeopt; | 655 deopt_mode = Safepoint::kLazyDeopt; |
656 } else if (slots <= FastNewContextStub::kMaximumSlots) { | 656 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
657 FastNewContextStub stub(isolate(), slots); | 657 FastNewContextStub stub(isolate(), slots); |
658 __ CallStub(&stub); | 658 __ CallStub(&stub); |
659 // Result of FastNewContextStub is always in new space. | 659 // Result of FastNewContextStub is always in new space. |
660 need_write_barrier = false; | 660 need_write_barrier = false; |
661 } else { | 661 } else { |
662 __ Push(x1); | 662 __ Push(x1); |
663 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 663 __ CallRuntime(Runtime::kNewFunctionContext); |
664 } | 664 } |
665 RecordSafepoint(deopt_mode); | 665 RecordSafepoint(deopt_mode); |
666 // Context is returned in x0. It replaces the context passed to us. It's | 666 // Context is returned in x0. It replaces the context passed to us. It's |
667 // saved in the stack and kept live in cp. | 667 // saved in the stack and kept live in cp. |
668 __ Mov(cp, x0); | 668 __ Mov(cp, x0); |
669 __ Str(x0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 669 __ Str(x0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
670 // Copy any necessary parameters into the context. | 670 // Copy any necessary parameters into the context. |
671 int num_parameters = scope()->num_parameters(); | 671 int num_parameters = scope()->num_parameters(); |
672 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 672 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
673 for (int i = first_parameter; i < num_parameters; i++) { | 673 for (int i = first_parameter; i < num_parameters; i++) { |
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2763 Label use_cache, call_runtime; | 2763 Label use_cache, call_runtime; |
2764 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 2764 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
2765 __ CheckEnumCache(object, null_value, x1, x2, x3, x4, &call_runtime); | 2765 __ CheckEnumCache(object, null_value, x1, x2, x3, x4, &call_runtime); |
2766 | 2766 |
2767 __ Ldr(object, FieldMemOperand(object, HeapObject::kMapOffset)); | 2767 __ Ldr(object, FieldMemOperand(object, HeapObject::kMapOffset)); |
2768 __ B(&use_cache); | 2768 __ B(&use_cache); |
2769 | 2769 |
2770 // Get the set of properties to enumerate. | 2770 // Get the set of properties to enumerate. |
2771 __ Bind(&call_runtime); | 2771 __ Bind(&call_runtime); |
2772 __ Push(object); | 2772 __ Push(object); |
2773 CallRuntime(Runtime::kGetPropertyNamesFast, 1, instr); | 2773 CallRuntime(Runtime::kGetPropertyNamesFast, instr); |
2774 | 2774 |
2775 __ Ldr(x1, FieldMemOperand(object, HeapObject::kMapOffset)); | 2775 __ Ldr(x1, FieldMemOperand(object, HeapObject::kMapOffset)); |
2776 DeoptimizeIfNotRoot(x1, Heap::kMetaMapRootIndex, instr, | 2776 DeoptimizeIfNotRoot(x1, Heap::kMetaMapRootIndex, instr, |
2777 Deoptimizer::kWrongMap); | 2777 Deoptimizer::kWrongMap); |
2778 | 2778 |
2779 __ Bind(&use_cache); | 2779 __ Bind(&use_cache); |
2780 } | 2780 } |
2781 | 2781 |
2782 | 2782 |
2783 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) { | 2783 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) { |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4480 | 4480 |
4481 | 4481 |
4482 void LCodeGen::DoReturn(LReturn* instr) { | 4482 void LCodeGen::DoReturn(LReturn* instr) { |
4483 if (FLAG_trace && info()->IsOptimizing()) { | 4483 if (FLAG_trace && info()->IsOptimizing()) { |
4484 // Push the return value on the stack as the parameter. | 4484 // Push the return value on the stack as the parameter. |
4485 // Runtime::TraceExit returns its parameter in x0. We're leaving the code | 4485 // Runtime::TraceExit returns its parameter in x0. We're leaving the code |
4486 // managed by the register allocator and tearing down the frame, it's | 4486 // managed by the register allocator and tearing down the frame, it's |
4487 // safe to write to the context register. | 4487 // safe to write to the context register. |
4488 __ Push(x0); | 4488 __ Push(x0); |
4489 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4489 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4490 __ CallRuntime(Runtime::kTraceExit, 1); | 4490 __ CallRuntime(Runtime::kTraceExit); |
4491 } | 4491 } |
4492 | 4492 |
4493 if (info()->saves_caller_doubles()) { | 4493 if (info()->saves_caller_doubles()) { |
4494 RestoreCallerDoubles(); | 4494 RestoreCallerDoubles(); |
4495 } | 4495 } |
4496 | 4496 |
4497 if (NeedsEagerFrame()) { | 4497 if (NeedsEagerFrame()) { |
4498 Register stack_pointer = masm()->StackPointer(); | 4498 Register stack_pointer = masm()->StackPointer(); |
4499 __ Mov(stack_pointer, fp); | 4499 __ Mov(stack_pointer, fp); |
4500 __ Pop(fp, lr); | 4500 __ Pop(fp, lr); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4750 DCHECK(ToRegister(instr->context()).is(cp)); | 4750 DCHECK(ToRegister(instr->context()).is(cp)); |
4751 Register scratch1 = x5; | 4751 Register scratch1 = x5; |
4752 Register scratch2 = x6; | 4752 Register scratch2 = x6; |
4753 DCHECK(instr->IsMarkedAsCall()); | 4753 DCHECK(instr->IsMarkedAsCall()); |
4754 | 4754 |
4755 // TODO(all): if Mov could handle object in new space then it could be used | 4755 // TODO(all): if Mov could handle object in new space then it could be used |
4756 // here. | 4756 // here. |
4757 __ LoadHeapObject(scratch1, instr->hydrogen()->pairs()); | 4757 __ LoadHeapObject(scratch1, instr->hydrogen()->pairs()); |
4758 __ Mov(scratch2, Smi::FromInt(instr->hydrogen()->flags())); | 4758 __ Mov(scratch2, Smi::FromInt(instr->hydrogen()->flags())); |
4759 __ Push(scratch1, scratch2); | 4759 __ Push(scratch1, scratch2); |
4760 CallRuntime(Runtime::kDeclareGlobals, 2, instr); | 4760 CallRuntime(Runtime::kDeclareGlobals, instr); |
4761 } | 4761 } |
4762 | 4762 |
4763 | 4763 |
4764 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) { | 4764 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) { |
4765 PushSafepointRegistersScope scope(this); | 4765 PushSafepointRegistersScope scope(this); |
4766 LoadContextFromDeferred(instr->context()); | 4766 LoadContextFromDeferred(instr->context()); |
4767 __ CallRuntimeSaveDoubles(Runtime::kStackGuard); | 4767 __ CallRuntimeSaveDoubles(Runtime::kStackGuard); |
4768 RecordSafepointWithLazyDeopt( | 4768 RecordSafepointWithLazyDeopt( |
4769 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 4769 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
4770 DCHECK(instr->HasEnvironment()); | 4770 DCHECK(instr->HasEnvironment()); |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5806 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { | 5806 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { |
5807 Register context = ToRegister(instr->context()); | 5807 Register context = ToRegister(instr->context()); |
5808 __ Str(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 5808 __ Str(context, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
5809 } | 5809 } |
5810 | 5810 |
5811 | 5811 |
5812 void LCodeGen::DoAllocateBlockContext(LAllocateBlockContext* instr) { | 5812 void LCodeGen::DoAllocateBlockContext(LAllocateBlockContext* instr) { |
5813 Handle<ScopeInfo> scope_info = instr->scope_info(); | 5813 Handle<ScopeInfo> scope_info = instr->scope_info(); |
5814 __ Push(scope_info); | 5814 __ Push(scope_info); |
5815 __ Push(ToRegister(instr->function())); | 5815 __ Push(ToRegister(instr->function())); |
5816 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5816 CallRuntime(Runtime::kPushBlockContext, instr); |
5817 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5817 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5818 } | 5818 } |
5819 | 5819 |
5820 | 5820 |
5821 } // namespace internal | 5821 } // namespace internal |
5822 } // namespace v8 | 5822 } // namespace v8 |
OLD | NEW |