OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // whereas successful compilation ensures the {is_compiled} predicate on the | 47 // whereas successful compilation ensures the {is_compiled} predicate on the |
48 // given function holds (except for live-edit, which compiles the world). | 48 // given function holds (except for live-edit, which compiles the world). |
49 | 49 |
50 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); | 50 static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag); |
51 static bool CompileBaseline(Handle<JSFunction> function); | 51 static bool CompileBaseline(Handle<JSFunction> function); |
52 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); | 52 static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode); |
53 static bool CompileDebugCode(Handle<JSFunction> function); | 53 static bool CompileDebugCode(Handle<JSFunction> function); |
54 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); | 54 static bool CompileDebugCode(Handle<SharedFunctionInfo> shared); |
55 static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script); | 55 static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script); |
56 | 56 |
57 // Prepare a compilation job for unoptimized code. Requires ParseAndAnalyse. | |
58 static CompilationJob* PrepareUnoptimizedCompilationJob( | |
Michael Starzinger
2016/08/19 10:54:14
This API method doesn't seem to be used nor implem
Michael Starzinger
2016/08/19 10:57:10
Ooops, overlooked the obvious. Please disregard th
| |
59 CompilationInfo* info); | |
60 | |
57 // Generate and install code from previously queued compilation job. | 61 // Generate and install code from previously queued compilation job. |
58 static void FinalizeCompilationJob(CompilationJob* job); | 62 static bool FinalizeCompilationJob(CompilationJob* job); |
59 | 63 |
60 // Give the compiler a chance to perform low-latency initialization tasks of | 64 // Give the compiler a chance to perform low-latency initialization tasks of |
61 // the given {function} on its instantiation. Note that only the runtime will | 65 // the given {function} on its instantiation. Note that only the runtime will |
62 // offer this chance, optimized closure instantiation will not call this. | 66 // offer this chance, optimized closure instantiation will not call this. |
63 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); | 67 static void PostInstantiation(Handle<JSFunction> function, PretenureFlag); |
64 | 68 |
65 // Parser::Parse, then Compiler::Analyze. | 69 // Parser::Parse, then Compiler::Analyze. |
66 static bool ParseAndAnalyze(ParseInfo* info); | 70 static bool ParseAndAnalyze(ParseInfo* info); |
67 // Rewrite, analyze scopes, and renumber. | 71 // Rewrite, analyze scopes, and renumber. |
68 static bool Analyze(ParseInfo* info); | 72 static bool Analyze(ParseInfo* info); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 | 586 |
583 // Report a persistent failure, disable future optimization on the function. | 587 // Report a persistent failure, disable future optimization on the function. |
584 // Should only be called on optimization compilation jobs. | 588 // Should only be called on optimization compilation jobs. |
585 Status AbortOptimization(BailoutReason reason) { | 589 Status AbortOptimization(BailoutReason reason) { |
586 DCHECK(info_->IsOptimizing()); | 590 DCHECK(info_->IsOptimizing()); |
587 info_->AbortOptimization(reason); | 591 info_->AbortOptimization(reason); |
588 state_ = State::kFailed; | 592 state_ = State::kFailed; |
589 return FAILED; | 593 return FAILED; |
590 } | 594 } |
591 | 595 |
592 void RecordOptimizationStats(); | |
593 | |
594 State state() const { return state_; } | 596 State state() const { return state_; } |
595 CompilationInfo* info() const { return info_; } | 597 CompilationInfo* info() const { return info_; } |
596 Isolate* isolate() const { return info()->isolate(); } | 598 Isolate* isolate() const { return info()->isolate(); } |
597 | 599 |
598 protected: | 600 protected: |
599 // Overridden by the actual implementation. | 601 // Overridden by the actual implementation. |
600 virtual Status PrepareJobImpl() = 0; | 602 virtual Status PrepareJobImpl() = 0; |
601 virtual Status ExecuteJobImpl() = 0; | 603 virtual Status ExecuteJobImpl() = 0; |
602 virtual Status FinalizeJobImpl() = 0; | 604 virtual Status FinalizeJobImpl() = 0; |
603 | 605 |
604 private: | 606 private: |
607 void RecordOptimizedCompilationStats() const; | |
608 void RecordUnoptimizedCompilationStats() const; | |
609 | |
610 void RecordCompilationStats() const { | |
Michael Starzinger
2016/08/19 10:54:14
nit: I'm not sure the job itself should record sta
rmcilroy
2016/08/22 13:27:08
Done.
| |
611 if (info_->IsOptimizing()) { | |
612 RecordOptimizedCompilationStats(); | |
613 } else { | |
614 RecordUnoptimizedCompilationStats(); | |
615 } | |
616 } | |
617 | |
605 CompilationInfo* info_; | 618 CompilationInfo* info_; |
606 base::TimeDelta time_taken_to_prepare_; | 619 base::TimeDelta time_taken_to_prepare_; |
607 base::TimeDelta time_taken_to_execute_; | 620 base::TimeDelta time_taken_to_execute_; |
608 base::TimeDelta time_taken_to_finalize_; | 621 base::TimeDelta time_taken_to_finalize_; |
609 const char* compiler_name_; | 622 const char* compiler_name_; |
610 State state_; | 623 State state_; |
611 | 624 |
612 MUST_USE_RESULT Status UpdateState(Status status, State next_state) { | 625 MUST_USE_RESULT Status UpdateState(Status status, State next_state) { |
613 if (status == SUCCEEDED) | 626 if (status == SUCCEEDED) |
614 state_ = next_state; | 627 state_ = next_state; |
615 else | 628 else |
616 state_ = State::kFailed; | 629 state_ = State::kFailed; |
617 return status; | 630 return status; |
618 } | 631 } |
619 }; | 632 }; |
620 | 633 |
621 } // namespace internal | 634 } // namespace internal |
622 } // namespace v8 | 635 } // namespace v8 |
623 | 636 |
624 #endif // V8_COMPILER_H_ | 637 #endif // V8_COMPILER_H_ |
OLD | NEW |