diff options
author | Alon Zakai <azakai@google.com> | 2022-07-19 16:03:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 16:03:01 -0700 |
commit | 1c53f7dd29e79bc1894959cad817b22f087689f7 (patch) | |
tree | c3d114a3359f4ba9175f7cff3bf3bc6b83c2b885 /src/ir | |
parent | 984078acc7625c44870a3d256deaa19b76894de0 (diff) | |
download | binaryen-1c53f7dd29e79bc1894959cad817b22f087689f7.tar.gz binaryen-1c53f7dd29e79bc1894959cad817b22f087689f7.tar.bz2 binaryen-1c53f7dd29e79bc1894959cad817b22f087689f7.zip |
[Strings] Add string.new GC variants (#4813)
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/cost.h | 2 | ||||
-rw-r--r-- | src/ir/effects.h | 5 |
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. |