summaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/cost.h2
-rw-r--r--src/ir/effects.h5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/ir/cost.h b/src/ir/cost.h
index 8ebc6eb9b..b48b777e1 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -672,7 +672,7 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
}
CostType visitRefAs(RefAs* curr) { return 1 + visit(curr->value); }
CostType visitStringNew(StringNew* curr) {
- return 8 + visit(curr->ptr) + visit(curr->length);
+ return 8 + visit(curr->ptr) + maybeVisit(curr->length);
}
CostType visitStringConst(StringConst* curr) { return 4; }
CostType visitStringMeasure(StringMeasure* curr) {
diff --git a/src/ir/effects.h b/src/ir/effects.h
index 58480f0ff..43d4868d8 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -732,7 +732,10 @@ private:
// we keep the code here simpler, but it does mean another optimization
// cycle may be needed in some cases.
}
- void visitStringNew(StringNew* curr) {}
+ void visitStringNew(StringNew* curr) {
+ // traps when out of bounds in linear memory or ref is null
+ parent.implicitTrap = true;
+ }
void visitStringConst(StringConst* curr) {}
void visitStringMeasure(StringMeasure* curr) {
// traps when ref is null.