avoiding unnecessary js_AddRoot

RESOLVED FIXED

Status

()

--
enhancement
RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: igor, Assigned: igor)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 attachment, 1 obsolete attachment)

v2
11.09 KB, patch
igor
: review+
Details | Diff | Splinter Review
(Assignee)

Description

9 years ago
Created attachment 411547 [details] [diff] [review]
v1

In couple of places in jsdbgapi.cpp the code uses js_AddRoot when that can be avoided. The first place is JS_SetTrap where js_AddRoot roots trap's closure. That is not necessary since the engine can simply enumerate all the traps during the GC and mark all trap closures is theyr are GC things. The second place is JS_GetPropertyDesc. There js_AddRoot can be replaced with JSAutoTempValueRooter.

The patch below removes these unnecessary calls and adds an api test to check the trap closure rooting.
Attachment #411547 - Flags: review?(brendan)
Comment on attachment 411547 [details] [diff] [review]
v1

>@@ -499,11 +499,17 @@ js_ResumeVtune(JSContext *cx, JSObject *
> extern JS_FRIEND_API(JSBool)
> js_InitEthogram(JSContext *cx, JSObject *obj,
>                 uintN argc, jsval *argv, jsval *rval);
> extern JS_FRIEND_API(JSBool)
> js_ShutdownEthogram(JSContext *cx, JSObject *obj,
>                     uintN argc, jsval *argv, jsval *rval);
> #endif /* MOZ_TRACEVIS */
> 
>+/*
>+ * Internal engine API's.
>+ */
>+extern void
>+js_MarkTraps(JSTracer *trc);

We have other js_* prototypes, even unifdef'ed in many cases, but I wonder if this one couldn't just go in jsgc.cpp instead of here. Not a big deal either way.

Thanks for cleaning up this old code!

/be
Attachment #411547 - Flags: review?(brendan) → review+
(Assignee)

Comment 2

9 years ago
Created attachment 411944 [details] [diff] [review]
v2

The new version moves the declaration of js_MarkTraps into jsgc.h
Attachment #411547 - Attachment is obsolete: true
Attachment #411944 - Flags: review+
(Assignee)

Comment 3

9 years ago
https://hg.mozilla.org/tracemonkey/rev/468c1592469f
Whiteboard: fixed-in-tracemonkey

Comment 4

9 years ago
http://hg.mozilla.org/mozilla-central/rev/468c1592469f
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.