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/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ArmOperandConverter i(this, instr); | 136 ArmOperandConverter i(this, instr); |
137 | 137 |
138 switch (ArchOpcodeField::decode(instr->opcode())) { | 138 switch (ArchOpcodeField::decode(instr->opcode())) { |
139 case kArchCallAddress: { | 139 case kArchCallAddress: { |
140 DirectCEntryStub stub(isolate()); | 140 DirectCEntryStub stub(isolate()); |
141 stub.GenerateCall(masm(), i.InputRegister(0)); | 141 stub.GenerateCall(masm(), i.InputRegister(0)); |
142 DCHECK_EQ(LeaveCC, i.OutputSBit()); | 142 DCHECK_EQ(LeaveCC, i.OutputSBit()); |
143 break; | 143 break; |
144 } | 144 } |
145 case kArchCallCodeObject: { | 145 case kArchCallCodeObject: { |
| 146 EnsureSpaceForLazyDeopt(); |
146 if (instr->InputAt(0)->IsImmediate()) { | 147 if (instr->InputAt(0)->IsImmediate()) { |
147 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), | 148 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), |
148 RelocInfo::CODE_TARGET); | 149 RelocInfo::CODE_TARGET); |
149 } else { | 150 } else { |
150 __ add(ip, i.InputRegister(0), | 151 __ add(ip, i.InputRegister(0), |
151 Operand(Code::kHeaderSize - kHeapObjectTag)); | 152 Operand(Code::kHeaderSize - kHeapObjectTag)); |
152 __ Call(ip); | 153 __ Call(ip); |
153 } | 154 } |
154 AddSafepointAndDeopt(instr); | 155 AddSafepointAndDeopt(instr); |
155 DCHECK_EQ(LeaveCC, i.OutputSBit()); | 156 DCHECK_EQ(LeaveCC, i.OutputSBit()); |
156 break; | 157 break; |
157 } | 158 } |
158 case kArchCallJSFunction: { | 159 case kArchCallJSFunction: { |
| 160 EnsureSpaceForLazyDeopt(); |
159 Register func = i.InputRegister(0); | 161 Register func = i.InputRegister(0); |
160 if (FLAG_debug_code) { | 162 if (FLAG_debug_code) { |
161 // Check the function's context matches the context argument. | 163 // Check the function's context matches the context argument. |
162 __ ldr(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); | 164 __ ldr(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); |
163 __ cmp(cp, kScratchReg); | 165 __ cmp(cp, kScratchReg); |
164 __ Assert(eq, kWrongFunctionContext); | 166 __ Assert(eq, kWrongFunctionContext); |
165 } | 167 } |
166 __ ldr(ip, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); | 168 __ ldr(ip, FieldMemOperand(func, JSFunction::kCodeEntryOffset)); |
167 __ Call(ip); | 169 __ Call(ip); |
168 AddSafepointAndDeopt(instr); | 170 AddSafepointAndDeopt(instr); |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 // No other combinations are possible. | 851 // No other combinations are possible. |
850 UNREACHABLE(); | 852 UNREACHABLE(); |
851 } | 853 } |
852 } | 854 } |
853 | 855 |
854 | 856 |
855 void CodeGenerator::AddNopForSmiCodeInlining() { | 857 void CodeGenerator::AddNopForSmiCodeInlining() { |
856 // On 32-bit ARM we do not insert nops for inlined Smi code. | 858 // On 32-bit ARM we do not insert nops for inlined Smi code. |
857 } | 859 } |
858 | 860 |
| 861 |
| 862 void CodeGenerator::EnsureSpaceForLazyDeopt() { |
| 863 int space_needed = Deoptimizer::patch_size(); |
| 864 if (!linkage()->info()->IsStub()) { |
| 865 // Ensure that we have enough space after the previous lazy-bailout |
| 866 // instruction for patching the code here. |
| 867 int current_pc = masm()->pc_offset(); |
| 868 if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
| 869 // Block literal pool emission for duration of padding. |
| 870 v8::internal::Assembler::BlockConstPoolScope block_const_pool(masm()); |
| 871 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 872 DCHECK_EQ(0, padding_size % v8::internal::Assembler::kInstrSize); |
| 873 while (padding_size > 0) { |
| 874 __ nop(); |
| 875 padding_size -= v8::internal::Assembler::kInstrSize; |
| 876 } |
| 877 } |
| 878 } |
| 879 MarkLazyDeoptSite(); |
| 880 } |
| 881 |
859 #undef __ | 882 #undef __ |
860 | 883 |
861 } // namespace compiler | 884 } // namespace compiler |
862 } // namespace internal | 885 } // namespace internal |
863 } // namespace v8 | 886 } // namespace v8 |
OLD | NEW |