From 721022b3412896f04e5c818605b2a8405c4489a1 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Fri, 17 Jun 2011 10:11:33 -0700 Subject: [PATCH] Bug 660734, part 1 - s/ContextAllocPolicy/TempAllocPolicy/ since it doesn't call cx->malloc_ (r=igor) --HG-- extra : rebase_source : 7ea0d6a7ed86a9c561efdd2d7b93623ea37c5b90 --- js/src/jsalloc.cpp | 4 ++-- js/src/jsalloc.h | 4 ++-- js/src/jsemit.cpp | 6 +++--- js/src/jsemit.h | 4 ++-- js/src/jshashtable.h | 4 ++-- js/src/jsiter.cpp | 2 +- js/src/jsparse.cpp | 2 +- js/src/jsprvtd.h | 9 ++++----- js/src/jsvector.h | 2 +- js/src/methodjit/MethodJIT.cpp | 2 +- js/src/methodjit/MethodJIT.h | 8 ++++---- js/src/methodjit/PolyIC.cpp | 6 +++--- js/src/shell/jsworkers.cpp | 2 +- 13 files changed, 27 insertions(+), 28 deletions(-) diff --git a/js/src/jsalloc.cpp b/js/src/jsalloc.cpp index 1f1eca9b33e..c9cc78b333d 100644 --- a/js/src/jsalloc.cpp +++ b/js/src/jsalloc.cpp @@ -42,13 +42,13 @@ namespace js { void * -ContextAllocPolicy::onOutOfMemory(void *p, size_t nbytes) +TempAllocPolicy::onOutOfMemory(void *p, size_t nbytes) { return cx->runtime->onOutOfMemory(p, nbytes, cx); } void -ContextAllocPolicy::reportAllocOverflow() const +TempAllocPolicy::reportAllocOverflow() const { js_ReportAllocationOverflow(cx); } diff --git a/js/src/jsalloc.h b/js/src/jsalloc.h index a4c360897c3..80a26d60e40 100644 --- a/js/src/jsalloc.h +++ b/js/src/jsalloc.h @@ -79,7 +79,7 @@ class SystemAllocPolicy * FIXME bug 647103 - rewrite this in terms of temporary allocation functions, * not the system ones. */ -class ContextAllocPolicy +class TempAllocPolicy { JSContext *const cx; @@ -90,7 +90,7 @@ class ContextAllocPolicy JS_FRIEND_API(void *) onOutOfMemory(void *p, size_t nbytes); public: - ContextAllocPolicy(JSContext *cx) : cx(cx) {} + TempAllocPolicy(JSContext *cx) : cx(cx) {} JSContext *context() const { return cx; diff --git a/js/src/jsemit.cpp b/js/src/jsemit.cpp index e3d375a2672..38e98970c89 100644 --- a/js/src/jsemit.cpp +++ b/js/src/jsemit.cpp @@ -117,9 +117,9 @@ JSCodeGenerator::JSCodeGenerator(Parser *parser, emitLevel(0), constMap(parser->context), constList(parser->context), - globalUses(ContextAllocPolicy(parser->context)), - closedArgs(ContextAllocPolicy(parser->context)), - closedVars(ContextAllocPolicy(parser->context)), + globalUses(parser->context), + closedArgs(parser->context), + closedVars(parser->context), traceIndex(0) { flags = TCF_COMPILING; diff --git a/js/src/jsemit.h b/js/src/jsemit.h index 90ef99a84ea..029d1c3de7f 100644 --- a/js/src/jsemit.h +++ b/js/src/jsemit.h @@ -645,13 +645,13 @@ struct JSCodeGenerator : public JSTreeContext JSAtomList upvarList; /* map of atoms to upvar indexes */ JSUpvarArray upvarMap; /* indexed upvar pairs (JS_realloc'ed) */ - typedef js::Vector GlobalUseVector; + typedef js::Vector GlobalUseVector; GlobalUseVector globalUses; /* per-script global uses */ JSAtomList globalMap; /* per-script map of global name to globalUses vector */ /* Vectors of pn_cookie slot values. */ - typedef js::Vector SlotVector; + typedef js::Vector SlotVector; SlotVector closedArgs; SlotVector closedVars; diff --git a/js/src/jshashtable.h b/js/src/jshashtable.h index 16304c0d4be..ad12b6631ff 100644 --- a/js/src/jshashtable.h +++ b/js/src/jshashtable.h @@ -808,7 +808,7 @@ struct DefaultHasher: PointerHasher::res * HashPolicy requirements: * - see "Hash policy" above (default js::DefaultHasher) * AllocPolicy: - * - see "Allocation policies" in jsalloc.h (default js::ContextAllocPolicy) + * - see "Allocation policies" in jsalloc.h * * N.B: HashMap is not reentrant: Key/Value/HashPolicy/AllocPolicy members * called by HashMap must not call back into the same HashMap object. @@ -1041,7 +1041,7 @@ class HashMap * HashPolicy requirements: * - see "Hash policy" above (default js::DefaultHasher) * AllocPolicy: - * - see "Allocation policies" in jsalloc.h (default js::ContextAllocPolicy) + * - see "Allocation policies" in jsalloc.h * * N.B: HashSet is not reentrant: T/HashPolicy/AllocPolicy members called by * HashSet must not call back into the same HashSet object. diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 1a9743d71c4..026d52194fa 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -155,7 +155,7 @@ struct IdHashPolicy { } }; -typedef HashSet IdSet; +typedef HashSet IdSet; static inline bool NewKeyValuePair(JSContext *cx, jsid id, const Value &val, Value *rval) diff --git a/js/src/jsparse.cpp b/js/src/jsparse.cpp index 59db5d819c5..22657250ea3 100644 --- a/js/src/jsparse.cpp +++ b/js/src/jsparse.cpp @@ -1209,7 +1209,7 @@ Compiler::defineGlobals(JSContext *cx, GlobalScope &globalScope, JSScript *scrip def.knownSlot = shape->slot; } - js::Vector worklist(cx); + js::Vector worklist(cx); if (!worklist.append(script)) return false; diff --git a/js/src/jsprvtd.h b/js/src/jsprvtd.h index ab8cacce125..a4721dcbf3a 100644 --- a/js/src/jsprvtd.h +++ b/js/src/jsprvtd.h @@ -158,12 +158,11 @@ struct Token; struct TokenPos; struct TokenPtr; -class ContextAllocPolicy; -class SystemAllocPolicy; +class TempAllocPolicy; template + class AllocPolicy = TempAllocPolicy> class Vector; template @@ -172,12 +171,12 @@ struct DefaultHasher; template , - class AllocPolicy = ContextAllocPolicy> + class AllocPolicy = TempAllocPolicy> class HashMap; template , - class AllocPolicy = ContextAllocPolicy> + class AllocPolicy = TempAllocPolicy> class HashSet; class PropertyCache; diff --git a/js/src/jsvector.h b/js/src/jsvector.h index 6dad6abe66b..c764ccbff0a 100644 --- a/js/src/jsvector.h +++ b/js/src/jsvector.h @@ -182,7 +182,7 @@ struct VectorImpl * N requirements: * - any value, however, N is clamped to min/max values * AllocPolicy: - * - see "Allocation policies" in jsalloc.h (default js::ContextAllocPolicy) + * - see "Allocation policies" in jsalloc.h (default js::TempAllocPolicy) * * N.B: Vector is not reentrant: T member functions called during Vector member * functions must not call back into the same object. diff --git a/js/src/methodjit/MethodJIT.cpp b/js/src/methodjit/MethodJIT.cpp index 4e3982d7d99..4181abdb320 100644 --- a/js/src/methodjit/MethodJIT.cpp +++ b/js/src/methodjit/MethodJIT.cpp @@ -57,7 +57,7 @@ using namespace js::mjit; js::mjit::CompilerAllocPolicy::CompilerAllocPolicy(JSContext *cx, Compiler &compiler) -: ContextAllocPolicy(cx), +: TempAllocPolicy(cx), oomFlag(&compiler.oomInVector) { } diff --git a/js/src/methodjit/MethodJIT.h b/js/src/methodjit/MethodJIT.h index 5a90abc8d51..37456536973 100644 --- a/js/src/methodjit/MethodJIT.h +++ b/js/src/methodjit/MethodJIT.h @@ -270,7 +270,7 @@ class JaegerCompartment { * setting a flag on the compiler when OOM occurs. The compiler is required * to check for OOM only before trying to use the contents of the list. */ -class CompilerAllocPolicy : public ContextAllocPolicy +class CompilerAllocPolicy : public TempAllocPolicy { bool *oomFlag; @@ -282,12 +282,12 @@ class CompilerAllocPolicy : public ContextAllocPolicy public: CompilerAllocPolicy(JSContext *cx, bool *oomFlag) - : ContextAllocPolicy(cx), oomFlag(oomFlag) {} + : TempAllocPolicy(cx), oomFlag(oomFlag) {} CompilerAllocPolicy(JSContext *cx, Compiler &compiler); - void *malloc_(size_t bytes) { return checkAlloc(ContextAllocPolicy::malloc_(bytes)); } + void *malloc_(size_t bytes) { return checkAlloc(TempAllocPolicy::malloc_(bytes)); } void *realloc_(void *p, size_t oldBytes, size_t bytes) { - return checkAlloc(ContextAllocPolicy::realloc_(p, oldBytes, bytes)); + return checkAlloc(TempAllocPolicy::realloc_(p, oldBytes, bytes)); } }; diff --git a/js/src/methodjit/PolyIC.cpp b/js/src/methodjit/PolyIC.cpp index 5aae3fcd261..4c1ea6b0934 100644 --- a/js/src/methodjit/PolyIC.cpp +++ b/js/src/methodjit/PolyIC.cpp @@ -1160,7 +1160,7 @@ class GetPropCompiler : public PICStubCompiler class ScopeNameCompiler : public PICStubCompiler { private: - typedef Vector JumpList; + typedef Vector JumpList; JSObject *scopeChain; JSAtom *atom; @@ -1371,7 +1371,7 @@ class ScopeNameCompiler : public PICStubCompiler LookupStatus generateCallStub(JSObject *obj) { Assembler masm; - Vector fails(cx); + Vector fails(cx); ScopeNameLabels &labels = pic.scopeNameLabels(); /* For GETXPROP, the object is already in objReg. */ @@ -1605,7 +1605,7 @@ class BindNameCompiler : public PICStubCompiler LookupStatus generateStub(JSObject *obj) { Assembler masm; - js::Vector fails(cx); + Vector fails(cx); BindNameLabels &labels = pic.bindNameLabels(); diff --git a/js/src/shell/jsworkers.cpp b/js/src/shell/jsworkers.cpp index 7dfd146f35c..2741aa1c3bd 100644 --- a/js/src/shell/jsworkers.cpp +++ b/js/src/shell/jsworkers.cpp @@ -1052,7 +1052,7 @@ ResolveRelativePath(JSContext *cx, const char *base, JSString *filename) return filename; // Otherwise return base[:dirLen + 1] + filename. - js::Vector result(cx); + js::Vector result(cx); size_t nchars; if (!JS_DecodeBytes(cx, base, dirLen + 1, NULL, &nchars)) return NULL;