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/VMFunctions.h"
#include "jscntxtinlines.h"
using namespace js;
using namespace js::ion;

View File

@ -382,7 +382,7 @@ class FreeOp : public JSFreeOp {
return shouldFreeLater_;
}
inline void free_(void* p);
inline void free_(void *p);
template <class T>
inline void delete_(T *p) {
@ -467,13 +467,17 @@ class PerThreadData : public js::PerThreadDataFriendFields
int gcAssertNoGCDepth;
#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;
JSContext *ionJSContext;
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;
/*
@ -1121,17 +1125,17 @@ struct JSRuntime : js::RuntimeFriendFields
* 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.
*/
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
* 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>
T *pod_malloc(JSCompartment *comp = NULL, JSContext *cx = NULL) {
@ -1360,7 +1364,8 @@ VersionIsKnown(JSVersion version)
}
inline void
FreeOp::free_(void* p) {
FreeOp::free_(void *p)
{
if (shouldFreeLater()) {
runtime()->gcHelperThread.freeLater(p);
return;
@ -1649,19 +1654,19 @@ struct JSContext : js::ContextFriendFields,
void enterGenerator(JSGenerator *gen);
void leaveGenerator(JSGenerator *gen);
inline void* malloc_(size_t bytes) {
inline void *malloc_(size_t bytes) {
return runtime->malloc_(bytes, compartment, this);
}
inline void* calloc_(size_t bytes) {
inline void *calloc_(size_t bytes) {
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);
}
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);
}
@ -2300,4 +2305,46 @@ class ContextAllocPolicy
#pragma warning(pop)
#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___ */

View File

@ -22,44 +22,6 @@
#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 {
inline void

View File

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

View File

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