Subj : Re: crash in JS_NewContext To : netscape.public.mozilla.jseng From : Weiyang Zhou Date : Wed Sep 07 2005 02:53 pm We are using mips-elf-gcc (GCC) 3.2. We really don't think it is the compiler's problem because the ALIGN macro is doing the things it suppose to do. Here are the values from the sprintf statement.: 807ef884 807ef888 8 8 4 You can see str is shifted to 8 bytes boundary from the start address of buf. "Brendan Eich" wrote in message news:431F2922.9000009@meer.net... > 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. >> >> >> .