Skip to content

Commit

Permalink
deserializeCostKind
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Aug 14, 2024
1 parent b4aa573 commit d8cc09d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions data/shared/src/main/scala/sigma/ast/methods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1533,10 +1533,13 @@ case object SGlobalMethods extends MonoTypeMethods {
.withInfo(Xor, "Byte-wise XOR of two collections of bytes",
ArgInfo("left", "left operand"), ArgInfo("right", "right operand"))

private val deserializeCostKind = PerItemCost(
baseCost = JitCost(20), perChunkCost = JitCost(7), chunkSize = 128)

lazy val desJava = ownerType.reprClass.getMethod("deserializeTo", classOf[SType], classOf[Coll[Byte]], classOf[RType[_]])

lazy val deserializeToMethod = SMethod(
this, "deserializeTo", SFunc(Array(SGlobal, SByteArray), tT, Array(paramT)), 3, Xor.costKind, Seq(tT)) // todo: cost
this, "deserializeTo", SFunc(Array(SGlobal, SByteArray), tT, Array(paramT)), 3, deserializeCostKind, Seq(tT))
.withIRInfo(MethodCallIrBuilder, desJava)
// .copy(irInfo = MethodIRInfo(None, Some(desJava), None))
.withInfo(MethodCall, "Byte-wise XOR of two collections of bytes", // todo: desc
Expand All @@ -1556,7 +1559,7 @@ case object SGlobalMethods extends MonoTypeMethods {
(implicit E: ErgoTreeEvaluator): Any = {
val tpe = mc.tpe
val cT = stypeToRType(tpe)
E.addSeqCost(Xor.costKind, bytes.length, Xor.opDesc) { () => // todo: cost
E.addSeqCost(deserializeCostKind, bytes.length, deserializeToMethod.opDesc) { () =>
G.deserializeTo(tpe, bytes)(cT)
}
}
Expand Down

0 comments on commit d8cc09d

Please sign in to comment.