Closed
Bug 779017
Opened 12 years ago
Closed 12 years ago
always create ScriptSource
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla17
People
(Reporter: Benjamin, Assigned: Benjamin)
References
Details
Attachments
(1 file)
(deleted),
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
JSScript's scriptSource_ pointer should never be NULL. If the source is not available, scriptSource_ should just be a shell. Adding the source code should be a different method. This will allow other items that are shared per compilation unit like filename and the source map to be moved to the ScriptSource struct.
Assignee | ||
Comment 1•12 years ago
|
||
Assignee: general → bpeterson
Attachment #647397 -
Flags: review?(jorendorff)
Comment 2•12 years ago
|
||
Comment on attachment 647397 [details] [diff] [review]
give every script a ScriptSource
Review of attachment 647397 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good except for a few nits. r=me with those fixed.
::: js/src/frontend/BytecodeCompiler.cpp
@@ +245,5 @@
> {
> if (!CheckLength(cx, length))
> return false;
> + ScriptSource *ss = cx->new_<ScriptSource>();
> + AutoAttachToRuntime attacher(cx->runtime, ss);
CompileScript() checks for null ss. This should too.
::: js/src/jsscript.cpp
@@ +1243,3 @@
> if (!ownSource) {
> const size_t nbytes = length * sizeof(jschar);
> + data.compressed = static_cast<unsigned char *>(cx->runtime->malloc_(nbytes));
Instead use cx->malloc_(nbytes) which reports the error on failure.
@@ +1363,4 @@
> return false;
> }
> + if (!xdr->codeBytes(data.compressed, byteLen)) {
> + xdr->cx()->free_(data.compressed);
This should only free this memory if we allocated it in the first place (that is, if mode is XDR_DECODE).
Also: if we are decoding, it should probably return length_, compressedLength_, and data.compressed to a consistent state before returning, right? (This ScriptSource is already attached to a script, I think, so it'll be destroyed eventually.) Maybe this can be rewritten to first decode to local variables, then call setSource() only on success.
Attachment #647397 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 3•12 years ago
|
||
Comment 4•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in
before you can comment on or make changes to this bug.
Description
•