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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2342283002: [turbofan] Constant-fold some ObjectIs checks based on feedback type. (Closed)
Patch Set: REBASE Created 4 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index 86cae22269b2c0482f4977c50b50ec0d9097d92c..fc7dcf8f939344dba37a79bb1d7eaf4a45611763 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -911,6 +911,21 @@ class RepresentationSelector {
}
}
+ void VisitObjectIs(Node* node, Type* type, SimplifiedLowering* lowering) {
+ Type* const input_type = TypeOf(node->InputAt(0));
+ if (input_type->Is(type)) {
+ VisitUnop(node, UseInfo::None(), MachineRepresentation::kBit);
Jarin 2016/09/16 15:37:11 Does it really buy you anything to send UseInfo::N
Benedikt Meurer 2016/09/16 17:14:32 I guess that would work. Do you want me to change
+ if (lower()) {
+ DeferReplacement(node, lowering->jsgraph()->Int32Constant(1));
+ }
+ } else {
+ VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
+ if (lower() && !input_type->Maybe(type)) {
+ DeferReplacement(node, lowering->jsgraph()->Int32Constant(0));
+ }
+ }
+ }
+
void VisitCall(Node* node, SimplifiedLowering* lowering) {
const CallDescriptor* desc = CallDescriptorOf(node->op());
int params = static_cast<int>(desc->ParameterCount());
@@ -2339,12 +2354,32 @@ class RepresentationSelector {
}
return;
}
- case IrOpcode::kObjectIsCallable:
- case IrOpcode::kObjectIsNumber:
- case IrOpcode::kObjectIsReceiver:
- case IrOpcode::kObjectIsSmi:
- case IrOpcode::kObjectIsString:
- case IrOpcode::kObjectIsUndetectable:
+ case IrOpcode::kObjectIsCallable: {
+ // TODO(turbofan): Add Type::Callable to optimize this?
+ VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
+ return;
+ }
+ case IrOpcode::kObjectIsNumber: {
+ VisitObjectIs(node, Type::Number(), lowering);
+ return;
+ }
+ case IrOpcode::kObjectIsReceiver: {
+ VisitObjectIs(node, Type::Receiver(), lowering);
+ return;
+ }
+ case IrOpcode::kObjectIsSmi: {
+ // TODO(turbofan): Optimize based on input representation.
+ VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
+ return;
+ }
+ case IrOpcode::kObjectIsString: {
+ VisitObjectIs(node, Type::String(), lowering);
+ return;
+ }
+ case IrOpcode::kObjectIsUndetectable: {
+ VisitObjectIs(node, Type::Undetectable(), lowering);
+ return;
+ }
case IrOpcode::kArrayBufferWasNeutered: {
VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
return;
« 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