From fc566f3cc9c272f6478830b4b5707e224bae5a2a Mon Sep 17 00:00:00 2001 From: Bob Dubner <rdubner@symas.com> Date: Thu, 16 May 2024 13:14:59 -0400 Subject: [PATCH] Trimmed __gg__initialize_variable() call --- gcc/cobol/genapi.cc | 49 ++++++++++++++++++++++-------------------- libgcobol/libgcobol.cc | 43 ++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 3ed02fa2d427..41311f60e788 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -1196,36 +1196,39 @@ initialize_variable_internal(cbl_refer_t refer, bool explicitly=false) } } - static const int JUST_ONCE = 0x400; - static const int EXPLICIT_BIT = 0x200; - static const int DEFAULTBYTE_BIT = 0x100; - static const int DEFAULT_BYTE_MASK = 0x0FF; + static const int DEFAULT_BYTE_MASK = 0x00000000FF; + static const int NSUBSCRIPT_MASK = 0x0000000F00; + static const int NSUBSCRIPT_SHIFT = 8; + static const int DEFAULTBYTE_BIT = 0x0000001000; + static const int EXPLICIT_BIT = 0x0000002000; + static const int REDEFINED_BIT = 0x0000004000; - int explicitbits = explicitly ? EXPLICIT_BIT : 0; - explicitbits |= wsclear() - ? DEFAULTBYTE_BIT + (*wsclear() & DEFAULT_BYTE_MASK) + int flag_bits = 0; + flag_bits |= explicitly ? EXPLICIT_BIT : 0; + flag_bits |= is_redefined && !explicitly ? REDEFINED_BIT : 0 ; + flag_bits |= wsclear() + ? DEFAULTBYTE_BIT + (*wsclear() & DEFAULT_BYTE_MASK) : 0; - if( is_redefined || explicitbits || !refer_is_clean(refer) ) + flag_bits |= (refer.nsubscript << NSUBSCRIPT_SHIFT) & NSUBSCRIPT_MASK; +// if( is_redefined || flag_bits || !refer_is_clean(refer) ) { refer_fill_dest(refer); gg_call(VOID, "__gg__initialize_variable", - 4, + 2, gg_get_address_of(refer.refer_decl_node), - is_redefined && !explicitly ? integer_one_node : integer_zero_node, - build_int_cst_type(UINT, refer.nsubscript), - build_int_cst_type(INT, explicitbits) ); - } - else - { - // We have a clean refer with no mods, so we can send just the pointer to - // the field - refer_fill_dest(refer); - gg_call(VOID, - "__gg__initialize_variable_clean", - 1, - gg_get_address_of(refer.field->var_decl_node)); - } + build_int_cst_type(INT, flag_bits) ); + } +// else +// { +// // We have a clean refer with no mods, so we can send just the pointer to +// // the field +// refer_fill_dest(refer); +// gg_call(VOID, +// "__gg__initialize_variable_clean", +// 1, +// gg_get_address_of(refer.field->var_decl_node)); +// } TRACE1 { diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc index f357026f4cf3..f2dd3818fb1c 100644 --- a/libgcobol/libgcobol.cc +++ b/libgcobol/libgcobol.cc @@ -3985,18 +3985,21 @@ static void init_var_both(cblc_field_t *var, unsigned char *qual_data, - int is_redefined, - unsigned int nsubscripts, - int explicitbits) - { - //fprintf(stderr, "CALLED WITH %s 0x%x\n", var->name, explicitbits); - static const int EXPLICIT_BIT = 0x200; - static const int DEFAULTBYTE_BIT = 0x100; - static const int DEFAULT_BYTE_MASK = 0x0FF; - - bool explicitly = !!(explicitbits & EXPLICIT_BIT); - bool defaultbyte_in_play = !!(explicitbits & DEFAULTBYTE_BIT); - char defaultbyte = explicitbits & DEFAULT_BYTE_MASK; + int flag_bits) + { + //fprintf(stderr, "CALLED WITH %s 0x%x\n", var->name, flag_bits); + static const int DEFAULT_BYTE_MASK = 0x00000000FF; + static const int NSUBSCRIPT_MASK = 0x0000000F00; + static const int NSUBSCRIPT_SHIFT = 8; + static const int DEFAULTBYTE_BIT = 0x0000001000; + static const int EXPLICIT_BIT = 0x0000002000; + static const int REDEFINED_BIT = 0x0000004000; + + bool is_redefined = !!(flag_bits & REDEFINED_BIT); + bool explicitly = !!(flag_bits & EXPLICIT_BIT); + bool defaultbyte_in_play = !!(flag_bits & DEFAULTBYTE_BIT); + char defaultbyte = flag_bits & DEFAULT_BYTE_MASK; + unsigned int nsubscripts = (flag_bits & NSUBSCRIPT_MASK) >> NSUBSCRIPT_SHIFT; if( var->data == NULL && var->attr & (temporary_e | intermediate_e) @@ -4147,8 +4150,6 @@ init_var_both(cblc_field_t *var, } } -explicitly = false; - if( is_redefined || a_parent_initialized || var->level == LEVEL66 || var->level == LEVEL88) { // Don't initialize variables that have the REDEFINES clause. Many things @@ -4243,7 +4244,7 @@ explicitly = false; { memcpy(outer_location, var->initial, var->capacity); } - else if( !explicitly ) + else { if( !defaultbyte_in_play ) { @@ -4269,7 +4270,7 @@ explicitly = false; { memcpy(outer_location, var->initial, var->capacity); } - else if( !explicitly ) + else { if( !defaultbyte_in_play ) { @@ -4387,15 +4388,11 @@ explicitly = false; extern "C" void __gg__initialize_variable(cblc_refer_t *var_ref, - int is_redefined, - unsigned int nsubscripts, - int explicitbits) + int flag_bits) { init_var_both( var_ref->field, var_ref->qual_data, - is_redefined, - nsubscripts, - explicitbits); + flag_bits); } extern "C" @@ -4404,8 +4401,6 @@ __gg__initialize_variable_clean(cblc_field_t *var) { init_var_both( var, var->data, - 0, - 0, 0); } -- GitLab