Skip to content

Commit

Permalink
Work around GC problem in embed API
Browse files Browse the repository at this point in the history
Cherry-picked from branch gc_dynamic_threshold on bacek's request.
See TT #1990
  • Loading branch information
nwellnhof committed Feb 2, 2011
1 parent 8f3e664 commit 1b1f6f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions frontend/parrot/main.c
Expand Up @@ -177,6 +177,11 @@ main(int argc, const char *argv[])
if (!Parrot_api_string_import(interp, parsed_flags.sourcefile, &source_str))
show_last_error_and_exit(interp);

if (parsed_flags.execute_packfile) {
if (!Parrot_api_pmc_wrap_string_array(interp, pir_argc, pir_argv, &argsarray))
show_last_error_and_exit(interp);
}

if (parsed_flags.have_pbc_file) {
if (!Parrot_api_load_bytecode_file(interp, source_str, &bytecodepmc))
show_last_error_and_exit(interp);
Expand All @@ -194,8 +199,6 @@ main(int argc, const char *argv[])
}

if (parsed_flags.execute_packfile) {
if (!Parrot_api_pmc_wrap_string_array(interp, pir_argc, pir_argv, &argsarray))
show_last_error_and_exit(interp);
if (!Parrot_api_run_bytecode(interp, bytecodepmc, argsarray))
show_last_error_and_exit(interp);
}
Expand Down
2 changes: 2 additions & 0 deletions t/src/embed/api.t
Expand Up @@ -152,8 +152,10 @@ int main(void) {
/* Step 1: Take the PIR, and compile it to PBC. Write to file */
Parrot_api_string_import(interp, "$temp_pir", &filename);
Parrot_api_toggle_gc(interp, 0);
Parrot_api_wrap_imcc_hack(interp, filename, 0, NULL, &bytecode, &run_pbc, imcc_run_api);
Parrot_api_serialize_bytecode_pmc(interp, bytecode, &pbc_s);
Parrot_api_toggle_gc(interp, 1);
Parrot_api_string_export_ascii(interp, pbc_s, &pbc_c);
Parrot_api_string_byte_length(interp, pbc_s, &length);
file = fopen("$temp_pbc", "w");
Expand Down
8 changes: 4 additions & 4 deletions tools/dev/pbc_to_exe.pir
Expand Up @@ -95,14 +95,14 @@ HEADER
show_last_error_and_exit(interp);
}

if (!Parrot_api_load_bytecode_bytes(interp, program_code_addr, bytecode_size, &pbc)) {
fprintf(stderr, "PARROT VM: Could not load bytecode");
show_last_error_and_exit(interp);
}
if (!Parrot_api_pmc_wrap_string_array(interp, argc, argv, &argsarray)) {
fprintf(stderr, "PARROT VM: Could not build args array");
show_last_error_and_exit(interp);
}
if (!Parrot_api_load_bytecode_bytes(interp, program_code_addr, bytecode_size, &pbc)) {
fprintf(stderr, "PARROT VM: Could not load bytecode");
show_last_error_and_exit(interp);
}
if (!Parrot_api_run_bytecode(interp, pbc, argsarray)) {
show_last_error_and_exit(interp);
}
Expand Down

0 comments on commit 1b1f6f7

Please sign in to comment.