Commit ccbfa918 authored by Georg Neis's avatar Georg Neis Committed by V8 LUCI CQ

[compiler] Slightly generalize type assertions

... to also apply to common integer bitset types.

Bug: v8:11724
Change-Id: I41077488688e924e4235911d3a90e15044c229bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2865747Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Auto-Submit: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74330}
parent 5e29241d
......@@ -27,9 +27,7 @@ Reduction AddTypeAssertionsReducer::Reduce(Node* node) {
visited_.Set(node, true);
Type type = NodeProperties::GetType(node);
if (!type.IsRange()) {
return NoChange();
}
if (!type.CanBeAsserted()) return NoChange();
Node* assertion = graph()->NewNode(simplified()->AssertType(type), node);
NodeProperties::SetType(assertion, type);
......
......@@ -5867,11 +5867,10 @@ Node* EffectControlLinearizer::CallBuiltin(Builtins::Name builtin,
Node* EffectControlLinearizer::LowerAssertType(Node* node) {
DCHECK_EQ(node->opcode(), IrOpcode::kAssertType);
Type type = OpParameter<Type>(node->op());
DCHECK(type.IsRange());
auto range = type.AsRange();
CHECK(type.CanBeAsserted());
Node* const input = node->InputAt(0);
Node* const min = __ NumberConstant(range->Min());
Node* const max = __ NumberConstant(range->Max());
Node* const min = __ NumberConstant(type.Min());
Node* const max = __ NumberConstant(type.Max());
CallBuiltin(Builtins::kCheckNumberInRange, node->op()->properties(), input,
min, max, __ SmiConstant(node->id()));
return input;
......
......@@ -413,6 +413,10 @@ class V8_EXPORT_PRIVATE Type {
(Is(Type::PlainNumber()) && Min() == Max());
}
bool CanBeAsserted() const {
return IsRange() || (Is(Type::Integral32()) && !IsNone());
}
const HeapConstantType* AsHeapConstant() const;
const OtherNumberConstantType* AsOtherNumberConstant() const;
const RangeType* AsRange() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment