Skip to content

Commit

Permalink
Add multithreaded version for string functions and remove static vari…
Browse files Browse the repository at this point in the history
…ables
  • Loading branch information
engboris committed Apr 24, 2024
1 parent 2e620aa commit b0109b9
Show file tree
Hide file tree
Showing 15 changed files with 15,160 additions and 329 deletions.
12 changes: 12 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
* codegen.c: handle profiling code generation under the
cb_flag_prof guard

2024-02-26 Boris Eng <[email protected]>

* codegen.c (output_strings_states, codegen_internal):
added structures for the data used by strings functions as local variables
in the C generated code
* parser.y (examine_format_variant, inspect_region):
function calls of strings functions have been replaced by calls to
thread-safe versions (using state structures instead of static variables)
* typeck.c: a lot of functions have been changed in that file in order to
make them coherent with the above changes and all those changes are
omitted for more concision

2024-02-19 Boris Eng <[email protected]>

* parser.y (screen_value_clause): replaced basic literals by literals
Expand Down
23 changes: 23 additions & 0 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,28 @@ output_nonlocal_field_cache (void)
output_storage ("\n/* End of fields */\n\n");
}

/* Strings states */

static void
output_strings_states (struct cb_program *prog)
{
unsigned int strings_used =
prog->flag_inspect_used ||
prog->flag_string_used ||
prog->flag_unstring_used;

if (strings_used)
output_local ("/* States of string statements */\n");
if (prog->flag_inspect_used)
output_local ("struct cob_inspect_state *inspect_st = NULL;\n");
if (prog->flag_string_used)
output_local ("struct cob_string_state *string_st = NULL;\n");
if (prog->flag_unstring_used)
output_local ("struct cob_unstring_state *unstring_st = NULL;\n");
if (strings_used)
output_newline ();
}

/* Literals, figurative constants and user-defined constants */

static void
Expand Down Expand Up @@ -14053,6 +14075,7 @@ codegen_internal (struct cb_program *prog, const int subsequent_call)
output_call_parameter_stack_pointers (prog);
output_frame_stack (prog);
output_dynamic_field_function_id_pointers ();
output_strings_states (prog);

if (prog->report_storage) {
output_target = prog->local_include->local_fp;
Expand Down
30 changes: 25 additions & 5 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -14944,7 +14944,11 @@ examine_format_variant:
t = cb_build_tallying_value (x, r);
break;
case EXAMINE_TAL_UNTIL_FIRST:
r = cb_list_add (r, CB_BUILD_FUNCALL_1 ("cob_inspect_before", x));
r = cb_list_add (r, CB_BUILD_FUNCALL_2 (
"cob_inspect_before_mt",
current_program->inspect_st_ref,
x
));
t = cb_build_tallying_characters (r);
break;
/* LCOV_EXCL_START */
Expand All @@ -14965,7 +14969,11 @@ examine_format_variant:
t = cb_build_replacing_leading (x, replacing_to, r);
break;
case EXAMINE_TAL_UNTIL_FIRST:
r = cb_list_add (r, CB_BUILD_FUNCALL_1 ("cob_inspect_before", x));
r = cb_list_add (r, CB_BUILD_FUNCALL_2 (
"cob_inspect_before_mt",
current_program->inspect_st_ref,
x
));
t = cb_build_replacing_characters (replacing_to, r);
break;
}
Expand All @@ -14988,7 +14996,11 @@ examine_format_variant:
t = cb_build_replacing_first (from, to, r);
break;
case EXAMINE_REP_UNTIL_FIRST:
r = cb_list_add (r, CB_BUILD_FUNCALL_1 ("cob_inspect_before", from));
r = cb_list_add (r, CB_BUILD_FUNCALL_2 (
"cob_inspect_before_mt",
current_program->inspect_st_ref,
from
));
t = cb_build_replacing_characters (to, r);
break;
/* LCOV_EXCL_START */
Expand Down Expand Up @@ -15202,14 +15214,22 @@ inspect_region:
inspect_before:
BEFORE _initial x
{
$$ = CB_BUILD_FUNCALL_1 ("cob_inspect_before", $3);
$$ = CB_BUILD_FUNCALL_2 (
"cob_inspect_before_mt",
current_program->inspect_st_ref,
$3
);
}
;

inspect_after:
AFTER _initial x
{
$$ = CB_BUILD_FUNCALL_1 ("cob_inspect_after", $3);
$$ = CB_BUILD_FUNCALL_2 (
"cob_inspect_after_mt",
current_program->inspect_st_ref,
$3
);
}
;

Expand Down
Loading

0 comments on commit b0109b9

Please sign in to comment.