Closed
Bug 879079
Opened 12 years ago
Closed 11 years ago
Fix some static analysis warnings in js/src
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: terrence, Assigned: terrence)
References
Details
(Whiteboard: [leave-open])
Attachments
(9 files)
54.29 KB,
patch
|
bhackett1024
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
4.93 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
6.48 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
32.76 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
3.90 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
2.98 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
1011 bytes,
patch
|
wingo
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
7.62 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
15.16 KB,
patch
|
sfink
:
review+
terrence
:
checkin+
|
Details | Diff | Splinter Review |
This fixes ValueToId, ToString and ToAtom by making them take a Handle when <CanGC>. This was mostly just changing args.get(i) to args.getHandle(i) and args[i] to args.handleAt(i). In spots where this wasn't appropriate I either added a new Rooted or -- for hot(ish) paths -- I re-used an existing root or fromMarkedLocation'd as required.
Attachment #757714 -
Flags: review?(bhackett1024)
Comment 1•12 years ago
|
||
Comment on attachment 757714 [details] [diff] [review]
v0
Review of attachment 757714 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/public/CallArgs.h
@@ +303,5 @@
> /*
> + * Returns the i-th zero-indexed argument as a handle, or |undefined| if
> + * there's no such argument.
> + */
> + HandleValue getHandle(unsigned i) const {
This name is pretty confusing since there is also a handleAt(i) method. How about handleOrUndefinedAt?
::: js/src/jsarray.cpp
@@ +1134,5 @@
>
> JS_ASSERT(start == MAX_ARRAY_INDEX + 1);
> RootedValue value(cx);
> RootedId id(cx);
> + Value indexv;
Can you make this a RootedValue to not abuse fromMarkedLocation? This code will almost never execute.
::: js/src/jsproxy.cpp
@@ +692,4 @@
> if (!str)
> return false;
> rval.setString(str);
> + v = v_;
Moving this assignment down introduces a rooting hazard. This function looks like it can be handled the same way as Trap1?
::: js/src/jsreflect.cpp
@@ +3084,5 @@
> return JS_FALSE;
>
> RootedValue val(cx);
> if (!serialize.program(pn, &val)) {
> + args.rval().setUndefined();
setNull
::: js/src/vm/Shape-inl.h
@@ +289,5 @@
> #endif
> if (self->hasShortID()) {
> int16_t id = self->shortid();
> + if (id < 0) {
> + Value v = Int32Value(id);
Ditto earlier comment, this code is cold.
Attachment #757714 -
Flags: review?(bhackett1024) → review+
Assignee | ||
Comment 2•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Whiteboard: [leave-open]
Assignee | ||
Updated•12 years ago
|
Attachment #757714 -
Flags: checkin+
Assignee | ||
Comment 3•12 years ago
|
||
This makes ToNumber take a MutableHandleValue.
Attachment #758830 -
Flags: review?(sphink)
Assignee | ||
Comment 4•12 years ago
|
||
This makes the |Value descriptor| parameter of js_DefineOwnProperty (the jsobj.h instance) a Handle. It also moves the function inside namespace js::, since it will be identical to the friend api version when we add handles to the api.
Attachment #758831 -
Flags: review?(sphink)
Updated•12 years ago
|
Attachment #758830 -
Flags: review?(sphink) → review+
Updated•12 years ago
|
Attachment #758831 -
Flags: review?(sphink) → review+
Comment 5•12 years ago
|
||
Assignee | ||
Comment 6•11 years ago
|
||
Assignee | ||
Comment 7•11 years ago
|
||
Backed out the ToNumber changes so we can investigate an SM(r) crash.
https://hg.mozilla.org/integration/mozilla-inbound/rev/702e35c02b97
Comment 8•11 years ago
|
||
Assignee | ||
Comment 9•11 years ago
|
||
Assignee | ||
Comment 10•11 years ago
|
||
The hard cases are places where we put an atom in a Value then immediately unpack it to call the static StringToNumber. I just exposed StringToNumber internally. There is one slow path where I had to add a Rooted. The rest are just trivial calls to args.handleAt.
Attachment #767500 -
Flags: review?(sphink)
Assignee | ||
Comment 11•11 years ago
|
||
This weeks inevitable breakage. When are we getting the static analysis on TBPL again?
Attachment #767510 -
Flags: review?(sphink)
Updated•11 years ago
|
Attachment #767510 -
Flags: review?(sphink) → review+
Comment 12•11 years ago
|
||
Comment on attachment 767500 [details] [diff] [review]
v0: handlify ToNumber (the other one)
Review of attachment 767500 [details] [diff] [review]:
-----------------------------------------------------------------
Oh good. This is a nice sweep through a bunch of stuff.
Attachment #767500 -
Flags: review?(sphink) → review+
Assignee | ||
Comment 13•11 years ago
|
||
Comment 14•11 years ago
|
||
Assignee | ||
Comment 15•11 years ago
|
||
This switches the type of Invoke/InvokeGetterSetter to Value instead of const Value&.
Attachment #767986 -
Flags: review?(sphink)
Assignee | ||
Comment 16•11 years ago
|
||
TokenStream's matchContextualKeyword should take a Handle<PropertyName*>. This is the only change needed to kill our last real rooting hazard... again.
Attachment #767987 -
Flags: review?(sphink)
Assignee | ||
Updated•11 years ago
|
Attachment #767987 -
Flags: review?(sphink) → review?(wingo)
Assignee | ||
Comment 17•11 years ago
|
||
The majority of users are StringValue(str) -> v.toString, so I added StringToSource.
Attachment #768006 -
Flags: review?(sphink)
Assignee | ||
Comment 18•11 years ago
|
||
I'm actually wondering if we shouldn't make CallArgs::operator[] return Handle.
Attachment #768014 -
Flags: review?(sphink)
Assignee | ||
Updated•11 years ago
|
Attachment #758830 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Attachment #767500 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Attachment #758831 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Attachment #767510 -
Flags: checkin+
Comment 19•11 years ago
|
||
Comment on attachment 767987 [details] [diff] [review]
matchContextualKeyword v0
LGTM; I didn't realize that Handles would automatically unwrap their values. In the future it might be a good idea to remove this behavior, to have the compiler let us know about this kind of error.
Attachment #767987 -
Flags: review?(wingo) → review+
Comment 20•11 years ago
|
||
Assignee | ||
Comment 21•11 years ago
|
||
(In reply to Andy Wingo from comment #19)
> Comment on attachment 767987 [details] [diff] [review]
> matchContextualKeyword v0
>
> LGTM; I didn't realize that Handles would automatically unwrap their values.
> In the future it might be a good idea to remove this behavior, to have the
> compiler let us know about this kind of error.
Bug 817164. Although considering that we explicitly don't want to root some paths for performance, we may never get to a spot where this is possible. In the meantime, the static analysis -- how I found this -- will keep this from regressing too far.
Updated•11 years ago
|
Attachment #767986 -
Flags: review?(sphink) → review+
Comment 22•11 years ago
|
||
Comment on attachment 768006 [details] [diff] [review]
ValueToSource v0
Review of attachment 768006 [details] [diff] [review]:
-----------------------------------------------------------------
This one is a little tricky, since it's a legit use of a bare JSString* in a place where you'd expect a Handle. If the JSAPI were Handlified, that would be fine without a comment, but right now I think it'd be better to mention /* No Handle needed. */ or something.
Attachment #768006 -
Flags: review?(sphink) → review+
Updated•11 years ago
|
Attachment #768014 -
Flags: review?(sphink) → review+
Assignee | ||
Comment 23•11 years ago
|
||
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/281bdbc7b3c4
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/620c2af655b5
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/0cc4ad9881a7
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/cc11bf500293
Comment 24•11 years ago
|
||
Updated•11 years ago
|
No longer blocks: ExactRooting
Assignee | ||
Updated•11 years ago
|
Attachment #767986 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Attachment #767987 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Attachment #768006 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Attachment #768014 -
Flags: checkin+
Assignee | ||
Updated•11 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Updated•11 years ago
|
Blocks: 773686
Keywords: dev-doc-needed
Updated•4 years ago
|
Keywords: dev-doc-needed
You need to log in
before you can comment on or make changes to this bug.
Description
•