summaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/child-typer.h41
-rw-r--r--src/ir/cost.h6
-rw-r--r--src/ir/effects.h36
3 files changed, 15 insertions, 68 deletions
diff --git a/src/ir/child-typer.h b/src/ir/child-typer.h
index e015f3db8..7c09dddb0 100644
--- a/src/ir/child-typer.h
+++ b/src/ir/child-typer.h
@@ -962,27 +962,17 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
void visitStringNew(StringNew* curr,
std::optional<HeapType> ht = std::nullopt) {
switch (curr->op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16:
- // TODO: This should be notePointer, but we don't have a memory.
- note(&curr->ptr, Type::i32);
- note(&curr->length, Type::i32);
- return;
- case StringNewUTF8Array:
- case StringNewWTF8Array:
case StringNewLossyUTF8Array:
case StringNewWTF16Array:
if (!ht) {
- ht = curr->ptr->type.getHeapType();
+ ht = curr->ref->type.getHeapType();
}
- note(&curr->ptr, Type(*ht, Nullable));
+ note(&curr->ref, Type(*ht, Nullable));
note(&curr->start, Type::i32);
note(&curr->end, Type::i32);
return;
case StringNewFromCodePoint:
- note(&curr->ptr, Type::i32);
+ note(&curr->ref, Type::i32);
return;
}
WASM_UNREACHABLE("unexpected op");
@@ -996,27 +986,12 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
void visitStringEncode(StringEncode* curr,
std::optional<HeapType> ht = std::nullopt) {
- note(&curr->ref, Type(HeapType::string, Nullable));
- switch (curr->op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16:
- // TODO: This should be notePointer, but we don't have a memory.
- note(&curr->ptr, Type::i32);
- return;
- case StringEncodeUTF8Array:
- case StringEncodeLossyUTF8Array:
- case StringEncodeWTF8Array:
- case StringEncodeWTF16Array:
- if (!ht) {
- ht = curr->ptr->type.getHeapType();
- }
- note(&curr->ptr, Type(*ht, Nullable));
- note(&curr->start, Type::i32);
- return;
+ if (!ht) {
+ ht = curr->array->type.getHeapType();
}
- WASM_UNREACHABLE("unexpected op");
+ note(&curr->str, Type(HeapType::string, Nullable));
+ note(&curr->array, Type(*ht, Nullable));
+ note(&curr->start, Type::i32);
}
void visitStringConcat(StringConcat* curr) {
diff --git a/src/ir/cost.h b/src/ir/cost.h
index 8af68dbf1..6622561b8 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -689,15 +689,15 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
}
CostType visitRefAs(RefAs* curr) { return 1 + visit(curr->value); }
CostType visitStringNew(StringNew* curr) {
- return 8 + visit(curr->ptr) + maybeVisit(curr->length) +
- maybeVisit(curr->start) + maybeVisit(curr->end);
+ return 8 + visit(curr->ref) + maybeVisit(curr->start) +
+ maybeVisit(curr->end);
}
CostType visitStringConst(StringConst* curr) { return 4; }
CostType visitStringMeasure(StringMeasure* curr) {
return 6 + visit(curr->ref);
}
CostType visitStringEncode(StringEncode* curr) {
- return 6 + visit(curr->ref) + visit(curr->ptr);
+ return 6 + visit(curr->str) + visit(curr->array) + visit(curr->start);
}
CostType visitStringConcat(StringConcat* curr) {
return 10 + visit(curr->left) + visit(curr->right);
diff --git a/src/ir/effects.h b/src/ir/effects.h
index 87b77601f..28de83850 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -941,23 +941,10 @@ private:
// cycle may be needed in some cases.
}
void visitStringNew(StringNew* curr) {
- // traps when out of bounds in linear memory or ref is null
+ // traps when ref is null
parent.implicitTrap = true;
- switch (curr->op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16:
- parent.readsMemory = true;
- break;
- case StringNewUTF8Array:
- case StringNewWTF8Array:
- case StringNewLossyUTF8Array:
- case StringNewWTF16Array:
- parent.readsArray = true;
- break;
- default: {
- }
+ if (curr->op != StringNewFromCodePoint) {
+ parent.readsArray = true;
}
}
void visitStringConst(StringConst* curr) {}
@@ -968,22 +955,7 @@ private:
void visitStringEncode(StringEncode* curr) {
// traps when ref is null or we write out of bounds.
parent.implicitTrap = true;
- switch (curr->op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16:
- parent.writesMemory = true;
- break;
- case StringEncodeUTF8Array:
- case StringEncodeLossyUTF8Array:
- case StringEncodeWTF8Array:
- case StringEncodeWTF16Array:
- parent.writesArray = true;
- break;
- default: {
- }
- }
+ parent.writesArray = true;
}
void visitStringConcat(StringConcat* curr) {
// traps when an input is null.