From dfca935138dd29aebb10d13fd7ccf9d1c9f50c76 Mon Sep 17 00:00:00 2001 From: Igor Sheludko Date: Wed, 8 Mar 2017 20:49:53 +0100 Subject: [PATCH] [turbofan] Make instanceof optimization constant-field-tracking compatible. BUG=v8:5495 Change-Id: I49e478f5d6b12a3b65f69fa8120a768f2dbd98f3 Reviewed-on: https://chromium-review.googlesource.com/451323 Reviewed-by: Jaroslav Sevcik Commit-Queue: Igor Sheludko Cr-Commit-Position: refs/heads/master@{#43753} --- .../js-native-context-specialization.cc | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc index fb8e53b034..c64060b779 100644 --- a/src/compiler/js-native-context-specialization.cc +++ b/src/compiler/js-native-context-specialization.cc @@ -217,21 +217,37 @@ Reduction JSNativeContextSpecialization::ReduceJSInstanceOf(Node* node) { Reduction const reduction = ReduceJSOrdinaryHasInstance(node); return reduction.Changed() ? reduction : Changed(node); } - } else if (access_info.IsDataConstant()) { - DCHECK(access_info.constant()->IsCallable()); - + } else if (access_info.IsDataConstant() || + access_info.IsDataConstantField()) { // Determine actual holder and perform prototype chain checks. Handle holder; if (access_info.holder().ToHandle(&holder)) { AssumePrototypesStable(access_info.receiver_maps(), holder); + } else { + holder = receiver; } + Handle constant; + if (access_info.IsDataConstant()) { + DCHECK(!FLAG_track_constant_fields); + constant = access_info.constant(); + } else { + DCHECK(FLAG_track_constant_fields); + DCHECK(access_info.IsDataConstantField()); + // The value must be callable therefore tagged. + DCHECK(CanBeTaggedPointer(access_info.field_representation())); + FieldIndex field_index = access_info.field_index(); + constant = JSObject::FastPropertyAt(holder, Representation::Tagged(), + field_index); + } + DCHECK(constant->IsCallable()); + // Monomorphic property access. effect = BuildCheckMaps(constructor, effect, control, access_info.receiver_maps()); // Call the @@hasInstance handler. - Node* target = jsgraph()->Constant(access_info.constant()); + Node* target = jsgraph()->Constant(constant); node->InsertInput(graph()->zone(), 0, target); node->ReplaceInput(1, constructor); node->ReplaceInput(2, object); @@ -1333,6 +1349,7 @@ JSNativeContextSpecialization::BuildPropertyAccess( DCHECK_EQ(AccessMode::kLoad, access_mode); value = jsgraph()->UndefinedConstant(); } else if (access_info.IsDataConstant()) { + DCHECK(!FLAG_track_constant_fields); Node* constant_value = jsgraph()->Constant(access_info.constant()); if (access_mode == AccessMode::kStore) { Node* check = graph()->NewNode(simplified()->ReferenceEqual(), value,