You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make Stylist no longer an unsafe pointer once we have fast RWArcs #2604
I-refactorNo impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.I-safetySome piece of code violates memory safety guarantees.
Took a look at this with help from @Ms2ger on IRC—an implementation moving the Stylist from LayoutTaskData to LayoutTask as an Arc<RwLock<Stylist>> panics with a deadlock. Similar deadlock seen when simply using a Mutex (albeit no panic). No luck, open to suggestions!
If we intentionally want to dynamically check the borrowing of Stylist, I think we can just stuff it into an Arc, and use get_mut().unwrap() when we want to mutate it. Granted, it's stylistically terrible, but it's probably better than a raw pointer.
I don't see how changing the ownership of the Stylist helps.
I don’t think we need dynamic checks at all if Stylist is in the DOM. Like the rest of DOM data, access is exclusive from the script task, and shared but read-only in the "early" phase (until flow tree construction) of layout.
I-refactorNo impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.I-safetySome piece of code violates memory safety guarantees.
Activity
SimonSapin commentedon Aug 12, 2014
RWArc<T>is gone, replaced byArc<RWLock<T>>. DoesRWLockstill have the same perf problems?pcwalton commentedon Mar 2, 2015
@SimonSapin I believe
RWLockis fast now, looking at Rust. We'll need to benchmark to make sure.mt2d2 commentedon Jul 3, 2015
Took a look at this with help from @Ms2ger on IRC—an implementation moving the
StylistfromLayoutTaskDatatoLayoutTaskas anArc<RwLock<Stylist>>panics with a deadlock. Similar deadlock seen when simply using a Mutex (albeit no panic). No luck, open to suggestions!Ms2ger commentedon Jul 6, 2015
That was master...mt2d2:stylist_arc_rwlock
pcwalton commentedon Jul 6, 2015
Probably needs finer-grained locking inside the Stylist then?
Make SharedLayoutContext threadsafe.
Make SharedLayoutContext threadsafe.
Make SharedLayoutContext threadsafe.
Make SharedLayoutContext threadsafe.
Make SharedLayoutContext threadsafe.
13 remaining items
eefriedman commentedon Nov 8, 2015
If we intentionally want to dynamically check the borrowing of Stylist, I think we can just stuff it into an Arc, and use
get_mut().unwrap()when we want to mutate it. Granted, it's stylistically terrible, but it's probably better than a raw pointer.I don't see how changing the ownership of the Stylist helps.
SimonSapin commentedon Nov 8, 2015
I don’t think we need dynamic checks at all if
Stylistis in the DOM. Like the rest of DOM data, access is exclusive from the script task, and shared but read-only in the "early" phase (until flow tree construction) of layout.eefriedman commentedon Nov 8, 2015
Oh, right... if Stylist is in the DOM, we don't need to mutate it from layout. Makes sense.
jdm commentedon Mar 10, 2016
Latest attempt at #7524.
emilio commentedon Apr 23, 2016
#10815 Should take care of this.
It uses an
ArcplusArc::get_mut, and seems to work just fine. It should not have almost any performance overhead.SimonSapin commentedon Apr 23, 2016
@emilio
Arc::get_mutclones the contents if the refcount is above one. Is this really desired here? This issue originally mentionsRWLock.emilio commentedon Apr 23, 2016
@SimonSapin: Stylist is not cloneable,
Arc::get_mutreturnsNoneif the refcount is not one (unlikeArc::make_mut).I'm using
Arc::get_mut(&mut rw_data.stylist).unwrap()and I haven't ever got a crash.SimonSapin commentedon Apr 23, 2016
Oh yeah, sorry, I got confused with
make_mut. But if the refcount really is always one, could this be aBox?emilio commentedon Apr 23, 2016
I think not since it has to be handed out to layout traversal (I mean to
SharedLayoutContext).The refcount is always one when we update the stylist in the layout thread, but not always.
emilio commentedon May 2, 2016
This is closed by #10815