Commit 36426ab7 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Remove unsound SeqString types.

A value of type OtherSeqString can change its type to OtherNonSeqString
via inplace internalization (and redirection via a ThinString). This can
lead to out of bounds memory accesses and generally correctness bugs, as
seen with crbug.com/822284.

This change might affect performance in some cases, and we'll need to
evaluate whether it's worth spending cycles on adding another mechanism
that leverages the sequential string information in a safe way on a case
by case basis.

Bug: chromium:822284
Change-Id: I0de77ec089a774236555f38c365f7548f454edfe
Reviewed-on: https://chromium-review.googlesource.com/966021Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51975}
parent 9ee2b916
...@@ -682,9 +682,6 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, ...@@ -682,9 +682,6 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kCheckString: case IrOpcode::kCheckString:
result = LowerCheckString(node, frame_state); result = LowerCheckString(node, frame_state);
break; break;
case IrOpcode::kCheckSeqString:
result = LowerCheckSeqString(node, frame_state);
break;
case IrOpcode::kCheckInternalizedString: case IrOpcode::kCheckInternalizedString:
result = LowerCheckInternalizedString(node, frame_state); result = LowerCheckInternalizedString(node, frame_state);
break; break;
...@@ -845,15 +842,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, ...@@ -845,15 +842,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kStringCharCodeAt: case IrOpcode::kStringCharCodeAt:
result = LowerStringCharCodeAt(node); result = LowerStringCharCodeAt(node);
break; break;
case IrOpcode::kSeqStringCharCodeAt:
result = LowerSeqStringCharCodeAt(node);
break;
case IrOpcode::kStringCodePointAt: case IrOpcode::kStringCodePointAt:
result = LowerStringCodePointAt(node, UnicodeEncodingOf(node->op())); result = LowerStringCodePointAt(node, UnicodeEncodingOf(node->op()));
break; break;
case IrOpcode::kSeqStringCodePointAt:
result = LowerSeqStringCodePointAt(node, UnicodeEncodingOf(node->op()));
break;
case IrOpcode::kStringToLowerCaseIntl: case IrOpcode::kStringToLowerCaseIntl:
result = LowerStringToLowerCaseIntl(node); result = LowerStringToLowerCaseIntl(node);
break; break;
...@@ -1497,24 +1488,6 @@ Node* EffectControlLinearizer::LowerCheckString(Node* node, Node* frame_state) { ...@@ -1497,24 +1488,6 @@ Node* EffectControlLinearizer::LowerCheckString(Node* node, Node* frame_state) {
return value; return value;
} }
Node* EffectControlLinearizer::LowerCheckSeqString(Node* node,
Node* frame_state) {
Node* value = node->InputAt(0);
Node* value_map = __ LoadField(AccessBuilder::ForMap(), value);
Node* value_instance_type =
__ LoadField(AccessBuilder::ForMapInstanceType(), value_map);
Node* check = __ Word32Equal(
__ Word32And(
value_instance_type,
__ Int32Constant(kStringRepresentationMask | kIsNotStringMask)),
__ Int32Constant(kSeqStringTag | kStringTag));
__ DeoptimizeIfNot(DeoptimizeReason::kWrongInstanceType, VectorSlotPair(),
check, frame_state);
return value;
}
Node* EffectControlLinearizer::LowerCheckInternalizedString(Node* node, Node* EffectControlLinearizer::LowerCheckInternalizedString(Node* node,
Node* frame_state) { Node* frame_state) {
Node* value = node->InputAt(0); Node* value = node->InputAt(0);
...@@ -2848,87 +2821,6 @@ Node* EffectControlLinearizer::LoadFromSeqString(Node* receiver, Node* position, ...@@ -2848,87 +2821,6 @@ Node* EffectControlLinearizer::LoadFromSeqString(Node* receiver, Node* position,
return done.PhiAt(0); return done.PhiAt(0);
} }
Node* EffectControlLinearizer::LowerSeqStringCharCodeAt(Node* node) {
Node* receiver = node->InputAt(0);
Node* position = node->InputAt(1);
Node* map = __ LoadField(AccessBuilder::ForMap(), receiver);
Node* instance_type = __ LoadField(AccessBuilder::ForMapInstanceType(), map);
Node* is_one_byte = __ Word32Equal(
__ Word32And(instance_type, __ Int32Constant(kStringEncodingMask)),
__ Int32Constant(kOneByteStringTag));
return LoadFromSeqString(receiver, position, is_one_byte);
}
Node* EffectControlLinearizer::LowerSeqStringCodePointAt(
Node* node, UnicodeEncoding encoding) {
Node* receiver = node->InputAt(0);
Node* position = node->InputAt(1);
Node* map = __ LoadField(AccessBuilder::ForMap(), receiver);
Node* instance_type = __ LoadField(AccessBuilder::ForMapInstanceType(), map);
Node* is_one_byte = __ Word32Equal(
__ Word32And(instance_type, __ Int32Constant(kStringEncodingMask)),
__ Int32Constant(kOneByteStringTag));
Node* first_char_code = LoadFromSeqString(receiver, position, is_one_byte);
auto return_result = __ MakeLabel(MachineRepresentation::kWord32);
// Check if first character code is outside of interval [0xD800, 0xDBFF].
Node* first_out =
__ Word32Equal(__ Word32And(first_char_code, __ Int32Constant(0xFC00)),
__ Int32Constant(0xD800));
// Return first character code.
__ GotoIfNot(first_out, &return_result, first_char_code);
// Check if position + 1 is still in range.
Node* length = ChangeSmiToInt32(
__ LoadField(AccessBuilder::ForStringLength(), receiver));
Node* next_position = __ Int32Add(position, __ Int32Constant(1));
Node* next_position_in_range = __ Int32LessThan(next_position, length);
__ GotoIfNot(next_position_in_range, &return_result, first_char_code);
// Load second character code.
Node* second_char_code =
LoadFromSeqString(receiver, next_position, is_one_byte);
// Check if second character code is outside of interval [0xDC00, 0xDFFF].
Node* second_out =
__ Word32Equal(__ Word32And(second_char_code, __ Int32Constant(0xFC00)),
__ Int32Constant(0xDC00));
__ GotoIfNot(second_out, &return_result, first_char_code);
Node* result;
switch (encoding) {
case UnicodeEncoding::UTF16:
result = __ Word32Or(
// Need to swap the order for big-endian platforms
#if V8_TARGET_BIG_ENDIAN
__ Word32Shl(first_char_code, __ Int32Constant(16)),
second_char_code);
#else
__ Word32Shl(second_char_code, __ Int32Constant(16)),
first_char_code);
#endif
break;
case UnicodeEncoding::UTF32: {
// Convert UTF16 surrogate pair into |word32| code point, encoded as
// UTF32.
Node* surrogate_offset =
__ Int32Constant(0x10000 - (0xD800 << 10) - 0xDC00);
// (lead << 10) + trail + SURROGATE_OFFSET
result = __ Int32Add(__ Word32Shl(first_char_code, __ Int32Constant(10)),
__ Int32Add(second_char_code, surrogate_offset));
break;
}
}
__ Goto(&return_result, result);
__ Bind(&return_result);
return return_result.PhiAt(0);
}
Node* EffectControlLinearizer::LowerStringFromCharCode(Node* node) { Node* EffectControlLinearizer::LowerStringFromCharCode(Node* node) {
Node* value = node->InputAt(0); Node* value = node->InputAt(0);
Node* code = __ Word32And(value, __ Uint32Constant(0xFFFF)); Node* code = __ Word32And(value, __ Uint32Constant(0xFFFF));
......
...@@ -63,7 +63,6 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer { ...@@ -63,7 +63,6 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Node* LowerCheckNumber(Node* node, Node* frame_state); Node* LowerCheckNumber(Node* node, Node* frame_state);
Node* LowerCheckReceiver(Node* node, Node* frame_state); Node* LowerCheckReceiver(Node* node, Node* frame_state);
Node* LowerCheckString(Node* node, Node* frame_state); Node* LowerCheckString(Node* node, Node* frame_state);
Node* LowerCheckSeqString(Node* node, Node* frame_state);
Node* LowerCheckSymbol(Node* node, Node* frame_state); Node* LowerCheckSymbol(Node* node, Node* frame_state);
void LowerCheckIf(Node* node, Node* frame_state); void LowerCheckIf(Node* node, Node* frame_state);
Node* LowerCheckedInt32Add(Node* node, Node* frame_state); Node* LowerCheckedInt32Add(Node* node, Node* frame_state);
...@@ -117,9 +116,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer { ...@@ -117,9 +116,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Node* LowerDeadValue(Node* node); Node* LowerDeadValue(Node* node);
Node* LowerStringToNumber(Node* node); Node* LowerStringToNumber(Node* node);
Node* LowerStringCharCodeAt(Node* node); Node* LowerStringCharCodeAt(Node* node);
Node* LowerSeqStringCharCodeAt(Node* node);
Node* LowerStringCodePointAt(Node* node, UnicodeEncoding encoding); Node* LowerStringCodePointAt(Node* node, UnicodeEncoding encoding);
Node* LowerSeqStringCodePointAt(Node* node, UnicodeEncoding encoding);
Node* LowerStringToLowerCaseIntl(Node* node); Node* LowerStringToLowerCaseIntl(Node* node);
Node* LowerStringToUpperCaseIntl(Node* node); Node* LowerStringToUpperCaseIntl(Node* node);
Node* LowerStringFromCharCode(Node* node); Node* LowerStringFromCharCode(Node* node);
......
...@@ -589,7 +589,6 @@ bool NodeProperties::CanBeNullOrUndefined(Node* receiver, Node* effect) { ...@@ -589,7 +589,6 @@ bool NodeProperties::CanBeNullOrUndefined(Node* receiver, Node* effect) {
switch (receiver->opcode()) { switch (receiver->opcode()) {
case IrOpcode::kCheckInternalizedString: case IrOpcode::kCheckInternalizedString:
case IrOpcode::kCheckNumber: case IrOpcode::kCheckNumber:
case IrOpcode::kCheckSeqString:
case IrOpcode::kCheckSmi: case IrOpcode::kCheckSmi:
case IrOpcode::kCheckString: case IrOpcode::kCheckString:
case IrOpcode::kCheckSymbol: case IrOpcode::kCheckSymbol:
......
...@@ -343,9 +343,7 @@ ...@@ -343,9 +343,7 @@
V(BooleanNot) \ V(BooleanNot) \
V(StringToNumber) \ V(StringToNumber) \
V(StringCharCodeAt) \ V(StringCharCodeAt) \
V(SeqStringCharCodeAt) \
V(StringCodePointAt) \ V(StringCodePointAt) \
V(SeqStringCodePointAt) \
V(StringFromCharCode) \ V(StringFromCharCode) \
V(StringFromCodePoint) \ V(StringFromCodePoint) \
V(StringIndexOf) \ V(StringIndexOf) \
...@@ -360,7 +358,6 @@ ...@@ -360,7 +358,6 @@
V(CheckInternalizedString) \ V(CheckInternalizedString) \
V(CheckReceiver) \ V(CheckReceiver) \
V(CheckString) \ V(CheckString) \
V(CheckSeqString) \
V(CheckSymbol) \ V(CheckSymbol) \
V(CheckSmi) \ V(CheckSmi) \
V(CheckHeapObject) \ V(CheckHeapObject) \
......
...@@ -47,32 +47,17 @@ bool HasOnlyNumberMaps(MapHandles const& maps) { ...@@ -47,32 +47,17 @@ bool HasOnlyNumberMaps(MapHandles const& maps) {
return true; return true;
} }
bool HasOnlySequentialStringMaps(MapHandles const& maps) {
for (auto map : maps) {
if (!map->IsStringMap()) return false;
if (!StringShape(map->instance_type()).IsSequential()) {
return false;
}
}
return true;
}
} // namespace } // namespace
bool PropertyAccessBuilder::TryBuildStringCheck(MapHandles const& maps, bool PropertyAccessBuilder::TryBuildStringCheck(MapHandles const& maps,
Node** receiver, Node** effect, Node** receiver, Node** effect,
Node* control) { Node* control) {
if (HasOnlyStringMaps(maps)) { if (HasOnlyStringMaps(maps)) {
if (HasOnlySequentialStringMaps(maps)) { // Monormorphic string access (ignoring the fact that there are multiple
*receiver = *effect = graph()->NewNode(simplified()->CheckSeqString(), // String maps).
*receiver, *effect, control); *receiver = *effect =
} else { graph()->NewNode(simplified()->CheckString(VectorSlotPair()), *receiver,
// Monormorphic string access (ignoring the fact that there are multiple *effect, control);
// String maps).
*receiver = *effect =
graph()->NewNode(simplified()->CheckString(VectorSlotPair()),
*receiver, *effect, control);
}
return true; return true;
} }
return false; return false;
......
...@@ -29,7 +29,6 @@ Reduction RedundancyElimination::Reduce(Node* node) { ...@@ -29,7 +29,6 @@ Reduction RedundancyElimination::Reduce(Node* node) {
case IrOpcode::kCheckNotTaggedHole: case IrOpcode::kCheckNotTaggedHole:
case IrOpcode::kCheckNumber: case IrOpcode::kCheckNumber:
case IrOpcode::kCheckReceiver: case IrOpcode::kCheckReceiver:
case IrOpcode::kCheckSeqString:
case IrOpcode::kCheckSmi: case IrOpcode::kCheckSmi:
case IrOpcode::kCheckString: case IrOpcode::kCheckString:
case IrOpcode::kCheckSymbol: case IrOpcode::kCheckSymbol:
......
...@@ -2350,34 +2350,14 @@ class RepresentationSelector { ...@@ -2350,34 +2350,14 @@ class RepresentationSelector {
MachineRepresentation::kTaggedPointer); MachineRepresentation::kTaggedPointer);
} }
case IrOpcode::kStringCharCodeAt: { case IrOpcode::kStringCharCodeAt: {
Type* string_type = TypeOf(node->InputAt(0)); return VisitBinop(node, UseInfo::AnyTagged(),
if (string_type->Is(Type::SeqString())) { UseInfo::TruncatingWord32(),
VisitBinop(node, UseInfo::AnyTagged(), UseInfo::TruncatingWord32(), MachineRepresentation::kWord32);
MachineRepresentation::kWord32);
if (lower()) {
NodeProperties::ChangeOp(node, simplified()->SeqStringCharCodeAt());
}
} else {
VisitBinop(node, UseInfo::AnyTagged(), UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32);
}
return;
} }
case IrOpcode::kStringCodePointAt: { case IrOpcode::kStringCodePointAt: {
Type* string_type = TypeOf(node->InputAt(0)); return VisitBinop(node, UseInfo::AnyTagged(),
if (string_type->Is(Type::SeqString())) { UseInfo::TruncatingWord32(),
VisitBinop(node, UseInfo::AnyTagged(), UseInfo::TruncatingWord32(), MachineRepresentation::kTaggedSigned);
MachineRepresentation::kWord32);
if (lower()) {
UnicodeEncoding encoding = UnicodeEncodingOf(node->op());
NodeProperties::ChangeOp(
node, simplified()->SeqStringCodePointAt(encoding));
}
} else {
VisitBinop(node, UseInfo::AnyTagged(), UseInfo::TruncatingWord32(),
MachineRepresentation::kTaggedSigned);
}
return;
} }
case IrOpcode::kStringFromCharCode: { case IrOpcode::kStringFromCharCode: {
VisitUnop(node, UseInfo::TruncatingWord32(), VisitUnop(node, UseInfo::TruncatingWord32(),
...@@ -2508,17 +2488,6 @@ class RepresentationSelector { ...@@ -2508,17 +2488,6 @@ class RepresentationSelector {
VisitCheck(node, Type::Symbol(), lowering); VisitCheck(node, Type::Symbol(), lowering);
return; return;
} }
case IrOpcode::kCheckSeqString: {
if (InputIs(node, Type::SeqString())) {
VisitUnop(node, UseInfo::AnyTagged(),
MachineRepresentation::kTaggedPointer);
if (lower()) DeferReplacement(node, node->InputAt(0));
} else {
VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(),
MachineRepresentation::kTaggedPointer);
}
return;
}
case IrOpcode::kAllocate: { case IrOpcode::kAllocate: {
ProcessInput(node, 0, UseInfo::TruncatingWord32()); ProcessInput(node, 0, UseInfo::TruncatingWord32());
......
...@@ -551,8 +551,7 @@ Type* AllocateTypeOf(const Operator* op) { ...@@ -551,8 +551,7 @@ Type* AllocateTypeOf(const Operator* op) {
UnicodeEncoding UnicodeEncodingOf(const Operator* op) { UnicodeEncoding UnicodeEncodingOf(const Operator* op) {
DCHECK(op->opcode() == IrOpcode::kStringFromCodePoint || DCHECK(op->opcode() == IrOpcode::kStringFromCodePoint ||
op->opcode() == IrOpcode::kStringCodePointAt || op->opcode() == IrOpcode::kStringCodePointAt);
op->opcode() == IrOpcode::kSeqStringCodePointAt);
return OpParameter<UnicodeEncoding>(op); return OpParameter<UnicodeEncoding>(op);
} }
...@@ -722,7 +721,6 @@ bool operator==(CheckMinusZeroParameters const& lhs, ...@@ -722,7 +721,6 @@ bool operator==(CheckMinusZeroParameters const& lhs,
#define EFFECT_DEPENDENT_OP_LIST(V) \ #define EFFECT_DEPENDENT_OP_LIST(V) \
V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \ V(StringCharCodeAt, Operator::kNoProperties, 2, 1) \
V(SeqStringCharCodeAt, Operator::kNoProperties, 2, 1) \
V(StringSubstring, Operator::kNoProperties, 3, 1) V(StringSubstring, Operator::kNoProperties, 3, 1)
#define SPECULATIVE_NUMBER_BINOP_LIST(V) \ #define SPECULATIVE_NUMBER_BINOP_LIST(V) \
...@@ -738,7 +736,6 @@ bool operator==(CheckMinusZeroParameters const& lhs, ...@@ -738,7 +736,6 @@ bool operator==(CheckMinusZeroParameters const& lhs,
V(CheckInternalizedString, 1, 1) \ V(CheckInternalizedString, 1, 1) \
V(CheckNotTaggedHole, 1, 1) \ V(CheckNotTaggedHole, 1, 1) \
V(CheckReceiver, 1, 1) \ V(CheckReceiver, 1, 1) \
V(CheckSeqString, 1, 1) \
V(CheckSymbol, 1, 1) \ V(CheckSymbol, 1, 1) \
V(CheckedInt32Add, 2, 1) \ V(CheckedInt32Add, 2, 1) \
V(CheckedInt32Div, 2, 1) \ V(CheckedInt32Div, 2, 1) \
...@@ -832,20 +829,6 @@ struct SimplifiedOperatorGlobalCache final { ...@@ -832,20 +829,6 @@ struct SimplifiedOperatorGlobalCache final {
StringCodePointAtOperator<UnicodeEncoding::UTF32> StringCodePointAtOperator<UnicodeEncoding::UTF32>
kStringCodePointAtOperatorUTF32; kStringCodePointAtOperatorUTF32;
template <UnicodeEncoding kEncoding>
struct SeqStringCodePointAtOperator final
: public Operator1<UnicodeEncoding> {
SeqStringCodePointAtOperator()
: Operator1<UnicodeEncoding>(IrOpcode::kSeqStringCodePointAt,
Operator::kFoldable | Operator::kNoThrow,
"SeqStringCodePointAt", 2, 1, 1, 1, 1, 0,
kEncoding) {}
};
SeqStringCodePointAtOperator<UnicodeEncoding::UTF16>
kSeqStringCodePointAtOperatorUTF16;
SeqStringCodePointAtOperator<UnicodeEncoding::UTF32>
kSeqStringCodePointAtOperatorUTF32;
template <UnicodeEncoding kEncoding> template <UnicodeEncoding kEncoding>
struct StringFromCodePointOperator final : public Operator1<UnicodeEncoding> { struct StringFromCodePointOperator final : public Operator1<UnicodeEncoding> {
StringFromCodePointOperator() StringFromCodePointOperator()
...@@ -1461,17 +1444,6 @@ const Operator* SimplifiedOperatorBuilder::StringCodePointAt( ...@@ -1461,17 +1444,6 @@ const Operator* SimplifiedOperatorBuilder::StringCodePointAt(
UNREACHABLE(); UNREACHABLE();
} }
const Operator* SimplifiedOperatorBuilder::SeqStringCodePointAt(
UnicodeEncoding encoding) {
switch (encoding) {
case UnicodeEncoding::UTF16:
return &cache_.kSeqStringCodePointAtOperatorUTF16;
case UnicodeEncoding::UTF32:
return &cache_.kSeqStringCodePointAtOperatorUTF32;
}
UNREACHABLE();
}
const Operator* SimplifiedOperatorBuilder::StringFromCodePoint( const Operator* SimplifiedOperatorBuilder::StringFromCodePoint(
UnicodeEncoding encoding) { UnicodeEncoding encoding) {
switch (encoding) { switch (encoding) {
......
...@@ -523,9 +523,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final ...@@ -523,9 +523,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* StringLessThan(); const Operator* StringLessThan();
const Operator* StringLessThanOrEqual(); const Operator* StringLessThanOrEqual();
const Operator* StringCharCodeAt(); const Operator* StringCharCodeAt();
const Operator* SeqStringCharCodeAt();
const Operator* StringCodePointAt(UnicodeEncoding encoding); const Operator* StringCodePointAt(UnicodeEncoding encoding);
const Operator* SeqStringCodePointAt(UnicodeEncoding encoding);
const Operator* StringFromCharCode(); const Operator* StringFromCharCode();
const Operator* StringFromCodePoint(UnicodeEncoding encoding); const Operator* StringFromCodePoint(UnicodeEncoding encoding);
const Operator* StringIndexOf(); const Operator* StringIndexOf();
...@@ -578,7 +576,6 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final ...@@ -578,7 +576,6 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* CheckNotTaggedHole(); const Operator* CheckNotTaggedHole();
const Operator* CheckNumber(const VectorSlotPair& feedback); const Operator* CheckNumber(const VectorSlotPair& feedback);
const Operator* CheckReceiver(); const Operator* CheckReceiver();
const Operator* CheckSeqString();
const Operator* CheckSmi(const VectorSlotPair& feedback); const Operator* CheckSmi(const VectorSlotPair& feedback);
const Operator* CheckString(const VectorSlotPair& feedback); const Operator* CheckString(const VectorSlotPair& feedback);
const Operator* CheckSymbol(); const Operator* CheckSymbol();
......
...@@ -86,8 +86,6 @@ Reduction TypedOptimization::Reduce(Node* node) { ...@@ -86,8 +86,6 @@ Reduction TypedOptimization::Reduce(Node* node) {
return ReduceCheckNumber(node); return ReduceCheckNumber(node);
case IrOpcode::kCheckString: case IrOpcode::kCheckString:
return ReduceCheckString(node); return ReduceCheckString(node);
case IrOpcode::kCheckSeqString:
return ReduceCheckSeqString(node);
case IrOpcode::kCheckEqualsInternalizedString: case IrOpcode::kCheckEqualsInternalizedString:
return ReduceCheckEqualsInternalizedString(node); return ReduceCheckEqualsInternalizedString(node);
case IrOpcode::kCheckEqualsSymbol: case IrOpcode::kCheckEqualsSymbol:
...@@ -216,16 +214,6 @@ Reduction TypedOptimization::ReduceCheckString(Node* node) { ...@@ -216,16 +214,6 @@ Reduction TypedOptimization::ReduceCheckString(Node* node) {
return NoChange(); return NoChange();
} }
Reduction TypedOptimization::ReduceCheckSeqString(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0);
Type* const input_type = NodeProperties::GetType(input);
if (input_type->Is(Type::SeqString())) {
ReplaceWithValue(node, input);
return Replace(input);
}
return NoChange();
}
Reduction TypedOptimization::ReduceCheckEqualsInternalizedString(Node* node) { Reduction TypedOptimization::ReduceCheckEqualsInternalizedString(Node* node) {
Node* const exp = NodeProperties::GetValueInput(node, 0); Node* const exp = NodeProperties::GetValueInput(node, 0);
Type* const exp_type = NodeProperties::GetType(exp); Type* const exp_type = NodeProperties::GetType(exp);
......
...@@ -41,7 +41,6 @@ class V8_EXPORT_PRIVATE TypedOptimization final ...@@ -41,7 +41,6 @@ class V8_EXPORT_PRIVATE TypedOptimization final
Reduction ReduceCheckMaps(Node* node); Reduction ReduceCheckMaps(Node* node);
Reduction ReduceCheckNumber(Node* node); Reduction ReduceCheckNumber(Node* node);
Reduction ReduceCheckString(Node* node); Reduction ReduceCheckString(Node* node);
Reduction ReduceCheckSeqString(Node* node);
Reduction ReduceCheckEqualsInternalizedString(Node* node); Reduction ReduceCheckEqualsInternalizedString(Node* node);
Reduction ReduceCheckEqualsSymbol(Node* node); Reduction ReduceCheckEqualsSymbol(Node* node);
Reduction ReduceLoadField(Node* node); Reduction ReduceLoadField(Node* node);
......
...@@ -1982,18 +1982,10 @@ Type* Typer::Visitor::TypeStringCharCodeAt(Node* node) { ...@@ -1982,18 +1982,10 @@ Type* Typer::Visitor::TypeStringCharCodeAt(Node* node) {
return typer_->cache_.kUint16; return typer_->cache_.kUint16;
} }
Type* Typer::Visitor::TypeSeqStringCharCodeAt(Node* node) {
return typer_->cache_.kUint16;
}
Type* Typer::Visitor::TypeStringCodePointAt(Node* node) { Type* Typer::Visitor::TypeStringCodePointAt(Node* node) {
return Type::Range(0.0, String::kMaxCodePoint, zone()); return Type::Range(0.0, String::kMaxCodePoint, zone());
} }
Type* Typer::Visitor::TypeSeqStringCodePointAt(Node* node) {
return Type::Range(0.0, String::kMaxCodePoint, zone());
}
Type* Typer::Visitor::TypeStringFromCharCode(Node* node) { Type* Typer::Visitor::TypeStringFromCharCode(Node* node) {
return TypeUnaryOp(node, StringFromCharCodeTyper); return TypeUnaryOp(node, StringFromCharCodeTyper);
} }
...@@ -2070,11 +2062,6 @@ Type* Typer::Visitor::TypeCheckString(Node* node) { ...@@ -2070,11 +2062,6 @@ Type* Typer::Visitor::TypeCheckString(Node* node) {
return Type::Intersect(arg, Type::String(), zone()); return Type::Intersect(arg, Type::String(), zone());
} }
Type* Typer::Visitor::TypeCheckSeqString(Node* node) {
Type* arg = Operand(node, 0);
return Type::Intersect(arg, Type::SeqString(), zone());
}
Type* Typer::Visitor::TypeCheckSymbol(Node* node) { Type* Typer::Visitor::TypeCheckSymbol(Node* node) {
Type* arg = Operand(node, 0); Type* arg = Operand(node, 0);
return Type::Intersect(arg, Type::Symbol(), zone()); return Type::Intersect(arg, Type::Symbol(), zone());
...@@ -2244,7 +2231,7 @@ Type* Typer::Visitor::TypeNewArgumentsElements(Node* node) { ...@@ -2244,7 +2231,7 @@ Type* Typer::Visitor::TypeNewArgumentsElements(Node* node) {
} }
Type* Typer::Visitor::TypeNewConsString(Node* node) { Type* Typer::Visitor::TypeNewConsString(Node* node) {
return Type::OtherNonSeqString(); return Type::OtherString();
} }
Type* Typer::Visitor::TypeArrayBufferWasNeutered(Node* node) { Type* Typer::Visitor::TypeArrayBufferWasNeutered(Node* node) {
......
...@@ -161,20 +161,18 @@ Type::bitset BitsetType::Lub(i::Map* map) { ...@@ -161,20 +161,18 @@ Type::bitset BitsetType::Lub(i::Map* map) {
case SHORT_EXTERNAL_STRING_TYPE: case SHORT_EXTERNAL_STRING_TYPE:
case SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE: case SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE:
case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
return kOtherNonSeqString;
case STRING_TYPE: case STRING_TYPE:
case ONE_BYTE_STRING_TYPE: case ONE_BYTE_STRING_TYPE:
return kOtherSeqString; return kOtherString;
case EXTERNAL_INTERNALIZED_STRING_TYPE: case EXTERNAL_INTERNALIZED_STRING_TYPE:
case EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE: case EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE: case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE:
case SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE: case SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
return kInternalizedNonSeqString;
case INTERNALIZED_STRING_TYPE: case INTERNALIZED_STRING_TYPE:
case ONE_BYTE_INTERNALIZED_STRING_TYPE: case ONE_BYTE_INTERNALIZED_STRING_TYPE:
return kInternalizedSeqString; return kInternalizedString;
case SYMBOL_TYPE: case SYMBOL_TYPE:
return kSymbol; return kSymbol;
case BIGINT_TYPE: case BIGINT_TYPE:
......
...@@ -114,22 +114,20 @@ namespace compiler { ...@@ -114,22 +114,20 @@ namespace compiler {
V(MinusZero, 1u << 10) \ V(MinusZero, 1u << 10) \
V(NaN, 1u << 11) \ V(NaN, 1u << 11) \
V(Symbol, 1u << 12) \ V(Symbol, 1u << 12) \
V(InternalizedNonSeqString, 1u << 13) \ V(InternalizedString, 1u << 13) \
V(InternalizedSeqString, 1u << 14) \ V(OtherString, 1u << 14) \
V(OtherNonSeqString, 1u << 15) \ V(OtherCallable, 1u << 15) \
V(OtherSeqString, 1u << 16) \ V(OtherObject, 1u << 16) \
V(OtherCallable, 1u << 17) \ V(OtherUndetectable, 1u << 17) \
V(OtherObject, 1u << 18) \ V(CallableProxy, 1u << 18) \
V(OtherUndetectable, 1u << 19) \ V(OtherProxy, 1u << 19) \
V(CallableProxy, 1u << 20) \ V(Function, 1u << 20) \
V(OtherProxy, 1u << 21) \ V(BoundFunction, 1u << 21) \
V(Function, 1u << 22) \ V(Hole, 1u << 22) \
V(BoundFunction, 1u << 23) \ V(OtherInternal, 1u << 23) \
V(Hole, 1u << 24) \ V(ExternalPointer, 1u << 24) \
V(OtherInternal, 1u << 25) \ V(Array, 1u << 25) \
V(ExternalPointer, 1u << 26) \ V(BigInt, 1u << 26) \
V(Array, 1u << 27) \
V(BigInt, 1u << 28) \
\ \
V(Signed31, kUnsigned30 | kNegative31) \ V(Signed31, kUnsigned30 | kNegative31) \
V(Signed32, kSigned31 | kOtherUnsigned31 | \ V(Signed32, kSigned31 | kOtherUnsigned31 | \
...@@ -150,12 +148,6 @@ namespace compiler { ...@@ -150,12 +148,6 @@ namespace compiler {
V(MinusZeroOrNaN, kMinusZero | kNaN) \ V(MinusZeroOrNaN, kMinusZero | kNaN) \
V(Number, kOrderedNumber | kNaN) \ V(Number, kOrderedNumber | kNaN) \
V(Numeric, kNumber | kBigInt) \ V(Numeric, kNumber | kBigInt) \
V(InternalizedString, kInternalizedNonSeqString | \
kInternalizedSeqString) \
V(OtherString, kOtherNonSeqString | kOtherSeqString) \
V(SeqString, kInternalizedSeqString | kOtherSeqString) \
V(NonSeqString, kInternalizedNonSeqString | \
kOtherNonSeqString) \
V(String, kInternalizedString | kOtherString) \ V(String, kInternalizedString | kOtherString) \
V(UniqueName, kSymbol | kInternalizedString) \ V(UniqueName, kSymbol | kInternalizedString) \
V(Name, kSymbol | kString) \ V(Name, kSymbol | kString) \
......
...@@ -1094,24 +1094,12 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) { ...@@ -1094,24 +1094,12 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
CheckValueInputIs(node, 1, Type::Unsigned32()); CheckValueInputIs(node, 1, Type::Unsigned32());
CheckTypeIs(node, Type::UnsignedSmall()); CheckTypeIs(node, Type::UnsignedSmall());
break; break;
case IrOpcode::kSeqStringCharCodeAt:
// (SeqString, Unsigned32) -> UnsignedSmall
CheckValueInputIs(node, 0, Type::SeqString());
CheckValueInputIs(node, 1, Type::Unsigned32());
CheckTypeIs(node, Type::UnsignedSmall());
break;
case IrOpcode::kStringCodePointAt: case IrOpcode::kStringCodePointAt:
// (String, Unsigned32) -> UnsignedSmall // (String, Unsigned32) -> UnsignedSmall
CheckValueInputIs(node, 0, Type::String()); CheckValueInputIs(node, 0, Type::String());
CheckValueInputIs(node, 1, Type::Unsigned32()); CheckValueInputIs(node, 1, Type::Unsigned32());
CheckTypeIs(node, Type::UnsignedSmall()); CheckTypeIs(node, Type::UnsignedSmall());
break; break;
case IrOpcode::kSeqStringCodePointAt:
// (String, Unsigned32) -> UnsignedSmall
CheckValueInputIs(node, 0, Type::String());
CheckValueInputIs(node, 1, Type::Unsigned32());
CheckTypeIs(node, Type::UnsignedSmall());
break;
case IrOpcode::kStringFromCharCode: case IrOpcode::kStringFromCharCode:
// Number -> String // Number -> String
CheckValueInputIs(node, 0, Type::Number()); CheckValueInputIs(node, 0, Type::Number());
...@@ -1396,10 +1384,6 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) { ...@@ -1396,10 +1384,6 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
CheckValueInputIs(node, 0, Type::Any()); CheckValueInputIs(node, 0, Type::Any());
CheckTypeIs(node, Type::String()); CheckTypeIs(node, Type::String());
break; break;
case IrOpcode::kCheckSeqString:
CheckValueInputIs(node, 0, Type::Any());
CheckTypeIs(node, Type::SeqString());
break;
case IrOpcode::kCheckSymbol: case IrOpcode::kCheckSymbol:
CheckValueInputIs(node, 0, Type::Any()); CheckValueInputIs(node, 0, Type::Any());
CheckTypeIs(node, Type::Symbol()); CheckTypeIs(node, Type::Symbol());
......
...@@ -273,11 +273,11 @@ struct Tests { ...@@ -273,11 +273,11 @@ struct Tests {
// Typing of Strings // Typing of Strings
Handle<String> s1 = fac->NewStringFromAsciiChecked("a"); Handle<String> s1 = fac->NewStringFromAsciiChecked("a");
CHECK(T.NewConstant(s1)->Is(T.InternalizedSeqString)); CHECK(T.NewConstant(s1)->Is(T.InternalizedString));
const uc16 two_byte[1] = {0x2603}; const uc16 two_byte[1] = {0x2603};
Handle<String> s2 = Handle<String> s2 =
fac->NewTwoByteInternalizedString(Vector<const uc16>(two_byte, 1), 1); fac->NewTwoByteInternalizedString(Vector<const uc16>(two_byte, 1), 1);
CHECK(T.NewConstant(s2)->Is(T.InternalizedSeqString)); CHECK(T.NewConstant(s2)->Is(T.InternalizedString));
} }
void Range() { void Range() {
...@@ -621,14 +621,11 @@ struct Tests { ...@@ -621,14 +621,11 @@ struct Tests {
CheckSub(T.UniqueName, T.Name); CheckSub(T.UniqueName, T.Name);
CheckSub(T.String, T.Name); CheckSub(T.String, T.Name);
CheckSub(T.InternalizedSeqString, T.InternalizedString);
CheckSub(T.InternalizedNonSeqString, T.InternalizedString);
CheckSub(T.InternalizedString, T.String); CheckSub(T.InternalizedString, T.String);
CheckSub(T.InternalizedString, T.UniqueName); CheckSub(T.InternalizedString, T.UniqueName);
CheckSub(T.InternalizedString, T.Name); CheckSub(T.InternalizedString, T.Name);
CheckSub(T.OtherSeqString, T.OtherString);
CheckSub(T.OtherNonSeqString, T.OtherString);
CheckSub(T.OtherString, T.String); CheckSub(T.OtherString, T.String);
CheckSub(T.OtherString, T.Name);
CheckSub(T.Symbol, T.UniqueName); CheckSub(T.Symbol, T.UniqueName);
CheckSub(T.Symbol, T.Name); CheckSub(T.Symbol, T.Name);
CheckUnordered(T.String, T.UniqueName); CheckUnordered(T.String, T.UniqueName);
...@@ -750,10 +747,6 @@ struct Tests { ...@@ -750,10 +747,6 @@ struct Tests {
CheckOverlap(T.NaN, T.Number); CheckOverlap(T.NaN, T.Number);
CheckDisjoint(T.Signed32, T.NaN); CheckDisjoint(T.Signed32, T.NaN);
CheckOverlap(T.UniqueName, T.Name); CheckOverlap(T.UniqueName, T.Name);
CheckOverlap(T.InternalizedNonSeqString, T.InternalizedString);
CheckOverlap(T.InternalizedSeqString, T.InternalizedString);
CheckOverlap(T.OtherNonSeqString, T.OtherString);
CheckOverlap(T.OtherSeqString, T.OtherString);
CheckOverlap(T.String, T.Name); CheckOverlap(T.String, T.Name);
CheckOverlap(T.InternalizedString, T.String); CheckOverlap(T.InternalizedString, T.String);
CheckOverlap(T.InternalizedString, T.UniqueName); CheckOverlap(T.InternalizedString, T.UniqueName);
......
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