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

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

Issue 1518773003: Turbofan instanceof lowering needs to address proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Missing typer rule. Created 5 years 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/typer.cc » ('j') | 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 670430609f069e582b02d079b84441a316fd1db7..56bc389a295c094b44fb1acebaeab18cc6f6d28a 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -1100,10 +1100,16 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) {
DCHECK_EQ(IrOpcode::kJSInstanceOf, node->opcode());
+ Node* const context = NodeProperties::GetContextInput(node);
+ Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0);
// If deoptimization is disabled, we cannot optimize.
if (!(flags() & kDeoptimizationEnabled)) return NoChange();
+ // If we are in a try block, don't optimize since the runtime call
+ // in the proxy case can throw.
+ if (NodeProperties::IsExceptionalCall(node)) return NoChange();
+
JSBinopReduction r(this, node);
Node* effect = r.effect();
Node* control = r.control();
@@ -1149,6 +1155,24 @@ Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) {
graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
object_map, r.left(), loop);
+ // Check if the lhs is a proxy.
+ Node* map_instance_type = effect = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForMapInstanceType()),
+ loop_object_map, loop_effect, control);
+ Node* is_proxy =
+ graph()->NewNode(machine()->Word32Equal(), map_instance_type,
+ jsgraph()->Uint32Constant(JS_PROXY_TYPE));
+ Node* branch_is_proxy = graph()->NewNode(
+ common()->Branch(BranchHint::kFalse), is_proxy, control);
+ Node* if_is_proxy = graph()->NewNode(common()->IfTrue(), branch_is_proxy);
+ Node* e_is_proxy = effect;
+
+ // If it is, make a runtime call to finish the lowering.
+ Node* bool_result = e_is_proxy = graph()->NewNode(
+ javascript()->CallRuntime(Runtime::kHasInPrototypeChain, 2), r.left(),
+ prototype, context, frame_state, e_is_proxy, if_is_proxy);
+
+ control = graph()->NewNode(common()->IfFalse(), branch_is_proxy);
Node* object_prototype = effect = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForMapPrototype()),
@@ -1184,14 +1208,14 @@ Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) {
loop_object_map->ReplaceInput(1, load_object_map);
loop->ReplaceInput(1, control);
- control =
- graph()->NewNode(common()->Merge(2), if_eq_proto, if_null_proto);
- effect = graph()->NewNode(common()->EffectPhi(2), e_eq_proto,
+ control = graph()->NewNode(common()->Merge(3), if_is_proxy, if_eq_proto,
+ if_null_proto);
+ effect = graph()->NewNode(common()->EffectPhi(3), e_is_proxy, e_eq_proto,
e_null_proto, control);
Node* result = graph()->NewNode(
- common()->Phi(MachineRepresentation::kTagged, 2),
+ common()->Phi(MachineRepresentation::kTagged, 3), bool_result,
jsgraph()->TrueConstant(), jsgraph()->FalseConstant(), control);
if (if_is_smi != nullptr) {
« no previous file with comments | « no previous file | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698