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

Side by Side 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: Fix the glitch. Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/js-graph.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
11 #include "src/compiler/node-matchers.h"
11 #include "src/compiler/node-properties-inl.h" 12 #include "src/compiler/node-properties-inl.h"
12 #include "src/compiler/node-properties.h" 13 #include "src/compiler/node-properties.h"
13 #include "src/full-codegen.h" 14 #include "src/full-codegen.h"
14 #include "src/parser.h" 15 #include "src/parser.h"
15 #include "src/scopes.h" 16 #include "src/scopes.h"
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 namespace compiler { 20 namespace compiler {
20 21
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 2053
2053 2054
2054 Node* AstGraphBuilder::BuildLoadGlobalObject() { 2055 Node* AstGraphBuilder::BuildLoadGlobalObject() {
2055 Node* context = GetFunctionContext(); 2056 Node* context = GetFunctionContext();
2056 const Operator* load_op = 2057 const Operator* load_op =
2057 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true); 2058 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true);
2058 return NewNode(load_op, context); 2059 return NewNode(load_op, context);
2059 } 2060 }
2060 2061
2061 2062
2062 Node* AstGraphBuilder::BuildToBoolean(Node* value) { 2063 Node* AstGraphBuilder::BuildToBoolean(Node* input) {
2063 // TODO(mstarzinger): Possible optimization is to NOP for boolean values. 2064 // TODO(titzer): this should be in a JSOperatorReducer.
2064 return NewNode(javascript()->ToBoolean(), value); 2065 switch (input->opcode()) {
2066 case IrOpcode::kInt32Constant:
2067 return jsgraph_->BooleanConstant(!Int32Matcher(input).Is(0));
2068 case IrOpcode::kFloat64Constant:
2069 return jsgraph_->BooleanConstant(!Float64Matcher(input).Is(0));
2070 case IrOpcode::kNumberConstant:
2071 return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0));
2072 case IrOpcode::kHeapConstant: {
2073 Handle<Object> object = HeapObjectMatcher<Object>(input).Value().handle();
2074 if (object->IsTrue()) return jsgraph_->TrueConstant();
2075 if (object->IsFalse()) return jsgraph_->FalseConstant();
2076 // TODO(turbofan): other constants.
2077 break;
2078 }
2079 default:
2080 break;
2081 }
2082 if (NodeProperties::IsTyped(input)) {
2083 Type* upper = NodeProperties::GetBounds(input).upper;
2084 if (upper->Is(Type::Boolean())) return input;
2085 }
2086
2087 return NewNode(javascript()->ToBoolean(), input);
2065 } 2088 }
2066 2089
2067 2090
2068 Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable, 2091 Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable,
2069 BailoutId bailout_id) { 2092 BailoutId bailout_id) {
2070 // TODO(mstarzinger): Should be unified with the VisitThrow implementation. 2093 // TODO(mstarzinger): Should be unified with the VisitThrow implementation.
2071 Node* variable_name = jsgraph()->Constant(variable->name()); 2094 Node* variable_name = jsgraph()->Constant(variable->name());
2072 const Operator* op = 2095 const Operator* op =
2073 javascript()->CallRuntime(Runtime::kThrowReferenceError, 1); 2096 javascript()->CallRuntime(Runtime::kThrowReferenceError, 1);
2074 Node* call = NewNode(op, variable_name); 2097 Node* call = NewNode(op, variable_name);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == 2168 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() ==
2146 IrOpcode::kDead); 2169 IrOpcode::kDead);
2147 NodeProperties::ReplaceFrameStateInput( 2170 NodeProperties::ReplaceFrameStateInput(
2148 node, environment()->Checkpoint(ast_id, combine)); 2171 node, environment()->Checkpoint(ast_id, combine));
2149 } 2172 }
2150 } 2173 }
2151 2174
2152 } 2175 }
2153 } 2176 }
2154 } // namespace v8::internal::compiler 2177 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698