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

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

Issue 681263004: Run ControlReducer early after graph building, then again later. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « no previous file | src/compiler/js-graph.h » ('j') | src/compiler/scheduler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 4887260813a38edb6fd9ca0d3c391cf07036894c..11e115998ce8964ceea897e1217098715879598c 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -8,6 +8,7 @@
#include "src/compiler/ast-loop-assignment-analyzer.h"
#include "src/compiler/control-builders.h"
#include "src/compiler/machine-operator.h"
+#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties-inl.h"
#include "src/compiler/node-properties.h"
#include "src/full-codegen.h"
@@ -2059,9 +2060,31 @@ Node* AstGraphBuilder::BuildLoadGlobalObject() {
}
-Node* AstGraphBuilder::BuildToBoolean(Node* value) {
- // TODO(mstarzinger): Possible optimization is to NOP for boolean values.
- return NewNode(javascript()->ToBoolean(), value);
+Node* AstGraphBuilder::BuildToBoolean(Node* input) {
+ // TODO(titzer): this should be in a JSOperatorReducer.
Michael Starzinger 2014/10/29 12:14:02 Yes, this should definitely be factored out at som
+ switch (input->opcode()) {
+ case IrOpcode::kInt32Constant:
+ return jsgraph_->BooleanConstant(!Int32Matcher(input).Is(0));
+ case IrOpcode::kFloat64Constant:
+ return jsgraph_->BooleanConstant(!Float64Matcher(input).Is(0));
+ case IrOpcode::kNumberConstant:
+ return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0));
+ case IrOpcode::kHeapConstant: {
+ Handle<Object> object = HeapObjectMatcher<Object>(input).Value().handle();
+ if (object->IsTrue()) return jsgraph_->TrueConstant();
+ if (object->IsFalse()) return jsgraph_->FalseConstant();
+ // XXX: other constants.
Michael Starzinger 2014/10/29 12:14:02 nit: s/XXX/TODO(turbofan)/
titzer 2014/10/29 15:17:09 Done.
+ break;
+ }
+ default:
+ break;
+ }
+ if (NodeProperties::IsTyped(input)) {
+ Type* upper = NodeProperties::GetBounds(input).upper;
+ if (upper->Is(Type::Boolean())) return input;
+ }
+
+ return NewNode(javascript()->ToBoolean(), input);
}
« no previous file with comments | « no previous file | src/compiler/js-graph.h » ('j') | src/compiler/scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698