[Vm-dev] VM Maker: VMMaker.oscog-nice.2214.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu May 18 15:41:10 UTC 2017
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2214.mcz
==================== 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:
http://mingw-w64-public.narkive.com/1mUoWEfG/setjmp-longjmp-crashes-second-setjmp-argument
https://patchwork.ozlabs.org/patch/437794/
http://www.agardner.me/golang/windows/cgo/64-bit/setjmp/longjmp/2016/02/29/go-windows-setjmp-x86.html
https://sourceforge.net/p/mingw-w64/bugs/465/
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') -----
preambleCCode
^
'/* Disable Intel compiler inlining of warning which is used for breakpoints */
#pragma auto_inline(off)
sqInt warnpid, erroronwarn;
void
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);
else
printf("\n%s\n", s);
}
void
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);
warning(sl);
}
#pragma auto_inline(on)
void
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);
#else
printf("\nClass %s does not have the required compact class index\n", s);
#endif
exit(-1);
}
/*
* 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)
#else
# define sigsetjmp(jb,ssmf) _setjmp(jb)
# define siglongjmp(jb,v) _longjmp(jb,v)
#endif
#define odd(v) ((int)(v)&1)
#define even(v) (!!odd(v))
'!
More information about the Vm-dev
mailing list