Bug 825714 followup: Silence various warnings and make various style corrections. r=billm

This commit is contained in:
Nicholas D. Matsakis 2013-01-25 14:09:25 -08:00
parent d35081c114
commit aa174a5dd7
5 changed files with 64 additions and 59 deletions

View File

@ -14,8 +14,6 @@
#include "ion/Bailouts.h" #include "ion/Bailouts.h"
#include "ion/VMFunctions.h" #include "ion/VMFunctions.h"
#include "jscntxtinlines.h"
using namespace js; using namespace js;
using namespace js::ion; using namespace js::ion;

View File

@ -382,7 +382,7 @@ class FreeOp : public JSFreeOp {
return shouldFreeLater_; return shouldFreeLater_;
} }
inline void free_(void* p); inline void free_(void *p);
template <class T> template <class T>
inline void delete_(T *p) { inline void delete_(T *p) {
@ -467,13 +467,17 @@ class PerThreadData : public js::PerThreadDataFriendFields
int gcAssertNoGCDepth; int gcAssertNoGCDepth;
#endif #endif
// If Ion code is on the stack, and has called into C++, this will be /*
// aligned to an Ion exit frame. * If Ion code is on the stack, and has called into C++, this will be
* aligned to an Ion exit frame.
*/
uint8_t *ionTop; uint8_t *ionTop;
JSContext *ionJSContext; JSContext *ionJSContext;
uintptr_t ionStackLimit; uintptr_t ionStackLimit;
// This points to the most recent Ion activation running on the thread. /*
* This points to the most recent Ion activation running on the thread.
*/
js::ion::IonActivation *ionActivation; js::ion::IonActivation *ionActivation;
/* /*
@ -1121,17 +1125,17 @@ struct JSRuntime : js::RuntimeFriendFields
* Call the system malloc while checking for GC memory pressure and * Call the system malloc while checking for GC memory pressure and
* reporting OOM error when cx is not null. We will not GC from here. * reporting OOM error when cx is not null. We will not GC from here.
*/ */
inline void* malloc_(size_t bytes, JSCompartment *comp = NULL, JSContext *cx = NULL); inline void *malloc_(size_t bytes, JSCompartment *comp = NULL, JSContext *cx = NULL);
/* /*
* Call the system calloc while checking for GC memory pressure and * Call the system calloc while checking for GC memory pressure and
* reporting OOM error when cx is not null. We will not GC from here. * reporting OOM error when cx is not null. We will not GC from here.
*/ */
inline void* calloc_(size_t bytes, JSCompartment *comp = NULL, JSContext *cx = NULL); inline void *calloc_(size_t bytes, JSCompartment *comp = NULL, JSContext *cx = NULL);
inline void* realloc_(void* p, size_t oldBytes, size_t newBytes, JSCompartment *comp = NULL, JSContext *cx = NULL); inline void *realloc_(void *p, size_t oldBytes, size_t newBytes, JSCompartment *comp = NULL, JSContext *cx = NULL);
inline void* realloc_(void* p, size_t bytes, JSCompartment *comp = NULL, JSContext *cx = NULL); inline void *realloc_(void *p, size_t bytes, JSCompartment *comp = NULL, JSContext *cx = NULL);
template <class T> template <class T>
T *pod_malloc(JSCompartment *comp = NULL, JSContext *cx = NULL) { T *pod_malloc(JSCompartment *comp = NULL, JSContext *cx = NULL) {
@ -1360,7 +1364,8 @@ VersionIsKnown(JSVersion version)
} }
inline void inline void
FreeOp::free_(void* p) { FreeOp::free_(void *p)
{
if (shouldFreeLater()) { if (shouldFreeLater()) {
runtime()->gcHelperThread.freeLater(p); runtime()->gcHelperThread.freeLater(p);
return; return;
@ -1649,19 +1654,19 @@ struct JSContext : js::ContextFriendFields,
void enterGenerator(JSGenerator *gen); void enterGenerator(JSGenerator *gen);
void leaveGenerator(JSGenerator *gen); void leaveGenerator(JSGenerator *gen);
inline void* malloc_(size_t bytes) { inline void *malloc_(size_t bytes) {
return runtime->malloc_(bytes, compartment, this); return runtime->malloc_(bytes, compartment, this);
} }
inline void* calloc_(size_t bytes) { inline void *calloc_(size_t bytes) {
return runtime->calloc_(bytes, compartment, this); return runtime->calloc_(bytes, compartment, this);
} }
inline void* realloc_(void* p, size_t bytes) { inline void *realloc_(void *p, size_t bytes) {
return runtime->realloc_(p, bytes, compartment, this); return runtime->realloc_(p, bytes, compartment, this);
} }
inline void* realloc_(void* p, size_t oldBytes, size_t newBytes) { inline void *realloc_(void *p, size_t oldBytes, size_t newBytes) {
return runtime->realloc_(p, oldBytes, newBytes, compartment, this); return runtime->realloc_(p, oldBytes, newBytes, compartment, this);
} }
@ -2300,4 +2305,46 @@ class ContextAllocPolicy
#pragma warning(pop) #pragma warning(pop)
#endif #endif
void *
JSRuntime::malloc_(size_t bytes, JSCompartment *comp, JSContext *cx)
{
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
updateMallocCounter(comp, bytes);
void *p = js_malloc(bytes);
return JS_LIKELY(!!p) ? p : onOutOfMemory(NULL, bytes, cx);
}
void *
JSRuntime::calloc_(size_t bytes, JSCompartment *comp, JSContext *cx)
{
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
updateMallocCounter(comp, bytes);
void *p = js_calloc(bytes);
return JS_LIKELY(!!p) ? p : onOutOfMemory(reinterpret_cast<void *>(1), bytes, cx);
}
void *
JSRuntime::realloc_(void *p, size_t oldBytes, size_t newBytes, JSCompartment *comp, JSContext *cx)
{
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
JS_ASSERT(oldBytes < newBytes);
updateMallocCounter(comp, newBytes - oldBytes);
void *p2 = js_realloc(p, newBytes);
return JS_LIKELY(!!p2) ? p2 : onOutOfMemory(p, newBytes, cx);
}
void *
JSRuntime::realloc_(void *p, size_t bytes, JSCompartment *comp, JSContext *cx)
{
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
/*
* For compatibility we do not account for realloc that increases
* previously allocated memory.
*/
if (!p)
updateMallocCounter(comp, bytes);
void *p2 = js_realloc(p, bytes);
return JS_LIKELY(!!p2) ? p2 : onOutOfMemory(p, bytes, cx);
}
#endif /* jscntxt_h___ */ #endif /* jscntxt_h___ */

View File

@ -22,44 +22,6 @@
#include "jsgcinlines.h" #include "jsgcinlines.h"
void*
JSRuntime::malloc_(size_t bytes, JSCompartment *comp, JSContext *cx) {
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
updateMallocCounter(comp, bytes);
void *p = js_malloc(bytes);
return JS_LIKELY(!!p) ? p : onOutOfMemory(NULL, bytes, cx);
}
void*
JSRuntime::calloc_(size_t bytes, JSCompartment *comp, JSContext *cx) {
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
updateMallocCounter(comp, bytes);
void *p = js_calloc(bytes);
return JS_LIKELY(!!p) ? p : onOutOfMemory(reinterpret_cast<void *>(1), bytes, cx);
}
void*
JSRuntime::realloc_(void* p, size_t oldBytes, size_t newBytes, JSCompartment *comp, JSContext *cx) {
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
JS_ASSERT(oldBytes < newBytes);
updateMallocCounter(comp, newBytes - oldBytes);
void *p2 = js_realloc(p, newBytes);
return JS_LIKELY(!!p2) ? p2 : onOutOfMemory(p, newBytes, cx);
}
void*
JSRuntime::realloc_(void* p, size_t bytes, JSCompartment *comp, JSContext *cx) {
JS_ASSERT_IF(cx != NULL, cx->compartment == comp);
/*
* For compatibility we do not account for realloc that increases
* previously allocated memory.
*/
if (!p)
updateMallocCounter(comp, bytes);
void *p2 = js_realloc(p, bytes);
return JS_LIKELY(!!p2) ? p2 : onOutOfMemory(p, bytes, cx);
}
namespace js { namespace js {
inline void inline void

View File

@ -143,10 +143,10 @@ class Allocator
inline void *parallelNewGCThing(gc::AllocKind thingKind, size_t thingSize); inline void *parallelNewGCThing(gc::AllocKind thingKind, size_t thingSize);
inline void* malloc_(size_t bytes); inline void *malloc_(size_t bytes);
inline void* calloc_(size_t bytes); inline void *calloc_(size_t bytes);
inline void* realloc_(void* p, size_t bytes); inline void *realloc_(void *p, size_t bytes);
inline void* realloc_(void* p, size_t oldBytes, size_t newBytes); inline void *realloc_(void *p, size_t oldBytes, size_t newBytes);
template <class T> inline T *pod_malloc(); template <class T> inline T *pod_malloc();
template <class T> inline T *pod_calloc(); template <class T> inline T *pod_calloc();
template <class T> inline T *pod_malloc(size_t numElems); template <class T> inline T *pod_malloc(size_t numElems);

View File

@ -9,8 +9,6 @@
#include "js/CharacterEncoding.h" #include "js/CharacterEncoding.h"
#include "jscntxtinlines.h"
using namespace JS; using namespace JS;
Latin1CharsZ Latin1CharsZ