Subj : Re: crash in JS_NewContext To : Weiyang Zhou From : Brendan Eich Date : Wed Sep 07 2005 11:53 am Weiyang Zhou wrote: > Hi, > > We are porting SpiderMonkey to an embedded system running on a RISC 32bit > microprocessor. What compiler are you using? > str = ALIGN(buf, JSString); Could you please provide disassembly of the generated code for this line? What you describe, especially the following, sounds like a compiler bug. /be > { > > char buffer[256]; > > sprintf(buffer, "%x %x %d %d %d\n", buf, str, ALIGNMENT(JSString), > sizeof(JSString), (jsuword)(buf) % ALIGNMENT(JSString)); > > printf("%s", buffer); > > } > ..... > > Then it won't crash during the initialization. You can see the debug code > doesn't do anything significant except it uses the stack. But it still > crashes when I start using JS_CompileScript. > > With the above debug statements, I saw a difference between Windows and the > target device. In Windows, (jsuword)(buf) % ALIGNMENT(JSString) is 0, but on > the target device, (jsuword)(buf) % ALIGNMENT(JSString) is 4. Will this > make the two macros in jsatom.c fail? ALIGNMENT(JSString) and > sizeof(JSString) are both 8 in the two enviroment. > > #define ALIGNMENT(t) JS_MAX(JSVAL_ALIGN, sizeof(t)) > #define ALIGN(b,t) ((t*) &(b)[ALIGNMENT(t) - (jsuword)(b) % > ALIGNMENT(t)]) > > Also, can anyone explain the purpose of the ALIGN macro? Any help will be > appreciated. Thanks a lot. > > > > .