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 kArchCallJSFunction: { | 220 case kArchCallJSFunction: { |
| 221 EnsureSpaceForLazyDeopt(); |
220 Register func = i.InputRegister(0); | 222 Register func = i.InputRegister(0); |
221 if (FLAG_debug_code) { | 223 if (FLAG_debug_code) { |
222 // Check the function's context matches the context argument. | 224 // Check the function's context matches the context argument. |
223 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); | 225 __ cmpp(rsi, FieldOperand(func, JSFunction::kContextOffset)); |
224 __ Assert(equal, kWrongFunctionContext); | 226 __ Assert(equal, kWrongFunctionContext); |
225 } | 227 } |
226 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 228 __ Call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
227 AddSafepointAndDeopt(instr); | 229 AddSafepointAndDeopt(instr); |
228 break; | 230 break; |
229 } | 231 } |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 __ movsd(dst, xmm0); | 986 __ movsd(dst, xmm0); |
985 } else { | 987 } else { |
986 // No other combinations are possible. | 988 // No other combinations are possible. |
987 UNREACHABLE(); | 989 UNREACHABLE(); |
988 } | 990 } |
989 } | 991 } |
990 | 992 |
991 | 993 |
992 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } | 994 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
993 | 995 |
| 996 |
| 997 void CodeGenerator::EnsureSpaceForLazyDeopt() { |
| 998 int space_needed = Deoptimizer::patch_size(); |
| 999 if (!linkage()->info()->IsStub()) { |
| 1000 // Ensure that we have enough space after the previous lazy-bailout |
| 1001 // instruction for patching the code here. |
| 1002 int current_pc = masm()->pc_offset(); |
| 1003 if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
| 1004 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 1005 __ Nop(padding_size); |
| 1006 } |
| 1007 } |
| 1008 MarkLazyDeoptSite(); |
| 1009 } |
| 1010 |
994 #undef __ | 1011 #undef __ |
995 | 1012 |
996 } // namespace internal | 1013 } // namespace internal |
997 } // namespace compiler | 1014 } // namespace compiler |
998 } // namespace v8 | 1015 } // namespace v8 |
OLD | NEW |