Skip to content

Commit 07763fe

Browse files
authored
fix(codegen): don't generate __tact_nop() for dump() and dumpStack() with debug=false (#3218)
1 parent 35002e3 commit 07763fe

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

dev-docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- [fix] Disallow self-inheritance for contracts and traits: PR [#3094](https://github.com/tact-lang/tact/pull/3094)
1313
- [fix] Added fixed-bytes support to bounced message size calculations: PR [#3129](https://github.com/tact-lang/tact/pull/3129)
1414
- Compiler now generates more efficient code for serialization: PR [#3213](https://github.com/tact-lang/tact/pull/3213)
15+
- [fix] Compiler now doesn't generate `__tact_nop()` for `dump()` and `dumpStack()` in default mode: PR [#3218](https://github.com/tact-lang/tact/pull/3218)
1516

1617
### Docs
1718

src/abi/global.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export const GlobalFunctions: Map<string, AbiFunction> = new Map([
250250
},
251251
generate: (ctx, args, resolved, ref) => {
252252
if (!enabledDebug(ctx.ctx)) {
253-
return `${ctx.used("__tact_nop")}()`;
253+
return ``;
254254
}
255255
const arg0 = args[0]!;
256256

@@ -319,7 +319,7 @@ export const GlobalFunctions: Map<string, AbiFunction> = new Map([
319319
},
320320
generate: (ctx, _args, _resolved, ref) => {
321321
if (!enabledDebug(ctx.ctx)) {
322-
return `${ctx.used("__tact_nop")}()`;
322+
return ``;
323323
}
324324
const filePath = ref.file
325325
? posixNormalize(path.relative(cwd(), ref.file!))

src/generator/writers/writeFunction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ export function writeStatement(
208208
}
209209
case "statement_expression": {
210210
const exp = writeExpression(f.expression, ctx);
211+
if (exp === "") {
212+
return;
213+
}
211214
ctx.append(`${exp};`);
212215
return;
213216
}

src/generator/writers/writeStdlib.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ export function writeStdlib(ctx: WriterContext): void {
99
// stdlib extension functions
1010
//
1111

12-
ctx.fun("__tact_nop", () => {
13-
ctx.signature(`() __tact_nop()`);
14-
ctx.context("stdlib");
15-
ctx.asm("", "NOP");
16-
});
17-
1812
ctx.fun("__tact_sha256", () => {
1913
ctx.signature(`int __tact_sha256(slice data)`);
2014
ctx.context("stdlib");

src/test/codegen-check/__snapshots__/codegen.test.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ exports[`codegen should correctly generate FunC code 1`] = `
6262
;; $MainContract$_fun_testIfOptimizationNegative
6363
((int, int, slice, cell), ()) $MainContract$_fun_testIfOptimizationNegative((int, int, slice, cell) $self, int $a) impure inline_ref;
6464
65+
;; $MainContract$_fun_testDumpCall
66+
((int, int, slice, cell), ()) $MainContract$_fun_testDumpCall((int, int, slice, cell) $self, int $a) impure inline_ref;
67+
6568
6669
;; main_MainContract.stdlib.fc
6770
global (int, slice, int, slice) __tact_context;
@@ -282,6 +285,11 @@ cell $Builder$_fun_endCell(builder $self) impure asm """
282285
return (($self'field, $self'value, $self'data, $self'mapping), ());
283286
}
284287
288+
((int, int, slice, cell), ()) $MainContract$_fun_testDumpCall((int, int, slice, cell) $self, int $a) impure inline_ref {
289+
var (($self'field, $self'value, $self'data, $self'mapping)) = $self;
290+
return (($self'field, $self'value, $self'data, $self'mapping), ());
291+
}
292+
285293
;;
286294
;; Get methods of a Contract MainContract
287295
;;
@@ -335,6 +343,13 @@ _ %testIfOptimizationNegative(int $a) method_id(87434) {
335343
return res;
336344
}
337345
346+
_ %testDumpCall(int $a) method_id(66927) {
347+
int $a = $a;
348+
var self = $MainContract$_contract_load();
349+
var res = self~$MainContract$_fun_testDumpCall($a);
350+
return res;
351+
}
352+
338353
;;
339354
;; Routing of a Contract MainContract
340355
;;

src/test/codegen-check/contracts/main.tact

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,9 @@ contract MainContract {
185185
return;
186186
}
187187
}
188+
189+
get fun testDumpCall(a: Int) {
190+
dump(a);
191+
dumpStack();
192+
}
188193
}

0 commit comments

Comments
 (0)