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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 class LChunk; | 489 class LChunk; |
490 | 490 |
491 // A helper class that calls the three compilation phases in | 491 // A helper class that calls the three compilation phases in |
492 // Crankshaft and keeps track of its state. The three phases | 492 // Crankshaft and keeps track of its state. The three phases |
493 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either | 493 // CreateGraph, OptimizeGraph and GenerateAndInstallCode can either |
494 // fail, bail-out to the full code generator or succeed. Apart from | 494 // fail, bail-out to the full code generator or succeed. Apart from |
495 // their return value, the status of the phase last run can be checked | 495 // their return value, the status of the phase last run can be checked |
496 // using last_status(). | 496 // using last_status(). |
497 class OptimizingCompiler: public ZoneObject { | 497 class OptimizingCompiler: public ZoneObject { |
498 public: | 498 public: |
499 explicit OptimizingCompiler(CompilationInfo* info) | 499 explicit OptimizingCompiler(CompilationInfo* info, |
500 uint32_t osr_pc_offset = 0) | |
500 : info_(info), | 501 : info_(info), |
501 graph_builder_(NULL), | 502 graph_builder_(NULL), |
502 graph_(NULL), | 503 graph_(NULL), |
503 chunk_(NULL), | 504 chunk_(NULL), |
505 osr_pc_offset_(osr_pc_offset), | |
titzer
2013/09/02 17:03:35
This is the PC offset of the backedge. It seems we
Yang
2013/09/03 08:50:10
Done.
| |
504 last_status_(FAILED) { } | 506 last_status_(FAILED) { } |
505 | 507 |
506 enum Status { | 508 enum Status { |
507 FAILED, BAILED_OUT, SUCCEEDED | 509 FAILED, BAILED_OUT, SUCCEEDED |
508 }; | 510 }; |
509 | 511 |
510 MUST_USE_RESULT Status CreateGraph(); | 512 MUST_USE_RESULT Status CreateGraph(); |
511 MUST_USE_RESULT Status OptimizeGraph(); | 513 MUST_USE_RESULT Status OptimizeGraph(); |
512 MUST_USE_RESULT Status GenerateAndInstallCode(); | 514 MUST_USE_RESULT Status GenerateAndInstallCode(); |
513 | 515 |
514 Status last_status() const { return last_status_; } | 516 Status last_status() const { return last_status_; } |
515 CompilationInfo* info() const { return info_; } | 517 CompilationInfo* info() const { return info_; } |
516 Isolate* isolate() const { return info()->isolate(); } | 518 Isolate* isolate() const { return info()->isolate(); } |
519 uint32_t osr_pc_offset() { return osr_pc_offset_; } | |
517 | 520 |
518 MUST_USE_RESULT Status AbortOptimization() { | 521 MUST_USE_RESULT Status AbortOptimization() { |
519 info_->AbortOptimization(); | 522 info_->AbortOptimization(); |
520 info_->shared_info()->DisableOptimization(info_->bailout_reason()); | 523 info_->shared_info()->DisableOptimization(info_->bailout_reason()); |
521 return SetLastStatus(BAILED_OUT); | 524 return SetLastStatus(BAILED_OUT); |
522 } | 525 } |
523 | 526 |
524 private: | 527 private: |
525 CompilationInfo* info_; | 528 CompilationInfo* info_; |
526 HOptimizedGraphBuilder* graph_builder_; | 529 HOptimizedGraphBuilder* graph_builder_; |
527 HGraph* graph_; | 530 HGraph* graph_; |
528 LChunk* chunk_; | 531 LChunk* chunk_; |
529 TimeDelta time_taken_to_create_graph_; | 532 TimeDelta time_taken_to_create_graph_; |
530 TimeDelta time_taken_to_optimize_; | 533 TimeDelta time_taken_to_optimize_; |
531 TimeDelta time_taken_to_codegen_; | 534 TimeDelta time_taken_to_codegen_; |
535 uint32_t osr_pc_offset_; | |
532 Status last_status_; | 536 Status last_status_; |
533 | 537 |
534 MUST_USE_RESULT Status SetLastStatus(Status status) { | 538 MUST_USE_RESULT Status SetLastStatus(Status status) { |
535 last_status_ = status; | 539 last_status_ = status; |
536 return last_status_; | 540 return last_status_; |
537 } | 541 } |
538 void RecordOptimizationStats(); | 542 void RecordOptimizationStats(); |
539 | 543 |
540 struct Timer { | 544 struct Timer { |
541 Timer(OptimizingCompiler* compiler, TimeDelta* location) | 545 Timer(OptimizingCompiler* compiler, TimeDelta* location) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 Handle<Context> context, | 597 Handle<Context> context, |
594 bool is_global, | 598 bool is_global, |
595 LanguageMode language_mode, | 599 LanguageMode language_mode, |
596 ParseRestriction restriction, | 600 ParseRestriction restriction, |
597 int scope_position); | 601 int scope_position); |
598 | 602 |
599 // Compile from function info (used for lazy compilation). Returns true on | 603 // Compile from function info (used for lazy compilation). Returns true on |
600 // success and false if the compilation resulted in a stack overflow. | 604 // success and false if the compilation resulted in a stack overflow. |
601 static bool CompileLazy(CompilationInfo* info); | 605 static bool CompileLazy(CompilationInfo* info); |
602 | 606 |
603 static void RecompileConcurrent(Handle<JSFunction> function); | 607 static void RecompileConcurrent(Handle<JSFunction> function, |
608 uint32_t osr_pc_offset = 0); | |
604 | 609 |
605 // Compile a shared function info object (the function is possibly lazily | 610 // Compile a shared function info object (the function is possibly lazily |
606 // compiled). | 611 // compiled). |
607 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 612 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
608 Handle<Script> script); | 613 Handle<Script> script); |
609 | 614 |
610 // Set the function info for a newly compiled function. | 615 // Set the function info for a newly compiled function. |
611 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 616 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
612 FunctionLiteral* lit, | 617 FunctionLiteral* lit, |
613 bool is_toplevel, | 618 bool is_toplevel, |
614 Handle<Script> script); | 619 Handle<Script> script); |
615 | 620 |
616 static void InstallOptimizedCode(OptimizingCompiler* info); | 621 static void InstallOptimizedCode(OptimizingCompiler* info); |
617 | 622 |
623 static bool CompileForOnStackReplacement(Handle<JSFunction> function, | |
624 BailoutId* ast_id_out); | |
625 | |
626 static bool CompileForConcurrentOSR(Handle<JSFunction> function, | |
627 BailoutId* ast_id_out); | |
628 | |
618 #ifdef ENABLE_DEBUGGER_SUPPORT | 629 #ifdef ENABLE_DEBUGGER_SUPPORT |
619 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 630 static bool MakeCodeForLiveEdit(CompilationInfo* info); |
620 #endif | 631 #endif |
621 | 632 |
622 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 633 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
623 CompilationInfo* info, | 634 CompilationInfo* info, |
624 Handle<SharedFunctionInfo> shared); | 635 Handle<SharedFunctionInfo> shared); |
625 }; | 636 }; |
626 | 637 |
627 | 638 |
(...skipping 17 matching lines...) Expand all Loading... | |
645 unsigned info_zone_start_allocation_size_; | 656 unsigned info_zone_start_allocation_size_; |
646 ElapsedTimer timer_; | 657 ElapsedTimer timer_; |
647 | 658 |
648 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 659 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
649 }; | 660 }; |
650 | 661 |
651 | 662 |
652 } } // namespace v8::internal | 663 } } // namespace v8::internal |
653 | 664 |
654 #endif // V8_COMPILER_H_ | 665 #endif // V8_COMPILER_H_ |
OLD | NEW |