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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 928213003: Model exceptional edges from call nodes in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments by Benedikt Meurer. Created 5 years, 10 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
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 277f0d5c8598a6a1822a9eaa17a92875c12e2069..49a3abd7d3d8e3e5e177c87ac63e4e2851d368ff 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -327,7 +327,12 @@ class AstGraphBuilder::ControlScopeForIteration : public ControlScope {
class AstGraphBuilder::ControlScopeForCatch : public ControlScope {
public:
ControlScopeForCatch(AstGraphBuilder* owner, TryCatchBuilder* control)
- : ControlScope(owner, 0), control_(control) {}
+ : ControlScope(owner, 0), control_(control) {
+ builder()->try_nesting_level_++; // Increment nesting.
+ }
+ ~ControlScopeForCatch() {
+ builder()->try_nesting_level_--; // Decrement nesting.
+ }
protected:
virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE {
@@ -353,7 +358,12 @@ class AstGraphBuilder::ControlScopeForFinally : public ControlScope {
public:
ControlScopeForFinally(AstGraphBuilder* owner, DeferredCommands* commands,
TryFinallyBuilder* control)
- : ControlScope(owner, 0), commands_(commands), control_(control) {}
+ : ControlScope(owner, 0), commands_(commands), control_(control) {
+ builder()->try_nesting_level_++; // Increment nesting.
+ }
+ ~ControlScopeForFinally() {
+ builder()->try_nesting_level_--; // Decrement nesting.
+ }
protected:
virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE {
@@ -378,6 +388,7 @@ AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info,
globals_(0, local_zone),
execution_control_(nullptr),
execution_context_(nullptr),
+ try_nesting_level_(0),
input_buffer_size_(0),
input_buffer_(nullptr),
exit_control_(nullptr),
@@ -486,8 +497,7 @@ bool AstGraphBuilder::CreateGraph() {
BuildReturn(jsgraph()->UndefinedConstant());
// Finish the basic structure of the graph.
- environment()->UpdateControlDependency(exit_control());
- graph()->SetEnd(NewNode(common()->End()));
+ graph()->SetEnd(graph()->NewNode(common()->End(), exit_control()));
return true;
}
@@ -2957,6 +2967,7 @@ Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count,
if (!has_context && !has_framestate && !has_control && !has_effect) {
result = graph()->NewNode(op, value_input_count, value_inputs, incomplete);
} else {
+ bool inside_try_scope = try_nesting_level_ > 0;
int input_count_with_deps = value_input_count;
if (has_context) ++input_count_with_deps;
if (has_framestate) ++input_count_with_deps;
@@ -2984,9 +2995,24 @@ Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count,
if (has_effect) {
environment_->UpdateEffectDependency(result);
}
- if (result->op()->ControlOutputCount() > 0 &&
- !environment()->IsMarkedAsUnreachable()) {
- environment_->UpdateControlDependency(result);
+ if (!environment()->IsMarkedAsUnreachable()) {
+ // Update the current control dependency for control-producing nodes.
+ if (NodeProperties::IsControl(result)) {
+ environment_->UpdateControlDependency(result);
+ }
+ // Add implicit exception continuation for throwing nodes.
+ if (!result->op()->HasProperty(Operator::kNoThrow) && inside_try_scope) {
+ Node* on_exception = graph()->NewNode(common()->IfException(), result);
+ environment_->UpdateControlDependency(on_exception);
+ if (FLAG_turbo_exceptions) {
+ execution_control()->ThrowValue(jsgraph()->UndefinedConstant());
+ }
+ }
+ // Add implicit success continuation for throwing nodes.
+ if (!result->op()->HasProperty(Operator::kNoThrow)) {
+ Node* on_success = graph()->NewNode(common()->IfSuccess(), result);
+ environment_->UpdateControlDependency(on_success);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698