Loading js/public/Utility.h +2 −2 Original line number Diff line number Diff line Loading @@ -546,14 +546,14 @@ struct ScopedFreePtrTraits static T* empty() { return NULL; } static void release(T* ptr) { js_free(ptr); } }; SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits) SCOPED_TEMPLATE(ScopedJSFreePtr, ScopedFreePtrTraits) template <typename T> struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T> { static void release(T *ptr) { js_delete(ptr); } }; SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits) SCOPED_TEMPLATE(ScopedJSDeletePtr, ScopedDeletePtrTraits) } /* namespace js */ Loading js/src/ctypes/CTypes.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ #endif #include "mozilla/StandardInteger.h" #include "mozilla/Scoped.h" using namespace std; Loading Loading @@ -6939,7 +6938,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) return TypeError(cx, "(an object with known size)", valData); } ScopedFreePtr<void> cargs(malloc(sizeArg)); ScopedJSFreePtr<void> cargs(malloc(sizeArg)); if (!ImplicitConvert(cx, valData, objArgType, cargs.get(), false, &freePointer)) { Loading @@ -6954,7 +6953,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) // 4. Prepare buffer for holding return value ScopedFreePtr<void> rvalue; ScopedJSFreePtr<void> rvalue; if (CType::GetTypeCode(returnType) != TYPE_void_t) { rvalue = malloc(Align(CType::GetSize(returnType), sizeof(ffi_arg))); Loading Loading @@ -7010,7 +7009,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) } // 7. Store C information as private ScopedFreePtr<CDataFinalizer::Private> ScopedJSFreePtr<CDataFinalizer::Private> p((CDataFinalizer::Private*)malloc(sizeof(CDataFinalizer::Private))); memmove(&p->CIF, &funInfoFinalizer->mCIF, sizeof(ffi_cif)); Loading js/src/frontend/BytecodeEmitter.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -2263,7 +2263,7 @@ EmitSwitch(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) uint32_t caseCount = pn2->pn_count; uint32_t tableLength = 0; js::ScopedFreePtr<ParseNode*> table(NULL); ScopedJSFreePtr<ParseNode*> table(NULL); if (caseCount == 0 || (caseCount == 1 && Loading Loading @@ -2455,7 +2455,7 @@ EmitSwitch(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) /* * Use malloc to avoid arena bloat for programs with many switches. * ScopedFreePtr takes care of freeing it on exit. * ScopedJSFreePtr takes care of freeing it on exit. */ if (tableLength != 0) { table = cx->pod_calloc<ParseNode*>(tableLength); Loading js/src/ion/Ion.cpp +6 −26 Original line number Diff line number Diff line Loading @@ -1023,25 +1023,6 @@ CompileBackEnd(MIRGenerator *mir) return codegen; } class AutoDestroyAllocator { LifoAlloc *alloc; public: AutoDestroyAllocator(LifoAlloc *alloc) : alloc(alloc) {} void cancel() { alloc = NULL; } ~AutoDestroyAllocator() { if (alloc) js_delete(alloc); } }; class SequentialCompileContext { public: ExecutionMode executionMode() { Loading @@ -1049,7 +1030,7 @@ public: } AbortReason compile(IonBuilder *builder, MIRGraph *graph, AutoDestroyAllocator &autoDestroy); ScopedJSDeletePtr<LifoAlloc> &autoDelete); }; void Loading Loading @@ -1131,7 +1112,7 @@ IonCompile(JSContext *cx, HandleScript script, HandleFunction fun, jsbytecode *o if (!alloc) return AbortReason_Alloc; AutoDestroyAllocator autoDestroy(alloc); ScopedJSDeletePtr<LifoAlloc> autoDelete(alloc); TempAllocator *temp = alloc->new_<TempAllocator>(alloc); if (!temp) Loading Loading @@ -1167,7 +1148,7 @@ IonCompile(JSContext *cx, HandleScript script, HandleFunction fun, jsbytecode *o if (!builder) return AbortReason_Alloc; AbortReason abortReason = compileContext.compile(builder, graph, autoDestroy); AbortReason abortReason = compileContext.compile(builder, graph, autoDelete); if (abortReason != AbortReason_NoAbort) IonSpew(IonSpew_Abort, "IM Compilation failed."); Loading Loading @@ -1198,7 +1179,7 @@ OffThreadCompilationAvailable(JSContext *cx) AbortReason SequentialCompileContext::compile(IonBuilder *builder, MIRGraph *graph, AutoDestroyAllocator &autoDestroy) ScopedJSDeletePtr<LifoAlloc> &autoDelete) { JS_ASSERT(!builder->script()->ion); JSContext *cx = GetIonContext()->cx; Loading @@ -1223,19 +1204,18 @@ SequentialCompileContext::compile(IonBuilder *builder, MIRGraph *graph, // The allocator and associated data will be destroyed after being // processed in the finishedOffThreadCompilations list. autoDestroy.cancel(); autoDelete.forget(); return AbortReason_NoAbort; } CodeGenerator *codegen = CompileBackEnd(builder); ScopedJSDeletePtr<CodeGenerator> codegen(CompileBackEnd(builder)); if (!codegen) { IonSpew(IonSpew_Abort, "Failed during back-end compilation."); return AbortReason_Disable; } bool success = codegen->link(); js_delete(codegen); IonSpewEndFunction(); Loading js/src/jsexn.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1147,7 +1147,7 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope) size_t size = offsetof(JSExnPrivate, stackElems) + priv->stackDepth * sizeof(JSStackTraceElem); js::ScopedFreePtr<JSExnPrivate> copy(static_cast<JSExnPrivate *>(cx->malloc_(size))); ScopedJSFreePtr<JSExnPrivate> copy(static_cast<JSExnPrivate *>(cx->malloc_(size))); if (!copy) return NULL; Loading @@ -1158,7 +1158,7 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope) } else { copy->errorReport = NULL; } js::ScopedFreePtr<JSErrorReport> autoFreeErrorReport(copy->errorReport); ScopedJSFreePtr<JSErrorReport> autoFreeErrorReport(copy->errorReport); copy->message.init(priv->message); if (!cx->compartment->wrap(cx, ©->message)) Loading Loading
js/public/Utility.h +2 −2 Original line number Diff line number Diff line Loading @@ -546,14 +546,14 @@ struct ScopedFreePtrTraits static T* empty() { return NULL; } static void release(T* ptr) { js_free(ptr); } }; SCOPED_TEMPLATE(ScopedFreePtr, ScopedFreePtrTraits) SCOPED_TEMPLATE(ScopedJSFreePtr, ScopedFreePtrTraits) template <typename T> struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T> { static void release(T *ptr) { js_delete(ptr); } }; SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits) SCOPED_TEMPLATE(ScopedJSDeletePtr, ScopedDeletePtrTraits) } /* namespace js */ Loading
js/src/ctypes/CTypes.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ #endif #include "mozilla/StandardInteger.h" #include "mozilla/Scoped.h" using namespace std; Loading Loading @@ -6939,7 +6938,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) return TypeError(cx, "(an object with known size)", valData); } ScopedFreePtr<void> cargs(malloc(sizeArg)); ScopedJSFreePtr<void> cargs(malloc(sizeArg)); if (!ImplicitConvert(cx, valData, objArgType, cargs.get(), false, &freePointer)) { Loading @@ -6954,7 +6953,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) // 4. Prepare buffer for holding return value ScopedFreePtr<void> rvalue; ScopedJSFreePtr<void> rvalue; if (CType::GetTypeCode(returnType) != TYPE_void_t) { rvalue = malloc(Align(CType::GetSize(returnType), sizeof(ffi_arg))); Loading Loading @@ -7010,7 +7009,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) } // 7. Store C information as private ScopedFreePtr<CDataFinalizer::Private> ScopedJSFreePtr<CDataFinalizer::Private> p((CDataFinalizer::Private*)malloc(sizeof(CDataFinalizer::Private))); memmove(&p->CIF, &funInfoFinalizer->mCIF, sizeof(ffi_cif)); Loading
js/src/frontend/BytecodeEmitter.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -2263,7 +2263,7 @@ EmitSwitch(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) uint32_t caseCount = pn2->pn_count; uint32_t tableLength = 0; js::ScopedFreePtr<ParseNode*> table(NULL); ScopedJSFreePtr<ParseNode*> table(NULL); if (caseCount == 0 || (caseCount == 1 && Loading Loading @@ -2455,7 +2455,7 @@ EmitSwitch(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) /* * Use malloc to avoid arena bloat for programs with many switches. * ScopedFreePtr takes care of freeing it on exit. * ScopedJSFreePtr takes care of freeing it on exit. */ if (tableLength != 0) { table = cx->pod_calloc<ParseNode*>(tableLength); Loading
js/src/ion/Ion.cpp +6 −26 Original line number Diff line number Diff line Loading @@ -1023,25 +1023,6 @@ CompileBackEnd(MIRGenerator *mir) return codegen; } class AutoDestroyAllocator { LifoAlloc *alloc; public: AutoDestroyAllocator(LifoAlloc *alloc) : alloc(alloc) {} void cancel() { alloc = NULL; } ~AutoDestroyAllocator() { if (alloc) js_delete(alloc); } }; class SequentialCompileContext { public: ExecutionMode executionMode() { Loading @@ -1049,7 +1030,7 @@ public: } AbortReason compile(IonBuilder *builder, MIRGraph *graph, AutoDestroyAllocator &autoDestroy); ScopedJSDeletePtr<LifoAlloc> &autoDelete); }; void Loading Loading @@ -1131,7 +1112,7 @@ IonCompile(JSContext *cx, HandleScript script, HandleFunction fun, jsbytecode *o if (!alloc) return AbortReason_Alloc; AutoDestroyAllocator autoDestroy(alloc); ScopedJSDeletePtr<LifoAlloc> autoDelete(alloc); TempAllocator *temp = alloc->new_<TempAllocator>(alloc); if (!temp) Loading Loading @@ -1167,7 +1148,7 @@ IonCompile(JSContext *cx, HandleScript script, HandleFunction fun, jsbytecode *o if (!builder) return AbortReason_Alloc; AbortReason abortReason = compileContext.compile(builder, graph, autoDestroy); AbortReason abortReason = compileContext.compile(builder, graph, autoDelete); if (abortReason != AbortReason_NoAbort) IonSpew(IonSpew_Abort, "IM Compilation failed."); Loading Loading @@ -1198,7 +1179,7 @@ OffThreadCompilationAvailable(JSContext *cx) AbortReason SequentialCompileContext::compile(IonBuilder *builder, MIRGraph *graph, AutoDestroyAllocator &autoDestroy) ScopedJSDeletePtr<LifoAlloc> &autoDelete) { JS_ASSERT(!builder->script()->ion); JSContext *cx = GetIonContext()->cx; Loading @@ -1223,19 +1204,18 @@ SequentialCompileContext::compile(IonBuilder *builder, MIRGraph *graph, // The allocator and associated data will be destroyed after being // processed in the finishedOffThreadCompilations list. autoDestroy.cancel(); autoDelete.forget(); return AbortReason_NoAbort; } CodeGenerator *codegen = CompileBackEnd(builder); ScopedJSDeletePtr<CodeGenerator> codegen(CompileBackEnd(builder)); if (!codegen) { IonSpew(IonSpew_Abort, "Failed during back-end compilation."); return AbortReason_Disable; } bool success = codegen->link(); js_delete(codegen); IonSpewEndFunction(); Loading
js/src/jsexn.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1147,7 +1147,7 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope) size_t size = offsetof(JSExnPrivate, stackElems) + priv->stackDepth * sizeof(JSStackTraceElem); js::ScopedFreePtr<JSExnPrivate> copy(static_cast<JSExnPrivate *>(cx->malloc_(size))); ScopedJSFreePtr<JSExnPrivate> copy(static_cast<JSExnPrivate *>(cx->malloc_(size))); if (!copy) return NULL; Loading @@ -1158,7 +1158,7 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope) } else { copy->errorReport = NULL; } js::ScopedFreePtr<JSErrorReport> autoFreeErrorReport(copy->errorReport); ScopedJSFreePtr<JSErrorReport> autoFreeErrorReport(copy->errorReport); copy->message.init(priv->message); if (!cx->compartment->wrap(cx, ©->message)) Loading