Bug 926596 - Set compartment_ in ForkJoinSlice for read only access to shared tables. (r=nmatsakis)
authorShu-yu Guo <shu@rfrn.org>
Tue, 15 Oct 2013 18:41:55 -0700
changeset 150858 da7c23b2d1c7e3bd07eba75d2c088a9fa9369789
parent 150857 349d02055f07ceaea5b2dfdf81be5b8b8a4de595
child 150859 d0fa5c45cabf3653f4587a8b499005705ee62c50
push id25469
push usercbook@mozilla.com
push dateWed, 16 Oct 2013 10:46:01 +0000
treeherderautoland@afae5911a1e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnmatsakis
bugs926596
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 926596 - Set compartment_ in ForkJoinSlice for read only access to shared tables. (r=nmatsakis)
js/src/vm/ForkJoin.cpp
--- a/js/src/vm/ForkJoin.cpp
+++ b/js/src/vm/ForkJoin.cpp
@@ -404,16 +404,17 @@ class ForkJoinShared : public TaskExecut
     // Requests that computation abort.
     void setAbortFlag(bool fatal);
 
     // Set the fatal flag for the next abort.
     void setPendingAbortFatal() { fatal_ = true; }
 
     JSRuntime *runtime() { return cx_->runtime(); }
     JS::Zone *zone() { return cx_->zone(); }
+    JSCompartment *compartment() { return cx_->compartment(); }
 
     JSContext *acquireContext() { PR_Lock(cxLock_); return cx_; }
     void releaseContext() { PR_Unlock(cxLock_); }
 };
 
 class AutoEnterWarmup
 {
     JSRuntime *runtime_;
@@ -1684,16 +1685,23 @@ ForkJoinSlice::ForkJoinSlice(PerThreadDa
     shared(shared),
     acquiredContext_(false)
 {
     /*
      * Unsafely set the zone. This is used to track malloc counters and to
      * trigger GCs and is otherwise not thread-safe to access.
      */
     zone_ = shared->zone();
+
+    /*
+     * Unsafely set the compartment. This is used to get read-only access to
+     * shared tables.
+     */
+    compartment_ = shared->compartment();
+
     allocator_ = allocator;
 }
 
 bool
 ForkJoinSlice::isMainThread() const
 {
     return perThreadData == &shared->runtime()->mainThread;
 }