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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } \ | 198 } \ |
199 } while (0) | 199 } while (0) |
200 | 200 |
201 | 201 |
202 // Assembles an instruction after register allocation, producing machine code. | 202 // Assembles an instruction after register allocation, producing machine code. |
203 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 203 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
204 X64OperandConverter i(this, instr); | 204 X64OperandConverter i(this, instr); |
205 | 205 |
206 switch (ArchOpcodeField::decode(instr->opcode())) { | 206 switch (ArchOpcodeField::decode(instr->opcode())) { |
207 case kArchCallCodeObject: { | 207 case kArchCallCodeObject: { |
| 208 EnsureSpaceForLazyDeopt(); |
208 if (HasImmediateInput(instr, 0)) { | 209 if (HasImmediateInput(instr, 0)) { |
209 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 210 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
210 __ Call(code, RelocInfo::CODE_TARGET); | 211 __ Call(code, RelocInfo::CODE_TARGET); |
211 } else { | 212 } else { |
212 Register reg = i.InputRegister(0); | 213 Register reg = i.InputRegister(0); |
213 int entry = Code::kHeaderSize - kHeapObjectTag; | 214 int entry = Code::kHeaderSize - kHeapObjectTag; |
214 __ Call(Operand(reg, entry)); | 215 __ Call(Operand(reg, entry)); |
215 } | 216 } |
216 AddSafepointAndDeopt(instr); | 217 AddSafepointAndDeopt(instr); |
217 break; | 218 break; |
218 } | 219 } |
219 case kArchCallAddress: | 220 case kArchCallAddress: |
220 if (HasImmediateInput(instr, 0)) { | 221 if (HasImmediateInput(instr, 0)) { |
221 Immediate64 imm = i.InputImmediate64(0); | 222 Immediate64 imm = i.InputImmediate64(0); |
222 DCHECK_EQ(kImm64Value, imm.type); | 223 DCHECK_EQ(kImm64Value, imm.type); |
223 __ Call(reinterpret_cast<byte*>(imm.value), RelocInfo::NONE64); | 224 __ Call(reinterpret_cast<byte*>(imm.value), RelocInfo::NONE64); |
224 } else { | 225 } else { |
225 __ call(i.InputRegister(0)); | 226 __ call(i.InputRegister(0)); |
226 } | 227 } |
227 break; | 228 break; |
228 case kArchCallJSFunction: { | 229 case kArchCallJSFunction: { |
| 230 EnsureSpaceForLazyDeopt(); |
229 Register func = i.InputRegister(0); | 231 Register func = i.InputRegister(0); |
230 if (FLAG_debug_code) { | 232 if (FLAG_debug_code) { |
231 // Check the function's context matches the context argument. | 233 // Check the function's context matches the context argument. |
232 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); | 234 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); |
233 __ Assert(equal, kWrongFunctionContext); | 235 __ Assert(equal, kWrongFunctionContext); |
234 } | 236 } |
235 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 237 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
236 AddSafepointAndDeopt(instr); | 238 AddSafepointAndDeopt(instr); |
237 break; | 239 break; |
238 } | 240 } |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 __ movsd(dst, xmm0); | 996 __ movsd(dst, xmm0); |
995 } else { | 997 } else { |
996 // No other combinations are possible. | 998 // No other combinations are possible. |
997 UNREACHABLE(); | 999 UNREACHABLE(); |
998 } | 1000 } |
999 } | 1001 } |
1000 | 1002 |
1001 | 1003 |
1002 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } | 1004 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
1003 | 1005 |
| 1006 |
| 1007 void CodeGenerator::EnsureSpaceForLazyDeopt() { |
| 1008 int space_needed = Deoptimizer::patch_size(); |
| 1009 if (!linkage()->info()->IsStub()) { |
| 1010 // Ensure that we have enough space after the previous lazy-bailout |
| 1011 // instruction for patching the code here. |
| 1012 int current_pc = masm()->pc_offset(); |
| 1013 if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
| 1014 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 1015 __ Nop(padding_size); |
| 1016 } |
| 1017 } |
| 1018 MarkLazyDeoptSite(); |
| 1019 } |
| 1020 |
1004 #undef __ | 1021 #undef __ |
1005 | 1022 |
1006 } // namespace internal | 1023 } // namespace internal |
1007 } // namespace compiler | 1024 } // namespace compiler |
1008 } // namespace v8 | 1025 } // namespace v8 |
OLD | NEW |