diff options
Diffstat (limited to 'deps/v8/src/compiler/control-builders.h')
-rw-r--r-- | deps/v8/src/compiler/control-builders.h | 84 |
1 files changed, 65 insertions, 19 deletions
diff --git a/deps/v8/src/compiler/control-builders.h b/deps/v8/src/compiler/control-builders.h index 11adfdb0f4..c22ee04a98 100644 --- a/deps/v8/src/compiler/control-builders.h +++ b/deps/v8/src/compiler/control-builders.h @@ -5,9 +5,7 @@ #ifndef V8_COMPILER_CONTROL_BUILDERS_H_ #define V8_COMPILER_CONTROL_BUILDERS_H_ -#include "src/v8.h" - -#include "src/compiler/graph-builder.h" +#include "src/compiler/ast-graph-builder.h" #include "src/compiler/node.h" namespace v8 { @@ -15,25 +13,24 @@ namespace internal { namespace compiler { // Base class for all control builders. Also provides a common interface for -// control builders to handle 'break' and 'continue' statements when they are -// used to model breakable statements. +// control builders to handle 'break' statements when they are used to model +// breakable statements. class ControlBuilder { public: - explicit ControlBuilder(StructuredGraphBuilder* builder) - : builder_(builder) {} + explicit ControlBuilder(AstGraphBuilder* builder) : builder_(builder) {} virtual ~ControlBuilder() {} - // Interface for break and continue. + // Interface for break. virtual void Break() { UNREACHABLE(); } - virtual void Continue() { UNREACHABLE(); } protected: - typedef StructuredGraphBuilder Builder; - typedef StructuredGraphBuilder::Environment Environment; + typedef AstGraphBuilder Builder; + typedef AstGraphBuilder::Environment Environment; Zone* zone() const { return builder_->local_zone(); } Environment* environment() { return builder_->environment(); } void set_environment(Environment* env) { builder_->set_environment(env); } + Node* the_hole() const { return builder_->jsgraph()->TheHoleConstant(); } Builder* builder_; }; @@ -42,7 +39,7 @@ class ControlBuilder { // Tracks control flow for a conditional statement. class IfBuilder FINAL : public ControlBuilder { public: - explicit IfBuilder(StructuredGraphBuilder* builder) + explicit IfBuilder(AstGraphBuilder* builder) : ControlBuilder(builder), then_environment_(NULL), else_environment_(NULL) {} @@ -62,23 +59,24 @@ class IfBuilder FINAL : public ControlBuilder { // Tracks control flow for an iteration statement. class LoopBuilder FINAL : public ControlBuilder { public: - explicit LoopBuilder(StructuredGraphBuilder* builder) + explicit LoopBuilder(AstGraphBuilder* builder) : ControlBuilder(builder), loop_environment_(NULL), continue_environment_(NULL), break_environment_(NULL) {} // Primitive control commands. - void BeginLoop(BitVector* assigned); + void BeginLoop(BitVector* assigned, bool is_osr = false); + void Continue(); void EndBody(); void EndLoop(); - // Primitive support for break and continue. - void Continue() FINAL; + // Primitive support for break. void Break() FINAL; - // Compound control command for conditional break. + // Compound control commands for conditional break. void BreakUnless(Node* condition); + void BreakWhen(Node* condition); private: Environment* loop_environment_; // Environment of the loop header. @@ -90,7 +88,7 @@ class LoopBuilder FINAL : public ControlBuilder { // Tracks control flow for a switch statement. class SwitchBuilder FINAL : public ControlBuilder { public: - explicit SwitchBuilder(StructuredGraphBuilder* builder, int case_count) + explicit SwitchBuilder(AstGraphBuilder* builder, int case_count) : ControlBuilder(builder), body_environment_(NULL), label_environment_(NULL), @@ -123,7 +121,7 @@ class SwitchBuilder FINAL : public ControlBuilder { // Tracks control flow for a block statement. class BlockBuilder FINAL : public ControlBuilder { public: - explicit BlockBuilder(StructuredGraphBuilder* builder) + explicit BlockBuilder(AstGraphBuilder* builder) : ControlBuilder(builder), break_environment_(NULL) {} // Primitive control commands. @@ -137,6 +135,54 @@ class BlockBuilder FINAL : public ControlBuilder { Environment* break_environment_; // Environment after the block exits. }; + +// Tracks control flow for a try-catch statement. +class TryCatchBuilder FINAL : public ControlBuilder { + public: + explicit TryCatchBuilder(AstGraphBuilder* builder) + : ControlBuilder(builder), + catch_environment_(NULL), + exit_environment_(NULL), + exception_node_(NULL) {} + + // Primitive control commands. + void BeginTry(); + void Throw(Node* exception); + void EndTry(); + void EndCatch(); + + // Returns the exception value inside the 'catch' body. + Node* GetExceptionNode() const { return exception_node_; } + + private: + Environment* catch_environment_; // Environment for the 'catch' body. + Environment* exit_environment_; // Environment after the statement. + Node* exception_node_; // Node for exception in 'catch' body. +}; + + +// Tracks control flow for a try-finally statement. +class TryFinallyBuilder FINAL : public ControlBuilder { + public: + explicit TryFinallyBuilder(AstGraphBuilder* builder) + : ControlBuilder(builder), + finally_environment_(NULL), + token_node_(NULL) {} + + // Primitive control commands. + void BeginTry(); + void LeaveTry(Node* token); + void EndTry(Node* token); + void EndFinally(); + + // Returns the dispatch token value inside the 'finally' body. + Node* GetDispatchTokenNode() const { return token_node_; } + + private: + Environment* finally_environment_; // Environment for the 'finally' body. + Node* token_node_; // Node for token in 'finally' body. +}; + } // namespace compiler } // namespace internal } // namespace v8 |