Bug 623297 - Reduce usage of JS_TRACE_MONITOR in jstracer (r=gal)

This commit is contained in:
Bill McCloskey 2011-02-01 10:16:44 -08:00
parent b47e0d23af
commit 0041160c2e
8 changed files with 276 additions and 217 deletions

View File

@ -2674,7 +2674,7 @@ JS_PUBLIC_API(void)
JS_FlushCaches(JSContext *cx)
{
#ifdef JS_TRACER
FlushJITCache(cx);
FlushJITCache(cx, &cx->compartment->traceMonitor);
#endif
}

View File

@ -2069,12 +2069,14 @@ js_ArrayCompPush(JSContext *cx, JSObject *obj, const Value &vp)
JSBool JS_FASTCALL
js_ArrayCompPush_tn(JSContext *cx, JSObject *obj, ValueArgType v)
{
TraceMonitor *tm = &JS_TRACE_MONITOR(cx);
if (!ArrayCompPushImpl(cx, obj, ValueArgToConstRef(v))) {
SetBuiltinError(cx);
SetBuiltinError(tm);
return JS_FALSE;
}
return WasBuiltinSuccessful(cx);
return WasBuiltinSuccessful(tm);
}
JS_DEFINE_CALLINFO_3(extern, BOOL_FAIL, js_ArrayCompPush_tn, CONTEXT, OBJECT,
VALUE, 0, nanojit::ACCSET_STORE_ANY)

View File

@ -72,7 +72,11 @@ using namespace js;
JS_FRIEND_API(void)
js_SetTraceableNativeFailed(JSContext *cx)
{
SetBuiltinError(cx);
/*
* We might not be on trace (we might have deep bailed) so we hope
* cx->compartment is correct.
*/
SetBuiltinError(&JS_TRACE_MONITOR(cx));
}
/*

View File

@ -815,17 +815,6 @@ private:
} /* namespace js */
/*
* N.B. JS_ON_TRACE(cx) is true if JIT code is on the stack in the current
* thread, regardless of whether cx is the context in which that trace is
* executing. cx must be a context on the current thread.
*/
#ifdef JS_TRACER
# define JS_ON_TRACE(cx) (cx->compartment && JS_TRACE_MONITOR(cx).ontrace())
#else
# define JS_ON_TRACE(cx) false
#endif
#ifdef DEBUG
# define FUNCTION_KIND_METER_LIST(_) \
_(allfun), _(heavy), _(nofreeupvar), _(onlyfreevar), \

View File

@ -85,10 +85,13 @@ typedef HashMap<JSFunction *,
DefaultHasher<JSFunction *>,
SystemAllocPolicy> ToSourceCache;
struct TraceMonitor;
/* Holds the execution state during trace execution. */
struct TracerState
{
JSContext* cx; // current VM context handle
TraceMonitor* traceMonitor; // current TM
double* stackBase; // native stack base
double* sp; // native stack pointer, stack[0] is spbase[0]
double* eos; // first unusable word after the native stack / begin of globals
@ -451,6 +454,17 @@ struct JS_FRIEND_API(JSCompartment) {
#define JS_TRACE_MONITOR(cx) (cx->compartment->traceMonitor)
#define JS_SCRIPTS_TO_GC(cx) (cx->compartment->scriptsToGC)
/*
* N.B. JS_ON_TRACE(cx) is true if JIT code is on the stack in the current
* thread, regardless of whether cx is the context in which that trace is
* executing. cx must be a context on the current thread.
*/
#ifdef JS_TRACER
# define JS_ON_TRACE(cx) (cx->compartment && JS_TRACE_MONITOR(cx).ontrace())
#else
# define JS_ON_TRACE(cx) false
#endif
namespace js {
static inline MathCache *
GetMathCache(JSContext *cx)

View File

@ -333,9 +333,11 @@ num_parseFloat(JSContext *cx, uintN argc, Value *vp)
static jsdouble FASTCALL
ParseFloat(JSContext* cx, JSString* str)
{
TraceMonitor *tm = &JS_TRACE_MONITOR(cx);
const jschar *bp = str->getChars(cx);
if (!bp) {
SetBuiltinError(cx);
SetBuiltinError(tm);
return js_NaN;
}
const jschar *end = bp + str->length();
@ -475,16 +477,18 @@ num_parseInt(JSContext *cx, uintN argc, Value *vp)
static jsdouble FASTCALL
ParseInt(JSContext* cx, JSString* str)
{
TraceMonitor *tm = &JS_TRACE_MONITOR(cx);
const jschar *start = str->getChars(cx);
if (!start) {
SetBuiltinError(cx);
SetBuiltinError(tm);
return js_NaN;
}
const jschar *end = start + str->length();
jsdouble d;
if (!ParseIntStringHelper(cx, start, end, 0, true, &d)) {
SetBuiltinError(cx);
SetBuiltinError(tm);
return js_NaN;
}
return d;

File diff suppressed because it is too large Load Diff

View File

@ -309,7 +309,10 @@ typedef Queue<uint16> SlotList;
class TypeMap : public Queue<JSValueType> {
Oracle *oracle;
public:
TypeMap(nanojit::Allocator* alloc) : Queue<JSValueType>(alloc) {}
TypeMap(nanojit::Allocator* alloc, Oracle *oracle)
: Queue<JSValueType>(alloc),
oracle(oracle)
{}
void set(unsigned stackSlots, unsigned ngslots,
const JSValueType* stackTypeMap, const JSValueType* globalTypeMap);
JS_REQUIRES_STACK void captureTypes(JSContext* cx, JSObject* globalObj, SlotList& slots, unsigned callDepth,
@ -523,9 +526,9 @@ struct UnstableExit
struct LinkableFragment : public VMFragment
{
LinkableFragment(const void* _ip, nanojit::Allocator* alloc
LinkableFragment(const void* _ip, nanojit::Allocator* alloc, Oracle *oracle
verbose_only(, uint32_t profFragID))
: VMFragment(_ip verbose_only(, profFragID)), typeMap(alloc), nStackTypes(0)
: VMFragment(_ip verbose_only(, profFragID)), typeMap(alloc, oracle), nStackTypes(0)
{ }
uint32 branchCount;
@ -546,9 +549,9 @@ struct LinkableFragment : public VMFragment
*/
struct TreeFragment : public LinkableFragment
{
TreeFragment(const void* _ip, nanojit::Allocator* alloc, JSObject* _globalObj,
TreeFragment(const void* _ip, nanojit::Allocator* alloc, Oracle *oracle, JSObject* _globalObj,
uint32 _globalShape, uint32 _argc verbose_only(, uint32_t profFragID)):
LinkableFragment(_ip, alloc verbose_only(, profFragID)),
LinkableFragment(_ip, alloc, oracle verbose_only(, profFragID)),
first(NULL),
next(NULL),
peer(NULL),
@ -644,6 +647,9 @@ public:
OP_LIMIT
};
/* The TraceMonitor for which we're profiling. */
TraceMonitor *traceMonitor;
/* The script in which the loop header lives. */
JSScript *entryScript;
@ -767,7 +773,7 @@ public:
return StackValue(false);
}
LoopProfile(JSStackFrame *entryfp, jsbytecode *top, jsbytecode *bottom);
LoopProfile(TraceMonitor *tm, JSStackFrame *entryfp, jsbytecode *top, jsbytecode *bottom);
void reset();
@ -796,6 +802,8 @@ public:
bool isCompilationExpensive(JSContext *cx, uintN depth);
bool isCompilationUnprofitable(JSContext *cx, uintN goodOps);
void decide(JSContext *cx);
void stopProfiling(JSContext *cx);
};
/*
@ -809,15 +817,15 @@ typedef enum BuiltinStatus {
} BuiltinStatus;
static JS_INLINE void
SetBuiltinError(JSContext *cx)
SetBuiltinError(TraceMonitor *tm)
{
JS_TRACE_MONITOR(cx).tracerState->builtinStatus |= BUILTIN_ERROR;
tm->tracerState->builtinStatus |= BUILTIN_ERROR;
}
static JS_INLINE bool
WasBuiltinSuccessful(JSContext *cx)
WasBuiltinSuccessful(TraceMonitor *tm)
{
return JS_TRACE_MONITOR(cx).tracerState->builtinStatus == 0;
return tm->tracerState->builtinStatus == 0;
}
#ifdef DEBUG_RECORDING_STATUS_NOT_BOOL
@ -1549,7 +1557,7 @@ class TraceRecorder
#undef OPDEF
JS_REQUIRES_STACK
TraceRecorder(JSContext* cx, VMSideExit*, VMFragment*,
TraceRecorder(JSContext* cx, TraceMonitor *tm, VMSideExit*, VMFragment*,
unsigned stackSlots, unsigned ngslots, JSValueType* typeMap,
VMSideExit* expectedInnerExit, JSScript* outerScript, jsbytecode* outerPC,
uint32 outerArgc, bool speculate);
@ -1573,8 +1581,8 @@ class TraceRecorder
friend class DetermineTypesVisitor;
friend class RecursiveSlotMap;
friend class UpRecursiveSlotMap;
friend MonitorResult RecordLoopEdge(JSContext*, uintN&);
friend TracePointAction RecordTracePoint(JSContext*, uintN &inlineCallCount,
friend MonitorResult RecordLoopEdge(JSContext*, TraceMonitor*, uintN&);
friend TracePointAction RecordTracePoint(JSContext*, TraceMonitor*, uintN &inlineCallCount,
bool *blacklist);
friend AbortResult AbortRecording(JSContext*, const char*);
friend class BoxArg;
@ -1582,7 +1590,7 @@ class TraceRecorder
public:
static bool JS_REQUIRES_STACK
startRecorder(JSContext*, VMSideExit*, VMFragment*,
startRecorder(JSContext*, TraceMonitor *, VMSideExit*, VMFragment*,
unsigned stackSlots, unsigned ngslots, JSValueType* typeMap,
VMSideExit* expectedInnerExit, JSScript* outerScript, jsbytecode* outerPC,
uint32 outerArgc, bool speculate);
@ -1656,7 +1664,6 @@ class TraceRecorder
#define REGEX_JIT_ENABLED(cx) ((cx)->traceJitEnabled || (cx)->methodJitEnabled)
#define TRACE_RECORDER(cx) (JS_TRACE_MONITOR(cx).recorder)
#define TRACE_PROFILER(cx) (JS_TRACE_MONITOR(cx).profile)
#define SET_TRACE_RECORDER(cx,tr) (JS_TRACE_MONITOR(cx).recorder = (tr))
#define JSOP_IN_RANGE(op,lo,hi) (uintN((op) - (lo)) <= uintN((hi) - (lo)))
#define JSOP_IS_BINARY(op) JSOP_IN_RANGE(op, JSOP_BITOR, JSOP_MOD)
@ -1713,7 +1720,7 @@ extern bool
OverfullJITCache(JSContext *cx, TraceMonitor* tm);
extern void
FlushJITCache(JSContext* cx);
FlushJITCache(JSContext* cx, TraceMonitor* tm);
extern JSObject *
GetBuiltinFunction(JSContext *cx, uintN index);