1 $NetBSD: patch-na,v 1.1 2009/09/09 17:01:07 tnn Exp $
3 # reported upstream as:
4 # https://bugzilla.mozilla.org/show_bug.cgi?id=512802
6 --- mozilla/js/src/jsscript.cpp.orig 2009-08-24 01:32:14.000000000 +0200
7 +++ mozilla/js/src/jsscript.cpp 2009-08-24 01:36:20.000000000 +0200
8 @@ -1370,19 +1370,49 @@ js_NewScript(JSContext *cx, uint32 lengt
9 size_t size, vectorSize;
13 +#define LP64_ALIGN(V) if ((V) & 7) (V) = (((V)|7) + 1)
14 +#define LP64_ALIGNP(P) if ((uintptr_t)(P) & 7) (P) = (uint8*)(((uintptr_t)(P)|7) + 1)
16 +#define LP64_ALIGN(V)
17 +#define LP64_ALIGNP(V)
20 - size = sizeof(JSScript) +
21 - sizeof(JSAtom *) * natoms +
22 - length * sizeof(jsbytecode) +
23 - nsrcnotes * sizeof(jssrcnote);
25 - size += sizeof(JSObjectArray) + nobjects * sizeof(JSObject *);
27 - size += sizeof(JSUpvarArray) + nupvars * sizeof(uint32);
29 - size += sizeof(JSObjectArray) + nregexps * sizeof(JSObject *);
31 - size += sizeof(JSTryNoteArray) + ntrynotes * sizeof(JSTryNote);
32 + size = sizeof(JSScript);
33 + if (nobjects != 0) {
35 + size += sizeof(JSObjectArray);
39 + size += sizeof(JSUpvarArray);
41 + if (nregexps != 0) {
43 + size += sizeof(JSObjectArray);
45 + if (ntrynotes != 0) {
47 + size += sizeof(JSTryNoteArray);
51 + size += sizeof(JSAtom *) * natoms;
53 + if (nobjects != 0) {
55 + size += nobjects * sizeof(JSObject *);
58 + size += nupvars * sizeof(uint32);
60 + if (nregexps != 0) {
62 + size += nregexps * sizeof(JSObject *);
64 + size += length * sizeof(jsbytecode) +
65 + nsrcnotes * sizeof(jssrcnote) +
66 + ntrynotes * sizeof(JSTryNote);
68 script = (JSScript *) JS_malloc(cx, size);
70 @@ -1393,23 +1423,28 @@ js_NewScript(JSContext *cx, uint32 lengt
72 cursor = (uint8 *)script + sizeof(JSScript);
74 + LP64_ALIGNP(cursor);
75 script->objectsOffset = (uint8)(cursor - (uint8 *)script);
76 cursor += sizeof(JSObjectArray);
79 + LP64_ALIGNP(cursor);
80 script->upvarsOffset = (uint8)(cursor - (uint8 *)script);
81 cursor += sizeof(JSUpvarArray);
84 + LP64_ALIGNP(cursor);
85 script->regexpsOffset = (uint8)(cursor - (uint8 *)script);
86 cursor += sizeof(JSObjectArray);
89 + LP64_ALIGNP(cursor);
90 script->trynotesOffset = (uint8)(cursor - (uint8 *)script);
91 cursor += sizeof(JSTryNoteArray);
95 + LP64_ALIGNP(cursor);
96 script->atomMap.length = natoms;
97 script->atomMap.vector = (JSAtom **)cursor;
98 vectorSize = natoms * sizeof(script->atomMap.vector[0]);
99 @@ -1423,6 +1458,7 @@ js_NewScript(JSContext *cx, uint32 lengt
103 + LP64_ALIGNP(cursor);
104 JS_SCRIPT_OBJECTS(script)->length = nobjects;
105 JS_SCRIPT_OBJECTS(script)->vector = (JSObject **)cursor;
106 vectorSize = nobjects * sizeof(JS_SCRIPT_OBJECTS(script)->vector[0]);
107 @@ -1431,6 +1467,7 @@ js_NewScript(JSContext *cx, uint32 lengt
111 + LP64_ALIGNP(cursor);
112 JS_SCRIPT_UPVARS(script)->length = nupvars;
113 JS_SCRIPT_UPVARS(script)->vector = (uint32 *)cursor;
114 vectorSize = nupvars * sizeof(JS_SCRIPT_UPVARS(script)->vector[0]);
115 @@ -1439,6 +1476,7 @@ js_NewScript(JSContext *cx, uint32 lengt
119 + LP64_ALIGNP(cursor);
120 JS_SCRIPT_REGEXPS(script)->length = nregexps;
121 JS_SCRIPT_REGEXPS(script)->vector = (JSObject **)cursor;
122 vectorSize = nregexps * sizeof(JS_SCRIPT_REGEXPS(script)->vector[0]);