Chromium Code Reviews| 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 "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| 11 #include "src/compilation-dependencies.h" | 11 #include "src/compilation-dependencies.h" |
| 12 #include "src/source-position.h" | 12 #include "src/source-position.h" |
| 13 #include "src/zone.h" | 13 #include "src/zone.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 class CompilationInfo; | 19 class CompilationInfo; |
| 20 class JavaScriptFrame; | 20 class JavaScriptFrame; |
| 21 class OptimizedCompileJob; | 21 class OptimizedCompileJob; |
| 22 class ParseInfo; | 22 class ParseInfo; |
| 23 class ScriptData; | 23 class ScriptData; |
| 24 namespace compiler { | |
| 25 class SourcePositionTable; | |
| 26 } | |
| 24 | 27 |
| 25 // The V8 compiler API. | 28 // The V8 compiler API. |
| 26 // | 29 // |
| 27 // This is the central hub for dispatching to the various compilers within V8. | 30 // This is the central hub for dispatching to the various compilers within V8. |
| 28 // Logic for which compiler to choose and how to wire compilation results into | 31 // Logic for which compiler to choose and how to wire compilation results into |
| 29 // the object heap should be kept inside this class. | 32 // the object heap should be kept inside this class. |
| 30 // | 33 // |
| 31 // General strategy: Scripts are translated into anonymous functions w/o | 34 // General strategy: Scripts are translated into anonymous functions w/o |
| 32 // parameters which then can be executed. If the source code contains other | 35 // parameters which then can be executed. If the source code contains other |
| 33 // functions, they might be compiled and allocated as part of the compilation | 36 // functions, they might be compiled and allocated as part of the compilation |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 } | 453 } |
| 451 | 454 |
| 452 base::SmartArrayPointer<char> GetDebugName() const; | 455 base::SmartArrayPointer<char> GetDebugName() const; |
| 453 | 456 |
| 454 Code::Kind output_code_kind() const { | 457 Code::Kind output_code_kind() const { |
| 455 return Code::ExtractKindFromFlags(code_flags_); | 458 return Code::ExtractKindFromFlags(code_flags_); |
| 456 } | 459 } |
| 457 | 460 |
| 458 StackFrame::Type GetOutputStackFrameType() const; | 461 StackFrame::Type GetOutputStackFrameType() const; |
| 459 | 462 |
| 463 void SetSourcePositionTable(compiler::SourcePositionTable* table) { | |
| 464 source_position_table_ = table; | |
|
titzer
2016/04/18 11:03:51
I'm not sure that the CompilationInfo is the best
Michael Starzinger
2016/04/18 11:08:47
Not a fan of adding this to CompilationInfo either
Clemens Hammacher
2016/04/18 11:18:09
Sounds reasonable. I will try to change it that wa
| |
| 465 } | |
| 466 | |
| 467 compiler::SourcePositionTable* GetSourcePositionTable() { | |
| 468 return source_position_table_; | |
| 469 } | |
| 470 | |
| 460 protected: | 471 protected: |
| 461 ParseInfo* parse_info_; | 472 ParseInfo* parse_info_; |
| 462 | 473 |
| 463 void DisableFutureOptimization() { | 474 void DisableFutureOptimization() { |
| 464 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { | 475 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { |
| 465 // If Crankshaft tried to optimize this function, bailed out, and | 476 // If Crankshaft tried to optimize this function, bailed out, and |
| 466 // doesn't want to try again, then use TurboFan next time. | 477 // doesn't want to try again, then use TurboFan next time. |
| 467 if (!shared_info()->dont_crankshaft() && | 478 if (!shared_info()->dont_crankshaft() && |
| 468 bailout_reason() != kOptimizedTooManyTimes) { | 479 bailout_reason() != kOptimizedTooManyTimes) { |
| 469 shared_info()->set_dont_crankshaft(true); | 480 shared_info()->set_dont_crankshaft(true); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 | 558 |
| 548 int optimization_id_; | 559 int optimization_id_; |
| 549 | 560 |
| 550 int osr_expr_stack_height_; | 561 int osr_expr_stack_height_; |
| 551 | 562 |
| 552 // The current OSR frame for specialization or {nullptr}. | 563 // The current OSR frame for specialization or {nullptr}. |
| 553 JavaScriptFrame* osr_frame_ = nullptr; | 564 JavaScriptFrame* osr_frame_ = nullptr; |
| 554 | 565 |
| 555 const char* debug_name_; | 566 const char* debug_name_; |
| 556 | 567 |
| 568 compiler::SourcePositionTable* source_position_table_ = nullptr; | |
| 569 | |
| 557 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 570 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
| 558 }; | 571 }; |
| 559 | 572 |
| 560 // A base class for compilation jobs intended to run concurrent to the main | 573 // A base class for compilation jobs intended to run concurrent to the main |
| 561 // thread. The job is split into three phases which are called in sequence on | 574 // thread. The job is split into three phases which are called in sequence on |
| 562 // different threads and with different limitations: | 575 // different threads and with different limitations: |
| 563 // 1) CreateGraph: Runs on main thread. No major limitations. | 576 // 1) CreateGraph: Runs on main thread. No major limitations. |
| 564 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs. | 577 // 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs. |
| 565 // 3) GenerateCode: Runs on main thread. No dependency changes. | 578 // 3) GenerateCode: Runs on main thread. No dependency changes. |
| 566 // | 579 // |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 MUST_USE_RESULT Status SetLastStatus(Status status) { | 629 MUST_USE_RESULT Status SetLastStatus(Status status) { |
| 617 last_status_ = status; | 630 last_status_ = status; |
| 618 return last_status_; | 631 return last_status_; |
| 619 } | 632 } |
| 620 }; | 633 }; |
| 621 | 634 |
| 622 } // namespace internal | 635 } // namespace internal |
| 623 } // namespace v8 | 636 } // namespace v8 |
| 624 | 637 |
| 625 #endif // V8_COMPILER_H_ | 638 #endif // V8_COMPILER_H_ |
| OLD | NEW |