Closed Bug 503155 Opened 15 years ago Closed 15 years ago

TM: js_DropScope uses ATOMIC_DECREMENT even during GC (which is single threaded)

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gal, Assigned: brendan)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(2 files, 2 obsolete files)

ATOMIC_DECREMENT turns out to be _extremely_ expensive due to the lock prefix. This is a major cost during GC. The attached patch tells js_DropScope whether the gc lock is currently being held, in which case a simple non-atomic decrement is sufficient.
Attached patch patch (obsolete) — Splinter Review
Assignee: general → gal
Attachment #387508 - Flags: review?(brendan)
Blocks: 503141
No longer blocks: 503141
Comment on attachment 387508 [details] [diff] [review]
patch

No, even simpler: assert CX_THREAD_IS_RUNNING_GC(cx) and always use the unlocked decrement.

/be
No, GetMutableScope calls DropScope from outside the GC.
(In reply to comment #3)
> No, GetMutableScope calls DropScope from outside the GC.

Oops, but that is a different call. It can never destroy a scope, in particular. Instead of adding flag param overhead, specialize just that function.

/be
Don't want to r+ myself, this is different-looking by enough code, but provably equivalent (check out the comments and assertion).

/be
Assignee: gal → brendan
Attachment #387508 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #387678 - Flags: review?(jorendorff)
Attachment #387508 - Flags: review?(brendan)
Want to get this in soon, scope-related patches stacking up all over.

/be
OS: Mac OS X → All
Hardware: x86 → All
Attachment #387678 - Attachment is obsolete: true
Attachment #387683 - Flags: review?(jorendorff)
Attachment #387678 - Flags: review?(jorendorff)
Comment on attachment 387683 [details] [diff] [review]
fix to #ifdef JS_THREADSAFE that assertion

This test flunks the assertion in js_GetMutableScope:

// a -> b -> c
function B(){}
var c = B.prototype = {x: 1};
function A(){}
var b = A.prototype = new B;
var a = new A;

// Kill c.
b.__proto__ = null;
c = B.prototype = null;
gc();

a.y = 2;
Attachment #387683 - Flags: review?(jorendorff)
Thanks, will fix.

/be
Flags: in-testsuite?
Attachment #387692 - Flags: review?(jorendorff) → review+
Comment on attachment 387692 [details] [diff] [review]
inline a bit more of js_DropScope into js_GetMutableScope

Looks good.
I cloned the

    JS_ASSERT(scope->nrefs > 0);

from js_DropScope into the tail of js_GetMutableScope too.

http://hg.mozilla.org/tracemonkey/rev/51ed66617fb5

/be
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/51ed66617fb5
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: