| 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 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 CodeGenerator::CodeGenerator(InstructionSequence* code) | 15 CodeGenerator::CodeGenerator(InstructionSequence* code) |
| 16 : code_(code), | 16 : code_(code), |
| 17 current_block_(NULL), | 17 current_block_(NULL), |
| 18 current_source_position_(SourcePosition::Invalid()), | 18 current_source_position_(SourcePosition::Invalid()), |
| 19 masm_(code->zone()->isolate(), NULL, 0), | 19 masm_(code->zone()->isolate(), NULL, 0), |
| 20 resolver_(this), | 20 resolver_(this), |
| 21 safepoints_(code->zone()), | 21 safepoints_(code->zone()), |
| 22 deoptimization_states_(code->zone()), | 22 deoptimization_states_(code->zone()), |
| 23 deoptimization_literals_(code->zone()), | 23 deoptimization_literals_(code->zone()), |
| 24 translations_(code->zone()) {} | 24 translations_(code->zone()), |
| 25 last_lazy_deopt_pc_(0) {} |
| 25 | 26 |
| 26 | 27 |
| 27 Handle<Code> CodeGenerator::GenerateCode() { | 28 Handle<Code> CodeGenerator::GenerateCode() { |
| 28 CompilationInfo* info = linkage()->info(); | 29 CompilationInfo* info = linkage()->info(); |
| 29 | 30 |
| 30 // Emit a code line info recording start event. | 31 // Emit a code line info recording start event. |
| 31 PositionsRecorder* recorder = masm()->positions_recorder(); | 32 PositionsRecorder* recorder = masm()->positions_recorder(); |
| 32 LOG_CODE_EVENT(isolate(), CodeStartLinePosInfoRecordEvent(recorder)); | 33 LOG_CODE_EVENT(isolate(), CodeStartLinePosInfoRecordEvent(recorder)); |
| 33 | 34 |
| 34 // Place function entry hook if requested to do so. | 35 // Place function entry hook if requested to do so. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 236 |
| 236 RecordSafepoint( | 237 RecordSafepoint( |
| 237 instr->pointer_map(), Safepoint::kSimple, 0, | 238 instr->pointer_map(), Safepoint::kSimple, 0, |
| 238 needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); | 239 needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); |
| 239 | 240 |
| 240 if (flags & CallDescriptor::kNeedsNopAfterCall) { | 241 if (flags & CallDescriptor::kNeedsNopAfterCall) { |
| 241 AddNopForSmiCodeInlining(); | 242 AddNopForSmiCodeInlining(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 if (needs_frame_state) { | 245 if (needs_frame_state) { |
| 246 MarkLazyDeoptSite(); |
| 245 // If the frame state is present, it starts at argument 1 | 247 // If the frame state is present, it starts at argument 1 |
| 246 // (just after the code address). | 248 // (just after the code address). |
| 247 InstructionOperandConverter converter(this, instr); | 249 InstructionOperandConverter converter(this, instr); |
| 248 // Deoptimization info starts at argument 1 | 250 // Deoptimization info starts at argument 1 |
| 249 size_t frame_state_offset = 1; | 251 size_t frame_state_offset = 1; |
| 250 FrameStateDescriptor* descriptor = | 252 FrameStateDescriptor* descriptor = |
| 251 GetFrameStateDescriptor(instr, frame_state_offset); | 253 GetFrameStateDescriptor(instr, frame_state_offset); |
| 252 int pc_offset = masm()->pc_offset(); | 254 int pc_offset = masm()->pc_offset(); |
| 253 int deopt_state_id = BuildTranslation(instr, pc_offset, frame_state_offset, | 255 int deopt_state_id = BuildTranslation(instr, pc_offset, frame_state_offset, |
| 254 descriptor->state_combine()); | 256 descriptor->state_combine()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } else if (op->IsImmediate()) { | 382 } else if (op->IsImmediate()) { |
| 381 InstructionOperandConverter converter(this, instr); | 383 InstructionOperandConverter converter(this, instr); |
| 382 Constant constant = converter.ToConstant(op); | 384 Constant constant = converter.ToConstant(op); |
| 383 Handle<Object> constant_object; | 385 Handle<Object> constant_object; |
| 384 switch (constant.type()) { | 386 switch (constant.type()) { |
| 385 case Constant::kInt32: | 387 case Constant::kInt32: |
| 386 constant_object = | 388 constant_object = |
| 387 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); | 389 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
| 388 break; | 390 break; |
| 389 case Constant::kFloat64: | 391 case Constant::kFloat64: |
| 390 constant_object = | 392 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); |
| 391 isolate()->factory()->NewHeapNumber(constant.ToFloat64()); | |
| 392 break; | 393 break; |
| 393 case Constant::kHeapObject: | 394 case Constant::kHeapObject: |
| 394 constant_object = constant.ToHeapObject(); | 395 constant_object = constant.ToHeapObject(); |
| 395 break; | 396 break; |
| 396 default: | 397 default: |
| 397 UNREACHABLE(); | 398 UNREACHABLE(); |
| 398 } | 399 } |
| 399 int literal_id = DefineDeoptimizationLiteral(constant_object); | 400 int literal_id = DefineDeoptimizationLiteral(constant_object); |
| 400 translation->StoreLiteral(literal_id); | 401 translation->StoreLiteral(literal_id); |
| 401 } else { | 402 } else { |
| 402 UNREACHABLE(); | 403 UNREACHABLE(); |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 | 406 |
| 407 |
| 408 void CodeGenerator::MarkLazyDeoptSite() { |
| 409 last_lazy_deopt_pc_ = masm()->pc_offset(); |
| 410 } |
| 411 |
| 406 #if !V8_TURBOFAN_BACKEND | 412 #if !V8_TURBOFAN_BACKEND |
| 407 | 413 |
| 408 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 414 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| 409 UNIMPLEMENTED(); | 415 UNIMPLEMENTED(); |
| 410 } | 416 } |
| 411 | 417 |
| 412 | 418 |
| 413 void CodeGenerator::AssembleArchBranch(Instruction* instr, | 419 void CodeGenerator::AssembleArchBranch(Instruction* instr, |
| 414 FlagsCondition condition) { | 420 FlagsCondition condition) { |
| 415 UNIMPLEMENTED(); | 421 UNIMPLEMENTED(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 445 } | 451 } |
| 446 | 452 |
| 447 | 453 |
| 448 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 454 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
| 449 | 455 |
| 450 #endif // !V8_TURBOFAN_BACKEND | 456 #endif // !V8_TURBOFAN_BACKEND |
| 451 | 457 |
| 452 } // namespace compiler | 458 } // namespace compiler |
| 453 } // namespace internal | 459 } // namespace internal |
| 454 } // namespace v8 | 460 } // namespace v8 |
| OLD | NEW |