Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler: fix toplevel with globaldeacode #1556

Merged
merged 2 commits into from
Jan 21, 2024
Merged

Compiler: fix toplevel with globaldeacode #1556

merged 2 commits into from
Jan 21, 2024

Conversation

hhugo
Copy link
Member

@hhugo hhugo commented Jan 21, 2024

Bug introduced in #1503

When using the toplevel and evaluating an expression. The corresponding bytecode received by jsoo look like a function body. In particular, it contains Return instructions returning the evaluated expression. The global DCE think that these returned values are unused and removes them. The PR marks all values returned at "toplevel" as escaping.

cc @micahcantor @OlivierNicole

@hhugo hhugo force-pushed the fix-toplevel-gdce branch from 7df0b16 to 4427bc3 Compare January 21, 2024 13:25
@hhugo hhugo force-pushed the fix-toplevel-gdce branch from 4427bc3 to 0afbc3b Compare January 21, 2024 13:37
@hhugo hhugo merged commit 23ea21f into master Jan 21, 2024
15 checks passed
@hhugo hhugo deleted the fix-toplevel-gdce branch January 21, 2024 14:30
vouillon added a commit that referenced this pull request Sep 22, 2024
vouillon added a commit that referenced this pull request Sep 23, 2024
It needs to take into account values flowing out of the toplevel function.
vouillon added a commit that referenced this pull request Sep 23, 2024
It needs to take into account values flowing out of the toplevel function.
PR #1556 added a workaround in the global deadcode analysis for this, but
it's better to fix the issue at its root.
hhugo pushed a commit that referenced this pull request Sep 23, 2024
It needs to take into account values flowing out of the toplevel function.
PR #1556 added a workaround in the global deadcode analysis for this, but
it's better to fix the issue at its root.
hhugo added a commit to hhugo/opam-repository that referenced this pull request Nov 22, 2024
CHANGES:

## Features/Changes
* Misc: update testsuite to OCaml 5.2
* Misc: CI uses opam.2.2 and no longer use sunset repo
* Misc: yojson is no longer optional
* Misc: reduce the diff with the wasm_of_ocaml fork
* Misc: finalize support for OCaml 5.3
* Compiler: speedup global_flow/global_deadcode pass on large bytecode
* Compiler: improved global dead code elimination (ocsigen/js_of_ocaml#2206)
* Compiler: speedup json parsing, relying on Yojson.Raw (ocsigen/js_of_ocaml#1640)
* Compiler: Decode sourcemap mappings only when necessary (ocsigen/js_of_ocaml#1664)
* Compiler: mark [TextEncoder] as reserved
* Compiler: add support for the Wasm backend in parts of the pipeline, in
  prevision for the merge of wasm_of_ocaml
* Compiler: introduce a Targetint module
  that follows the semantic of the backend (js or wasm)
* Compiler: warn on joo_global_object
* Compiler: revisit static env handling (ocsigen/js_of_ocaml#1708)
* Compiler: Emit index source_map to avoid changing mappings (ocsigen/js_of_ocaml#1714, ocsigen/js_of_ocaml#1715)
* Compiler: improved source map generation (ocsigen/js_of_ocaml#1716)
* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
* Runtime: backtraces are really expensive, they need to be explicitly
  requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1)
* Runtime: allow dynlink of precompiled js with separate compilation (ocsigen/js_of_ocaml#1676)
* Runtime: reimplement the runtime of weak and ephemeron (ocsigen/js_of_ocaml#1707)
* Lib: Modify Typed_array API for compatibility with WebAssembly
* Lib: add details element and toggle event (ocsigen/js_of_ocaml#1728)
* Toplevel: no longer set globals for toplevel initialization
* Runtime: precompute constants used in `caml_lxm_next` (ocsigen/js_of_ocaml#1730)
* Runtime: cleanup runtime

## Bug fixes
* Runtime: fix parsing of unsigned integers (0u2147483648) (ocsigen/js_of_ocaml#1633, ocsigen/js_of_ocaml#1666)
* Runtime: fix incorrect pos_in after unmarshalling
* Runtime: make float_of_string stricter (ocsigen/js_of_ocaml#1609)
* Toplevel: fix missing primitives with separate compilation
* Compiler: fix link of packed modules with separate compilation
* Compiler: Fixed the static evaluation of some equalities (ocsigen/js_of_ocaml#1659)
* Compiler: fix global analysis bug (subsumes ocsigen/js_of_ocaml#1556)
hhugo added a commit to hhugo/opam-repository that referenced this pull request Nov 23, 2024
CHANGES:

## Features/Changes
* Misc: update testsuite to OCaml 5.2
* Misc: CI uses opam.2.2 and no longer use sunset repo
* Misc: yojson is no longer optional
* Misc: reduce the diff with the wasm_of_ocaml fork
* Misc: finalize support for OCaml 5.3
* Compiler: speedup global_flow/global_deadcode pass on large bytecode
* Compiler: improved global dead code elimination (ocsigen/js_of_ocaml#2206)
* Compiler: speedup json parsing, relying on Yojson.Raw (ocsigen/js_of_ocaml#1640)
* Compiler: Decode sourcemap mappings only when necessary (ocsigen/js_of_ocaml#1664)
* Compiler: mark [TextEncoder] as reserved
* Compiler: add support for the Wasm backend in parts of the pipeline, in
  prevision for the merge of wasm_of_ocaml
* Compiler: introduce a Targetint module
  that follows the semantic of the backend (js or wasm)
* Compiler: warn on joo_global_object
* Compiler: revisit static env handling (ocsigen/js_of_ocaml#1708)
* Compiler: Emit index source_map to avoid changing mappings (ocsigen/js_of_ocaml#1714, ocsigen/js_of_ocaml#1715)
* Compiler: improved source map generation (ocsigen/js_of_ocaml#1716)
* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
* Runtime: backtraces are really expensive, they need to be explicitly
  requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1)
* Runtime: allow dynlink of precompiled js with separate compilation (ocsigen/js_of_ocaml#1676)
* Runtime: reimplement the runtime of weak and ephemeron (ocsigen/js_of_ocaml#1707)
* Lib: Modify Typed_array API for compatibility with WebAssembly
* Lib: add details element and toggle event (ocsigen/js_of_ocaml#1728)
* Toplevel: no longer set globals for toplevel initialization
* Runtime: precompute constants used in `caml_lxm_next` (ocsigen/js_of_ocaml#1730)
* Runtime: cleanup runtime

## Bug fixes
* Runtime: fix parsing of unsigned integers (0u2147483648) (ocsigen/js_of_ocaml#1633, ocsigen/js_of_ocaml#1666)
* Runtime: fix incorrect pos_in after unmarshalling
* Runtime: make float_of_string stricter (ocsigen/js_of_ocaml#1609)
* Toplevel: fix missing primitives with separate compilation
* Compiler: fix link of packed modules with separate compilation
* Compiler: Fixed the static evaluation of some equalities (ocsigen/js_of_ocaml#1659)
* Compiler: fix global analysis bug (subsumes ocsigen/js_of_ocaml#1556)
hhugo added a commit to hhugo/opam-repository that referenced this pull request Nov 26, 2024
CHANGES:

## Features/Changes
* Misc: update testsuite to OCaml 5.2
* Misc: CI uses opam.2.2 and no longer use sunset repo
* Misc: yojson is no longer optional
* Misc: reduce the diff with the wasm_of_ocaml fork
* Misc: finalize support for OCaml 5.3
* Compiler: speedup global_flow/global_deadcode pass on large bytecode
* Compiler: improved global dead code elimination (ocsigen/js_of_ocaml#2206)
* Compiler: speedup json parsing, relying on Yojson.Raw (ocsigen/js_of_ocaml#1640)
* Compiler: Decode sourcemap mappings only when necessary (ocsigen/js_of_ocaml#1664)
* Compiler: mark [TextEncoder] as reserved
* Compiler: add support for the Wasm backend in parts of the pipeline, in
  prevision for the merge of wasm_of_ocaml
* Compiler: introduce a Targetint module
  that follows the semantic of the backend (js or wasm)
* Compiler: warn on joo_global_object
* Compiler: revisit static env handling (ocsigen/js_of_ocaml#1708)
* Compiler: Emit index source_map to avoid changing mappings (ocsigen/js_of_ocaml#1714, ocsigen/js_of_ocaml#1715)
* Compiler: improved source map generation (ocsigen/js_of_ocaml#1716)
* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
* Runtime: backtraces are really expensive, they need to be explicitly
  requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1)
* Runtime: allow dynlink of precompiled js with separate compilation (ocsigen/js_of_ocaml#1676)
* Runtime: reimplement the runtime of weak and ephemeron (ocsigen/js_of_ocaml#1707)
* Lib: Modify Typed_array API for compatibility with WebAssembly
* Lib: add details element and toggle event (ocsigen/js_of_ocaml#1728)
* Toplevel: no longer set globals for toplevel initialization
* Runtime: precompute constants used in `caml_lxm_next` (ocsigen/js_of_ocaml#1730)
* Runtime: cleanup runtime

## Bug fixes
* Runtime: fix parsing of unsigned integers (0u2147483648) (ocsigen/js_of_ocaml#1633, ocsigen/js_of_ocaml#1666)
* Runtime: fix incorrect pos_in after unmarshalling
* Runtime: make float_of_string stricter (ocsigen/js_of_ocaml#1609)
* Toplevel: fix missing primitives with separate compilation
* Compiler: fix link of packed modules with separate compilation
* Compiler: Fixed the static evaluation of some equalities (ocsigen/js_of_ocaml#1659)
* Compiler: fix global analysis bug (subsumes ocsigen/js_of_ocaml#1556)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant