OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/macro-assembler-arm64.h" | 7 #include "src/arm64/macro-assembler-arm64.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } \ | 125 } \ |
126 } while (0); | 126 } while (0); |
127 | 127 |
128 | 128 |
129 // Assembles an instruction after register allocation, producing machine code. | 129 // Assembles an instruction after register allocation, producing machine code. |
130 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 130 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
131 Arm64OperandConverter i(this, instr); | 131 Arm64OperandConverter i(this, instr); |
132 InstructionCode opcode = instr->opcode(); | 132 InstructionCode opcode = instr->opcode(); |
133 switch (ArchOpcodeField::decode(opcode)) { | 133 switch (ArchOpcodeField::decode(opcode)) { |
134 case kArchCallCodeObject: { | 134 case kArchCallCodeObject: { |
| 135 EnsureSpaceForLazyDeopt(); |
135 if (instr->InputAt(0)->IsImmediate()) { | 136 if (instr->InputAt(0)->IsImmediate()) { |
136 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), | 137 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), |
137 RelocInfo::CODE_TARGET); | 138 RelocInfo::CODE_TARGET); |
138 } else { | 139 } else { |
139 Register target = i.InputRegister(0); | 140 Register target = i.InputRegister(0); |
140 __ Add(target, target, Code::kHeaderSize - kHeapObjectTag); | 141 __ Add(target, target, Code::kHeaderSize - kHeapObjectTag); |
141 __ Call(target); | 142 __ Call(target); |
142 } | 143 } |
143 AddSafepointAndDeopt(instr); | 144 AddSafepointAndDeopt(instr); |
144 break; | 145 break; |
145 } | 146 } |
146 case kArchCallJSFunction: { | 147 case kArchCallJSFunction: { |
| 148 EnsureSpaceForLazyDeopt(); |
147 Register func = i.InputRegister(0); | 149 Register func = i.InputRegister(0); |
148 if (FLAG_debug_code) { | 150 if (FLAG_debug_code) { |
149 // Check the function's context matches the context argument. | 151 // Check the function's context matches the context argument. |
150 UseScratchRegisterScope scope(masm()); | 152 UseScratchRegisterScope scope(masm()); |
151 Register temp = scope.AcquireX(); | 153 Register temp = scope.AcquireX(); |
152 __ Ldr(temp, FieldMemOperand(func, JSFunction::kContextOffset)); | 154 __ Ldr(temp, FieldMemOperand(func, JSFunction::kContextOffset)); |
153 __ cmp(cp, temp); | 155 __ cmp(cp, temp); |
154 __ Assert(eq, kWrongFunctionContext); | 156 __ Assert(eq, kWrongFunctionContext); |
155 } | 157 } |
156 __ Ldr(x10, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); | 158 __ Ldr(x10, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 } | 839 } |
838 } else { | 840 } else { |
839 // No other combinations are possible. | 841 // No other combinations are possible. |
840 UNREACHABLE(); | 842 UNREACHABLE(); |
841 } | 843 } |
842 } | 844 } |
843 | 845 |
844 | 846 |
845 void CodeGenerator::AddNopForSmiCodeInlining() { __ movz(xzr, 0); } | 847 void CodeGenerator::AddNopForSmiCodeInlining() { __ movz(xzr, 0); } |
846 | 848 |
| 849 |
| 850 void CodeGenerator::EnsureSpaceForLazyDeopt() { |
| 851 int space_needed = Deoptimizer::patch_size(); |
| 852 if (!linkage()->info()->IsStub()) { |
| 853 // Ensure that we have enough space after the previous lazy-bailout |
| 854 // instruction for patching the code here. |
| 855 intptr_t current_pc = masm()->pc_offset(); |
| 856 |
| 857 if (current_pc < (last_lazy_deopt_pc_ + space_needed)) { |
| 858 intptr_t padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 859 DCHECK((padding_size % kInstructionSize) == 0); |
| 860 InstructionAccurateScope instruction_accurate( |
| 861 masm(), padding_size / kInstructionSize); |
| 862 |
| 863 while (padding_size > 0) { |
| 864 __ nop(); |
| 865 padding_size -= kInstructionSize; |
| 866 } |
| 867 } |
| 868 } |
| 869 MarkLazyDeoptSite(); |
| 870 } |
| 871 |
847 #undef __ | 872 #undef __ |
848 | 873 |
849 } // namespace compiler | 874 } // namespace compiler |
850 } // namespace internal | 875 } // namespace internal |
851 } // namespace v8 | 876 } // namespace v8 |
OLD | NEW |