| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 current_block_(-1), | 53 current_block_(-1), |
| 54 current_instruction_(-1), | 54 current_instruction_(-1), |
| 55 instructions_(chunk->instructions()), | 55 instructions_(chunk->instructions()), |
| 56 deoptimizations_(4), | 56 deoptimizations_(4), |
| 57 deoptimization_literals_(8), | 57 deoptimization_literals_(8), |
| 58 inlined_function_count_(0), | 58 inlined_function_count_(0), |
| 59 scope_(chunk->graph()->info()->scope()), | 59 scope_(chunk->graph()->info()->scope()), |
| 60 status_(UNUSED), | 60 status_(UNUSED), |
| 61 deferred_(8), | 61 deferred_(8), |
| 62 osr_pc_offset_(-1), | 62 osr_pc_offset_(-1), |
| 63 deoptimization_reloc_size(), |
| 63 resolver_(this) { | 64 resolver_(this) { |
| 64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 65 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Simple accessors. | 68 // Simple accessors. |
| 68 MacroAssembler* masm() const { return masm_; } | 69 MacroAssembler* masm() const { return masm_; } |
| 69 | 70 |
| 70 // Support for converting LOperands to assembler types. | 71 // Support for converting LOperands to assembler types. |
| 71 Operand ToOperand(LOperand* op) const; | 72 Operand ToOperand(LOperand* op) const; |
| 72 Register ToRegister(LOperand* op) const; | 73 Register ToRegister(LOperand* op) const; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 95 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); | 96 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
| 96 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | 97 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 97 Label* map_check); | 98 Label* map_check); |
| 98 | 99 |
| 99 // Parallel move support. | 100 // Parallel move support. |
| 100 void DoParallelMove(LParallelMove* move); | 101 void DoParallelMove(LParallelMove* move); |
| 101 | 102 |
| 102 // Emit frame translation commands for an environment. | 103 // Emit frame translation commands for an environment. |
| 103 void WriteTranslation(LEnvironment* environment, Translation* translation); | 104 void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 104 | 105 |
| 106 void EnsureRelocSpaceForDeoptimization(); |
| 107 |
| 105 // Declare methods that deal with the individual node types. | 108 // Declare methods that deal with the individual node types. |
| 106 #define DECLARE_DO(type) void Do##type(L##type* node); | 109 #define DECLARE_DO(type) void Do##type(L##type* node); |
| 107 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 110 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 108 #undef DECLARE_DO | 111 #undef DECLARE_DO |
| 109 | 112 |
| 110 private: | 113 private: |
| 111 enum Status { | 114 enum Status { |
| 112 UNUSED, | 115 UNUSED, |
| 113 GENERATING, | 116 GENERATING, |
| 114 DONE, | 117 DONE, |
| 115 ABORTED | 118 ABORTED |
| 116 }; | 119 }; |
| 117 | 120 |
| 118 bool is_unused() const { return status_ == UNUSED; } | 121 bool is_unused() const { return status_ == UNUSED; } |
| 119 bool is_generating() const { return status_ == GENERATING; } | 122 bool is_generating() const { return status_ == GENERATING; } |
| 120 bool is_done() const { return status_ == DONE; } | 123 bool is_done() const { return status_ == DONE; } |
| 121 bool is_aborted() const { return status_ == ABORTED; } | 124 bool is_aborted() const { return status_ == ABORTED; } |
| 122 | 125 |
| 126 int strict_mode_flag() const { |
| 127 return info_->is_strict() ? kStrictMode : kNonStrictMode; |
| 128 } |
| 129 |
| 123 LChunk* chunk() const { return chunk_; } | 130 LChunk* chunk() const { return chunk_; } |
| 124 Scope* scope() const { return scope_; } | 131 Scope* scope() const { return scope_; } |
| 125 HGraph* graph() const { return chunk_->graph(); } | 132 HGraph* graph() const { return chunk_->graph(); } |
| 126 | 133 |
| 127 int GetNextEmittedBlock(int block); | 134 int GetNextEmittedBlock(int block); |
| 128 LInstruction* GetNextInstruction(); | 135 LInstruction* GetNextInstruction(); |
| 129 | 136 |
| 130 void EmitClassOfTest(Label* if_true, | 137 void EmitClassOfTest(Label* if_true, |
| 131 Label* if_false, | 138 Label* if_false, |
| 132 Handle<String> class_name, | 139 Handle<String> class_name, |
| 133 Register input, | 140 Register input, |
| 134 Register temporary, | 141 Register temporary, |
| 135 Register temporary2); | 142 Register temporary2); |
| 136 | 143 |
| 137 int StackSlotCount() const { return chunk()->spill_slot_count(); } | 144 int StackSlotCount() const { return chunk()->spill_slot_count(); } |
| 138 int ParameterCount() const { return scope()->num_parameters(); } | 145 int ParameterCount() const { return scope()->num_parameters(); } |
| 139 | 146 |
| 140 void Abort(const char* format, ...); | 147 void Abort(const char* format, ...); |
| 141 void Comment(const char* format, ...); | 148 void Comment(const char* format, ...); |
| 142 | 149 |
| 143 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } | 150 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } |
| 144 | 151 |
| 145 // Code generation passes. Returns true if code generation should | 152 // Code generation passes. Returns true if code generation should |
| 146 // continue. | 153 // continue. |
| 147 bool GeneratePrologue(); | 154 bool GeneratePrologue(); |
| 148 bool GenerateBody(); | 155 bool GenerateBody(); |
| 149 bool GenerateDeferredCode(); | 156 bool GenerateDeferredCode(); |
| 157 // Pad the reloc info to ensure that we have enough space to patch during |
| 158 // deoptimization. |
| 159 bool GenerateRelocPadding(); |
| 150 bool GenerateSafepointTable(); | 160 bool GenerateSafepointTable(); |
| 151 | 161 |
| 152 void CallCode(Handle<Code> code, | 162 void CallCode(Handle<Code> code, RelocInfo::Mode mode, LInstruction* instr, |
| 153 RelocInfo::Mode mode, | 163 bool adjusted = true); |
| 154 LInstruction* instr); | 164 void CallRuntime(const Runtime::Function* fun, int argc, LInstruction* instr, |
| 155 void CallRuntime(const Runtime::Function* function, | 165 bool adjusted = true); |
| 156 int num_arguments, | 166 void CallRuntime(Runtime::FunctionId id, int argc, LInstruction* instr, |
| 157 LInstruction* instr); | 167 bool adjusted = true) { |
| 158 void CallRuntime(Runtime::FunctionId id, | |
| 159 int num_arguments, | |
| 160 LInstruction* instr) { | |
| 161 const Runtime::Function* function = Runtime::FunctionForId(id); | 168 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 162 CallRuntime(function, num_arguments, instr); | 169 CallRuntime(function, argc, instr, adjusted); |
| 163 } | 170 } |
| 164 | 171 |
| 165 // Generate a direct call to a known function. Expects the function | 172 // Generate a direct call to a known function. Expects the function |
| 166 // to be in edi. | 173 // to be in edi. |
| 167 void CallKnownFunction(Handle<JSFunction> function, | 174 void CallKnownFunction(Handle<JSFunction> function, |
| 168 int arity, | 175 int arity, |
| 169 LInstruction* instr); | 176 LInstruction* instr); |
| 170 | 177 |
| 171 void LoadHeapObject(Register result, Handle<HeapObject> object); | 178 void LoadHeapObject(Register result, Handle<HeapObject> object); |
| 172 | 179 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 196 void DoMathLog(LUnaryMathOperation* instr); | 203 void DoMathLog(LUnaryMathOperation* instr); |
| 197 void DoMathCos(LUnaryMathOperation* instr); | 204 void DoMathCos(LUnaryMathOperation* instr); |
| 198 void DoMathSin(LUnaryMathOperation* instr); | 205 void DoMathSin(LUnaryMathOperation* instr); |
| 199 | 206 |
| 200 // Support for recording safepoint and position information. | 207 // Support for recording safepoint and position information. |
| 201 void RecordSafepoint(LPointerMap* pointers, | 208 void RecordSafepoint(LPointerMap* pointers, |
| 202 Safepoint::Kind kind, | 209 Safepoint::Kind kind, |
| 203 int arguments, | 210 int arguments, |
| 204 int deoptimization_index); | 211 int deoptimization_index); |
| 205 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); | 212 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); |
| 213 void RecordSafepoint(int deoptimization_index); |
| 206 void RecordSafepointWithRegisters(LPointerMap* pointers, | 214 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 207 int arguments, | 215 int arguments, |
| 208 int deoptimization_index); | 216 int deoptimization_index); |
| 209 void RecordPosition(int position); | 217 void RecordPosition(int position); |
| 210 | 218 |
| 211 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 219 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 212 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); | 220 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); |
| 213 void EmitBranch(int left_block, int right_block, Condition cc); | 221 void EmitBranch(int left_block, int right_block, Condition cc); |
| 214 void EmitCmpI(LOperand* left, LOperand* right); | 222 void EmitCmpI(LOperand* left, LOperand* right); |
| 215 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env); | 223 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 243 const ZoneList<LInstruction*>* instructions_; | 251 const ZoneList<LInstruction*>* instructions_; |
| 244 ZoneList<LEnvironment*> deoptimizations_; | 252 ZoneList<LEnvironment*> deoptimizations_; |
| 245 ZoneList<Handle<Object> > deoptimization_literals_; | 253 ZoneList<Handle<Object> > deoptimization_literals_; |
| 246 int inlined_function_count_; | 254 int inlined_function_count_; |
| 247 Scope* const scope_; | 255 Scope* const scope_; |
| 248 Status status_; | 256 Status status_; |
| 249 TranslationBuffer translations_; | 257 TranslationBuffer translations_; |
| 250 ZoneList<LDeferredCode*> deferred_; | 258 ZoneList<LDeferredCode*> deferred_; |
| 251 int osr_pc_offset_; | 259 int osr_pc_offset_; |
| 252 | 260 |
| 261 struct DeoptimizationRelocSize { |
| 262 int min_size; |
| 263 int last_pc_offset; |
| 264 }; |
| 265 |
| 266 DeoptimizationRelocSize deoptimization_reloc_size; |
| 267 |
| 253 // Builder that keeps track of safepoints in the code. The table | 268 // Builder that keeps track of safepoints in the code. The table |
| 254 // itself is emitted at the end of the generated code. | 269 // itself is emitted at the end of the generated code. |
| 255 SafepointTableBuilder safepoints_; | 270 SafepointTableBuilder safepoints_; |
| 256 | 271 |
| 257 // Compiler from a set of parallel moves to a sequential list of moves. | 272 // Compiler from a set of parallel moves to a sequential list of moves. |
| 258 LGapResolver resolver_; | 273 LGapResolver resolver_; |
| 259 | 274 |
| 260 friend class LDeferredCode; | 275 friend class LDeferredCode; |
| 261 friend class LEnvironment; | 276 friend class LEnvironment; |
| 262 friend class SafepointGenerator; | 277 friend class SafepointGenerator; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 285 private: | 300 private: |
| 286 LCodeGen* codegen_; | 301 LCodeGen* codegen_; |
| 287 Label entry_; | 302 Label entry_; |
| 288 Label exit_; | 303 Label exit_; |
| 289 Label* external_exit_; | 304 Label* external_exit_; |
| 290 }; | 305 }; |
| 291 | 306 |
| 292 } } // namespace v8::internal | 307 } } // namespace v8::internal |
| 293 | 308 |
| 294 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 309 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
| OLD | NEW |