[turbofan] Introduce ChangeTaggedToTaggedSigned operator.
We were missing a case for Tagged->TaggedSigned conversions when the input type is known to be Type::SignedSmall. BUG=chromium:687029 R=jarin@chromium.org Review-Url: https://codereview.chromium.org/2666863002 Cr-Commit-Position: refs/heads/master@{#42809}
This commit is contained in:
parent
418c9eca79
commit
68ae57ce1e
@ -633,6 +633,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
|
||||
case IrOpcode::kChangeTaggedToFloat64:
|
||||
result = LowerChangeTaggedToFloat64(node);
|
||||
break;
|
||||
case IrOpcode::kChangeTaggedToTaggedSigned:
|
||||
result = LowerChangeTaggedToTaggedSigned(node);
|
||||
break;
|
||||
case IrOpcode::kTruncateTaggedToBit:
|
||||
result = LowerTruncateTaggedToBit(node);
|
||||
break;
|
||||
@ -1032,6 +1035,27 @@ Node* EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node) {
|
||||
return LowerTruncateTaggedToFloat64(node);
|
||||
}
|
||||
|
||||
Node* EffectControlLinearizer::LowerChangeTaggedToTaggedSigned(Node* node) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
auto if_not_smi = __ MakeDeferredLabel<1>();
|
||||
auto done = __ MakeLabel<2>(MachineRepresentation::kWord32);
|
||||
|
||||
Node* check = ObjectIsSmi(value);
|
||||
__ GotoUnless(check, &if_not_smi);
|
||||
__ Goto(&done, value);
|
||||
|
||||
__ Bind(&if_not_smi);
|
||||
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
|
||||
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
|
||||
vfalse = __ ChangeFloat64ToInt32(vfalse);
|
||||
vfalse = ChangeInt32ToSmi(vfalse);
|
||||
__ Goto(&done, vfalse);
|
||||
|
||||
__ Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
}
|
||||
|
||||
Node* EffectControlLinearizer::LowerTruncateTaggedToFloat64(Node* node) {
|
||||
Node* value = node->InputAt(0);
|
||||
|
||||
|
@ -51,6 +51,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
|
||||
Node* LowerChangeTaggedToBit(Node* node);
|
||||
Node* LowerChangeTaggedToInt32(Node* node);
|
||||
Node* LowerChangeTaggedToUint32(Node* node);
|
||||
Node* LowerChangeTaggedToTaggedSigned(Node* node);
|
||||
Node* LowerCheckBounds(Node* node, Node* frame_state);
|
||||
Node* LowerCheckInternalizedString(Node* node, Node* frame_state);
|
||||
Node* LowerCheckMaps(Node* node, Node* frame_state);
|
||||
|
@ -191,6 +191,7 @@
|
||||
V(ChangeTaggedToInt32) \
|
||||
V(ChangeTaggedToUint32) \
|
||||
V(ChangeTaggedToFloat64) \
|
||||
V(ChangeTaggedToTaggedSigned) \
|
||||
V(ChangeInt31ToTaggedSigned) \
|
||||
V(ChangeInt32ToTagged) \
|
||||
V(ChangeUint32ToTagged) \
|
||||
|
@ -271,9 +271,15 @@ Node* RepresentationChanger::GetTaggedSignedRepresentationFor(
|
||||
return TypeError(node, output_rep, output_type,
|
||||
MachineRepresentation::kTaggedSigned);
|
||||
}
|
||||
} else if (CanBeTaggedPointer(output_rep) &&
|
||||
use_info.type_check() == TypeCheckKind::kSignedSmall) {
|
||||
op = simplified()->CheckedTaggedToTaggedSigned();
|
||||
} else if (CanBeTaggedPointer(output_rep)) {
|
||||
if (use_info.type_check() == TypeCheckKind::kSignedSmall) {
|
||||
op = simplified()->CheckedTaggedToTaggedSigned();
|
||||
} else if (output_type->Is(Type::SignedSmall())) {
|
||||
op = simplified()->ChangeTaggedToTaggedSigned();
|
||||
} else {
|
||||
return TypeError(node, output_rep, output_type,
|
||||
MachineRepresentation::kTaggedSigned);
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kBit &&
|
||||
use_info.type_check() == TypeCheckKind::kSignedSmall) {
|
||||
// TODO(turbofan): Consider adding a Bailout operator that just deopts.
|
||||
|
@ -469,6 +469,7 @@ UnicodeEncoding UnicodeEncodingOf(const Operator* op) {
|
||||
V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0) \
|
||||
V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0) \
|
||||
V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0) \
|
||||
V(ChangeTaggedToTaggedSigned, Operator::kNoProperties, 1, 0) \
|
||||
V(ChangeFloat64ToTagged, Operator::kNoProperties, 1, 0) \
|
||||
V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0) \
|
||||
V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \
|
||||
|
@ -366,6 +366,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
|
||||
const Operator* ChangeTaggedToInt32();
|
||||
const Operator* ChangeTaggedToUint32();
|
||||
const Operator* ChangeTaggedToFloat64();
|
||||
const Operator* ChangeTaggedToTaggedSigned();
|
||||
const Operator* ChangeInt31ToTaggedSigned();
|
||||
const Operator* ChangeInt32ToTagged();
|
||||
const Operator* ChangeUint32ToTagged();
|
||||
|
@ -1012,6 +1012,8 @@ void Verifier::Visitor::Check(Node* node) {
|
||||
// CheckTypeIs(node, to));
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeTaggedToTaggedSigned:
|
||||
break;
|
||||
case IrOpcode::kTruncateTaggedToFloat64: {
|
||||
// NumberOrUndefined /\ Tagged -> Number /\ UntaggedFloat64
|
||||
// TODO(neis): Activate once ChangeRepresentation works in typer.
|
||||
|
14
test/mjsunit/regress/regress-crbug-687029.js
Normal file
14
test/mjsunit/regress/regress-crbug-687029.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
function foo(x) {
|
||||
x = Math.clz32(x);
|
||||
return "a".indexOf("a", x);
|
||||
}
|
||||
foo(1);
|
||||
foo(1);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
foo();
|
Loading…
Reference in New Issue
Block a user