Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
2421-YCF-Don-t-do-unnecessary-transformations-o...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2421-YCF-Don-t-do-unnecessary-transformations-of-special-.patch of Package erlang
From 120fe9f7775e47b5eda386dbc99801cb688de36d Mon Sep 17 00:00:00 2001 From: Kjell Winblad <kjellwinblad@gmail.com> Date: Mon, 8 Mar 2021 16:25:39 +0100 Subject: [PATCH 1/2] YCF: Don't do unnecessary transformations of special code sections --- .../custom_code_save_restore_yield_state.c | 19 ++++++++++++++++++- ...custom_code_save_restore_yield_state.c.out | 8 +++++++- erts/lib_src/yielding_c_fun/test/test.sh | 4 ++-- erts/lib_src/yielding_c_fun/ycf_node.c | 15 --------------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c b/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c index 739cd9702a..7b0bc7c1c2 100644 --- a/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c +++ b/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c @@ -31,6 +31,11 @@ #define YCF_YIELD() +int fun2(int x){ + YCF_YIELD(); + return x; +} + int fun(char x){ int y = 10; /*special_code_start:ON_SAVE_YIELD_STATE*/ @@ -46,7 +51,14 @@ int fun(char x){ /*special_code_end*/ /*special_code_start:ON_DESTROY_STATE_OR_RETURN*/ if(0){ - printf("I got destroyed or returned y=%d\n", y); + int hej = 123; + printf("I got destroyed or returned y=%d hej=%d\n", y, hej); + } + /*special_code_end*/ + /*special_code_start:ON_DESTROY_STATE*/ + if(0){ + int hej = 321; + printf("I got destroyed y=%d call_in_special_code=%d hej=%d\n", y, fun2(42), hej); } /*special_code_end*/ /*special_code_start:ON_RESTORE_YIELD_STATE*/ @@ -107,6 +119,11 @@ int main( int argc, const char* argv[] ) int ret = 0; long nr_of_reductions = 1; #ifdef YCF_YIELD_CODE_GENERATED + ret = fun_ycf_gen_yielding(&nr_of_reductions,&wb,NULL,allocator,freer,NULL,0,NULL,1); + printf("CALLING DESTROY\n"); + fun_ycf_gen_destroy(wb); + wb = NULL; + printf("DESTROY ENDED\n"); do{ ret = fun_ycf_gen_yielding(&nr_of_reductions,&wb,NULL,allocator,freer,NULL,0,NULL,1); if(wb != NULL){ diff --git a/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c.out b/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c.out index 639fd64b46..fa552157e1 100644 --- a/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c.out +++ b/erts/lib_src/yielding_c_fun/test/examples/custom_code_save_restore_yield_state.c.out @@ -1,5 +1,11 @@ y=10 y=42 z=10 +CALLING DESTROY +I got destroyed or returned y=42 hej=123 +I got destroyed y=42 call_in_special_code=42 hej=321 +DESTROY ENDED +y=10 +y=42 z=10 TRAPPED y=42 x=9 y=42 x=18 @@ -7,5 +13,5 @@ y=42 x=18 y=42 x=9 SUCCESS I returned y=42 -I got destroyed or returned y=42 +I got destroyed or returned y=42 hej=123 RETURNED 9 diff --git a/erts/lib_src/yielding_c_fun/test/test.sh b/erts/lib_src/yielding_c_fun/test/test.sh index c2c79655da..692cf1a3e9 100755 --- a/erts/lib_src/yielding_c_fun/test/test.sh +++ b/erts/lib_src/yielding_c_fun/test/test.sh @@ -58,7 +58,7 @@ TMP_O_FILE2=$TMP_DIR/tmp2.o TMP_H_FILE=$TMP_DIR/tmp.h TMP_CC_OUT=$TMP_DIR/a.out -CC_ARGS="-std=c99 -pedantic -Wall" +CC_ARGS="-std=c99 -pedantic -Wall -g" CC=clang @@ -102,7 +102,7 @@ SIMPLE_TEST_FILES_YIELD_FUNS=("-fnoauto fun" "-fnoauto fun -fnoauto sub_fun_1 -fnoauto sub_fun_2 -fnoauto sub_fun_3" "-fnoauto A -fnoauto B" "-fnoauto fun" - "-fnoauto fun" + "-fnoauto fun -fnoauto fun2" "-fnoauto fun" "-fnoauto fun" "-fnoauto fun" diff --git a/erts/lib_src/yielding_c_fun/ycf_node.c b/erts/lib_src/yielding_c_fun/ycf_node.c index 362f151d40..74a1483208 100644 --- a/erts/lib_src/yielding_c_fun/ycf_node.c +++ b/erts/lib_src/yielding_c_fun/ycf_node.c @@ -289,21 +289,6 @@ void ycf_node_search_and_replace_statements_in_node(ycf_node* n, ycf_node* (*rep ycf_node_code_scope* s){ if(n->type == ycf_node_type_code_scope){ ycf_node_search_and_replace_statements_in_scope(&n->u.code_scope, replacer, context); - } else if(n->type == ycf_node_type_on_destroy_state_code || - n->type == ycf_node_type_on_restore_yield_state_code || - n->type == ycf_node_type_on_save_yield_state_code || - n->type == ycf_node_type_on_destroy_state_or_return_code || - n->type == ycf_node_type_on_return_code) { - ycf_node* replace_candidate = n->u.special_code_block.code.if_statement; - ycf_node* possible_replacement = replacer(replace_candidate, s, context); - if(replace_candidate != possible_replacement){ - n->u.special_code_block.code.if_statement = possible_replacement; - } else { - ycf_node_search_and_replace_statements_in_node(n->u.special_code_block.code.if_statement, - replacer, - context, - s); - } } else if (n->type == ycf_node_type_if){ ycf_node_search_and_replace_statements_in_node(n->u.if_n.if_statement, replacer, context, s); } else if (n->type == ycf_node_type_if_else){ -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor