| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "deoptimizer.h" | 33 #include "deoptimizer.h" |
| 34 #include "safepoint-table.h" | 34 #include "safepoint-table.h" |
| 35 #include "scopes.h" | 35 #include "scopes.h" |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 // Forward declarations. | 40 // Forward declarations. |
| 41 class LDeferredCode; | 41 class LDeferredCode; |
| 42 class LGapNode; |
| 42 class SafepointGenerator; | 43 class SafepointGenerator; |
| 43 | 44 |
| 45 class LGapResolver BASE_EMBEDDED { |
| 46 public: |
| 47 LGapResolver(); |
| 48 const ZoneList<LMoveOperands>* Resolve(const ZoneList<LMoveOperands>* moves, |
| 49 LOperand* marker_operand); |
| 50 |
| 51 private: |
| 52 LGapNode* LookupNode(LOperand* operand); |
| 53 bool CanReach(LGapNode* a, LGapNode* b, int visited_id); |
| 54 bool CanReach(LGapNode* a, LGapNode* b); |
| 55 void RegisterMove(LMoveOperands move); |
| 56 void AddResultMove(LOperand* from, LOperand* to); |
| 57 void AddResultMove(LGapNode* from, LGapNode* to); |
| 58 void ResolveCycle(LGapNode* start, LOperand* marker_operand); |
| 59 |
| 60 ZoneList<LGapNode*> nodes_; |
| 61 ZoneList<LGapNode*> identified_cycles_; |
| 62 ZoneList<LMoveOperands> result_; |
| 63 int next_visited_id_; |
| 64 }; |
| 65 |
| 44 | 66 |
| 45 class LCodeGen BASE_EMBEDDED { | 67 class LCodeGen BASE_EMBEDDED { |
| 46 public: | 68 public: |
| 47 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 69 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 48 : chunk_(chunk), | 70 : chunk_(chunk), |
| 49 masm_(assembler), | 71 masm_(assembler), |
| 50 info_(info), | 72 info_(info), |
| 51 current_block_(-1), | 73 current_block_(-1), |
| 52 current_instruction_(-1), | 74 current_instruction_(-1), |
| 53 instructions_(chunk->instructions()), | 75 instructions_(chunk->instructions()), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 // Try to generate code for the entire chunk, but it may fail if the | 86 // Try to generate code for the entire chunk, but it may fail if the |
| 65 // chunk contains constructs we cannot handle. Returns true if the | 87 // chunk contains constructs we cannot handle. Returns true if the |
| 66 // code generation attempt succeeded. | 88 // code generation attempt succeeded. |
| 67 bool GenerateCode(); | 89 bool GenerateCode(); |
| 68 | 90 |
| 69 // Finish the code by setting stack height, safepoint, and bailout | 91 // Finish the code by setting stack height, safepoint, and bailout |
| 70 // information on it. | 92 // information on it. |
| 71 void FinishCode(Handle<Code> code); | 93 void FinishCode(Handle<Code> code); |
| 72 | 94 |
| 73 // Deferred code support. | 95 // Deferred code support. |
| 96 template<int T> |
| 97 void DoDeferredGenericBinaryStub(LTemplateInstruction<1, 2, T>* instr, |
| 98 Token::Value op); |
| 74 void DoDeferredNumberTagD(LNumberTagD* instr); | 99 void DoDeferredNumberTagD(LNumberTagD* instr); |
| 75 void DoDeferredNumberTagI(LNumberTagI* instr); | 100 void DoDeferredNumberTagI(LNumberTagI* instr); |
| 76 void DoDeferredTaggedToI(LTaggedToI* instr); | 101 void DoDeferredTaggedToI(LTaggedToI* instr); |
| 77 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); | 102 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); |
| 78 void DoDeferredStackCheck(LGoto* instr); | 103 void DoDeferredStackCheck(LGoto* instr); |
| 104 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
| 105 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 106 Label* map_check); |
| 79 | 107 |
| 80 // Parallel move support. | 108 // Parallel move support. |
| 81 void DoParallelMove(LParallelMove* move); | 109 void DoParallelMove(LParallelMove* move); |
| 82 | 110 |
| 83 // Emit frame translation commands for an environment. | 111 // Emit frame translation commands for an environment. |
| 84 void WriteTranslation(LEnvironment* environment, Translation* translation); | 112 void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 85 | 113 |
| 86 // Declare methods that deal with the individual node types. | 114 // Declare methods that deal with the individual node types. |
| 87 #define DECLARE_DO(type) void Do##type(L##type* node); | 115 #define DECLARE_DO(type) void Do##type(L##type* node); |
| 88 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 116 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 100 bool is_generating() const { return status_ == GENERATING; } | 128 bool is_generating() const { return status_ == GENERATING; } |
| 101 bool is_done() const { return status_ == DONE; } | 129 bool is_done() const { return status_ == DONE; } |
| 102 bool is_aborted() const { return status_ == ABORTED; } | 130 bool is_aborted() const { return status_ == ABORTED; } |
| 103 | 131 |
| 104 LChunk* chunk() const { return chunk_; } | 132 LChunk* chunk() const { return chunk_; } |
| 105 Scope* scope() const { return scope_; } | 133 Scope* scope() const { return scope_; } |
| 106 HGraph* graph() const { return chunk_->graph(); } | 134 HGraph* graph() const { return chunk_->graph(); } |
| 107 MacroAssembler* masm() const { return masm_; } | 135 MacroAssembler* masm() const { return masm_; } |
| 108 | 136 |
| 109 Register scratch0() { return r9; } | 137 Register scratch0() { return r9; } |
| 110 SwVfpRegister single_scratch0() { return s0; } | 138 DwVfpRegister double_scratch0() { return d0; } |
| 111 SwVfpRegister single_scratch1() { return s1; } | |
| 112 DwVfpRegister double_scratch0() { return d1; } | |
| 113 | 139 |
| 114 int GetNextEmittedBlock(int block); | 140 int GetNextEmittedBlock(int block); |
| 115 LInstruction* GetNextInstruction(); | 141 LInstruction* GetNextInstruction(); |
| 116 | 142 |
| 117 void EmitClassOfTest(Label* if_true, | 143 void EmitClassOfTest(Label* if_true, |
| 118 Label* if_false, | 144 Label* if_false, |
| 119 Handle<String> class_name, | 145 Handle<String> class_name, |
| 120 Register input, | 146 Register input, |
| 121 Register temporary, | 147 Register temporary, |
| 122 Register temporary2); | 148 Register temporary2); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 148 const Runtime::Function* function = Runtime::FunctionForId(id); | 174 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 149 CallRuntime(function, num_arguments, instr); | 175 CallRuntime(function, num_arguments, instr); |
| 150 } | 176 } |
| 151 | 177 |
| 152 // Generate a direct call to a known function. Expects the function | 178 // Generate a direct call to a known function. Expects the function |
| 153 // to be in edi. | 179 // to be in edi. |
| 154 void CallKnownFunction(Handle<JSFunction> function, | 180 void CallKnownFunction(Handle<JSFunction> function, |
| 155 int arity, | 181 int arity, |
| 156 LInstruction* instr); | 182 LInstruction* instr); |
| 157 | 183 |
| 158 void LoadPrototype(Register result, Handle<JSObject> prototype); | 184 void LoadHeapObject(Register result, Handle<HeapObject> object); |
| 159 | 185 |
| 160 void RegisterLazyDeoptimization(LInstruction* instr); | 186 void RegisterLazyDeoptimization(LInstruction* instr); |
| 161 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); | 187 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
| 162 void DeoptimizeIf(Condition cc, LEnvironment* environment); | 188 void DeoptimizeIf(Condition cc, LEnvironment* environment); |
| 163 | 189 |
| 164 void AddToTranslation(Translation* translation, | 190 void AddToTranslation(Translation* translation, |
| 165 LOperand* op, | 191 LOperand* op, |
| 166 bool is_tagged); | 192 bool is_tagged); |
| 167 void PopulateDeoptimizationData(Handle<Code> code); | 193 void PopulateDeoptimizationData(Handle<Code> code); |
| 168 int DefineDeoptimizationLiteral(Handle<Object> literal); | 194 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 184 // LOperand is loaded into dbl_scratch, unless already a double register. | 210 // LOperand is loaded into dbl_scratch, unless already a double register. |
| 185 DoubleRegister EmitLoadDoubleRegister(LOperand* op, | 211 DoubleRegister EmitLoadDoubleRegister(LOperand* op, |
| 186 SwVfpRegister flt_scratch, | 212 SwVfpRegister flt_scratch, |
| 187 DoubleRegister dbl_scratch); | 213 DoubleRegister dbl_scratch); |
| 188 | 214 |
| 189 int ToInteger32(LConstantOperand* op) const; | 215 int ToInteger32(LConstantOperand* op) const; |
| 190 Operand ToOperand(LOperand* op); | 216 Operand ToOperand(LOperand* op); |
| 191 MemOperand ToMemOperand(LOperand* op) const; | 217 MemOperand ToMemOperand(LOperand* op) const; |
| 192 | 218 |
| 193 // Specific math operations - used from DoUnaryMathOperation. | 219 // Specific math operations - used from DoUnaryMathOperation. |
| 220 void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
| 194 void DoMathAbs(LUnaryMathOperation* instr); | 221 void DoMathAbs(LUnaryMathOperation* instr); |
| 195 void DoMathFloor(LUnaryMathOperation* instr); | 222 void DoMathFloor(LUnaryMathOperation* instr); |
| 196 void DoMathSqrt(LUnaryMathOperation* instr); | 223 void DoMathSqrt(LUnaryMathOperation* instr); |
| 197 | 224 |
| 198 // Support for recording safepoint and position information. | 225 // Support for recording safepoint and position information. |
| 199 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); | 226 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); |
| 200 void RecordSafepointWithRegisters(LPointerMap* pointers, | 227 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 201 int arguments, | 228 int arguments, |
| 202 int deoptimization_index); | 229 int deoptimization_index); |
| 230 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 231 int arguments, |
| 232 int deoptimization_index); |
| 203 void RecordPosition(int position); | 233 void RecordPosition(int position); |
| 204 | 234 |
| 205 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 235 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 206 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); | 236 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); |
| 207 void EmitBranch(int left_block, int right_block, Condition cc); | 237 void EmitBranch(int left_block, int right_block, Condition cc); |
| 208 void EmitCmpI(LOperand* left, LOperand* right); | 238 void EmitCmpI(LOperand* left, LOperand* right); |
| 209 void EmitNumberUntagD(Register input, | 239 void EmitNumberUntagD(Register input, |
| 210 DoubleRegister result, | 240 DoubleRegister result, |
| 211 LEnvironment* env); | 241 LEnvironment* env); |
| 212 | 242 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 private: | 306 private: |
| 277 LCodeGen* codegen_; | 307 LCodeGen* codegen_; |
| 278 Label entry_; | 308 Label entry_; |
| 279 Label exit_; | 309 Label exit_; |
| 280 Label* external_exit_; | 310 Label* external_exit_; |
| 281 }; | 311 }; |
| 282 | 312 |
| 283 } } // namespace v8::internal | 313 } } // namespace v8::internal |
| 284 | 314 |
| 285 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 315 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| OLD | NEW |