[cxx] Fixes for all lanes to build as C++ but w/o configure.ac change. (mono/mono...
authorJay Krell <jaykrell@microsoft.com>
Tue, 14 Jan 2020 11:32:08 +0000 (03:32 -0800)
committerBernhard Urban-Forster <lewurm@gmail.com>
Tue, 14 Jan 2020 11:32:08 +0000 (12:32 +0100)
* [cxx] dlmalloc remove extern "C" and remove NO_MALLINFO.

* [cxx] Move CallInst bitfields to the end to minimize padding for alignment
and fix an unexplained LLVM problem.

Commit migrated from https://github.com/mono/mono/commit/dc866c2aadb6f6aba04ca0b5eb5799c4e5b7a0fd

src/mono/mono/mini/mini.h
src/mono/mono/utils/dlmalloc.c
src/mono/mono/utils/dlmalloc.h

index 134adb7..6d51b73 100644 (file)
@@ -783,16 +783,34 @@ struct MonoCallInst {
        MonoInst *out_args;
        MonoInst *vret_var;
        gconstpointer fptr;
+       MonoJitICallId jit_icall_id;
        guint stack_usage;
        guint stack_align_amount;
+       regmask_t used_iregs;
+       regmask_t used_fregs;
+       GSList *out_ireg_args;
+       GSList *out_freg_args;
+       GSList *outarg_vts;
+       CallInfo *call_info;
+#ifdef ENABLE_LLVM
+       LLVMCallInfo *cinfo;
+       int rgctx_arg_reg, imt_arg_reg;
+#endif
+#ifdef TARGET_ARM
+       /* See the comment in mini-arm.c!mono_arch_emit_call for RegTypeFP. */
+       GSList *float_args;
+#endif
+       // Bitfields are at the end due to an unexplained problem with C++ and LLVM.
+       // This is also their ideal place to minimize padding for alignment,
+       // unless there is a placement to increase locality.
+
        guint is_virtual : 1;
        // FIXME tailcall field is written after read; prefer MONO_IS_TAILCALL_OPCODE.
        guint tailcall : 1;
        /* If this is TRUE, 'fptr' points to a MonoJumpInfo instead of an address. */
        guint fptr_is_patch : 1;
-       MonoJitICallId jit_icall_id;
        /*
-        * If this is true, then the call returns a vtype in a register using the same 
+        * If this is true, then the call returns a vtype in a register using the same
         * calling convention as OP_CALL.
         */
        guint vret_in_reg : 1;
@@ -804,20 +822,6 @@ struct MonoCallInst {
        guint32 rgctx_reg : 1;
        /* Whenever the call will need an unbox trampoline */
        guint need_unbox_trampoline : 1;
-       regmask_t used_iregs;
-       regmask_t used_fregs;
-       GSList *out_ireg_args;
-       GSList *out_freg_args;
-       GSList *outarg_vts;
-       CallInfo *call_info;
-#ifdef ENABLE_LLVM
-       LLVMCallInfo *cinfo;
-       int rgctx_arg_reg, imt_arg_reg;
-#endif
-#ifdef TARGET_ARM
-       /* See the comment in mini-arm.c!mono_arch_emit_call for RegTypeFP. */
-       GSList *float_args;
-#endif
 };
 
 struct MonoCallArgParm {
index 4201044..ed68e41 100644 (file)
@@ -652,10 +652,6 @@ struct mallinfo {
 #endif /* HAVE_USR_INCLUDE_MALLOC_H */
 #endif /* NO_MALLINFO */
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 #if !ONLY_MSPACES
 
 /* ------------------- Declarations of public routines ------------------- */
@@ -1146,10 +1142,6 @@ int mspace_mallopt(int, int);
 
 #endif /* MSPACES */
 
-#ifdef __cplusplus
-};  /* end of extern "C" */
-#endif /* __cplusplus */
-
 /*
   ========================================================================
   To make a fully customizable malloc.h header file, cut everything
index 5619215..327cc4c 100644 (file)
 #include <stddef.h>   /* for size_t */
 #include <mono/utils/mono-compiler.h>
 
-// Returning an undefined struct by value from extern "C"
-// is sometimes an error. Mono does not use the code (dlmallinfo)..
-//
-// Other fixes:
-//   - define the struct
-//   - #if __cplusplus
-//   - #if HOST_WASM
-//   - #ifndef HAVE_USR_INCLUDE_MALLOC_H
-//   - Make it not extern "C".
-//   - Return the struct through an out parameter.
-//   - remove extern "C" entirely in dlmalloc.
-//
-// Mono does not use the function (dlmallinfo).
-//
-#define NO_MALLINFO 1 /* mono */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #if !ONLY_MSPACES
 
 #ifndef USE_DL_PREFIX
@@ -554,8 +534,4 @@ int mspace_mallopt(int, int);
 
 #endif  /* MSPACES */
 
-#ifdef __cplusplus
-};  /* end of extern "C" */
-#endif
-
 #endif /* MALLOC_280_H */