| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return instr->InputAt(index)->IsImmediate(); | 105 return instr->InputAt(index)->IsImmediate(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 // Assembles an instruction after register allocation, producing machine code. | 109 // Assembles an instruction after register allocation, producing machine code. |
| 110 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 110 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| 111 IA32OperandConverter i(this, instr); | 111 IA32OperandConverter i(this, instr); |
| 112 | 112 |
| 113 switch (ArchOpcodeField::decode(instr->opcode())) { | 113 switch (ArchOpcodeField::decode(instr->opcode())) { |
| 114 case kArchCallCodeObject: { | 114 case kArchCallCodeObject: { |
| 115 EnsureSpaceForLazyDeopt(); |
| 115 if (HasImmediateInput(instr, 0)) { | 116 if (HasImmediateInput(instr, 0)) { |
| 116 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 117 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
| 117 __ call(code, RelocInfo::CODE_TARGET); | 118 __ call(code, RelocInfo::CODE_TARGET); |
| 118 } else { | 119 } else { |
| 119 Register reg = i.InputRegister(0); | 120 Register reg = i.InputRegister(0); |
| 120 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); | 121 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); |
| 121 } | 122 } |
| 122 AddSafepointAndDeopt(instr); | 123 AddSafepointAndDeopt(instr); |
| 123 break; | 124 break; |
| 124 } | 125 } |
| 125 case kArchCallJSFunction: { | 126 case kArchCallJSFunction: { |
| 127 EnsureSpaceForLazyDeopt(); |
| 126 Register func = i.InputRegister(0); | 128 Register func = i.InputRegister(0); |
| 127 if (FLAG_debug_code) { | 129 if (FLAG_debug_code) { |
| 128 // Check the function's context matches the context argument. | 130 // Check the function's context matches the context argument. |
| 129 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 131 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
| 130 __ Assert(equal, kWrongFunctionContext); | 132 __ Assert(equal, kWrongFunctionContext); |
| 131 } | 133 } |
| 132 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 134 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
| 133 AddSafepointAndDeopt(instr); | 135 AddSafepointAndDeopt(instr); |
| 134 break; | 136 break; |
| 135 } | 137 } |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 __ movsd(src0, xmm0); | 927 __ movsd(src0, xmm0); |
| 926 } else { | 928 } else { |
| 927 // No other combinations are possible. | 929 // No other combinations are possible. |
| 928 UNREACHABLE(); | 930 UNREACHABLE(); |
| 929 } | 931 } |
| 930 } | 932 } |
| 931 | 933 |
| 932 | 934 |
| 933 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } | 935 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
| 934 | 936 |
| 937 |
| 938 void CodeGenerator::EnsureSpaceForLazyDeopt() { |
| 939 int space_needed = Deoptimizer::patch_size(); |
| 940 if (!linkage()->info()->IsStub()) { |
| 941 // Ensure that we have enough space after the previous lazy-bailout |
| 942 // instruction for patching the code here. |
| 943 int current_pc = masm()->pc_offset(); |
| 944 if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
| 945 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 946 __ Nop(padding_size); |
| 947 } |
| 948 } |
| 949 MarkLazyDeoptSite(); |
| 950 } |
| 951 |
| 935 #undef __ | 952 #undef __ |
| 936 | 953 |
| 937 } // namespace compiler | 954 } // namespace compiler |
| 938 } // namespace internal | 955 } // namespace internal |
| 939 } // namespace v8 | 956 } // namespace v8 |
| OLD | NEW |