From 6a9c421c3f7d66d6d436f8c2e78f22e76eaf4990 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Tue, 24 Nov 2015 09:42:40 -0800 Subject: [PATCH] Backed out changeset eb9e244e3834 (bug 1227535) for static build bustage in ModuleObject.h CLOSED TREE --- js/src/builtin/ModuleObject.cpp | 17 +++------- js/src/builtin/ModuleObject.h | 7 ++-- js/src/gc/Zone.h | 58 +-------------------------------- js/src/jsscript.h | 2 +- js/src/vm/MallocProvider.h | 6 ++-- js/src/vm/ScopeObject.h | 1 - 6 files changed, 10 insertions(+), 81 deletions(-) diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 5b5dfd0e426..9ede3e2f45a 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -219,11 +219,6 @@ IndirectBindingMap::Binding::Binding(ModuleEnvironmentObject* environment, Shape : environment(environment), shape(shape) {} -IndirectBindingMap::IndirectBindingMap(Zone* zone) - : map_(ZoneAllocPolicy(zone)) -{ -} - bool IndirectBindingMap::init() { @@ -588,8 +583,7 @@ ModuleObject::create(ExclusiveContext* cx, HandleObject enclosingStaticScope) self->initReservedSlot(StaticScopeSlot, ObjectOrNullValue(enclosingStaticScope)); - Zone* zone = cx->zone(); - IndirectBindingMap* bindings = zone->new_(zone); + IndirectBindingMap* bindings = cx->new_(); if (!bindings || !bindings->init()) { ReportOutOfMemory(cx); return nullptr; @@ -597,11 +591,9 @@ ModuleObject::create(ExclusiveContext* cx, HandleObject enclosingStaticScope) self->initReservedSlot(ImportBindingsSlot, PrivateValue(bindings)); - FunctionDeclarationVector* funDecls = zone->new_(zone); - if (!funDecls) { - ReportOutOfMemory(cx); + FunctionDeclarationVector* funDecls = cx->new_(cx); + if (!funDecls) return nullptr; - } self->initReservedSlot(FunctionDeclarationsSlot, PrivateValue(funDecls)); return self; @@ -834,8 +826,7 @@ ModuleObject::createNamespace(JSContext* cx, HandleModuleObject self, HandleArra if (!ns) return nullptr; - Zone* zone = cx->zone(); - IndirectBindingMap* bindings = zone->new_(zone); + IndirectBindingMap* bindings = cx->new_(); if (!bindings || !bindings->init()) { ReportOutOfMemory(cx); return nullptr; diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h index fce97c54ece..d374f5fa3db 100644 --- a/js/src/builtin/ModuleObject.h +++ b/js/src/builtin/ModuleObject.h @@ -10,8 +10,6 @@ #include "jsapi.h" #include "jsatom.h" -#include "gc/Zone.h" - #include "js/TraceableVector.h" #include "vm/NativeObject.h" @@ -86,7 +84,6 @@ typedef Handle HandleExportEntryObject; class IndirectBindingMap { public: - IndirectBindingMap(Zone* zone); bool init(); void trace(JSTracer* trc); @@ -118,7 +115,7 @@ class IndirectBindingMap RelocatablePtrShape shape; }; - typedef HashMap Map; + typedef HashMap Map; Map map_; }; @@ -192,7 +189,7 @@ struct FunctionDeclaration RelocatablePtrFunction fun; }; -using FunctionDeclarationVector = TraceableVector; +using FunctionDeclarationVector = TraceableVector; class ModuleObject : public NativeObject { diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index ea3c14df6f1..8cdb1d65f1d 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -144,7 +144,7 @@ struct Zone : public JS::shadow::Zone, void onTooMuchMalloc(); void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) { - if (!js::CurrentThreadCanAccessRuntime(runtime_)) + if (!CurrentThreadCanAccessRuntime(runtime_)) return nullptr; return runtimeFromMainThread()->onOutOfMemory(allocFunc, nbytes, reallocPtr); } @@ -576,62 +576,6 @@ class CompartmentsIterT typedef CompartmentsIterT CompartmentsIter; -/* - * Allocation policy that uses Zone::pod_malloc and friends, so that memory - * pressure is accounted for on the zone. This is suitable for memory associated - * with GC things allocated in the zone. - * - * Since it doesn't hold a JSContext (those may not live long enough), it can't - * report out-of-memory conditions itself; the caller must check for OOM and - * take the appropriate action. - * - * FIXME bug 647103 - replace these *AllocPolicy names. - */ -class ZoneAllocPolicy -{ - Zone* const zone; - - public: - MOZ_IMPLICIT ZoneAllocPolicy(Zone* zone) : zone(zone) {} - - template - T* maybe_pod_malloc(size_t numElems) { - return zone->maybe_pod_malloc(numElems); - } - - template - T* maybe_pod_calloc(size_t numElems) { - return zone->maybe_pod_calloc(numElems); - } - - template - T* maybe_pod_realloc(T* p, size_t oldSize, size_t newSize) { - return zone->maybe_pod_realloc(p, oldSize, newSize); - } - - template - T* pod_malloc(size_t numElems) { - return zone->pod_malloc(numElems); - } - - template - T* pod_calloc(size_t numElems) { - return zone->pod_calloc(numElems); - } - - template - T* pod_realloc(T* p, size_t oldSize, size_t newSize) { - return zone->pod_realloc(p, oldSize, newSize); - } - - void free_(void* p) { js_free(p); } - void reportAllocOverflow() const {} - - bool checkSimulatedOOM() const { - return !js::oom::ShouldFailWithOOM(); - } -}; - } // namespace js #endif // gc_Zone_h diff --git a/js/src/jsscript.h b/js/src/jsscript.h index fe32926b602..4ceb869c48a 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -18,6 +18,7 @@ #include "jsopcode.h" #include "jstypes.h" +#include "builtin/ModuleObject.h" #include "gc/Barrier.h" #include "gc/Rooting.h" #include "jit/IonCode.h" @@ -46,7 +47,6 @@ class BreakpointSite; class BindingIter; class Debugger; class LazyScript; -class ModuleObject; class NestedScopeObject; class RegExpObject; struct SourceCompressionTask; diff --git a/js/src/vm/MallocProvider.h b/js/src/vm/MallocProvider.h index 1feac1557fe..6d6eb1c886a 100644 --- a/js/src/vm/MallocProvider.h +++ b/js/src/vm/MallocProvider.h @@ -21,11 +21,9 @@ * - SystemAllocPolicy: No extra functionality over bare allocators. * * - TempAllocPolicy: Adds automatic error reporting to the provided - * JSContext when allocations fail. + * Context when allocations fail. * - * - RuntimeAllocPolicy: Forwards to the JSRuntime MallocProvider. - * - * - ZoneAllocPolicy: Forwards to the Zone MallocProvider. + * - RuntimeAllocPolicy: forwards to the JSRuntime MallocProvider. * * - MallocProvider. A mixin base class that handles automatically updating * the GC's state in response to allocations that are tied to a GC lifetime diff --git a/js/src/vm/ScopeObject.h b/js/src/vm/ScopeObject.h index 3123aeaf2f4..2f32549f0da 100644 --- a/js/src/vm/ScopeObject.h +++ b/js/src/vm/ScopeObject.h @@ -11,7 +11,6 @@ #include "jsobj.h" #include "jsweakmap.h" -#include "builtin/ModuleObject.h" #include "gc/Barrier.h" #include "vm/ArgumentsObject.h" #include "vm/ProxyObject.h"