Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: src/compiler/control-builders.h

Issue 873423004: First stab at try-catch and try-finally in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed moarer comments by Ben Titzer. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/control-builders.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/control-builders.h
diff --git a/src/compiler/control-builders.h b/src/compiler/control-builders.h
index 7ab12d892cdd6dc727a676fd18e1adb078fff0ce..d190f61f5dc2b480b2910fbebc1bb97c6e261577 100644
--- a/src/compiler/control-builders.h
+++ b/src/compiler/control-builders.h
@@ -15,16 +15,15 @@ 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(AstGraphBuilder* builder) : builder_(builder) {}
virtual ~ControlBuilder() {}
- // Interface for break and continue.
+ // Interface for break.
virtual void Break() { UNREACHABLE(); }
- virtual void Continue() { UNREACHABLE(); }
protected:
typedef AstGraphBuilder Builder;
@@ -69,11 +68,11 @@ class LoopBuilder FINAL : public ControlBuilder {
// Primitive control commands.
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 commands for conditional break.
@@ -137,6 +136,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
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/control-builders.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698