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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1188503003: [turbofan] The AstGraphBuilder does not need to care about types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 3554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 Node* AstGraphBuilder::BuildStoreExternal(ExternalReference reference, 3565 Node* AstGraphBuilder::BuildStoreExternal(ExternalReference reference,
3566 MachineType type, Node* value) { 3566 MachineType type, Node* value) {
3567 StoreRepresentation representation(type, kNoWriteBarrier); 3567 StoreRepresentation representation(type, kNoWriteBarrier);
3568 return NewNode(jsgraph()->machine()->Store(representation), 3568 return NewNode(jsgraph()->machine()->Store(representation),
3569 jsgraph()->ExternalConstant(reference), 3569 jsgraph()->ExternalConstant(reference),
3570 jsgraph()->IntPtrConstant(0), value); 3570 jsgraph()->IntPtrConstant(0), value);
3571 } 3571 }
3572 3572
3573 3573
3574 Node* AstGraphBuilder::BuildToBoolean(Node* input) { 3574 Node* AstGraphBuilder::BuildToBoolean(Node* input) {
3575 // TODO(titzer): This should be in a JSOperatorReducer. 3575 // TODO(bmeurer, mstarzinger): Refactor this into a separate optimization
3576 // method.
3576 switch (input->opcode()) { 3577 switch (input->opcode()) {
3577 case IrOpcode::kInt32Constant:
3578 return jsgraph_->BooleanConstant(!Int32Matcher(input).Is(0));
3579 case IrOpcode::kFloat64Constant:
3580 return jsgraph_->BooleanConstant(!Float64Matcher(input).Is(0));
3581 case IrOpcode::kNumberConstant: 3578 case IrOpcode::kNumberConstant:
3582 return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0)); 3579 return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0));
3583 case IrOpcode::kHeapConstant: { 3580 case IrOpcode::kHeapConstant: {
3584 Handle<Object> object = HeapObjectMatcher<Object>(input).Value().handle(); 3581 Handle<Object> object = HeapObjectMatcher<Object>(input).Value().handle();
3585 return jsgraph_->BooleanConstant(object->BooleanValue()); 3582 return jsgraph_->BooleanConstant(object->BooleanValue());
3586 } 3583 }
3584 case IrOpcode::kJSEqual:
3585 case IrOpcode::kJSNotEqual:
3586 case IrOpcode::kJSStrictEqual:
3587 case IrOpcode::kJSStrictNotEqual:
3588 case IrOpcode::kJSLessThan:
3589 case IrOpcode::kJSLessThanOrEqual:
3590 case IrOpcode::kJSGreaterThan:
3591 case IrOpcode::kJSGreaterThanOrEqual:
3592 case IrOpcode::kJSUnaryNot:
3593 case IrOpcode::kJSToBoolean:
3594 case IrOpcode::kJSDeleteProperty:
3595 case IrOpcode::kJSHasProperty:
3596 case IrOpcode::kJSInstanceOf:
3597 return input;
3587 default: 3598 default:
3588 break; 3599 break;
3589 } 3600 }
3590 if (NodeProperties::IsTyped(input)) {
3591 Type* upper = NodeProperties::GetBounds(input).upper;
3592 if (upper->Is(Type::Boolean())) return input;
3593 }
3594
3595 return NewNode(javascript()->ToBoolean(), input); 3601 return NewNode(javascript()->ToBoolean(), input);
3596 } 3602 }
3597 3603
3598 3604
3599 Node* AstGraphBuilder::BuildToName(Node* input, BailoutId bailout_id) { 3605 Node* AstGraphBuilder::BuildToName(Node* input, BailoutId bailout_id) {
3600 // TODO(turbofan): Possible optimization is to NOP on name constants. But the 3606 // TODO(turbofan): Possible optimization is to NOP on name constants. But the
3601 // same caveat as with BuildToBoolean applies, and it should be factored out 3607 // same caveat as with BuildToBoolean applies, and it should be factored out
3602 // into a JSOperatorReducer. 3608 // into a JSOperatorReducer.
3603 Node* name = NewNode(javascript()->ToName(), input); 3609 Node* name = NewNode(javascript()->ToName(), input);
3604 PrepareFrameState(name, bailout_id); 3610 PrepareFrameState(name, bailout_id);
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
4061 // Phi does not exist yet, introduce one. 4067 // Phi does not exist yet, introduce one.
4062 value = NewPhi(inputs, value, control); 4068 value = NewPhi(inputs, value, control);
4063 value->ReplaceInput(inputs - 1, other); 4069 value->ReplaceInput(inputs - 1, other);
4064 } 4070 }
4065 return value; 4071 return value;
4066 } 4072 }
4067 4073
4068 } // namespace compiler 4074 } // namespace compiler
4069 } // namespace internal 4075 } // namespace internal
4070 } // namespace v8 4076 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698