Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The documentation changelog is kept separately: [CHANGELOG-DOCS](./CHANGELOG-DOC

### Code generation

- Optimized opcode parsing for fallback and text receivers: PR [#3331](https://github.com/tact-lang/tact/pull/3331)
- Reordered arguments of the `__tact_store_address_opt` function to optimize gas consumption: PR [#3333](https://github.com/tact-lang/tact/pull/3333)

## [1.6.13] - 2025-05-29
Expand Down
10 changes: 10 additions & 0 deletions src/benchmarks/nft/gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@
"deploy nft": "10299",
"batch deploy nft": "650666"
}
},
{
"label": "1.6.13 with optimized opcode parsing for fallback and text receivers",
"pr": "https://github.com/tact-lang/tact/pull/3331",
"gas": {
"transfer": "6907",
"get static data": "4388",
"deploy nft": "10263",
"batch deploy nft": "648848"
}
}
]
}
10 changes: 10 additions & 0 deletions src/benchmarks/nft/size.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@
"item cells": "10",
"item bits": "5185"
}
},
{
"label": "1.6.13 with optimized opcode parsing for fallback and text receivers",
"pr": "https://github.com/tact-lang/tact/pull/3331",
"size": {
"collection cells": "39",
"collection bits": "19564",
"item cells": "10",
"item bits": "5185"
}
}
]
}
13 changes: 13 additions & 0 deletions src/benchmarks/sbt/gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@
"revoke": "3778",
"take excess": "5577"
}
},
{
"label": "1.6.13 with optimized opcode parsing for fallback and text receivers",
"pr": "https://github.com/tact-lang/tact/pull/3331",
"gas": {
"deploy": "3940",
"request owner": "4848",
"prove ownership": "5026",
"get static data": "4678",
"destroy": "6125",
"revoke": "3742",
"take excess": "5541"
}
}
]
}
14 changes: 7 additions & 7 deletions src/generator/writers/writeRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ export function writeNonBouncedRouter(
receivers.comment.length > 0 ||
typeof receivers.commentFallback !== "undefined";

wCtx.append("int op = 0;");
wCtx.append("int in_msg_length = slice_bits(in_msg);");
wCtx.inBlock("if (in_msg_length >= 32)", () => {
wCtx.append(`op = in_msg${opcodeReader}(32);`);

if (doesHaveTextReceivers) {
wCtx.append(
`int op = (in_msg_length >= 32) ? in_msg${opcodeReader}(32) : 0;`,
);
if (doesHaveTextReceivers) {
wCtx.inBlock("if (in_msg_length >= 32)", () => {
writeBinaryReceivers(opcodeReader === "~load_uint");
}
});
});
}

// NOTE: It should be more efficient to write all binary receivers inside
// `in_msg_length` length if-check regardless of text receivers,
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/__snapshots__/packaging.spec.ts.snap

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/test/codegen-check/__snapshots__/codegen.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,9 @@ _ %asSlice() method_id(68231) {

;; Handle bounced messages
if (msg_bounced) { return (); }
int op = 0;
int in_msg_length = slice_bits(in_msg);
int op = (in_msg_length >= 32) ? in_msg~load_uint(32) : 0;
if (in_msg_length >= 32) {
op = in_msg~load_uint(32);
;; Receive Bin message
if (op == 0x2) {
var $m = empty_tuple();
Expand Down
6 changes: 3 additions & 3 deletions src/test/e2e-emulated/debug/__snapshots__/dump.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`dump should dump values correctly in a receiver 1`] = `
"#DEBUG#: File src/test/e2e-emulated/debug/dump.tact:2:5:
#DEBUG#: dumpStack()
#DEBUG#: stack(1 values) : 10999604800
#DEBUG#: stack(1 values) : 10999556400
#DEBUG#: File src/test/e2e-emulated/debug/dump.tact:3:5:
#DEBUG#: dump("Hello world!")
#DEBUG#: Hello world!
Expand All @@ -21,13 +21,13 @@ exports[`dump should dump values correctly in a receiver 1`] = `
#DEBUG#: null
#DEBUG#: File src/test/e2e-emulated/debug/dump.tact:8:5:
#DEBUG#: dump(myAddress())
#DEBUG#: EQBW6PMGWgu6Gmg_pFckrGpQxm2ImeVELrquQXN0FaneV9fj
#DEBUG#: EQAOdLgPqDU7Iakg-03LKk-3VfNPuNtiCnNLn9bpfYYCG-Tl
#DEBUG#: File src/test/e2e-emulated/debug/dump.tact:10:5:
#DEBUG#: dump(address)
#DEBUG#: EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N
#DEBUG#: File src/test/e2e-emulated/debug/dump.tact:11:5:
#DEBUG#: dump(myBalance())
#DEBUG#: 10999604800
#DEBUG#: 10999556400
#DEBUG#: File src/test/e2e-emulated/debug/dump.tact:15:5:
#DEBUG#: dump(maybeBool1)
#DEBUG#: null
Expand Down
18 changes: 9 additions & 9 deletions src/test/gas-consumption/__snapshots__/gas.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ exports[`benchmarks benchmark readFwdFee: code size 1`] = `116`;

exports[`benchmarks benchmark readFwdFee: gas used 1`] = `1968`;

exports[`benchmarks benchmark sha256: gas hash string big 1`] = `2154`;
exports[`benchmarks benchmark sha256: gas hash string big 1`] = `2126`;

exports[`benchmarks benchmark sha256: gas hash string big repeated 1`] = `2155`;
exports[`benchmarks benchmark sha256: gas hash string big repeated 1`] = `2127`;

exports[`benchmarks benchmark sha256: gas hash string big repeated more 1`] = `2157`;
exports[`benchmarks benchmark sha256: gas hash string big repeated more 1`] = `2129`;

exports[`benchmarks benchmark sha256: gas hash string slice 1`] = `2154`;
exports[`benchmarks benchmark sha256: gas hash string slice 1`] = `2126`;

exports[`benchmarks benchmark sha256: gas hash string slice repeated 1`] = `2155`;
exports[`benchmarks benchmark sha256: gas hash string slice repeated 1`] = `2127`;

exports[`benchmarks benchmark sha256: gas hash string slice repeated more 1`] = `2157`;
exports[`benchmarks benchmark sha256: gas hash string slice repeated more 1`] = `2129`;

exports[`benchmarks benchmark sha256: gas hash string small 1`] = `1975`;
exports[`benchmarks benchmark sha256: gas hash string small 1`] = `1947`;

exports[`benchmarks benchmark sha256: gas hash string small repeated 1`] = `1975`;
exports[`benchmarks benchmark sha256: gas hash string small repeated 1`] = `1947`;

exports[`benchmarks benchmark sha256: gas hash string small repeated more 1`] = `1975`;
exports[`benchmarks benchmark sha256: gas hash string small repeated more 1`] = `1947`;

exports[`benchmarks benchmark sqrt via geom mean: code size 1`] = `265`;

Expand Down