mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
LF: reduce recursion depth in Archive decoder. (#8827)
We inline the unnecessary decodeExprBody call inside decodeExpr. This reduces the recursion depth of decoding expression inside archive, increasing hence the depth of expression the scala part of the stack can handle without blowing off the stack. Before the change the test //daml-lf/tests:test-scenario-stable-many-fields crashed 25 out of 100 runs. After the changes the test crashed not once out of 100 runs. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
c8b82f8e7a
commit
f4c7ea3df0
@ -797,14 +797,8 @@ private[archive] class DecodeV1(minor: LV.Minor) extends Decode.OfPackage[PLF.Pa
|
||||
ImmArray(lfTyConApp.getArgsList.asScala.map(decodeType)),
|
||||
)
|
||||
|
||||
private[lf] def decodeExpr(lfExpr: PLF.Expr, definition: String): Expr =
|
||||
decodeLocation(lfExpr, definition) match {
|
||||
case None => decodeExprBody(lfExpr, definition)
|
||||
case Some(loc) => ELocation(loc, decodeExprBody(lfExpr, definition))
|
||||
}
|
||||
|
||||
private[this] def decodeExprBody(lfExpr: PLF.Expr, definition: String): Expr =
|
||||
lfExpr.getSumCase match {
|
||||
private[lf] def decodeExpr(lfExpr: PLF.Expr, definition: String): Expr = {
|
||||
val expr = lfExpr.getSumCase match {
|
||||
case PLF.Expr.SumCase.VAR_STR =>
|
||||
assertUntil(LV.Features.internedStrings, "Expr.var_str")
|
||||
EVar(toName(lfExpr.getVarStr))
|
||||
@ -1058,6 +1052,11 @@ private[archive] class DecodeV1(minor: LV.Minor) extends Decode.OfPackage[PLF.Pa
|
||||
case PLF.Expr.SumCase.SUM_NOT_SET =>
|
||||
throw ParseError("Expr.SUM_NOT_SET")
|
||||
}
|
||||
decodeLocation(lfExpr, definition) match {
|
||||
case None => expr
|
||||
case Some(loc) => ELocation(loc, expr)
|
||||
}
|
||||
}
|
||||
|
||||
private[this] def decodeCaseAlt(lfCaseAlt: PLF.CaseAlt, definition: String): CaseAlt = {
|
||||
val pat: CasePat = lfCaseAlt.getSumCase match {
|
||||
|
Loading…
Reference in New Issue
Block a user