Closed Bug 389880 Opened 17 years ago Closed 17 years ago

Removal of gcflags from jsNewString+ functions.

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

References

Details

Attachments

(1 file, 1 obsolete file)

js_NewDependentString, js_NewStringCopyN and js_NewStringCopyZ takes an extra gcflags argument for symmetry with js_NewString. Yet in almost all cases the functions are called with 0 as gcflags. The only exception is js_InitRuntimeStringState where js_NewStringCopyN is called with GCF_LOCK flag. But even in that place GCF_LOCK can be replaced by 0 as the string is atomized as pinned atom which roots the string.

So it would be nice to remove the extra arg to shrink the code.
Attached patch implementation v1 (obsolete) — Splinter Review
The patch removes gcflag from js_NewDependentString, js_NewStringCopyN and js_NewStringCopyZ. It also moves emptyAtom initialization to js_InitAtomState so js_InitRuntimeStringState can just set JSRuntime.emptyString to atom's string.
Attachment #274205 - Flags: review?(brendan)
Comment on attachment 274205 [details] [diff] [review]
implementation v1

Only one nit/question:

>-JS_FRIEND_API(const char *)
>-js_AtomToPrintableString(JSContext *cx, JSAtom *atom)
>-{
>-    return js_ValueToPrintableString(cx, ATOM_KEY(atom));
>-}
>-

Any reason to move this? Doesn't seem necessary.

/be
Attachment #274205 - Flags: review?(brendan) → review+
The new version does not move js_AtomToPrintableString and forward-declare AtomizeHashedKey before js_InitPinnedAtoms, the first function that uses it, to follow the rest of SM code.
Attachment #274205 - Attachment is obsolete: true
Attachment #274263 - Flags: review+
I checked in the patch from comment 3 to the trunk: 

Checking in js/src/jsapi.c;
/cvsroot/mozilla/js/src/jsapi.c,v  <--  jsapi.c
new revision: 3.341; previous revision: 3.340
done
Checking in js/src/jsatom.c;
/cvsroot/mozilla/js/src/jsatom.c,v  <--  jsatom.c
new revision: 3.101; previous revision: 3.100
done
Checking in js/src/jscntxt.c;
/cvsroot/mozilla/js/src/jscntxt.c,v  <--  jscntxt.c
new revision: 3.115; previous revision: 3.114
done
Checking in js/src/jsfun.c;
/cvsroot/mozilla/js/src/jsfun.c,v  <--  jsfun.c
new revision: 3.205; previous revision: 3.204
done
Checking in js/src/jsregexp.c;
/cvsroot/mozilla/js/src/jsregexp.c,v  <--  jsregexp.c
new revision: 3.158; previous revision: 3.157
done
Checking in js/src/jsstr.c;
/cvsroot/mozilla/js/src/jsstr.c,v  <--  jsstr.c
new revision: 3.152; previous revision: 3.151
done
Checking in js/src/jsstr.h;
/cvsroot/mozilla/js/src/jsstr.h,v  <--  jsstr.h
new revision: 3.39; previous revision: 3.38
done
Checking in js/src/jsxml.c;
/cvsroot/mozilla/js/src/jsxml.c,v  <--  jsxml.c
new revision: 3.163; previous revision: 3.162
done
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Depends on: 390348
Blocks: 387481
Flags: in-testsuite-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: