| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ | 28 #ifndef V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ |
| 29 #define V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ | 29 #define V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ |
| 30 | 30 |
| 31 #include "deoptimizer.h" | 31 #include "deoptimizer.h" |
| 32 #include "mips/lithium-gap-resolver-mips.h" | 32 #include "mips/lithium-gap-resolver-mips.h" |
| 33 #include "mips/lithium-mips.h" | 33 #include "mips/lithium-mips.h" |
| 34 #include "lithium-codegen.h" |
| 34 #include "safepoint-table.h" | 35 #include "safepoint-table.h" |
| 35 #include "scopes.h" | 36 #include "scopes.h" |
| 36 #include "v8utils.h" | 37 #include "v8utils.h" |
| 37 | 38 |
| 38 namespace v8 { | 39 namespace v8 { |
| 39 namespace internal { | 40 namespace internal { |
| 40 | 41 |
| 41 // Forward declarations. | 42 // Forward declarations. |
| 42 class LDeferredCode; | 43 class LDeferredCode; |
| 43 class SafepointGenerator; | 44 class SafepointGenerator; |
| 44 | 45 |
| 45 class LCodeGen V8_FINAL BASE_EMBEDDED { | 46 class LCodeGen: public LCodeGenBase { |
| 46 public: | 47 public: |
| 47 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 48 : zone_(info->zone()), | 49 : LCodeGenBase(chunk, assembler, info), |
| 49 chunk_(static_cast<LPlatformChunk*>(chunk)), | |
| 50 masm_(assembler), | |
| 51 info_(info), | |
| 52 current_block_(-1), | |
| 53 current_instruction_(-1), | |
| 54 instructions_(chunk->instructions()), | |
| 55 deoptimizations_(4, info->zone()), | 50 deoptimizations_(4, info->zone()), |
| 56 deopt_jump_table_(4, info->zone()), | 51 deopt_jump_table_(4, info->zone()), |
| 57 deoptimization_literals_(8, info->zone()), | 52 deoptimization_literals_(8, info->zone()), |
| 58 inlined_function_count_(0), | 53 inlined_function_count_(0), |
| 59 scope_(info->scope()), | 54 scope_(info->scope()), |
| 60 status_(UNUSED), | |
| 61 translations_(info->zone()), | 55 translations_(info->zone()), |
| 62 deferred_(8, info->zone()), | 56 deferred_(8, info->zone()), |
| 63 osr_pc_offset_(-1), | 57 osr_pc_offset_(-1), |
| 64 last_lazy_deopt_pc_(0), | |
| 65 frame_is_built_(false), | 58 frame_is_built_(false), |
| 66 safepoints_(info->zone()), | 59 safepoints_(info->zone()), |
| 67 resolver_(this), | 60 resolver_(this), |
| 68 expected_safepoint_kind_(Safepoint::kSimple), | 61 expected_safepoint_kind_(Safepoint::kSimple), |
| 69 old_position_(RelocInfo::kNoPosition) { | 62 old_position_(RelocInfo::kNoPosition) { |
| 70 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 63 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 71 } | 64 } |
| 72 | 65 |
| 73 | 66 |
| 74 // Simple accessors. | |
| 75 MacroAssembler* masm() const { return masm_; } | |
| 76 CompilationInfo* info() const { return info_; } | |
| 77 Isolate* isolate() const { return info_->isolate(); } | |
| 78 Factory* factory() const { return isolate()->factory(); } | |
| 79 Heap* heap() const { return isolate()->heap(); } | |
| 80 Zone* zone() const { return zone_; } | |
| 81 | |
| 82 int LookupDestination(int block_id) const { | 67 int LookupDestination(int block_id) const { |
| 83 return chunk()->LookupDestination(block_id); | 68 return chunk()->LookupDestination(block_id); |
| 84 } | 69 } |
| 85 | 70 |
| 86 bool IsNextEmittedBlock(int block_id) const { | 71 bool IsNextEmittedBlock(int block_id) const { |
| 87 return LookupDestination(block_id) == GetNextEmittedBlock(); | 72 return LookupDestination(block_id) == GetNextEmittedBlock(); |
| 88 } | 73 } |
| 89 | 74 |
| 90 bool NeedsEagerFrame() const { | 75 bool NeedsEagerFrame() const { |
| 91 return GetStackSlotCount() > 0 || | 76 return GetStackSlotCount() > 0 || |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 155 |
| 171 // Emit frame translation commands for an environment. | 156 // Emit frame translation commands for an environment. |
| 172 void WriteTranslation(LEnvironment* environment, Translation* translation); | 157 void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 173 | 158 |
| 174 // Declare methods that deal with the individual node types. | 159 // Declare methods that deal with the individual node types. |
| 175 #define DECLARE_DO(type) void Do##type(L##type* node); | 160 #define DECLARE_DO(type) void Do##type(L##type* node); |
| 176 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 161 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 177 #undef DECLARE_DO | 162 #undef DECLARE_DO |
| 178 | 163 |
| 179 private: | 164 private: |
| 180 enum Status { | |
| 181 UNUSED, | |
| 182 GENERATING, | |
| 183 DONE, | |
| 184 ABORTED | |
| 185 }; | |
| 186 | |
| 187 bool is_unused() const { return status_ == UNUSED; } | |
| 188 bool is_generating() const { return status_ == GENERATING; } | |
| 189 bool is_done() const { return status_ == DONE; } | |
| 190 bool is_aborted() const { return status_ == ABORTED; } | |
| 191 | |
| 192 StrictModeFlag strict_mode_flag() const { | 165 StrictModeFlag strict_mode_flag() const { |
| 193 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; | 166 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; |
| 194 } | 167 } |
| 195 | 168 |
| 196 LPlatformChunk* chunk() const { return chunk_; } | |
| 197 Scope* scope() const { return scope_; } | 169 Scope* scope() const { return scope_; } |
| 198 HGraph* graph() const { return chunk()->graph(); } | |
| 199 | 170 |
| 200 Register scratch0() { return kLithiumScratchReg; } | 171 Register scratch0() { return kLithiumScratchReg; } |
| 201 Register scratch1() { return kLithiumScratchReg2; } | 172 Register scratch1() { return kLithiumScratchReg2; } |
| 202 DoubleRegister double_scratch0() { return kLithiumScratchDouble; } | 173 DoubleRegister double_scratch0() { return kLithiumScratchDouble; } |
| 203 | 174 |
| 204 int GetNextEmittedBlock() const; | |
| 205 LInstruction* GetNextInstruction(); | 175 LInstruction* GetNextInstruction(); |
| 206 | 176 |
| 207 void EmitClassOfTest(Label* if_true, | 177 void EmitClassOfTest(Label* if_true, |
| 208 Label* if_false, | 178 Label* if_false, |
| 209 Handle<String> class_name, | 179 Handle<String> class_name, |
| 210 Register input, | 180 Register input, |
| 211 Register temporary, | 181 Register temporary, |
| 212 Register temporary2); | 182 Register temporary2); |
| 213 | 183 |
| 214 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } | 184 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } |
| 215 | 185 |
| 216 void Abort(BailoutReason reason); | 186 void Abort(BailoutReason reason); |
| 217 void FPRINTF_CHECKING Comment(const char* format, ...); | |
| 218 | 187 |
| 219 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } | 188 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } |
| 220 | 189 |
| 221 // Code generation passes. Returns true if code generation should | 190 // Code generation passes. Returns true if code generation should |
| 222 // continue. | 191 // continue. |
| 223 bool GeneratePrologue(); | 192 bool GeneratePrologue(); |
| 224 bool GenerateBody(); | |
| 225 bool GenerateDeferredCode(); | 193 bool GenerateDeferredCode(); |
| 226 bool GenerateDeoptJumpTable(); | 194 bool GenerateDeoptJumpTable(); |
| 227 bool GenerateSafepointTable(); | 195 bool GenerateSafepointTable(); |
| 228 | 196 |
| 229 // Generates the custom OSR entrypoint and sets the osr_pc_offset. | 197 // Generates the custom OSR entrypoint and sets the osr_pc_offset. |
| 230 void GenerateOsrPrologue(); | 198 void GenerateOsrPrologue(); |
| 231 | 199 |
| 232 enum SafepointMode { | 200 enum SafepointMode { |
| 233 RECORD_SIMPLE_SAFEPOINT, | 201 RECORD_SIMPLE_SAFEPOINT, |
| 234 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS | 202 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 235 }; | 203 }; |
| 236 | 204 |
| 237 void CallCode(Handle<Code> code, | 205 void CallCode(Handle<Code> code, |
| 238 RelocInfo::Mode mode, | 206 RelocInfo::Mode mode, |
| 239 LInstruction* instr); | 207 LInstruction* instr); |
| 240 | 208 |
| 241 void CallCodeGeneric(Handle<Code> code, | 209 void CallCodeGeneric(Handle<Code> code, |
| 242 RelocInfo::Mode mode, | 210 RelocInfo::Mode mode, |
| 243 LInstruction* instr, | 211 LInstruction* instr, |
| 244 SafepointMode safepoint_mode); | 212 SafepointMode safepoint_mode); |
| 245 | 213 |
| 246 void CallRuntime(const Runtime::Function* function, | 214 void CallRuntime(const Runtime::Function* function, |
| 247 int num_arguments, | 215 int num_arguments, |
| 248 LInstruction* instr); | 216 LInstruction* instr, |
| 217 SaveFPRegsMode save_doubles = kDontSaveFPRegs); |
| 249 | 218 |
| 250 void CallRuntime(Runtime::FunctionId id, | 219 void CallRuntime(Runtime::FunctionId id, |
| 251 int num_arguments, | 220 int num_arguments, |
| 252 LInstruction* instr) { | 221 LInstruction* instr) { |
| 253 const Runtime::Function* function = Runtime::FunctionForId(id); | 222 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 254 CallRuntime(function, num_arguments, instr); | 223 CallRuntime(function, num_arguments, instr); |
| 255 } | 224 } |
| 256 | 225 |
| 226 void LoadContextFromDeferred(LOperand* context); |
| 257 void CallRuntimeFromDeferred(Runtime::FunctionId id, | 227 void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 258 int argc, | 228 int argc, |
| 259 LInstruction* instr); | 229 LInstruction* instr, |
| 230 LOperand* context); |
| 260 | 231 |
| 261 enum A1State { | 232 enum A1State { |
| 262 A1_UNINITIALIZED, | 233 A1_UNINITIALIZED, |
| 263 A1_CONTAINS_TARGET | 234 A1_CONTAINS_TARGET |
| 264 }; | 235 }; |
| 265 | 236 |
| 266 // Generate a direct call to a known function. Expects the function | 237 // Generate a direct call to a known function. Expects the function |
| 267 // to be in a1. | 238 // to be in a1. |
| 268 void CallKnownFunction(Handle<JSFunction> function, | 239 void CallKnownFunction(Handle<JSFunction> function, |
| 269 int formal_parameter_count, | 240 int formal_parameter_count, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 Safepoint::DeoptMode mode); | 289 Safepoint::DeoptMode mode); |
| 319 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); | 290 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); |
| 320 void RecordSafepoint(Safepoint::DeoptMode mode); | 291 void RecordSafepoint(Safepoint::DeoptMode mode); |
| 321 void RecordSafepointWithRegisters(LPointerMap* pointers, | 292 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 322 int arguments, | 293 int arguments, |
| 323 Safepoint::DeoptMode mode); | 294 Safepoint::DeoptMode mode); |
| 324 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, | 295 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 325 int arguments, | 296 int arguments, |
| 326 Safepoint::DeoptMode mode); | 297 Safepoint::DeoptMode mode); |
| 327 void RecordPosition(int position); | 298 void RecordPosition(int position); |
| 328 void RecordAndUpdatePosition(int position); | 299 void RecordAndUpdatePosition(int position) V8_OVERRIDE; |
| 329 | 300 |
| 330 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 301 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 331 void EmitGoto(int block); | 302 void EmitGoto(int block); |
| 332 template<class InstrType> | 303 template<class InstrType> |
| 333 void EmitBranch(InstrType instr, | 304 void EmitBranch(InstrType instr, |
| 334 Condition condition, | 305 Condition condition, |
| 335 Register src1, | 306 Register src1, |
| 336 const Operand& src2); | 307 const Operand& src2); |
| 337 template<class InstrType> | 308 template<class InstrType> |
| 338 void EmitBranchF(InstrType instr, | 309 void EmitBranchF(InstrType instr, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // All registers are clobbered. | 368 // All registers are clobbered. |
| 398 // If 'remainder' is no_reg, it is not computed. | 369 // If 'remainder' is no_reg, it is not computed. |
| 399 void EmitSignedIntegerDivisionByConstant(Register result, | 370 void EmitSignedIntegerDivisionByConstant(Register result, |
| 400 Register dividend, | 371 Register dividend, |
| 401 int32_t divisor, | 372 int32_t divisor, |
| 402 Register remainder, | 373 Register remainder, |
| 403 Register scratch, | 374 Register scratch, |
| 404 LEnvironment* environment); | 375 LEnvironment* environment); |
| 405 | 376 |
| 406 | 377 |
| 407 void EnsureSpaceForLazyDeopt(); | 378 void EnsureSpaceForLazyDeopt(int space_needed) V8_OVERRIDE; |
| 408 void DoLoadKeyedExternalArray(LLoadKeyed* instr); | 379 void DoLoadKeyedExternalArray(LLoadKeyed* instr); |
| 409 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); | 380 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); |
| 410 void DoLoadKeyedFixedArray(LLoadKeyed* instr); | 381 void DoLoadKeyedFixedArray(LLoadKeyed* instr); |
| 411 void DoStoreKeyedExternalArray(LStoreKeyed* instr); | 382 void DoStoreKeyedExternalArray(LStoreKeyed* instr); |
| 412 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); | 383 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); |
| 413 void DoStoreKeyedFixedArray(LStoreKeyed* instr); | 384 void DoStoreKeyedFixedArray(LStoreKeyed* instr); |
| 414 | 385 |
| 415 Zone* zone_; | |
| 416 LPlatformChunk* const chunk_; | |
| 417 MacroAssembler* const masm_; | |
| 418 CompilationInfo* const info_; | |
| 419 | |
| 420 int current_block_; | |
| 421 int current_instruction_; | |
| 422 const ZoneList<LInstruction*>* instructions_; | |
| 423 ZoneList<LEnvironment*> deoptimizations_; | 386 ZoneList<LEnvironment*> deoptimizations_; |
| 424 ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; | 387 ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; |
| 425 ZoneList<Handle<Object> > deoptimization_literals_; | 388 ZoneList<Handle<Object> > deoptimization_literals_; |
| 426 int inlined_function_count_; | 389 int inlined_function_count_; |
| 427 Scope* const scope_; | 390 Scope* const scope_; |
| 428 Status status_; | |
| 429 TranslationBuffer translations_; | 391 TranslationBuffer translations_; |
| 430 ZoneList<LDeferredCode*> deferred_; | 392 ZoneList<LDeferredCode*> deferred_; |
| 431 int osr_pc_offset_; | 393 int osr_pc_offset_; |
| 432 int last_lazy_deopt_pc_; | |
| 433 bool frame_is_built_; | 394 bool frame_is_built_; |
| 434 | 395 |
| 435 // Builder that keeps track of safepoints in the code. The table | 396 // Builder that keeps track of safepoints in the code. The table |
| 436 // itself is emitted at the end of the generated code. | 397 // itself is emitted at the end of the generated code. |
| 437 SafepointTableBuilder safepoints_; | 398 SafepointTableBuilder safepoints_; |
| 438 | 399 |
| 439 // Compiler from a set of parallel moves to a sequential list of moves. | 400 // Compiler from a set of parallel moves to a sequential list of moves. |
| 440 LGapResolver resolver_; | 401 LGapResolver resolver_; |
| 441 | 402 |
| 442 Safepoint::Kind expected_safepoint_kind_; | 403 Safepoint::Kind expected_safepoint_kind_; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 LCodeGen* codegen_; | 478 LCodeGen* codegen_; |
| 518 Label entry_; | 479 Label entry_; |
| 519 Label exit_; | 480 Label exit_; |
| 520 Label* external_exit_; | 481 Label* external_exit_; |
| 521 int instruction_index_; | 482 int instruction_index_; |
| 522 }; | 483 }; |
| 523 | 484 |
| 524 } } // namespace v8::internal | 485 } } // namespace v8::internal |
| 525 | 486 |
| 526 #endif // V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ | 487 #endif // V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ |
| OLD | NEW |