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/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 | 10 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 i, Smi::FromInt(deoptimization_states_[i]->translation_id_)); | 233 i, Smi::FromInt(deoptimization_states_[i]->translation_id_)); |
234 data->SetArgumentsStackHeight(i, Smi::FromInt(0)); | 234 data->SetArgumentsStackHeight(i, Smi::FromInt(0)); |
235 data->SetPc(i, Smi::FromInt(-1)); | 235 data->SetPc(i, Smi::FromInt(-1)); |
236 } | 236 } |
237 | 237 |
238 code_object->set_deoptimization_data(*data); | 238 code_object->set_deoptimization_data(*data); |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 void CodeGenerator::AddSafepointAndDeopt(Instruction* instr) { | 242 void CodeGenerator::AddSafepointAndDeopt(Instruction* instr) { |
243 CallDescriptor::DeoptimizationSupport deopt = | 243 CallDescriptor::Flags flags(MiscField::decode(instr->opcode())); |
244 static_cast<CallDescriptor::DeoptimizationSupport>( | |
245 MiscField::decode(instr->opcode())); | |
246 | 244 |
247 bool needs_frame_state = (deopt & CallDescriptor::kNeedsFrameState) != 0; | 245 bool needs_frame_state = (flags & CallDescriptor::kNeedsFrameState); |
248 | 246 |
249 Safepoint::Id safepoint_id = RecordSafepoint( | 247 Safepoint::Id safepoint_id = RecordSafepoint( |
250 instr->pointer_map(), Safepoint::kSimple, 0, | 248 instr->pointer_map(), Safepoint::kSimple, 0, |
251 needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); | 249 needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); |
252 | 250 |
253 if ((deopt & CallDescriptor::kLazyDeoptimization) != 0) { | 251 if (flags & CallDescriptor::kLazyDeoptimization) { |
254 RecordLazyDeoptimizationEntry(instr, safepoint_id); | 252 RecordLazyDeoptimizationEntry(instr, safepoint_id); |
255 } | 253 } |
256 | 254 |
257 if (needs_frame_state) { | 255 if (needs_frame_state) { |
258 // If the frame state is present, it starts at argument 1 | 256 // If the frame state is present, it starts at argument 1 |
259 // (just after the code address). | 257 // (just after the code address). |
260 InstructionOperandConverter converter(this, instr); | 258 InstructionOperandConverter converter(this, instr); |
261 // Argument 1 is deoptimization id. | 259 // Argument 1 is deoptimization id. |
262 int deoptimization_id = converter.ToConstant(instr->InputAt(1)).ToInt32(); | 260 int deoptimization_id = converter.ToConstant(instr->InputAt(1)).ToInt32(); |
263 // The actual frame state values start with argument 2. | 261 // The actual frame state values start with argument 2. |
264 int first_state_value_offset = 2; | 262 int first_state_value_offset = 2; |
265 #if DEBUG | 263 #if DEBUG |
266 // Make sure all the values live in stack slots or they are immediates. | 264 // Make sure all the values live in stack slots or they are immediates. |
267 // (The values should not live in register because registers are clobbered | 265 // (The values should not live in register because registers are clobbered |
268 // by calls.) | 266 // by calls.) |
269 FrameStateDescriptor* descriptor = | 267 FrameStateDescriptor* descriptor = |
270 code()->GetDeoptimizationEntry(deoptimization_id); | 268 code()->GetDeoptimizationEntry(deoptimization_id); |
271 for (int i = 0; i < descriptor->size(); i++) { | 269 for (int i = 0; i < descriptor->size(); i++) { |
272 InstructionOperand* op = instr->InputAt(first_state_value_offset + i); | 270 InstructionOperand* op = instr->InputAt(first_state_value_offset + i); |
273 CHECK(op->IsStackSlot() || op->IsImmediate()); | 271 CHECK(op->IsStackSlot() || op->IsImmediate()); |
274 } | 272 } |
275 #endif | 273 #endif |
276 BuildTranslation(instr, first_state_value_offset, deoptimization_id); | 274 BuildTranslation(instr, first_state_value_offset, deoptimization_id); |
277 safepoints()->RecordLazyDeoptimizationIndex(deoptimization_id); | 275 safepoints()->RecordLazyDeoptimizationIndex(deoptimization_id); |
278 } | 276 } |
| 277 |
| 278 if (flags & CallDescriptor::kNeedsNopAfterCall) { |
| 279 AddNopForSmiCodeInlining(); |
| 280 } |
279 } | 281 } |
280 | 282 |
281 | 283 |
282 void CodeGenerator::RecordLazyDeoptimizationEntry(Instruction* instr, | 284 void CodeGenerator::RecordLazyDeoptimizationEntry(Instruction* instr, |
283 Safepoint::Id safepoint_id) { | 285 Safepoint::Id safepoint_id) { |
284 InstructionOperandConverter i(this, instr); | 286 InstructionOperandConverter i(this, instr); |
285 | 287 |
286 Label after_call; | 288 Label after_call; |
287 masm()->bind(&after_call); | 289 masm()->bind(&after_call); |
288 | 290 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 411 } |
410 | 412 |
411 | 413 |
412 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 414 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
413 | 415 |
414 #endif // !V8_TURBOFAN_BACKEND | 416 #endif // !V8_TURBOFAN_BACKEND |
415 | 417 |
416 } // namespace compiler | 418 } // namespace compiler |
417 } // namespace internal | 419 } // namespace internal |
418 } // namespace v8 | 420 } // namespace v8 |
OLD | NEW |