VM Maker: VMMaker.oscog-nice.2214.mcz

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

VM Maker: VMMaker.oscog-nice.2214.mcz

Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:

==================== Summary ====================

Name: VMMaker.oscog-nice.2214
Author: nice
Time: 18 May 2017, 5:38:43.506121 pm
UUID: 9b032b43-4355-954e-9c08-66df1f3d8138
Ancestors: VMMaker.oscog-eem.2213

Use a special form of sigsetjmp to avoid stack unwinding on Windows 64.

Note 1: stack unwinding is for C++ exception handling (for example for calling destructors).
We do not need it, and it requires the presence of specific information on stack which is not honoured by our JIT frames.

Note 2: this patch is specific to Mingw-w64. It might not work for another compiler (MSVC/Intel/...). Someone making the Vm compile with other tools might have to amend this #preambleCCode again.

In mingw, there is a possibility to pass a 2nd parameter to a _setjmp, and if this 2nd argument is NULL, there will be no context unwinding. This knowledge is extracted from these references:


At current time of writing, _setjmp has 2 arguments #ifndef USE_NO_MINGW_SETJMP_TWO_ARGS
and no header defines that by default:
grep -r USE_NO_MINGW_SETJMP_TWO_ARGS /usr/x86_64-w64-mingw32/sys-root/mingw/include

=============== Diff against VMMaker.oscog-eem.2213 ===============

Item was changed:
  ----- Method: StackInterpreter class>>preambleCCode (in category 'translation') -----
  '/* Disable Intel compiler inlining of warning which is used for breakpoints */
  #pragma auto_inline(off)
  sqInt warnpid, erroronwarn;
  warning(char *s) { /* Print an error message but don''t necessarily exit. */
  if (erroronwarn) error(s);
  if (warnpid)
  printf("\n%s pid %ld\n", s, (long)warnpid);
  printf("\n%s\n", s);
  warningat(char *s, int l) { /* ditto with line number. */
  /* use alloca to call warning so one does not have to remember to set two breakpoints... */
  char *sl = alloca(strlen(s) + 16);
  sprintf(sl, "%s %d", s, l);
  #pragma auto_inline(on)
  invalidCompactClassError(char *s) { /* Print a (compact) class index error message and exit. */
  #if SPURVM
  printf("\nClass %s does not have the required class index\n", s);
  printf("\nClass %s does not have the required compact class index\n", s);
   * Define sigsetjmp and siglongjmp to be the most minimal setjmp/longjmp available on the platform.
+  * Note: on windows 64 via mingw-w64, the 2nd argument NULL to _setjmp prevents stack unwinding
  #undef sigsetjmp
  #undef siglongjmp
+ #if _WIN64
+ # define sigsetjmp(jb,ssmf) _setjmp(jb,NULL)
+ # define siglongjmp(jb,v) longjmp(jb,v)
+ #elif _WIN32
- #if _WIN32
  # define sigsetjmp(jb,ssmf) setjmp(jb)
  # define siglongjmp(jb,v) longjmp(jb,v)
  # define sigsetjmp(jb,ssmf) _setjmp(jb)
  # define siglongjmp(jb,v) _longjmp(jb,v)
  #define odd(v) ((int)(v)&1)
  #define even(v) (!!odd(v))