Bugzilla
Quick Search
Browse
Advanced Search
Reports
Quick Search Help
Documentation
New Account
Log In
Login with GitHub
Remember
Forgot Password
Mozilla Home
Privacy
Cookies
Legal
Attachment 8728297 Details for
Bug 1254893
[patch]
Keep a list of wasm::Modules per compartment.
Bug-1254893---Keep-a-list-of-wasmModules-per-compa.patch (text/plain), 8.37 KB, created by
Shu-yu Guo [:shu]
(
hide
)
Description:
Keep a list of wasm::Modules per compartment.
Filename:
MIME Type:
Creator:
Shu-yu Guo [:shu]
Size:
8.37 KB
patch
obsolete
># HG changeset patch ># User Shu-yu Guo <shu@rfrn.org> > >Bug 1254893 - Keep a list of wasm::Modules per compartment. > >diff --git a/js/src/asmjs/WasmModule.cpp b/js/src/asmjs/WasmModule.cpp >index efdb3d4..23f4a09 100644 >--- a/js/src/asmjs/WasmModule.cpp >+++ b/js/src/asmjs/WasmModule.cpp >@@ -1563,26 +1563,30 @@ WasmModuleObject::create(ExclusiveContext* cx) > > bool > WasmModuleObject::init(Module* module) > { > MOZ_ASSERT(is<WasmModuleObject>()); > MOZ_ASSERT(!hasModule()); > if (!module) > return false; >+ module->setOwner(this); >+ compartment()->wasmModules.insertBack(module); > setReservedSlot(MODULE_SLOT, PrivateValue(module)); > return true; > } > > Module& > WasmModuleObject::module() const > { > MOZ_ASSERT(is<WasmModuleObject>()); > MOZ_ASSERT(hasModule()); >- return *(Module*)getReservedSlot(MODULE_SLOT).toPrivate(); >+ Module& m = *(Module*)getReservedSlot(MODULE_SLOT).toPrivate(); >+ MOZ_ASSERT(m.owner() == this); >+ return m; > } > > void > WasmModuleObject::addSizeOfMisc(MallocSizeOf mallocSizeOf, size_t* code, size_t* data) > { > if (hasModule()) > module().addSizeOfMisc(mallocSizeOf, code, data); > } >diff --git a/js/src/asmjs/WasmModule.h b/js/src/asmjs/WasmModule.h >index fd7cd36..c0b8d73 100644 >--- a/js/src/asmjs/WasmModule.h >+++ b/js/src/asmjs/WasmModule.h >@@ -14,16 +14,18 @@ > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > > #ifndef wasm_module_h > #define wasm_module_h > >+#include "mozilla/LinkedList.h" >+ > #include "asmjs/WasmTypes.h" > #include "gc/Barrier.h" > #include "vm/MallocProvider.h" > #include "vm/NativeObject.h" > > namespace js { > > class AsmJSModule; >@@ -438,17 +440,17 @@ typedef UniquePtr<ModuleData> UniqueModuleData; > // - Dynamic linking patches code or global data that relies on the address of > // the heap and imports of a module. A module may only be dynamically linked > // once. However, a dynamically-linked module may be cloned so that the clone > // can be independently dynamically linked. > // > // Once fully dynamically linked, a Module can have its exports invoked via > // callExport(). > >-class Module >+class Module : public mozilla::LinkedListElement<Module> > { > typedef UniquePtr<const ModuleData> UniqueConstModuleData; > struct ImportExit { > void* code; > jit::BaselineScript* baselineScript; > HeapPtrFunction fun; > static_assert(sizeof(HeapPtrFunction) == sizeof(void*), "for JIT access"); > }; >@@ -481,16 +483,19 @@ class Module > // Initialized during dynamicallyLink: > bool dynamicallyLinked_; > BufferPtr heap_; > > // Mutated after dynamicallyLink: > bool profilingEnabled_; > FuncLabelVector funcLabels_; > >+ // Back pointer to the JS object. >+ ReadBarriered<WasmModuleObject*> ownerObject_; >+ > uint8_t* rawHeapPtr() const; > uint8_t*& rawHeapPtr(); > WasmActivation*& activation(); > void specializeToHeap(ArrayBufferObjectMaybeShared* heap); > void despecializeFromHeap(ArrayBufferObjectMaybeShared* heap); > bool sendCodeRangesToProfiler(JSContext* cx); > MOZ_WARN_UNUSED_RESULT bool setProfilingEnabled(JSContext* cx, bool enabled); > ImportExit& importToExit(const Import& import); >@@ -506,16 +511,19 @@ class Module > static const unsigned OffsetOfImportExitFun = offsetof(ImportExit, fun); > static const unsigned SizeOfEntryArg = sizeof(EntryArg); > > explicit Module(UniqueModuleData module); > virtual ~Module(); > virtual void trace(JSTracer* trc); > virtual void addSizeOfMisc(MallocSizeOf mallocSizeOf, size_t* code, size_t* data); > >+ void setOwner(WasmModuleObject* owner) { MOZ_ASSERT(!ownerObject_); ownerObject_ = owner; } >+ WasmModuleObject* owner() const { MOZ_ASSERT(ownerObject_); return ownerObject_; } >+ > uint8_t* code() const { return module_->code.get(); } > uint32_t codeBytes() const { return module_->codeBytes; } > uint8_t* globalData() const { return code() + module_->codeBytes; } > uint32_t globalBytes() const { return module_->globalBytes; } > HeapUsage heapUsage() const { return module_->heapUsage; } > bool usesHeap() const { return UsesHeap(module_->heapUsage); } > bool hasSharedHeap() const { return module_->heapUsage == HeapUsage::Shared; } > CompileArgs compileArgs() const { return module_->compileArgs; } >diff --git a/js/src/gc/Barrier.cpp b/js/src/gc/Barrier.cpp >index aaf0a81..197237b 100644 >--- a/js/src/gc/Barrier.cpp >+++ b/js/src/gc/Barrier.cpp >@@ -4,16 +4,17 @@ > * License, v. 2.0. If a copy of the MPL was not distributed with this > * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ > > #include "gc/Barrier.h" > > #include "jscompartment.h" > #include "jsobj.h" > >+#include "asmjs/WasmModule.h" > #include "builtin/TypedObject.h" > #include "gc/Policy.h" > #include "gc/Zone.h" > #include "js/HashTable.h" > #include "js/Value.h" > #include "vm/ScopeObject.h" > #include "vm/SharedArrayObject.h" > #include "vm/Symbol.h" >diff --git a/js/src/gc/Policy.h b/js/src/gc/Policy.h >index 15da0be..b5a9438 100644 >--- a/js/src/gc/Policy.h >+++ b/js/src/gc/Policy.h >@@ -45,16 +45,17 @@ class PropertyName; > class RegExpObject; > class SavedFrame; > class ScopeObject; > class ScriptSourceObject; > class Shape; > class SharedArrayBufferObject; > class StructTypeDescr; > class UnownedBaseShape; >+class WasmModuleObject; > namespace jit { > class JitCode; > } // namespace jit > } // namespace js > > // Expand the given macro D for each public GC pointer. > #define FOR_EACH_PUBLIC_GC_POINTER_TYPE(D) \ > D(JS::Symbol*) \ >@@ -100,16 +101,17 @@ class JitCode; > D(js::RegExpObject*) \ > D(js::SavedFrame*) \ > D(js::ScopeObject*) \ > D(js::ScriptSourceObject*) \ > D(js::Shape*) \ > D(js::SharedArrayBufferObject*) \ > D(js::StructTypeDescr*) \ > D(js::UnownedBaseShape*) \ >+ D(js::WasmModuleObject*) \ > D(js::jit::JitCode*) > > // Expand the given macro D for each internal tagged GC pointer type. > #define FOR_EACH_INTERNAL_TAGGED_GC_POINTER_TYPE(D) \ > D(js::TaggedProto) > > // Expand the macro D for every GC reference type that we know about. > #define FOR_EACH_GC_POINTER_TYPE(D) \ >diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h >index 35be936..01095b0 100644 >--- a/js/src/jscompartment.h >+++ b/js/src/jscompartment.h >@@ -2,16 +2,17 @@ > * vim: set ts=8 sts=4 et sw=4 tw=99: > * This Source Code Form is subject to the terms of the Mozilla Public > * License, v. 2.0. If a copy of the MPL was not distributed with this > * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ > > #ifndef jscompartment_h > #define jscompartment_h > >+#include "mozilla/LinkedList.h" > #include "mozilla/Maybe.h" > #include "mozilla/MemoryReporting.h" > #include "mozilla/Variant.h" > #include "mozilla/XorShift128PlusRNG.h" > > #include "builtin/RegExp.h" > #include "gc/Barrier.h" > #include "gc/Zone.h" >@@ -25,16 +26,20 @@ namespace js { > namespace jit { > class JitCompartment; > } // namespace jit > > namespace gc { > template<class Node> class ComponentFinder; > } // namespace gc > >+namespace wasm { >+class Module; >+} // namespace wasm >+ > struct NativeIterator; > class ClonedBlockObject; > > /* > * A single-entry cache for some base-10 double-to-string conversions. This > * helps date-format-xparb.js. It also avoids skewing the results for > * v8-splay.js when measured by the SunSpider harness, where the splay tree > * initialization (which includes many repeated double-to-string conversions) >@@ -460,16 +465,19 @@ struct JSCompartment > // Inline transparent typed objects do not initially have an array buffer, > // but can have that buffer created lazily if it is accessed later. This > // table manages references from such typed objects to their buffers. > js::ObjectWeakMap* lazyArrayBuffers; > > // All unboxed layouts in the compartment. > mozilla::LinkedList<js::UnboxedLayout> unboxedLayouts; > >+ // All wasm modules in the compartment. >+ mozilla::LinkedList<js::wasm::Module> wasmModules; >+ > private: > // All non-syntactic lexical scopes in the compartment. These are kept in > // a map because when loading scripts into a non-syntactic scope, we need > // to use the same lexical scope to persist lexical bindings. > js::ObjectWeakMap* nonSyntacticLexicalScopes_; > > public: > /* During GC, stores the index of this compartment in rt->compartments. */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Flags:
terrence
: review+
luke
: feedback+
Actions:
View
|
Diff
|
Review
Attachments on
bug 1254893
:
8728295
|
8728296
|
8728297
|
8728298
|
8728299
|
8728300
|
8728301
|
8728903
|
8728904
|
8728905
|
8728907
|
8728908
|
8728909
|
8728910
|
8728912
|
8729333
|
8729334
|
8729359
|
8729683
|
8729748
|
8729759
|
8729812