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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 2943293002: [turbofan] Do constant-folding of JSHasInPrototypeChain early. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index c35691918c35e71a61786c2e8337b8f8a55589cb..b4c9332c1739662ba41e5ea6a34b44e1937a2b5b 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -1390,63 +1390,11 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
return NoChange();
}
-JSTypedLowering::InferHasInPrototypeChainResult
-JSTypedLowering::InferHasInPrototypeChain(Node* receiver, Node* effect,
- Handle<HeapObject> prototype) {
- ZoneHandleSet<Map> receiver_maps;
- NodeProperties::InferReceiverMapsResult result =
- NodeProperties::InferReceiverMaps(receiver, effect, &receiver_maps);
- if (result == NodeProperties::kNoReceiverMaps) return kMayBeInPrototypeChain;
-
- // Check if either all or none of the {receiver_maps} have the given
- // {prototype} in their prototype chain.
- bool all = true;
- bool none = true;
- for (size_t i = 0; i < receiver_maps.size(); ++i) {
- Handle<Map> receiver_map = receiver_maps[i];
- if (receiver_map->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE) {
- return kMayBeInPrototypeChain;
- }
- if (result == NodeProperties::kUnreliableReceiverMaps) {
- // In case of an unreliable {result} we need to ensure that all
- // {receiver_maps} are stable, because otherwise we cannot trust
- // the {receiver_maps} information, since arbitrary side-effects
- // may have happened.
- if (!receiver_map->is_stable()) {
- return kMayBeInPrototypeChain;
- }
- }
- for (PrototypeIterator j(receiver_map);; j.Advance()) {
- if (j.IsAtEnd()) {
- all = false;
- break;
- }
- Handle<HeapObject> const current =
- PrototypeIterator::GetCurrent<HeapObject>(j);
- if (current.is_identical_to(prototype)) {
- none = false;
- break;
- }
- if (!current->map()->is_stable() ||
- current->map()->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE) {
- return kMayBeInPrototypeChain;
- }
- }
- }
- DCHECK_IMPLIES(all, !none);
- DCHECK_IMPLIES(none, !all);
-
- if (all) return kIsInPrototypeChain;
- if (none) return kIsNotInPrototypeChain;
- return kMayBeInPrototypeChain;
-}
-
Reduction JSTypedLowering::ReduceJSHasInPrototypeChain(Node* node) {
DCHECK_EQ(IrOpcode::kJSHasInPrototypeChain, node->opcode());
Node* value = NodeProperties::GetValueInput(node, 0);
Type* value_type = NodeProperties::GetType(value);
Node* prototype = NodeProperties::GetValueInput(node, 1);
- Type* prototype_type = NodeProperties::GetType(prototype);
Node* context = NodeProperties::GetContextInput(node);
Node* frame_state = NodeProperties::GetFrameStateInput(node);
Node* effect = NodeProperties::GetEffectInput(node);
@@ -1460,18 +1408,6 @@ Reduction JSTypedLowering::ReduceJSHasInPrototypeChain(Node* node) {
return Replace(value);
}
- // Check if we can constant-fold the prototype chain walk
- // for the given {value} and the {prototype}.
- if (prototype_type->IsHeapConstant()) {
- InferHasInPrototypeChainResult result = InferHasInPrototypeChain(
- value, effect, prototype_type->AsHeapConstant()->Value());
- if (result != kMayBeInPrototypeChain) {
- Node* value = jsgraph()->BooleanConstant(result == kIsInPrototypeChain);
- ReplaceWithValue(node, value, effect, control);
- return Replace(value);
- }
- }
-
Node* check0 = graph()->NewNode(simplified()->ObjectIsSmi(), value);
Node* branch0 =
graph()->NewNode(common()->Branch(BranchHint::kFalse), check0, control);
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698