Bug 660734, part 1 - s/ContextAllocPolicy/TempAllocPolicy/ since it doesn't call cx->malloc_ (r=igor)
authorLuke Wagner <luke@mozilla.com>
Fri, 17 Jun 2011 10:11:33 -0700
changeset 71381 47b578958aa4372e97c539164fbc156b43617db8
parent 71380 cd2baff5325106e2ae8de2c225fc3452dc9568d7
child 71382 31e3b521775b5c4ff477848fe1650d67af84e332
push id20538
push usercleary@mozilla.com
push dateMon, 20 Jun 2011 23:59:42 +0000
treeherdermozilla-central@a285146675dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersigor
bugs660734
milestone7.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 660734, part 1 - s/ContextAllocPolicy/TempAllocPolicy/ since it doesn't call cx->malloc_ (r=igor)
js/src/jsalloc.cpp
js/src/jsalloc.h
js/src/jsemit.cpp
js/src/jsemit.h
js/src/jshashtable.h
js/src/jsiter.cpp
js/src/jsparse.cpp
js/src/jsprvtd.h
js/src/jsvector.h
js/src/methodjit/MethodJIT.cpp
js/src/methodjit/MethodJIT.h
js/src/methodjit/PolyIC.cpp
js/src/shell/jsworkers.cpp
--- a/js/src/jsalloc.cpp
+++ b/js/src/jsalloc.cpp
@@ -37,20 +37,20 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "jsalloc.h"
 #include "jscntxt.h"
 
 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);
 }
 
 } /* namespace js */
--- a/js/src/jsalloc.h
+++ b/js/src/jsalloc.h
@@ -74,28 +74,28 @@ class SystemAllocPolicy
  * Allocation policy that calls the system memory functions and reports errors
  * to the context. Since the JSContext given on construction is stored for
  * the lifetime of the container, this policy may only be used for containers
  * whose lifetime is a shorter than the given JSContext.
  *
  * FIXME bug 647103 - rewrite this in terms of temporary allocation functions,
  * not the system ones.
  */
-class ContextAllocPolicy
+class TempAllocPolicy
 {
     JSContext *const cx;
 
     /*
      * Non-inline helper to call JSRuntime::onOutOfMemory with minimal
      * code bloat.
      */
     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;
     }
 
     void *malloc_(size_t bytes) {
         void *p = js_malloc(bytes);
         if (JS_UNLIKELY(!p))
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -112,19 +112,19 @@ JSCodeGenerator::JSCodeGenerator(Parser 
     stackDepth(0), maxStackDepth(0),
     ntrynotes(0), lastTryNode(NULL),
     spanDeps(NULL), jumpTargets(NULL), jtFreeList(NULL),
     numSpanDeps(0), numJumpTargets(0), spanDepTodo(0),
     arrayCompDepth(0),
     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;
     memset(&prolog, 0, sizeof prolog);
     memset(&main, 0, sizeof main);
     current = &main;
     firstLine = prolog.currentLine = main.currentLine = lineno;
     prolog.noteMask = main.noteMask = SRCNOTE_CHUNK - 1;
--- a/js/src/jsemit.h
+++ b/js/src/jsemit.h
@@ -640,23 +640,23 @@ struct JSCodeGenerator : public JSTreeCo
 
     JSCGObjectList  objectList;     /* list of emitted objects */
     JSCGObjectList  regexpList;     /* list of emitted regexp that will be
                                        cloned during execution */
 
     JSAtomList      upvarList;      /* map of atoms to upvar indexes */
     JSUpvarArray    upvarMap;       /* indexed upvar pairs (JS_realloc'ed) */
 
-    typedef js::Vector<js::GlobalSlotArray::Entry, 16, js::ContextAllocPolicy> GlobalUseVector;
+    typedef js::Vector<js::GlobalSlotArray::Entry, 16> 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<uint32, 8, js::ContextAllocPolicy> SlotVector;
+    typedef js::Vector<uint32, 8> SlotVector;
     SlotVector      closedArgs;
     SlotVector      closedVars;
 
     uint16          traceIndex;     /* index for the next JSOP_TRACE instruction */
 
     /*
      * Initialize cg to allocate bytecode space from codePool, source note
      * space from notePool, and all other arena-allocated temporaries from
--- a/js/src/jshashtable.h
+++ b/js/src/jshashtable.h
@@ -803,17 +803,17 @@ struct DefaultHasher<T *>: PointerHasher
  * values. In particular, HashMap calls constructors and destructors of all
  * objects added so non-PODs may be used safely.
  *
  * Key/Value requirements:
  *  - default constructible, copyable, destructible, assignable
  * HashPolicy requirements:
  *  - see "Hash policy" above (default js::DefaultHasher<Key>)
  * 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.
  * N.B: Due to the lack of exception handling, the user must call |init()|.
  */
 template <class Key, class Value, class HashPolicy, class AllocPolicy>
 class HashMap
 {
@@ -1036,17 +1036,17 @@ class HashMap
  * particular, HashSet calls constructors and destructors of all objects added
  * so non-PODs may be used safely.
  *
  * T requirements:
  *  - default constructible, copyable, destructible, assignable
  * HashPolicy requirements:
  *  - see "Hash policy" above (default js::DefaultHasher<Key>)
  * 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.
  * N.B: Due to the lack of exception handling, the user must call |init()|.
  */
 template <class T, class HashPolicy, class AllocPolicy>
 class HashSet
 {
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -150,17 +150,17 @@ struct IdHashPolicy {
     static HashNumber hash(jsid id) {
         return JSID_BITS(id);
     }
     static bool match(jsid id1, jsid id2) {
         return id1 == id2;
     }
 };
 
-typedef HashSet<jsid, IdHashPolicy, ContextAllocPolicy> IdSet;
+typedef HashSet<jsid, IdHashPolicy> IdSet;
 
 static inline bool
 NewKeyValuePair(JSContext *cx, jsid id, const Value &val, Value *rval)
 {
     Value vec[2] = { IdToValue(id), val };
     AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vec), vec);
 
     JSObject *aobj = NewDenseCopiedArray(cx, 2, vec);
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -1204,17 +1204,17 @@ Compiler::defineGlobals(JSContext *cx, G
         const Shape *shape =
             DefineNativeProperty(cx, globalObj, id, rval, PropertyStub, StrictPropertyStub,
                                  JSPROP_ENUMERATE | JSPROP_PERMANENT, 0, 0);
         if (!shape)
             return false;
         def.knownSlot = shape->slot;
     }
 
-    js::Vector<JSScript *, 16, ContextAllocPolicy> worklist(cx);
+    js::Vector<JSScript *, 16> worklist(cx);
     if (!worklist.append(script))
         return false;
 
     /*
      * Recursively walk through all scripts we just compiled. For each script,
      * go through all global uses. Each global use indexes into globalScope->defs.
      * Use this information to repoint each use to the correct slot in the global
      * object.
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -153,36 +153,35 @@ class CallArgs;
 
 struct Compiler;
 struct Parser;
 class TokenStream;
 struct Token;
 struct TokenPos;
 struct TokenPtr;
 
-class ContextAllocPolicy;
-class SystemAllocPolicy;
+class TempAllocPolicy;
 
 template <class T,
           size_t MinInlineCapacity = 0,
-          class AllocPolicy = ContextAllocPolicy>
+          class AllocPolicy = TempAllocPolicy>
 class Vector;
 
 template <class>
 struct DefaultHasher;
 
 template <class Key,
           class Value,
           class HashPolicy = DefaultHasher<Key>,
-          class AllocPolicy = ContextAllocPolicy>
+          class AllocPolicy = TempAllocPolicy>
 class HashMap;
 
 template <class T,
           class HashPolicy = DefaultHasher<T>,
-          class AllocPolicy = ContextAllocPolicy>
+          class AllocPolicy = TempAllocPolicy>
 class HashSet;
 
 class PropertyCache;
 struct PropertyCacheEntry;
 
 struct Shape;
 struct EmptyShape;
 class Bindings;
--- a/js/src/jsvector.h
+++ b/js/src/jsvector.h
@@ -177,17 +177,17 @@ struct VectorImpl<T, N, AP, true>
  * dynamic allocation.
  *
  * T requirements:
  *  - default and copy constructible, assignable, destructible
  *  - operations do not throw
  * 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.
  */
 template <class T, size_t N, class AllocPolicy>
 class Vector : private AllocPolicy
 {
     /* utilities */
--- a/js/src/methodjit/MethodJIT.cpp
+++ b/js/src/methodjit/MethodJIT.cpp
@@ -52,17 +52,17 @@
 #include "jsgcinlines.h"
 #include "jsinterpinlines.h"
 
 using namespace js;
 using namespace js::mjit;
 
 
 js::mjit::CompilerAllocPolicy::CompilerAllocPolicy(JSContext *cx, Compiler &compiler)
-: ContextAllocPolicy(cx),
+: TempAllocPolicy(cx),
   oomFlag(&compiler.oomInVector)
 {
 }
 void
 StackFrame::methodjitStaticAsserts()
 {
         /* Static assert for x86 trampolines in MethodJIT.cpp. */
 #if defined(JS_CPU_X86)
--- a/js/src/methodjit/MethodJIT.h
+++ b/js/src/methodjit/MethodJIT.h
@@ -265,34 +265,34 @@ class JaegerCompartment {
 
 /*
  * Allocation policy for compiler jstl objects. The goal is to free the
  * compiler from having to check and propagate OOM after every time we
  * append to a vector. We do this by reporting OOM to the engine and
  * 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;
 
     void *checkAlloc(void *p) {
         if (!p)
             *oomFlag = true;
         return p;
     }
 
   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));
     }
 };
 
 namespace ic {
 # if defined JS_POLYIC
     struct PICInfo;
     struct GetElementIC;
     struct SetElementIC;
--- a/js/src/methodjit/PolyIC.cpp
+++ b/js/src/methodjit/PolyIC.cpp
@@ -1155,17 +1155,17 @@ class GetPropCompiler : public PICStubCo
 
         return generateStub(getprop.holder, getprop.shape);
     }
 };
 
 class ScopeNameCompiler : public PICStubCompiler
 {
   private:
-    typedef Vector<Jump, 8, ContextAllocPolicy> JumpList;
+    typedef Vector<Jump, 8> JumpList;
 
     JSObject *scopeChain;
     JSAtom *atom;
     GetPropertyHelper<ScopeNameCompiler> getprop;
     ScopeNameCompiler *thisFromCtor() { return this; }
 
     void patchPreviousToHere(CodeLocationLabel cs)
     {
@@ -1366,17 +1366,17 @@ class ScopeNameCompiler : public PICStub
     enum CallObjPropKind {
         ARG,
         VAR
     };
 
     LookupStatus generateCallStub(JSObject *obj)
     {
         Assembler masm;
-        Vector<Jump, 8, ContextAllocPolicy> fails(cx);
+        Vector<Jump, 8> fails(cx);
         ScopeNameLabels &labels = pic.scopeNameLabels();
 
         /* For GETXPROP, the object is already in objReg. */
         if (pic.kind == ic::PICInfo::NAME || pic.kind == ic::PICInfo::CALLNAME)
             masm.loadPtr(Address(JSFrameReg, StackFrame::offsetOfScopeChain()), pic.objReg);
 
         JS_ASSERT(obj == getprop.holder);
         JS_ASSERT(getprop.holder != scopeChain->getGlobal());
@@ -1600,17 +1600,17 @@ class BindNameCompiler : public PICStubC
         else
             jump = labels.getInlineJump(pic.getFastShapeGuard());
         repatcher.relink(jump, cs);
     }
 
     LookupStatus generateStub(JSObject *obj)
     {
         Assembler masm;
-        js::Vector<Jump, 8, ContextAllocPolicy> fails(cx);
+        Vector<Jump, 8> fails(cx);
 
         BindNameLabels &labels = pic.bindNameLabels();
 
         /* Guard on the shape of the scope chain. */
         masm.loadPtr(Address(JSFrameReg, StackFrame::offsetOfScopeChain()), pic.objReg);
         masm.loadShape(pic.objReg, pic.shapeReg);
         Jump firstShape = masm.branch32(Assembler::NotEqual, pic.shapeReg,
                                         Imm32(scopeChain->shape()));
--- a/js/src/shell/jsworkers.cpp
+++ b/js/src/shell/jsworkers.cpp
@@ -1047,17 +1047,17 @@ ResolveRelativePath(JSContext *cx, const
             dirLen = i;
     }
 
     // If base is relative and contains no directories, use filename unchanged.
     if (!IsAbsolute(base) && dirLen == (size_t) -1)
         return filename;
 
     // Otherwise return base[:dirLen + 1] + filename.
-    js::Vector<jschar, 0, js::ContextAllocPolicy> result(cx);
+    js::Vector<jschar, 0> result(cx);
     size_t nchars;
     if (!JS_DecodeBytes(cx, base, dirLen + 1, NULL, &nchars))
         return NULL;
     if (!result.reserve(dirLen + 1 + fileLen))
         return NULL;
     JS_ALWAYS_TRUE(result.resize(dirLen + 1));
     if (!JS_DecodeBytes(cx, base, dirLen + 1, result.begin(), &nchars))
         return NULL;