| 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 19 matching lines...) Expand all  Loading... | 
|   30 }; |   30 }; | 
|   31  |   31  | 
|   32  |   32  | 
|   33 CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage, |   33 CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage, | 
|   34                              InstructionSequence* code, CompilationInfo* info) |   34                              InstructionSequence* code, CompilationInfo* info) | 
|   35     : frame_(frame), |   35     : frame_(frame), | 
|   36       linkage_(linkage), |   36       linkage_(linkage), | 
|   37       code_(code), |   37       code_(code), | 
|   38       info_(info), |   38       info_(info), | 
|   39       labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), |   39       labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), | 
|   40       current_block_(BasicBlock::RpoNumber::Invalid()), |   40       current_block_(RpoNumber::Invalid()), | 
|   41       current_source_position_(SourcePosition::Invalid()), |   41       current_source_position_(SourcePosition::Invalid()), | 
|   42       masm_(info->isolate(), NULL, 0), |   42       masm_(info->isolate(), NULL, 0), | 
|   43       resolver_(this), |   43       resolver_(this), | 
|   44       safepoints_(code->zone()), |   44       safepoints_(code->zone()), | 
|   45       handlers_(code->zone()), |   45       handlers_(code->zone()), | 
|   46       deoptimization_states_(code->zone()), |   46       deoptimization_states_(code->zone()), | 
|   47       deoptimization_literals_(code->zone()), |   47       deoptimization_literals_(code->zone()), | 
|   48       translations_(code->zone()), |   48       translations_(code->zone()), | 
|   49       last_lazy_deopt_pc_(0), |   49       last_lazy_deopt_pc_(0), | 
|   50       jump_tables_(nullptr), |   50       jump_tables_(nullptr), | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|   78       if (block->IsDeferred() == (deferred == 0)) { |   78       if (block->IsDeferred() == (deferred == 0)) { | 
|   79         continue; |   79         continue; | 
|   80       } |   80       } | 
|   81       // Align loop headers on 16-byte boundaries. |   81       // Align loop headers on 16-byte boundaries. | 
|   82       if (block->IsLoopHeader()) masm()->Align(16); |   82       if (block->IsLoopHeader()) masm()->Align(16); | 
|   83       // Bind a label for a block. |   83       // Bind a label for a block. | 
|   84       current_block_ = block->rpo_number(); |   84       current_block_ = block->rpo_number(); | 
|   85       if (FLAG_code_comments) { |   85       if (FLAG_code_comments) { | 
|   86         // TODO(titzer): these code comments are a giant memory leak. |   86         // TODO(titzer): these code comments are a giant memory leak. | 
|   87         Vector<char> buffer = Vector<char>::New(32); |   87         Vector<char> buffer = Vector<char>::New(32); | 
|   88         SNPrintF(buffer, "-- B%d start --", block->id().ToInt()); |   88         SNPrintF(buffer, "-- B%d start --", block->rpo_number().ToInt()); | 
|   89         masm()->RecordComment(buffer.start()); |   89         masm()->RecordComment(buffer.start()); | 
|   90       } |   90       } | 
|   91       masm()->bind(GetLabel(current_block_)); |   91       masm()->bind(GetLabel(current_block_)); | 
|   92       for (int i = block->code_start(); i < block->code_end(); ++i) { |   92       for (int i = block->code_start(); i < block->code_end(); ++i) { | 
|   93         AssembleInstruction(code()->InstructionAt(i)); |   93         AssembleInstruction(code()->InstructionAt(i)); | 
|   94       } |   94       } | 
|   95     } |   95     } | 
|   96   } |   96   } | 
|   97  |   97  | 
|   98   // Assemble all out-of-line code. |   98   // Assemble all out-of-line code. | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  152   } |  152   } | 
|  153  |  153  | 
|  154   // Emit a code line info recording stop event. |  154   // Emit a code line info recording stop event. | 
|  155   void* line_info = recorder->DetachJITHandlerData(); |  155   void* line_info = recorder->DetachJITHandlerData(); | 
|  156   LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(*result, line_info)); |  156   LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(*result, line_info)); | 
|  157  |  157  | 
|  158   return result; |  158   return result; | 
|  159 } |  159 } | 
|  160  |  160  | 
|  161  |  161  | 
|  162 bool CodeGenerator::IsNextInAssemblyOrder(BasicBlock::RpoNumber block) const { |  162 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const { | 
|  163   return code()->InstructionBlockAt(current_block_)->ao_number().IsNext( |  163   return code()->InstructionBlockAt(current_block_)->ao_number().IsNext( | 
|  164       code()->InstructionBlockAt(block)->ao_number()); |  164       code()->InstructionBlockAt(block)->ao_number()); | 
|  165 } |  165 } | 
|  166  |  166  | 
|  167  |  167  | 
|  168 void CodeGenerator::RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind, |  168 void CodeGenerator::RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind, | 
|  169                                     int arguments, |  169                                     int arguments, | 
|  170                                     Safepoint::DeoptMode deopt_mode) { |  170                                     Safepoint::DeoptMode deopt_mode) { | 
|  171   const ZoneList<InstructionOperand*>* operands = |  171   const ZoneList<InstructionOperand*>* operands = | 
|  172       pointers->GetNormalizedOperands(); |  172       pointers->GetNormalizedOperands(); | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|  192     AssembleSourcePosition(SourcePositionInstruction::cast(instr)); |  192     AssembleSourcePosition(SourcePositionInstruction::cast(instr)); | 
|  193   } else { |  193   } else { | 
|  194     // Assemble architecture-specific code for the instruction. |  194     // Assemble architecture-specific code for the instruction. | 
|  195     AssembleArchInstruction(instr); |  195     AssembleArchInstruction(instr); | 
|  196  |  196  | 
|  197     FlagsMode mode = FlagsModeField::decode(instr->opcode()); |  197     FlagsMode mode = FlagsModeField::decode(instr->opcode()); | 
|  198     FlagsCondition condition = FlagsConditionField::decode(instr->opcode()); |  198     FlagsCondition condition = FlagsConditionField::decode(instr->opcode()); | 
|  199     if (mode == kFlags_branch) { |  199     if (mode == kFlags_branch) { | 
|  200       // Assemble a branch after this instruction. |  200       // Assemble a branch after this instruction. | 
|  201       InstructionOperandConverter i(this, instr); |  201       InstructionOperandConverter i(this, instr); | 
|  202       BasicBlock::RpoNumber true_rpo = i.InputRpo(instr->InputCount() - 2); |  202       RpoNumber true_rpo = i.InputRpo(instr->InputCount() - 2); | 
|  203       BasicBlock::RpoNumber false_rpo = i.InputRpo(instr->InputCount() - 1); |  203       RpoNumber false_rpo = i.InputRpo(instr->InputCount() - 1); | 
|  204  |  204  | 
|  205       if (true_rpo == false_rpo) { |  205       if (true_rpo == false_rpo) { | 
|  206         // redundant branch. |  206         // redundant branch. | 
|  207         if (!IsNextInAssemblyOrder(true_rpo)) { |  207         if (!IsNextInAssemblyOrder(true_rpo)) { | 
|  208           AssembleArchJump(true_rpo); |  208           AssembleArchJump(true_rpo); | 
|  209         } |  209         } | 
|  210         return; |  210         return; | 
|  211       } |  211       } | 
|  212       if (IsNextInAssemblyOrder(true_rpo)) { |  212       if (IsNextInAssemblyOrder(true_rpo)) { | 
|  213         // true block is next, can fall through if condition negated. |  213         // true block is next, can fall through if condition negated. | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  336   CallDescriptor::Flags flags(MiscField::decode(instr->opcode())); |  336   CallDescriptor::Flags flags(MiscField::decode(instr->opcode())); | 
|  337  |  337  | 
|  338   bool needs_frame_state = (flags & CallDescriptor::kNeedsFrameState); |  338   bool needs_frame_state = (flags & CallDescriptor::kNeedsFrameState); | 
|  339  |  339  | 
|  340   RecordSafepoint( |  340   RecordSafepoint( | 
|  341       instr->pointer_map(), Safepoint::kSimple, 0, |  341       instr->pointer_map(), Safepoint::kSimple, 0, | 
|  342       needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); |  342       needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); | 
|  343  |  343  | 
|  344   if (flags & CallDescriptor::kHasExceptionHandler) { |  344   if (flags & CallDescriptor::kHasExceptionHandler) { | 
|  345     InstructionOperandConverter i(this, instr); |  345     InstructionOperandConverter i(this, instr); | 
|  346     BasicBlock::RpoNumber handler_rpo = |  346     RpoNumber handler_rpo = | 
|  347         i.InputRpo(static_cast<int>(instr->InputCount()) - 1); |  347         i.InputRpo(static_cast<int>(instr->InputCount()) - 1); | 
|  348     handlers_.push_back({GetLabel(handler_rpo), masm()->pc_offset()}); |  348     handlers_.push_back({GetLabel(handler_rpo), masm()->pc_offset()}); | 
|  349   } |  349   } | 
|  350  |  350  | 
|  351   if (flags & CallDescriptor::kNeedsNopAfterCall) { |  351   if (flags & CallDescriptor::kNeedsNopAfterCall) { | 
|  352     AddNopForSmiCodeInlining(); |  352     AddNopForSmiCodeInlining(); | 
|  353   } |  353   } | 
|  354  |  354  | 
|  355   if (needs_frame_state) { |  355   if (needs_frame_state) { | 
|  356     MarkLazyDeoptSite(); |  356     MarkLazyDeoptSite(); | 
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  585   UNIMPLEMENTED(); |  585   UNIMPLEMENTED(); | 
|  586 } |  586 } | 
|  587  |  587  | 
|  588  |  588  | 
|  589 void CodeGenerator::AssembleArchBoolean(Instruction* instr, |  589 void CodeGenerator::AssembleArchBoolean(Instruction* instr, | 
|  590                                         FlagsCondition condition) { |  590                                         FlagsCondition condition) { | 
|  591   UNIMPLEMENTED(); |  591   UNIMPLEMENTED(); | 
|  592 } |  592 } | 
|  593  |  593  | 
|  594  |  594  | 
|  595 void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { |  595 void CodeGenerator::AssembleArchJump(RpoNumber target) { UNIMPLEMENTED(); } | 
|  596   UNIMPLEMENTED(); |  | 
|  597 } |  | 
|  598  |  596  | 
|  599  |  597  | 
|  600 void CodeGenerator::AssembleDeoptimizerCall(int deoptimization_id) { |  598 void CodeGenerator::AssembleDeoptimizerCall(int deoptimization_id) { | 
|  601   UNIMPLEMENTED(); |  599   UNIMPLEMENTED(); | 
|  602 } |  600 } | 
|  603  |  601  | 
|  604  |  602  | 
|  605 void CodeGenerator::AssemblePrologue() { UNIMPLEMENTED(); } |  603 void CodeGenerator::AssemblePrologue() { UNIMPLEMENTED(); } | 
|  606  |  604  | 
|  607  |  605  | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|  634     : masm_(gen->masm()), next_(gen->ools_) { |  632     : masm_(gen->masm()), next_(gen->ools_) { | 
|  635   gen->ools_ = this; |  633   gen->ools_ = this; | 
|  636 } |  634 } | 
|  637  |  635  | 
|  638  |  636  | 
|  639 OutOfLineCode::~OutOfLineCode() {} |  637 OutOfLineCode::~OutOfLineCode() {} | 
|  640  |  638  | 
|  641 }  // namespace compiler |  639 }  // namespace compiler | 
|  642 }  // namespace internal |  640 }  // namespace internal | 
|  643 }  // namespace v8 |  641 }  // namespace v8 | 
| OLD | NEW |