Detection from C as to whether our caller was OCaml#662
Detection from C as to whether our caller was OCaml#662mshinwell wants to merge 1 commit intoocaml:trunkfrom
Conversation
|
Wouldn't it be better to make it explicit it relies on |
|
I don't see why. (You could imagine a version of this that doesn't use that variable, for example.) |
|
Also, there's a good reason why this should not be thought of as a function call: it must be fully independent of any inlining decisions made by the C compiler. |
|
I am not saying it should be a function, I say it should "look like a function" (so, the parens after the macro), so that the programmer knows it is dynamically determined (by opposition to macros that are statically determined). |
|
Not only this macro is not portable across C compilers, but it is wrong for arm, arm64, powerpc, s390x, and sparc. (Hint: in these architectures, the C function returns to glue code in caml_c_call, which then returns to the OCaml code at address Could you please rethink the need for such a test? It's going to be a portability nightmare. |
|
This is only needed as an optimisation. Let me propose another means by which it could be accomplished in a different PR. |
|
Please see #664 |
ce76e02 flambda-backend: Bugfix for type_application (ocaml#746) 44f3afb flambda-backend: PR580 for main branch (ocaml#743) b851eaa flambda-backend: Backport first part of ocaml/ocaml PR10498 (ocaml#737) fafb4bd flambda-backend: Fix return mode for eta-expanded function in type_argument (ocaml#735) c31f6c3 flambda-backend: Fix treatment of functions called [@nontail] (ocaml#725) 847781e flambda-backend: Fix build_upstream post-PR703 (ocaml#712) bfcbbf8 flambda-backend: Extend Pblock value kind to handle variants (ocaml#703) b2cab95 flambda-backend: Merge ocaml-jst a6d6e0e flambda-backend: Merge ocaml-jst 88a4f63 flambda-backend: Use Pmakearray for immutable arrays (ocaml#699) eeaa44b flambda-backend: Install an ocamldoc binary (ocaml#695) 48d322b flambda-backend: Ensure that GC is not invoked from bounds check failures (ocaml#681) 4370fa1 flambda-backend: Review changes of term directory (ocaml#602) 65a4566 flambda-backend: Add code coverage using bisect_ppx (ocaml#352) 63ab65f flambda-backend: Bugfix for primitive inclusion (ocaml#662) 7e3e0c8 flambda-backend: Fix inclusion checks for primitives (ocaml#661) 96c68f9 flambda-backend: Speed up linking by changing cmxa format (ocaml#607) 1829150 flambda-backend: Bugfix for Translmod.all_idents (ocaml#659) git-subtree-dir: ocaml git-subtree-split: ce76e02
This patch adds a macro that can be used in C functions to determine whether they were directly called from OCaml code. This is needed for Spacetime instrumentation.
I am pretty sure this is correct for Unix, but I am unsure about Windows. @alainfrisch : can you comment? Should we be using the gcc builtin for
SYS_cygwin?