mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[FunC] Deprecate pragma compute-asm-ltr
It changes all hashes, since the compiler needs to manipulate the stack in a different way now.
This commit is contained in:
parent
aaf3ca335d
commit
1e4b20a061
11 changed files with 41 additions and 71 deletions
|
@ -4,32 +4,26 @@
|
|||
// and is parsed just using regexp ^\[\s*"(.*?)"\s*,\s*(.*?)\s*]
|
||||
// Some tests can be commented out, or they can be multiline, it works.
|
||||
|
||||
// note, that deployed version of elector,config and multisig differ since it is compiled with func-0.1.0.
|
||||
// Newer compilers optimize arithmetic and logic expression that can be calculated at the compile time
|
||||
["elector/elector-code.fc", 115226404411715505328583639896096915745686314074575650766750648324043316883483]
|
||||
["config/config-code.fc", 10913070768607625342121305745084703121685937915388357634624451844356456145601]
|
||||
["eth-bridge-multisig/multisig-code.fc", 101509909129354488841890823627011033360100627957439967918234053299675481277954]
|
||||
// Since pragma compute-asm-ltr became deprecated (and always on), it changed all hashes
|
||||
["elector/elector-code.fc", 96915288474895095375636985346314354662782784860648058159878921867365312683154]
|
||||
["config/config-code.fc", 22290399841823616942485152190379024190655691555189464909245612965253206016940]
|
||||
["eth-bridge-multisig/multisig-code.fc", 61794576422183943960272839720117943378686303983578297509099019523440847170337]
|
||||
|
||||
["bsc-bridge-collector/votes-collector.fc", 62190447221288642706570413295807615918589884489514159926097051017036969900417]
|
||||
["uni-lock-wallet/uni-lockup-wallet.fc", 61959738324779104851267145467044677651344601417998258530238254441977103654381]
|
||||
["nft-collection/nft-collection-editable.fc", 45561997735512210616567774035540357815786262097548276229169737015839077731274]
|
||||
["dns-collection/nft-collection.fc", 107999822699841936063083742021519765435859194241091312445235370766165379261859]
|
||||
["bsc-bridge-collector/votes-collector.fc", 92944270384900724656771477263840139047476985690583064733832286422277180224175]
|
||||
["uni-lock-wallet/uni-lockup-wallet.fc", 27323712737699566411771249412638860892056222617959925563185009479925143218351]
|
||||
["nft-collection/nft-collection-editable.fc", 3265272879406938912616104900469474227258611213495548733729957432831667074606]
|
||||
["dns-collection/nft-collection.fc", 50100285311144683401305558797522852568981620193836838830789475785944491291928]
|
||||
|
||||
|
||||
// note, that deployed version of tele-nft-item differs since it is compiled with func-0.3.0.
|
||||
// After introducing of try/catch construction, c2 register is not always the default one.
|
||||
// Thus it is necessary to save it upon jumps, differences of deployed and below compiled is that
|
||||
// "c2 SAVE" is added to the beginning of recv_internal. It does not change behavior.
|
||||
["tele-nft-item/nft-item.fc", 69777543125381987786450436977742010705076866061362104025338034583422166453344]
|
||||
["tele-nft-item/nft-item.fc", 112456603551352598193405120624678866030139400186800709562240012518003340977105]
|
||||
|
||||
["storage/storage-contract.fc", 91377830060355733016937375216020277778264560226873154627574229667513068328151]
|
||||
["storage/storage-provider.fc", 13618336676213331164384407184540461509022654507176709588621016553953760588122]
|
||||
["nominator-pool/pool.fc", 69767057279163099864792356875696330339149706521019810113334238732928422055375]
|
||||
["jetton-minter/jetton-minter.fc", 9028309926287301331466371999814928201427184114165428257502393474125007156494]
|
||||
["gg-marketplace/nft-marketplace-v2.fc", 92199806964112524639740773542356508485601908152150843819273107618799016205930]
|
||||
["jetton-wallet/jetton-wallet.fc", 86251125787443633057458168028617933212663498001665054651523310772884328206542]
|
||||
// (May 2024) reordered includes, they were in a wrong order
|
||||
["whales-nominators/nominators.fc", 64989185004203073400683226767264384908045055609681310145961012819587514238303]
|
||||
["storage/storage-contract.fc", 44542652015163304335966522853331133393011733370692441537470366854345658892851]
|
||||
["storage/storage-provider.fc", 108677173951298337060746154977967122806502520160062519672276937694037317935577]
|
||||
["nominator-pool/pool.fc", 113824867250406571749406540634759859835643042958487527298742314026185451318138]
|
||||
["jetton-minter/jetton-minter.fc", 59172251235013928378816323931018560572240088017859486196396002876800156186183]
|
||||
["gg-marketplace/nft-marketplace-v2.fc", 65550944551194537105854154716861234168502062117999272754502885031166440057836]
|
||||
["jetton-wallet/jetton-wallet.fc", 26109413028643307141901410795152471606217725316052170190064118584402007124948]
|
||||
["whales-nominators/nominators.fc", 32017040532734767645954674692768344406402364921654403435168703583553605058036]
|
||||
|
||||
|
||||
// (April 2024) tact hashes changed, because '__tact_address_eq()' is now inlined as a wrapper
|
||||
|
|
|
@ -51,8 +51,6 @@ tuple test_tuple(int x) method_id(13) {
|
|||
return asm_func(x, x += 1, x, x, x~inc(x / 20), x, x = x * 2);
|
||||
}
|
||||
|
||||
#pragma compute-asm-ltr;
|
||||
|
||||
(int, int, int, int, int, int, int) test_call_asm_new(int x) method_id(18) {
|
||||
return asm_func(x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x);
|
||||
}
|
||||
|
@ -83,11 +81,11 @@ TESTCASE | 13 | 100 | [ 100 50 105 210 210 211 211 ]
|
|||
TESTCASE | 14 | 100 | 100 50 105 210 210 211 211
|
||||
TESTCASE | 15 | 100 | 100 50 105 210 210 211 211
|
||||
TESTCASE | 16 | 100 | 100 50 105 210 210 211 211
|
||||
TESTCASE | 17 | 100 | 100 50 105 210 210 211 211
|
||||
TESTCASE | 17 | 100 | 101 50 106 212 100 101 101
|
||||
TESTCASE | 18 | 100 | 210 210 211 211 100 50 105
|
||||
TESTCASE | 19 | 100 | 100 50 105 210 210 211 211
|
||||
TESTCASE | 20 | 80 | 80 89 1 8 8
|
||||
TESTCASE | 20 | 9 | 9 -40 -10 -1 13
|
||||
|
||||
@code_hash 67078680159561921827850021610104736412668316252257881932102553152922274405210
|
||||
@code_hash 91381947614024372269097215913018978221053550615790649489637387647848569490128
|
||||
-}
|
||||
|
|
|
@ -60,8 +60,6 @@ int foo(int x) {
|
|||
return (t, t2);
|
||||
}
|
||||
|
||||
#pragma compute-asm-ltr;
|
||||
|
||||
(tuple, tuple) test_new_1() method_id(21) {
|
||||
t = empty_tuple();
|
||||
tuple t2 = asmFunc1(foo(11), foo(22), foo(33));
|
||||
|
@ -105,11 +103,11 @@ int foo(int x) {
|
|||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 11 | | [ 11 22 33 ] [ 110 220 330 ]
|
||||
TESTCASE | 12 | | [ 33 22 11 ] [ 330 220 110 ]
|
||||
TESTCASE | 13 | | [ 22 33 11 ] [ 220 330 110 ]
|
||||
TESTCASE | 12 | | [ 11 22 33 ] [ 330 220 110 ]
|
||||
TESTCASE | 13 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
TESTCASE | 14 | | [ 11 22 33 44 55 ] [ 220 330 440 110 550 ]
|
||||
TESTCASE | 15 | | [ 33 22 ] [ 220 330 ]
|
||||
TESTCASE | 16 | | [ 22 33 11 ] [ 220 330 110 ]
|
||||
TESTCASE | 15 | | [ 22 33 ] [ 220 330 ]
|
||||
TESTCASE | 16 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
TESTCASE | 21 | | [ 11 22 33 ] [ 110 220 330 ]
|
||||
TESTCASE | 22 | | [ 11 22 33 ] [ 330 220 110 ]
|
||||
TESTCASE | 23 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
|
@ -117,5 +115,5 @@ TESTCASE | 24 | | [ 11 22 33 44 55 ] [ 220 330 440 110 550 ]
|
|||
TESTCASE | 25 | | [ 22 33 ] [ 220 330 ]
|
||||
TESTCASE | 26 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
|
||||
@code_hash 53895312198338603934600244087571743055624960603383611438828666636202841531600
|
||||
@code_hash 93068291567112337250118419287631047120002003622184251973082208096953112184588
|
||||
-}
|
||||
|
|
|
@ -152,8 +152,9 @@ TESTCASE | 103 | | [ 12 [] 34 91 ]
|
|||
//
|
||||
NEWC // _5
|
||||
ENDC // to_be_ref
|
||||
123 PUSHINT // to_be_ref _8=123
|
||||
NEWC // to_be_ref _8=123 _9
|
||||
NEWC // to_be_ref _8
|
||||
123 PUSHINT // to_be_ref _8 _9=123
|
||||
SWAP // to_be_ref _9=123 _8
|
||||
8 STU // to_be_ref in_c
|
||||
STREF // in_c
|
||||
ENDC // _16
|
||||
|
@ -186,13 +187,12 @@ TESTCASE | 103 | | [ 12 [] 34 91 ]
|
|||
16 PUSHINT // dict minv _57=16
|
||||
SDSKIPFIRST // dict minv
|
||||
...
|
||||
32 PUSHINT // dict minv1 minv2 minv3 found123 _78=456 dict _79=32
|
||||
32 PUSHINT // dict minv1 minv2 minv3 found123 found456 _83=32
|
||||
789 PUSHINT // dict minv1 minv2 minv3 found123 found456 _83=32 _84=789
|
||||
s0 s7 s7 XCHG3 // found456 minv1 minv2 minv3 found123 _84=789 dict _83=32
|
||||
DICTIGET
|
||||
NULLSWAPIFNOT // dict minv1 minv2 minv3 found123 _99 _100
|
||||
789 PUSHINT
|
||||
s2 POP
|
||||
s0 s6 XCHG
|
||||
32 PUSHINT // found456 minv1 minv2 minv3 found123 _83=789 dict _84=32
|
||||
NULLSWAPIFNOT // found456 minv1 minv2 minv3 found123 _101 _102
|
||||
NIP // found456 minv1 minv2 minv3 found123 found789
|
||||
...
|
||||
4 TUPLE // _86
|
||||
}>
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
;; But swapping arguments may sometimes lead to bytecode changes (see test2),
|
||||
;; both with compute-asm-ltr and without it.
|
||||
|
||||
#pragma compute-asm-ltr;
|
||||
|
||||
builder begin_cell() pure asm "NEWC";
|
||||
cell end_cell(builder b) pure asm "ENDC";
|
||||
slice begin_parse(cell c) pure asm "CTOS";
|
||||
|
|
|
@ -62,5 +62,5 @@ _ main() {
|
|||
{-
|
||||
TESTCASE | 0 | | 0
|
||||
|
||||
@code_hash 98157584761932576648981760908342408003231747902562138202913714302941716912743
|
||||
@code_hash 61273295789179921867241079778489100375537711211918844448475493726205774530743
|
||||
-}
|
||||
|
|
|
@ -52,5 +52,5 @@ _ main() {
|
|||
{-
|
||||
TESTCASE | 0 | | 0
|
||||
|
||||
@code_hash 35542701048549611407499491204004197688673151742407097578098250360682143458214
|
||||
@code_hash 13830542019509784148027107880226447201604257839069192762244575629978154217223
|
||||
-}
|
||||
|
|
|
@ -348,6 +348,7 @@ int func_proceed(const std::vector<std::string> &sources, std::ostream &outs, st
|
|||
funC::define_keywords();
|
||||
funC::define_builtins();
|
||||
pragma_allow_post_modification.always_on_and_deprecated("0.5.0");
|
||||
pragma_compute_asm_ltr.always_on_and_deprecated("0.5.0");
|
||||
|
||||
int ok = 0, proc = 0;
|
||||
try {
|
||||
|
@ -366,7 +367,6 @@ int func_proceed(const std::vector<std::string> &sources, std::ostream &outs, st
|
|||
if (!proc) {
|
||||
throw src::Fatal{"no source files, no output"};
|
||||
}
|
||||
pragma_compute_asm_ltr.check_enable_in_libs();
|
||||
pragma_remove_unused_functions.check_enable_in_libs();
|
||||
return funC::generate_output(outs, errs);
|
||||
} catch (src::Fatal& fatal) {
|
||||
|
|
|
@ -686,7 +686,7 @@ typedef std::vector<FormalArg> FormalArgList;
|
|||
struct AsmOpList;
|
||||
|
||||
struct CodeBlob {
|
||||
enum { _ComputeAsmLtr = 2, _ForbidImpure = 4 };
|
||||
enum { _ForbidImpure = 4 };
|
||||
int var_cnt, in_var_cnt, op_cnt;
|
||||
TypeExpr* ret_type;
|
||||
std::string name;
|
||||
|
|
|
@ -267,14 +267,8 @@ std::vector<var_idx_t> pre_compile_let(CodeBlob& code, Expr* lhs, Expr* rhs, con
|
|||
return right;
|
||||
}
|
||||
|
||||
std::vector<var_idx_t> pre_compile_tensor(const std::vector<Expr *> args, CodeBlob &code,
|
||||
std::vector<std::pair<SymDef*, var_idx_t>> *lval_globs,
|
||||
std::vector<int> arg_order) {
|
||||
if (arg_order.empty()) {
|
||||
arg_order.resize(args.size());
|
||||
std::iota(arg_order.begin(), arg_order.end(), 0);
|
||||
}
|
||||
func_assert(args.size() == arg_order.size());
|
||||
std::vector<var_idx_t> pre_compile_tensor(const std::vector<Expr *>& args, CodeBlob &code,
|
||||
std::vector<std::pair<SymDef*, var_idx_t>> *lval_globs) {
|
||||
std::vector<std::vector<var_idx_t>> res_lists(args.size());
|
||||
|
||||
struct ModifiedVar {
|
||||
|
@ -282,7 +276,7 @@ std::vector<var_idx_t> pre_compile_tensor(const std::vector<Expr *> args, CodeBl
|
|||
Op* op;
|
||||
};
|
||||
auto modified_vars = std::make_shared<std::vector<ModifiedVar>>();
|
||||
for (size_t i : arg_order) {
|
||||
for (size_t i = 0; i < args.size(); ++i) {
|
||||
res_lists[i] = args[i]->pre_compile(code, lval_globs);
|
||||
for (size_t j = 0; j < res_lists[i].size(); ++j) {
|
||||
TmpVar& var = code.vars.at(res_lists[i][j]);
|
||||
|
@ -329,7 +323,7 @@ std::vector<var_idx_t> Expr::pre_compile(CodeBlob& code, std::vector<std::pair<S
|
|||
}
|
||||
switch (cls) {
|
||||
case _Tensor: {
|
||||
return pre_compile_tensor(args, code, lval_globs, {});
|
||||
return pre_compile_tensor(args, code, lval_globs);
|
||||
}
|
||||
case _Apply: {
|
||||
func_assert(sym);
|
||||
|
@ -344,22 +338,16 @@ std::vector<var_idx_t> Expr::pre_compile(CodeBlob& code, std::vector<std::pair<S
|
|||
op_call = op_call->next.get();
|
||||
}
|
||||
applied_sym = op_call->fun_ref;
|
||||
func = dynamic_cast<SymValFunc*>(applied_sym->value);
|
||||
// soon we'll get rid of this pragma: it will be always on, we'll pass just {} here and below
|
||||
bool compute_asm_ltr = code.flags & CodeBlob::_ComputeAsmLtr;
|
||||
// a function may call anotherF with shuffled arguments: f(x,y) { return anotherF(y,x) }
|
||||
// then op_call looks like (_1,_0), so use op_call->right for correct positions in Op::_Call below
|
||||
// it's correct, since every argument has width 1
|
||||
std::vector<var_idx_t> res_inner = pre_compile_tensor(args, code, lval_globs, compute_asm_ltr ? std::vector<var_idx_t>{} : func->arg_order);
|
||||
std::vector<var_idx_t> res_inner = pre_compile_tensor(args, code, lval_globs);
|
||||
res.reserve(res_inner.size());
|
||||
for (var_idx_t right_idx : op_call->right) {
|
||||
res.emplace_back(res_inner[right_idx]);
|
||||
}
|
||||
} else if (func && func->arg_order.size() == args.size() && !(code.flags & CodeBlob::_ComputeAsmLtr)) {
|
||||
//std::cerr << "!!! reordering " << args.size() << " arguments of " << sym->name() << std::endl;
|
||||
res = pre_compile_tensor(args, code, lval_globs, func->arg_order);
|
||||
} else {
|
||||
res = pre_compile_tensor(args, code, lval_globs, {});
|
||||
res = pre_compile_tensor(args, code, lval_globs);
|
||||
}
|
||||
auto rvect = new_tmp_vect(code);
|
||||
auto& op = code.emplace_back(here, Op::_Call, rvect, res, applied_sym);
|
||||
|
|
|
@ -266,9 +266,6 @@ void parse_const_decl(Lexer& lex) {
|
|||
}
|
||||
lex.next();
|
||||
CodeBlob code;
|
||||
if (pragma_compute_asm_ltr.enabled()) {
|
||||
code.flags |= CodeBlob::_ComputeAsmLtr;
|
||||
}
|
||||
// Handles processing and resolution of literals and consts
|
||||
auto x = parse_expr(lex, code, false); // also does lex.next() !
|
||||
if (x->flags != Expr::_IsRvalue) {
|
||||
|
@ -1216,9 +1213,6 @@ blk_fl::val parse_stmt(Lexer& lex, CodeBlob& code) {
|
|||
CodeBlob* parse_func_body(Lexer& lex, FormalArgList arg_list, TypeExpr* ret_type, bool marked_as_pure) {
|
||||
lex.expect('{');
|
||||
CodeBlob* blob = new CodeBlob{ret_type};
|
||||
if (pragma_compute_asm_ltr.enabled()) {
|
||||
blob->flags |= CodeBlob::_ComputeAsmLtr;
|
||||
}
|
||||
if (marked_as_pure) {
|
||||
blob->flags |= CodeBlob::_ForbidImpure;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue