Bug 881333 - Use accessor methods for cx->compartment and cx->runtime, r=luke.

This commit is contained in:
Brian Hackett 2013-06-10 15:22:18 -06:00
parent e5d30a8e59
commit 327a300d21
104 changed files with 1072 additions and 1059 deletions

View File

@ -96,13 +96,13 @@ class EvalScriptGuard
~EvalScriptGuard() {
if (script_) {
CallDestroyScriptHook(cx_->runtime->defaultFreeOp(), script_);
CallDestroyScriptHook(cx_->runtime()->defaultFreeOp(), script_);
script_->isActiveEval = false;
script_->isCachedEval = true;
EvalCacheEntry cacheEntry = {script_, lookup_.callerScript, lookup_.pc};
lookup_.str = lookupStr_;
if (lookup_.str && IsEvalCacheCandidate(script_))
cx_->runtime->evalCache.relookupOrAdd(p_, lookup_, cacheEntry);
cx_->runtime()->evalCache.relookupOrAdd(p_, lookup_, cacheEntry);
}
}
@ -113,10 +113,10 @@ class EvalScriptGuard
lookup_.callerScript = callerScript;
lookup_.version = cx_->findVersion();
lookup_.pc = pc;
p_ = cx_->runtime->evalCache.lookupForAdd(lookup_);
p_ = cx_->runtime()->evalCache.lookupForAdd(lookup_);
if (p_) {
script_ = p_->script;
cx_->runtime->evalCache.remove(p_);
cx_->runtime()->evalCache.remove(p_);
CallNewScriptHook(cx_, script_, NullPtr());
script_->isCachedEval = false;
script_->isActiveEval = true;
@ -360,7 +360,7 @@ js::DirectEvalFromIon(JSContext *cx,
EvalScriptGuard esg(cx);
// Ion will not perform cross compartment direct eval calls.
JSPrincipals *principals = cx->compartment->principals;
JSPrincipals *principals = cx->compartment()->principals;
esg.lookupInEvalCache(stableStr, callerScript, pc);

View File

@ -2049,7 +2049,7 @@ js_InitIntlClass(JSContext *cx, HandleObject obj)
// Skip initialization of the Intl constructors during initialization of the
// self-hosting global as we may get here before self-hosted code is compiled,
// and no core code refers to the Intl classes.
if (!cx->runtime->isSelfHostingGlobal(cx->global())) {
if (!cx->runtime()->isSelfHostingGlobal(cx->global())) {
if (!InitCollatorClass(cx, Intl, global))
return NULL;
if (!InitNumberFormatClass(cx, Intl, global))

View File

@ -1174,7 +1174,7 @@ MapObject::construct(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return false;
ValueMap *map = cx->new_<ValueMap>(cx->runtime);
ValueMap *map = cx->new_<ValueMap>(cx->runtime());
if (!map)
return false;
if (!map->init()) {
@ -1208,7 +1208,7 @@ MapObject::construct(JSContext *cx, unsigned argc, Value *vp)
js_ReportOutOfMemory(cx);
return false;
}
WriteBarrierPost(cx->runtime, map, hkey);
WriteBarrierPost(cx->runtime(), map, hkey);
}
if (!iter.close())
return false;
@ -1307,7 +1307,7 @@ MapObject::set_impl(JSContext *cx, CallArgs args)
js_ReportOutOfMemory(cx);
return false;
}
WriteBarrierPost(cx->runtime, &map, key);
WriteBarrierPost(cx->runtime(), &map, key);
args.rval().setUndefined();
return true;
}
@ -1670,7 +1670,7 @@ SetObject::construct(JSContext *cx, unsigned argc, Value *vp)
if (!obj)
return false;
ValueSet *set = cx->new_<ValueSet>(cx->runtime);
ValueSet *set = cx->new_<ValueSet>(cx->runtime());
if (!set)
return false;
if (!set->init()) {
@ -1690,7 +1690,7 @@ SetObject::construct(JSContext *cx, unsigned argc, Value *vp)
js_ReportOutOfMemory(cx);
return false;
}
WriteBarrierPost(cx->runtime, set, key);
WriteBarrierPost(cx->runtime(), set, key);
}
if (!iter.close())
return false;
@ -1761,7 +1761,7 @@ SetObject::add_impl(JSContext *cx, CallArgs args)
js_ReportOutOfMemory(cx);
return false;
}
WriteBarrierPost(cx->runtime, &set, key);
WriteBarrierPost(cx->runtime(), &set, key);
args.rval().setUndefined();
return true;
}

View File

@ -204,7 +204,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
{
if (args.length() == 0) {
RegExpStatics *res = cx->regExpStatics();
Rooted<JSAtom*> empty(cx, cx->runtime->emptyString);
Rooted<JSAtom*> empty(cx, cx->runtime()->emptyString);
RegExpObject *reobj = builder.build(empty, res->getFlags());
if (!reobj)
return false;
@ -263,7 +263,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
RootedAtom source(cx);
if (sourceValue.isUndefined()) {
source = cx->runtime->emptyString;
source = cx->runtime()->emptyString;
} else {
/* Coerce to string and compile. */
JSString *str = ToString<CanGC>(cx, sourceValue);

View File

@ -203,19 +203,19 @@ GC(JSContext *cx, unsigned argc, jsval *vp)
}
#ifndef JS_MORE_DETERMINISTIC
size_t preBytes = cx->runtime->gcBytes;
size_t preBytes = cx->runtime()->gcBytes;
#endif
if (compartment)
PrepareForDebugGC(cx->runtime);
PrepareForDebugGC(cx->runtime());
else
PrepareForFullGC(cx->runtime);
GCForReason(cx->runtime, gcreason::API);
PrepareForFullGC(cx->runtime());
GCForReason(cx->runtime(), gcreason::API);
char buf[256] = { '\0' };
#ifndef JS_MORE_DETERMINISTIC
JS_snprintf(buf, sizeof(buf), "before %lu, after %lu\n",
(unsigned long)preBytes, (unsigned long)cx->runtime->gcBytes);
(unsigned long)preBytes, (unsigned long)cx->runtime()->gcBytes);
#endif
JSString *str = JS_NewStringCopyZ(cx, buf);
if (!str)
@ -268,7 +268,7 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp)
JSGCParamKey param = paramMap[paramIndex].param;
if (argc == 1) {
uint32_t value = JS_GetGCParameter(cx->runtime, param);
uint32_t value = JS_GetGCParameter(cx->runtime(), param);
vp[0] = JS_NumberValue(value);
return true;
}
@ -289,7 +289,7 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp)
}
if (param == JSGC_MAX_BYTES) {
uint32_t gcBytes = JS_GetGCParameter(cx->runtime, JSGC_BYTES);
uint32_t gcBytes = JS_GetGCParameter(cx->runtime(), JSGC_BYTES);
if (value < gcBytes) {
JS_ReportError(cx,
"attempt to set maxBytes to the value less than the current "
@ -299,7 +299,7 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp)
}
}
JS_SetGCParameter(cx->runtime, param, value);
JS_SetGCParameter(cx->runtime(), param, value);
*vp = JSVAL_VOID;
return true;
}
@ -355,7 +355,7 @@ GCPreserveCode(JSContext *cx, unsigned argc, jsval *vp)
return JS_FALSE;
}
cx->runtime->alwaysPreserveCode = true;
cx->runtime()->alwaysPreserveCode = true;
*vp = JSVAL_VOID;
return JS_TRUE;
@ -414,7 +414,7 @@ ScheduleGC(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
SelectForGC(JSContext *cx, unsigned argc, jsval *vp)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
for (unsigned i = 0; i < argc; i++) {
Value arg(JS_ARGV(cx, vp)[i]);
@ -438,7 +438,7 @@ VerifyPreBarriers(JSContext *cx, unsigned argc, jsval *vp)
ReportUsageError(cx, callee, "Too many arguments");
return JS_FALSE;
}
gc::VerifyBarriers(cx->runtime, gc::PreBarrierVerifier);
gc::VerifyBarriers(cx->runtime(), gc::PreBarrierVerifier);
*vp = JSVAL_VOID;
return JS_TRUE;
}
@ -451,7 +451,7 @@ VerifyPostBarriers(JSContext *cx, unsigned argc, jsval *vp)
ReportUsageError(cx, callee, "Too many arguments");
return JS_FALSE;
}
gc::VerifyBarriers(cx->runtime, gc::PostBarrierVerifier);
gc::VerifyBarriers(cx->runtime(), gc::PostBarrierVerifier);
*vp = JSVAL_VOID;
return JS_TRUE;
}
@ -468,7 +468,7 @@ GCState(JSContext *cx, unsigned argc, jsval *vp)
}
const char *state;
gc::State globalState = cx->runtime->gcIncrementalState;
gc::State globalState = cx->runtime()->gcIncrementalState;
if (globalState == gc::NO_INCREMENTAL)
state = "none";
else if (globalState == gc::MARK)
@ -522,7 +522,7 @@ GCSlice(JSContext *cx, unsigned argc, jsval *vp)
limit = false;
}
GCDebugSlice(cx->runtime, limit, budget);
GCDebugSlice(cx->runtime(), limit, budget);
*vp = JSVAL_VOID;
return JS_TRUE;
}
@ -850,9 +850,9 @@ EnableSPSProfilingAssertions(JSContext *cx, unsigned argc, jsval *vp)
static ProfileEntry stack[1000];
static uint32_t stack_size = 0;
SetRuntimeProfilingStack(cx->runtime, stack, &stack_size, 1000);
cx->runtime->spsProfiler.enableSlowAssertions(args[0].toBoolean());
cx->runtime->spsProfiler.enable(true);
SetRuntimeProfilingStack(cx->runtime(), stack, &stack_size, 1000);
cx->runtime()->spsProfiler.enableSlowAssertions(args[0].toBoolean());
cx->runtime()->spsProfiler.enable(true);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return true;
@ -861,8 +861,8 @@ EnableSPSProfilingAssertions(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
DisableSPSProfiling(JSContext *cx, unsigned argc, jsval *vp)
{
if (cx->runtime->spsProfiler.installed())
cx->runtime->spsProfiler.enable(false);
if (cx->runtime()->spsProfiler.installed())
cx->runtime()->spsProfiler.enable(false);
return true;
}
@ -878,7 +878,7 @@ DisplayName(JSContext *cx, unsigned argc, jsval *vp)
JSFunction *fun = args[0].toObject().toFunction();
JSString *str = fun->displayAtom();
vp->setString(str == NULL ? cx->runtime->emptyString : str);
vp->setString(str == NULL ? cx->runtime()->emptyString : str);
return true;
}

View File

@ -6518,7 +6518,7 @@ CData::GetRuntime(JSContext* cx, unsigned argc, jsval* vp)
return JS_FALSE;
}
void* data = static_cast<void*>(cx->runtime);
void* data = static_cast<void*>(cx->runtime());
JSObject* result = CData::Create(cx, targetType, NullPtr(), &data, true);
if (!result)
return JS_FALSE;

View File

@ -314,7 +314,7 @@ frontend::CompileLazyFunction(JSContext *cx, HandleFunction fun, LazyScript *laz
const jschar *chars, size_t length)
{
CompileOptions options(cx);
options.setPrincipals(cx->compartment->principals)
options.setPrincipals(cx->compartment()->principals)
.setOriginPrincipals(lazy->parent()->originPrincipals)
.setVersion(lazy->parent()->getVersion())
.setFileAndLine(lazy->parent()->filename(), lazy->lineno())

View File

@ -87,7 +87,7 @@ AtomThingMapPtr<Map>::ensureMap(JSContext *cx)
{
if (map_)
return true;
map_ = cx->runtime->parseMapPool.acquire<Map>();
map_ = cx->runtime()->parseMapPool.acquire<Map>();
return !!map_;
}
@ -97,7 +97,7 @@ AtomThingMapPtr<Map>::releaseMap(JSContext *cx)
{
if (!map_)
return;
cx->runtime->parseMapPool.release(map_);
cx->runtime()->parseMapPool.release(map_);
map_ = NULL;
}
@ -105,7 +105,7 @@ template <typename ParseHandler>
inline bool
AtomDecls<ParseHandler>::init()
{
map = cx->runtime->parseMapPool.acquire<AtomDefnListMap>();
map = cx->runtime()->parseMapPool.acquire<AtomDefnListMap>();
return map;
}
@ -114,7 +114,7 @@ inline
AtomDecls<ParseHandler>::~AtomDecls()
{
if (map)
cx->runtime->parseMapPool.release(map);
cx->runtime()->parseMapPool.release(map);
}
} /* namespace frontend */

View File

@ -412,7 +412,7 @@ Parser<ParseHandler>::Parser(JSContext *cx, const CompileOptions &options,
traceListHead(NULL),
pc(NULL),
sct(NULL),
keepAtoms(cx->runtime),
keepAtoms(cx->runtime()),
foldConstants(foldConstants),
compileAndGo(options.compileAndGo),
selfHostingMode(options.selfHostingMode),
@ -422,7 +422,7 @@ Parser<ParseHandler>::Parser(JSContext *cx, const CompileOptions &options,
// XXX bug 678037 always disable syntax parsing for now.
handler.disableSyntaxParser();
cx->runtime->activeCompilations++;
cx->runtime()->activeCompilations++;
// The Mozilla specific 'strict' option adds extra warnings which are not
// generated if functions are parsed lazily. Note that the standard
@ -438,7 +438,7 @@ Parser<ParseHandler>::~Parser()
{
JSContext *cx = context;
cx->tempLifoAlloc().release(tempPoolMark);
cx->runtime->activeCompilations--;
cx->runtime()->activeCompilations--;
/*
* The parser can allocate enormous amounts of memory for large functions.
@ -2323,7 +2323,7 @@ template <>
ParseNode *
Parser<FullParseHandler>::moduleDecl()
{
JS_ASSERT(tokenStream.currentToken().name() == context->runtime->atomState.module);
JS_ASSERT(tokenStream.currentToken().name() == context->runtime()->atomState.module);
if (!((pc->sc->isGlobalSharedContext() || pc->sc->isModuleBox()) && pc->atBodyLevel()))
{
report(ParseError, false, NULL, JSMSG_MODULE_STATEMENT);
@ -2464,7 +2464,7 @@ Parser<ParseHandler>::maybeParseDirective(Node pn, bool *cont)
// in other browsers first.
handler.setPrologue(pn);
if (directive == context->runtime->atomState.useStrict) {
if (directive == context->runtime()->atomState.useStrict) {
// We're going to be in strict mode. Note that this scope explicitly
// had "use strict";
pc->sc->setExplicitUseStrict();

View File

@ -311,8 +311,8 @@ TokenStream::TokenStream(JSContext *cx, const CompileOptions &options,
if (originPrincipals)
JS_HoldPrincipals(originPrincipals);
JSSourceHandler listener = cx->runtime->debugHooks.sourceHandler;
void *listenerData = cx->runtime->debugHooks.sourceHandlerData;
JSSourceHandler listener = cx->runtime()->debugHooks.sourceHandler;
void *listenerData = cx->runtime()->debugHooks.sourceHandlerData;
if (listener)
listener(options.filename, options.lineno, base, length, &listenerTSData, listenerData);
@ -370,7 +370,7 @@ TokenStream::~TokenStream()
if (sourceMap)
js_free(sourceMap);
if (originPrincipals)
JS_DropPrincipals(cx->runtime, originPrincipals);
JS_DropPrincipals(cx->runtime(), originPrincipals);
}
/* Use the fastest available getc. */
@ -635,8 +635,8 @@ CompileError::throwError()
* sending the error on to the regular error reporter.
*/
bool reportError = true;
if (JSDebugErrorHook hook = cx->runtime->debugHooks.debugErrorHook) {
reportError = hook(cx, message, &report, cx->runtime->debugHooks.debugErrorHookData);
if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
reportError = hook(cx, message, &report, cx->runtime()->debugHooks.debugErrorHookData);
}
/* Report the error */

View File

@ -226,20 +226,20 @@ GatherRooters(Vector<Rooter, 0, SystemAllocPolicy> &rooters,
void
JS::CheckStackRoots(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (rt->gcZeal_ != ZealStackRootingValue)
return;
// GCs can't happen when analysis/inference/compilation are active.
if (cx->compartment->activeAnalysis)
if (cx->compartment()->activeAnalysis)
return;
if (rt->mainThread.suppressGC)
return;
// Can switch to the atoms compartment during analysis.
if (IsAtomsCompartment(cx->compartment)) {
if (IsAtomsCompartment(cx->compartment())) {
for (CompartmentsIter c(rt); !c.done(); c.next()) {
if (c.get()->activeAnalysis)
return;
@ -852,8 +852,8 @@ MaybeVerifyPostBarriers(JSRuntime *rt, bool always)
void
js::gc::MaybeVerifyBarriers(JSContext *cx, bool always)
{
MaybeVerifyPreBarriers(cx->runtime, always);
MaybeVerifyPostBarriers(cx->runtime, always);
MaybeVerifyPreBarriers(cx->runtime(), always);
MaybeVerifyPostBarriers(cx->runtime(), always);
}
void

View File

@ -1156,7 +1156,7 @@ class MOZ_STACK_CLASS ModuleCompiler
}
bool init() {
if (!cx_->compartment->ensureIonCompartmentExists(cx_))
if (!cx_->compartment()->ensureIonCompartmentExists(cx_))
return false;
if (!globals_.init() || !exits_.init())
@ -1460,7 +1460,7 @@ class MOZ_STACK_CLASS ModuleCompiler
size_t allocedBytes = totalBytes + gc::PageSize;
// Allocate the slab of memory.
JSC::ExecutableAllocator *execAlloc = cx_->compartment->ionCompartment()->execAlloc();
JSC::ExecutableAllocator *execAlloc = cx_->compartment()->ionCompartment()->execAlloc();
JSC::ExecutablePool *pool;
uint8_t *unalignedBytes = (uint8_t*)execAlloc->alloc(allocedBytes, &pool, JSC::ASMJS_CODE);
if (!unalignedBytes)
@ -4632,7 +4632,7 @@ CheckFunctionBody(ModuleCompiler &m, ModuleCompiler::Func &func, LifoAlloc &lifo
// Force Ion allocations to occur in the LifoAlloc while in scope.
TempAllocator *tempAlloc = lifo.new_<TempAllocator>(&lifo);
IonContext icx(m.cx()->compartment, tempAlloc);
IonContext icx(m.cx()->compartment(), tempAlloc);
// Allocate objects required for MIR generation.
// Memory for the objects is provided by the LifoAlloc argument,
@ -4640,7 +4640,7 @@ CheckFunctionBody(ModuleCompiler &m, ModuleCompiler::Func &func, LifoAlloc &lifo
MIRGraph *graph = lifo.new_<MIRGraph>(tempAlloc);
CompileInfo *info = lifo.new_<CompileInfo>(locals.count(),
SequentialExecution);
MIRGenerator *mirGen = lifo.new_<MIRGenerator>(m.cx()->compartment, tempAlloc, graph, info);
MIRGenerator *mirGen = lifo.new_<MIRGenerator>(m.cx()->compartment(), tempAlloc, graph, info);
JS_ASSERT(tempAlloc && graph && info && mirGen);
FunctionCompiler f(m, func, Move(locals), mirGen);
@ -4719,7 +4719,7 @@ CheckFunctionBodiesSequential(ModuleCompiler &m)
IonSpewNewFunction(&mirGen->graph(), NullPtr());
IonContext icx(m.cx()->compartment, &mirGen->temp());
IonContext icx(m.cx()->compartment(), &mirGen->temp());
if (!OptimizeMIR(mirGen))
return m.fail(func.fn(), "internal compiler failure (probably out of memory)");
@ -4755,7 +4755,7 @@ struct ParallelGroupState
static AsmJSParallelTask *
GetFinishedCompilation(ModuleCompiler &m, ParallelGroupState &group)
{
AutoLockWorkerThreadState lock(m.cx()->runtime);
AutoLockWorkerThreadState lock(m.cx()->runtime());
while (!group.state.asmJSWorkerFailed()) {
if (!group.state.asmJSFinishedList.empty()) {
@ -4860,7 +4860,7 @@ CancelOutstandingJobs(ModuleCompiler &m, ParallelGroupState &group)
if (!group.outstandingJobs)
return;
AutoLockWorkerThreadState lock(m.cx()->runtime);
AutoLockWorkerThreadState lock(m.cx()->runtime());
// From the compiling tasks, eliminate those waiting for worker assignation.
group.outstandingJobs -= group.state.asmJSWorklist.length();
@ -4894,7 +4894,7 @@ static bool
CheckFunctionBodiesParallel(ModuleCompiler &m)
{
// Saturate all worker threads plus the main thread.
WorkerThreadState &state = *m.cx()->runtime->workerThreadState;
WorkerThreadState &state = *m.cx()->runtime()->workerThreadState;
size_t numParallelJobs = state.numThreads + 1;
// Allocate scoped AsmJSParallelTask objects. Each contains a unique
@ -5760,16 +5760,16 @@ js::CompileAsmJS(JSContext *cx, TokenStream &ts, ParseNode *fn, const CompileOpt
if (!cx->hasOption(JSOPTION_ASMJS))
return Warn(cx, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by javascript.options.asmjs in about:config");
if (cx->compartment->debugMode())
if (cx->compartment()->debugMode())
return Warn(cx, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by debugger");
#ifdef JS_ASMJS
if (!EnsureAsmJSSignalHandlersInstalled(cx->runtime))
if (!EnsureAsmJSSignalHandlersInstalled(cx->runtime()))
return Warn(cx, JSMSG_USE_ASM_TYPE_FAIL, "Platform missing signal handler support");
# ifdef JS_PARALLEL_COMPILATION
if (OffThreadCompilationEnabled(cx)) {
if (!EnsureParallelCompilationInitialized(cx->runtime))
if (!EnsureParallelCompilationInitialized(cx->runtime()))
return Warn(cx, JSMSG_USE_ASM_TYPE_FAIL, "Failed compilation thread initialization");
}
# endif
@ -5811,7 +5811,7 @@ js::IsAsmJSCompilationAvailable(JSContext *cx, unsigned argc, Value *vp)
#ifdef JS_ASMJS
bool available = JSC::MacroAssembler().supportsFloatingPoint() &&
!cx->compartment->debugMode() &&
!cx->compartment()->debugMode() &&
cx->hasOption(JSOPTION_ASMJS);
#else
bool available = false;

View File

@ -258,15 +258,15 @@ AsmJSActivation::AsmJSActivation(JSContext *cx, const AsmJSModule &module)
profiler_(NULL),
resumePC_(NULL)
{
if (cx->runtime->spsProfiler.enabled()) {
profiler_ = &cx->runtime->spsProfiler;
if (cx->runtime()->spsProfiler.enabled()) {
profiler_ = &cx->runtime()->spsProfiler;
profiler_->enterNative("asm.js code", this);
}
prev_ = cx_->runtime->mainThread.asmJSActivationStack_;
prev_ = cx_->runtime()->mainThread.asmJSActivationStack_;
JSRuntime::AutoLockForOperationCallback lock(cx_->runtime);
cx_->runtime->mainThread.asmJSActivationStack_ = this;
JSRuntime::AutoLockForOperationCallback lock(cx_->runtime());
cx_->runtime()->mainThread.asmJSActivationStack_ = this;
(void) errorRejoinSP_; // squelch GCC warning
}
@ -276,10 +276,10 @@ AsmJSActivation::~AsmJSActivation()
if (profiler_)
profiler_->exitNative();
JS_ASSERT(cx_->runtime->mainThread.asmJSActivationStack_ == this);
JS_ASSERT(cx_->runtime()->mainThread.asmJSActivationStack_ == this);
JSRuntime::AutoLockForOperationCallback lock(cx_->runtime);
cx_->runtime->mainThread.asmJSActivationStack_ = prev_;
JSRuntime::AutoLockForOperationCallback lock(cx_->runtime());
cx_->runtime()->mainThread.asmJSActivationStack_ = prev_;
}
static const unsigned ASM_MODULE_SLOT = 0;

View File

@ -133,7 +133,7 @@ ion::InvalidationBailout(InvalidationBailoutStack *sp, size_t *frameSizeOut,
IonSpew(IonSpew_Invalidate, " new ra %p", (void *) frame->returnAddress());
}
iter.ionScript()->decref(cx->runtime->defaultFreeOp());
iter.ionScript()->decref(cx->runtime()->defaultFreeOp());
return retval;
}

View File

@ -503,7 +503,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
// If SPS Profiler is enabled, mark the frame as having pushed an SPS entry.
// This may be wrong for the last frame of ArgumentCheck bailout, but
// that will be fixed later.
if (cx->runtime->spsProfiler.enabled() && ionScript->hasSPSInstrumentation()) {
if (cx->runtime()->spsProfiler.enabled() && ionScript->hasSPSInstrumentation()) {
IonSpew(IonSpew_BaselineBailouts, " Setting SPS flag on frame!");
flags |= BaselineFrame::HAS_PUSHED_SPS_FRAME;
}
@ -615,11 +615,11 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
// If coming from an invalidation bailout, and this is the topmost
// value, and a value override has been specified, don't read from the
// iterator. Otherwise, we risk using a garbage value.
if (!iter.moreFrames() && i == exprStackSlots - 1 && cx->runtime->hasIonReturnOverride()) {
if (!iter.moreFrames() && i == exprStackSlots - 1 && cx->runtime()->hasIonReturnOverride()) {
JS_ASSERT(invalidate);
iter.skip();
IonSpew(IonSpew_BaselineBailouts, " [Return Override]");
v = cx->runtime->takeIonReturnOverride();
v = cx->runtime()->takeIonReturnOverride();
} else {
v = iter.read();
}
@ -793,16 +793,16 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
// Ion would already have pushed an SPS entry for this frame.
// The pc for this entry would be set to NULL.
// Make sure it's set to script->pc.
if (cx->runtime->spsProfiler.enabled()) {
if (cx->runtime()->spsProfiler.enabled()) {
if (caller && bailoutKind == Bailout_ArgumentCheck) {
IonSpew(IonSpew_BaselineBailouts, " Setting PCidx on innermost "
"inlined frame's parent's SPS entry (%s:%d) (pcIdx=%d)!",
caller->filename(), caller->lineno, callerPC - caller->code);
cx->runtime->spsProfiler.updatePC(caller, callerPC);
cx->runtime()->spsProfiler.updatePC(caller, callerPC);
} else if (bailoutKind != Bailout_ArgumentCheck) {
IonSpew(IonSpew_BaselineBailouts,
" Popping SPS entry for innermost inlined frame's SPS entry");
cx->runtime->spsProfiler.exit(cx, script, fun);
cx->runtime()->spsProfiler.exit(cx, script, fun);
}
}
} else {
@ -911,7 +911,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
return false;
// Push return address into ICCall_Scripted stub, immediately after the call.
void *baselineCallReturnAddr = cx->compartment->ionCompartment()->baselineCallReturnAddr();
void *baselineCallReturnAddr = cx->compartment()->ionCompartment()->baselineCallReturnAddr();
JS_ASSERT(baselineCallReturnAddr);
if (!builder.writePtr(baselineCallReturnAddr, "ReturnAddr"))
return false;
@ -990,7 +990,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
// Push return address into the ArgumentsRectifier code, immediately after the ioncode
// call.
void *rectReturnAddr = cx->compartment->ionCompartment()->getArgumentsRectifierReturnAddr();
void *rectReturnAddr = cx->compartment()->ionCompartment()->getArgumentsRectifierReturnAddr();
JS_ASSERT(rectReturnAddr);
if (!builder.writePtr(rectReturnAddr, "ReturnAddr"))
return false;

View File

@ -196,7 +196,7 @@ BaselineCompiler::compile()
baselineScript->toggleBarriers(true);
// All SPS instrumentation is emitted toggled off. Toggle them on if needed.
if (cx->runtime->spsProfiler.enabled())
if (cx->runtime()->spsProfiler.enabled())
baselineScript->toggleSPS(true);
return Method_Compiled;
@ -297,7 +297,7 @@ BaselineCompiler::emitOutOfLinePostBarrierSlot()
#endif
masm.setupUnalignedABICall(2, scratch);
masm.movePtr(ImmWord(cx->runtime), scratch);
masm.movePtr(ImmWord(cx->runtime()), scratch);
masm.passABIArg(scratch);
masm.passABIArg(objReg);
masm.callWithABI(JS_FUNC_TO_DATA_PTR(void *, PostWriteBarrier));
@ -411,7 +411,7 @@ bool
BaselineCompiler::emitStackCheck()
{
Label skipCall;
uintptr_t *limitAddr = &cx->runtime->mainThread.ionStackLimit;
uintptr_t *limitAddr = &cx->runtime()->mainThread.ionStackLimit;
masm.loadPtr(AbsoluteAddress(limitAddr), R0.scratchReg());
masm.branchPtr(Assembler::AboveOrEqual, BaselineStackReg, R0.scratchReg(), &skipCall);
@ -430,7 +430,7 @@ bool
BaselineCompiler::emitInterruptCheck()
{
Label done;
void *interrupt = (void *)&cx->compartment->rt->interrupt;
void *interrupt = (void *)&cx->compartment()->rt->interrupt;
masm.branch32(Assembler::Equal, AbsoluteAddress(interrupt), Imm32(0), &done);
prepareVMCall();
@ -512,7 +512,7 @@ BaselineCompiler::emitDebugTrap()
bool enabled = script->stepModeEnabled() || script->hasBreakpointsAt(pc);
// Emit patchable call to debug trap handler.
IonCode *handler = cx->compartment->ionCompartment()->debugTrapHandler(cx);
IonCode *handler = cx->compartment()->ionCompartment()->debugTrapHandler(cx);
mozilla::DebugOnly<CodeOffsetLabel> offset = masm.toggledCall(handler, enabled);
#ifdef DEBUG
@ -555,7 +555,7 @@ BaselineCompiler::emitSPSPop()
Label noPop;
masm.branchTest32(Assembler::Zero, frame.addressOfFlags(),
Imm32(BaselineFrame::HAS_PUSHED_SPS_FRAME), &noPop);
masm.spsPopFrameSafe(&cx->runtime->spsProfiler, R1.scratchReg());
masm.spsPopFrameSafe(&cx->runtime()->spsProfiler, R1.scratchReg());
masm.bind(&noPop);
}
@ -1597,11 +1597,11 @@ BaselineCompiler::emit_JSOP_GETGNAME()
return true;
}
if (name == cx->names().NaN) {
frame.push(cx->runtime->NaNValue);
frame.push(cx->runtime()->NaNValue);
return true;
}
if (name == cx->names().Infinity) {
frame.push(cx->runtime->positiveInfinityValue);
frame.push(cx->runtime()->positiveInfinityValue);
return true;
}
@ -1814,7 +1814,7 @@ BaselineCompiler::emit_JSOP_SETALIASEDVAR()
// Scope coordinate object is already in R2.scratchReg().
frame.syncStack(0);
Nursery &nursery = cx->runtime->gcNursery;
Nursery &nursery = cx->runtime()->gcNursery;
Label skipBarrier;
Label isTenured;
masm.branchTestObject(Assembler::NotEqual, R0, &skipBarrier);

View File

@ -52,7 +52,7 @@ BaselineFrame::popBlock(JSContext *cx)
{
JS_ASSERT(hasBlockChain());
if (cx->compartment->debugMode())
if (cx->compartment()->debugMode())
DebugScopes::onPopBlock(cx, this);
if (blockChain_->needsClone()) {

View File

@ -145,7 +145,7 @@ BaselineFrame::initForOsr(StackFrame *fp, uint32_t numStackValues)
*valueSlot(i) = fp->slots()[i];
JSContext *cx = GetIonContext()->cx;
if (cx->compartment->debugMode()) {
if (cx->compartment()->debugMode()) {
// In debug mode, update any Debugger.Frame objects for the StackFrame to
// point to the BaselineFrame.

View File

@ -520,7 +520,7 @@ ICUpdatedStub::initUpdatingChain(JSContext *cx, ICStubSpace *space)
IonCode *
ICStubCompiler::getStubCode()
{
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
// Check for existing cached stubcode.
uint32_t stubKey = getKey();
@ -534,7 +534,7 @@ ICStubCompiler::getStubCode()
masm.setSecondScratchReg(BaselineSecondScratchReg);
#endif
AutoFlushCache afc("ICStubCompiler::getStubCode", cx->runtime->ionRuntime());
AutoFlushCache afc("ICStubCompiler::getStubCode", cx->runtime()->ionRuntime());
if (!generateStubCode(masm))
return NULL;
Linker linker(masm);
@ -562,7 +562,7 @@ ICStubCompiler::getStubCode()
bool
ICStubCompiler::tailCallVM(const VMFunction &fun, MacroAssembler &masm)
{
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(fun);
if (!code)
return false;
@ -575,7 +575,7 @@ ICStubCompiler::tailCallVM(const VMFunction &fun, MacroAssembler &masm)
bool
ICStubCompiler::callVM(const VMFunction &fun, MacroAssembler &masm)
{
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(fun);
if (!code)
return false;
@ -587,7 +587,7 @@ ICStubCompiler::callVM(const VMFunction &fun, MacroAssembler &masm)
bool
ICStubCompiler::callTypeUpdateIC(MacroAssembler &masm, uint32_t objectOffset)
{
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(DoTypeUpdateFallbackInfo);
if (!code)
return false;
@ -635,7 +635,7 @@ ICStubCompiler::guardProfilingEnabled(MacroAssembler &masm, Register scratch, La
skip);
// Check if profiling is enabled
uint32_t *enabledAddr = cx->runtime->spsProfiler.addressOfEnabled();
uint32_t *enabledAddr = cx->runtime()->spsProfiler.addressOfEnabled();
masm.branch32(Assembler::Equal, AbsoluteAddress(enabledAddr), Imm32(0), skip);
}
@ -644,7 +644,7 @@ inline bool
ICStubCompiler::emitPostWriteBarrierSlot(MacroAssembler &masm, Register obj, Register scratch,
GeneralRegisterSet saveRegs)
{
Nursery &nursery = cx->runtime->gcNursery;
Nursery &nursery = cx->runtime()->gcNursery;
Label skipBarrier;
Label isTenured;
@ -659,7 +659,7 @@ ICStubCompiler::emitPostWriteBarrierSlot(MacroAssembler &masm, Register obj, Reg
saveRegs = GeneralRegisterSet::Intersect(saveRegs, GeneralRegisterSet::Volatile());
masm.PushRegsInMask(saveRegs);
masm.setupUnalignedABICall(2, scratch);
masm.movePtr(ImmWord(cx->runtime), scratch);
masm.movePtr(ImmWord(cx->runtime()), scratch);
masm.passABIArg(scratch);
masm.passABIArg(obj);
masm.callWithABI(JS_FUNC_TO_DATA_PTR(void *, PostWriteBarrier));
@ -801,7 +801,7 @@ PrepareOsrTempData(JSContext *cx, ICUseCount_Fallback *stub, BaselineFrame *fram
size_t totalSpace = AlignBytes(stackFrameSpace, sizeof(Value)) +
AlignBytes(ionOsrTempDataSpace, sizeof(Value));
IonOsrTempData *info = (IonOsrTempData *)cx->runtime->getIonRuntime(cx)->allocateOsrTempData(totalSpace);
IonOsrTempData *info = (IonOsrTempData *)cx->runtime()->getIonRuntime(cx)->allocateOsrTempData(totalSpace);
if (!info)
return NULL;
@ -993,11 +993,11 @@ DoProfilerFallback(JSContext *cx, BaselineFrame *frame, ICProfiler_Fallback *stu
FallbackICSpew(cx, stub, "Profiler");
SPSProfiler *profiler = &cx->runtime->spsProfiler;
SPSProfiler *profiler = &cx->runtime()->spsProfiler;
// Manually enter SPS this time.
JS_ASSERT(profiler->enabled());
if (!cx->runtime->spsProfiler.enter(cx, script, func))
if (!cx->runtime()->spsProfiler.enter(cx, script, func))
return false;
frame->setPushedSPSFrame();
@ -1052,14 +1052,14 @@ ICProfiler_PushFunction::Compiler::generateStubCode(MacroAssembler &masm)
// Profiling should be enabled if we ever reach here.
#ifdef DEBUG
Label spsEnabled;
uint32_t *enabledAddr = cx->runtime->spsProfiler.addressOfEnabled();
uint32_t *enabledAddr = cx->runtime()->spsProfiler.addressOfEnabled();
masm.branch32(Assembler::NotEqual, AbsoluteAddress(enabledAddr), Imm32(0), &spsEnabled);
masm.breakpoint();
masm.bind(&spsEnabled);
#endif
// Push SPS entry.
masm.spsPushFrame(&cx->runtime->spsProfiler,
masm.spsPushFrame(&cx->runtime()->spsProfiler,
Address(BaselineStubReg, ICProfiler_PushFunction::offsetOfStr()),
Address(BaselineStubReg, ICProfiler_PushFunction::offsetOfScript()),
scratch,
@ -1722,7 +1722,7 @@ DoCompareFallback(JSContext *cx, BaselineFrame *frame, ICCompare_Fallback *stub,
return true;
}
if (!cx->runtime->jitSupportsFloatingPoint && (lhs.isNumber() || rhs.isNumber()))
if (!cx->runtime()->jitSupportsFloatingPoint && (lhs.isNumber() || rhs.isNumber()))
return true;
if (lhs.isNumber() && rhs.isNumber()) {
@ -2133,7 +2133,7 @@ DoToBoolFallback(JSContext *cx, BaselineFrame *frame, ICToBool_Fallback *stub, H
return true;
}
if (arg.isDouble() && cx->runtime->jitSupportsFloatingPoint) {
if (arg.isDouble() && cx->runtime()->jitSupportsFloatingPoint) {
IonSpew(IonSpew_BaselineIC, " Generating ToBool(Double) stub.");
ICToBool_Double::Compiler compiler(cx);
ICStub *doubleStub = compiler.getStub(compiler.getStubSpace(script));
@ -2519,7 +2519,7 @@ DoBinaryArithFallback(JSContext *cx, BaselineFrame *frame, ICBinaryArith_Fallbac
JS_ASSERT(ret.isNumber());
if (lhs.isDouble() || rhs.isDouble() || ret.isDouble()) {
if (!cx->runtime->jitSupportsFloatingPoint)
if (!cx->runtime()->jitSupportsFloatingPoint)
return true;
switch (op) {
@ -2981,7 +2981,7 @@ DoUnaryArithFallback(JSContext *cx, BaselineFrame *frame, ICUnaryArith_Fallback
if (val.isNumber() && res.isNumber() &&
op == JSOP_NEG &&
cx->runtime->jitSupportsFloatingPoint)
cx->runtime()->jitSupportsFloatingPoint)
{
IonSpew(IonSpew_BaselineIC, " Generating %s(Number => Number) stub", js_CodeName[op]);
// Unlink int32 stubs, the double stub handles both cases and TI specializes for both.
@ -3569,7 +3569,7 @@ TryAttachGetElemStub(JSContext *cx, HandleScript script, ICGetElem_Fallback *stu
if (obj->isTypedArray() && rhs.isInt32() && res.isNumber() &&
!TypedArrayGetElemStubExists(stub, obj))
{
if (!cx->runtime->jitSupportsFloatingPoint && TypedArrayRequiresFloatingPoint(obj))
if (!cx->runtime()->jitSupportsFloatingPoint && TypedArrayRequiresFloatingPoint(obj))
return true;
IonSpew(IonSpew_BaselineIC, " Generating GetElem(TypedArray[Int32]) stub");
@ -3773,7 +3773,7 @@ ICGetElem_String::Compiler::generateStubCode(MacroAssembler &masm)
&failure);
// Load static string.
masm.movePtr(ImmWord(&cx->compartment->rt->staticStrings.unitStaticTable), str);
masm.movePtr(ImmWord(&cx->compartment()->rt->staticStrings.unitStaticTable), str);
masm.loadPtr(BaseIndex(str, scratchReg, ScalePointer), str);
// Return.
@ -4235,7 +4235,7 @@ DoSetElemFallback(JSContext *cx, BaselineFrame *frame, ICSetElem_Fallback *stub,
}
if (obj->isTypedArray() && index.isInt32() && rhs.isNumber()) {
if (!cx->runtime->jitSupportsFloatingPoint && TypedArrayRequiresFloatingPoint(obj))
if (!cx->runtime()->jitSupportsFloatingPoint && TypedArrayRequiresFloatingPoint(obj))
return true;
uint32_t len = TypedArray::length(obj);
@ -4391,7 +4391,7 @@ ICSetElem_Dense::Compiler::generateStubCode(MacroAssembler &masm)
&dontConvertDoubles);
// Note that double arrays are only created by IonMonkey, so if we have no
// floating-point support Ion is disabled and there should be no double arrays.
if (cx->runtime->jitSupportsFloatingPoint)
if (cx->runtime()->jitSupportsFloatingPoint)
masm.convertInt32ValueToDouble(valueAddr, regs.getAny(), &dontConvertDoubles);
else
masm.breakpoint();
@ -4579,7 +4579,7 @@ ICSetElemDenseAddCompiler::generateStubCode(MacroAssembler &masm)
&dontConvertDoubles);
// Note that double arrays are only created by IonMonkey, so if we have no
// floating-point support Ion is disabled and there should be no double arrays.
if (cx->runtime->jitSupportsFloatingPoint)
if (cx->runtime()->jitSupportsFloatingPoint)
masm.convertInt32ValueToDouble(valueAddr, regs.getAny(), &dontConvertDoubles);
else
masm.breakpoint();
@ -4675,7 +4675,7 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
// If the value is a double, clamp to uint8 and jump back.
// Else, jump to failure.
masm.bind(&notInt32);
if (cx->runtime->jitSupportsFloatingPoint) {
if (cx->runtime()->jitSupportsFloatingPoint) {
masm.branchTestDouble(Assembler::NotEqual, value, &failure);
masm.unboxDouble(value, FloatReg0);
masm.clampDoubleToUint8(FloatReg0, secondScratch);
@ -4697,7 +4697,7 @@ ICSetElem_TypedArray::Compiler::generateStubCode(MacroAssembler &masm)
// Else, jump to failure.
Label failureRestoreRegs;
masm.bind(&notInt32);
if (cx->runtime->jitSupportsFloatingPoint) {
if (cx->runtime()->jitSupportsFloatingPoint) {
masm.branchTestDouble(Assembler::NotEqual, value, &failure);
masm.unboxDouble(value, FloatReg0);
masm.branchTruncateDouble(FloatReg0, secondScratch, &failureRestoreRegs);
@ -5715,7 +5715,7 @@ ICGetProp_CallScripted::Compiler::generateStubCode(MacroAssembler &masm)
JS_ASSERT(ArgumentsRectifierReg != code);
IonCode *argumentsRectifier =
cx->compartment->ionCompartment()->getArgumentsRectifier(SequentialExecution);
cx->compartment()->ionCompartment()->getArgumentsRectifier(SequentialExecution);
masm.movePtr(ImmGCPtr(argumentsRectifier), code);
masm.loadPtr(Address(code, IonCode::offsetOfCode()), code);
@ -5741,7 +5741,7 @@ ICGetProp_CallScripted::Compiler::generateStubCode(MacroAssembler &masm)
// Update profiling entry before leaving function.
masm.load32(Address(BaselineStubReg, ICGetProp_CallScripted::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
}
@ -5829,7 +5829,7 @@ ICGetProp_CallNative::Compiler::generateStubCode(MacroAssembler &masm)
// Update profiling entry before leaving function.
masm.load32(Address(BaselineStubReg, ICGetProp_CallNative::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
regs.add(scratch);
@ -5917,7 +5917,7 @@ ICGetPropCallDOMProxyNativeCompiler::generateStubCode(MacroAssembler &masm,
// Update profiling entry before leaving function.
masm.load32(Address(BaselineStubReg, ICGetProp_CallDOMProxyNative::offsetOfPCOffset()),
pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
regs.add(scratch);
@ -6064,7 +6064,7 @@ ICGetProp_DOMProxyShadowed::Compiler::generateStubCode(MacroAssembler &masm)
// Update profiling entry before leaving function.
masm.load32(Address(BaselineStubReg, ICGetProp_DOMProxyShadowed::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
regs.add(scratch);
@ -6615,7 +6615,7 @@ ICSetProp_CallScripted::Compiler::generateStubCode(MacroAssembler &masm)
JS_ASSERT(ArgumentsRectifierReg != code);
IonCode *argumentsRectifier =
cx->compartment->ionCompartment()->getArgumentsRectifier(SequentialExecution);
cx->compartment()->ionCompartment()->getArgumentsRectifier(SequentialExecution);
masm.movePtr(ImmGCPtr(argumentsRectifier), code);
masm.loadPtr(Address(code, IonCode::offsetOfCode()), code);
@ -6641,7 +6641,7 @@ ICSetProp_CallScripted::Compiler::generateStubCode(MacroAssembler &masm)
// Update profiling entry before leaving function.
masm.load32(Address(BaselineStubReg, ICSetProp_CallScripted::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
}
@ -6739,7 +6739,7 @@ ICSetProp_CallNative::Compiler::generateStubCode(MacroAssembler &masm)
// Update profiling entry before leaving function.
masm.load32(Address(BaselineStubReg, ICSetProp_CallNative::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
regs.add(scratch);
@ -6974,8 +6974,8 @@ DoCallFallback(JSContext *cx, BaselineFrame *frame, ICCall_Fallback *stub, uint3
return false;
// Maybe update PC in profiler entry before leaving this script by call.
if (cx->runtime->spsProfiler.enabled() && frame->hasPushedSPSFrame())
cx->runtime->spsProfiler.updatePC(script, pc);
if (cx->runtime()->spsProfiler.enabled() && frame->hasPushedSPSFrame())
cx->runtime()->spsProfiler.updatePC(script, pc);
if (!MaybeCloneFunctionAtCallsite(cx, &callee, script, pc))
return false;
@ -7205,7 +7205,7 @@ ICCall_Fallback::Compiler::postGenerateStubCode(MacroAssembler &masm, Handle<Ion
{
CodeOffsetLabel offset(returnOffset_);
offset.fixup(&masm);
cx->compartment->ionCompartment()->initBaselineCallReturnAddr(code->raw() + offset.offset());
cx->compartment()->ionCompartment()->initBaselineCallReturnAddr(code->raw() + offset.offset());
return true;
}
@ -7371,7 +7371,7 @@ ICCallScriptedCompiler::generateStubCode(MacroAssembler &masm)
JS_ASSERT(ArgumentsRectifierReg != argcReg);
IonCode *argumentsRectifier =
cx->compartment->ionCompartment()->getArgumentsRectifier(SequentialExecution);
cx->compartment()->ionCompartment()->getArgumentsRectifier(SequentialExecution);
masm.movePtr(ImmGCPtr(argumentsRectifier), code);
masm.loadPtr(Address(code, IonCode::offsetOfCode()), code);
@ -7400,7 +7400,7 @@ ICCallScriptedCompiler::generateStubCode(MacroAssembler &masm)
masm.load32(Address(BaselineStubReg, ICCall_Scripted::offsetOfPCOffset()), pcIdx);
else
masm.load32(Address(BaselineStubReg, ICCall_AnyScripted::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
}
@ -7523,7 +7523,7 @@ ICCall_Native::Compiler::generateStubCode(MacroAssembler &masm)
guardProfilingEnabled(masm, scratch, &skipProfilerUpdate);
masm.load32(Address(BaselineStubReg, ICCall_Native::offsetOfPCOffset()), pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
}
@ -7630,7 +7630,7 @@ ICCall_ScriptedApplyArguments::Compiler::generateStubCode(MacroAssembler &masm)
JS_ASSERT(ArgumentsRectifierReg != argcReg);
IonCode *argumentsRectifier =
cx->compartment->ionCompartment()->getArgumentsRectifier(SequentialExecution);
cx->compartment()->ionCompartment()->getArgumentsRectifier(SequentialExecution);
masm.movePtr(ImmGCPtr(argumentsRectifier), target);
masm.loadPtr(Address(target, IonCode::offsetOfCode()), target);
@ -7650,7 +7650,7 @@ ICCall_ScriptedApplyArguments::Compiler::generateStubCode(MacroAssembler &masm)
masm.load32(Address(BaselineStubReg, ICCall_ScriptedApplyArguments::offsetOfPCOffset()),
pcIdx);
masm.spsUpdatePCIdx(&cx->runtime->spsProfiler, pcIdx, scratch);
masm.spsUpdatePCIdx(&cx->runtime()->spsProfiler, pcIdx, scratch);
masm.bind(&skipProfilerUpdate);
}
@ -7704,7 +7704,7 @@ ICTableSwitch::Compiler::generateStubCode(MacroAssembler &masm)
masm.bind(&notInt32);
masm.branchTestDouble(Assembler::NotEqual, R0, &outOfRange);
if (cx->runtime->jitSupportsFloatingPoint) {
if (cx->runtime()->jitSupportsFloatingPoint) {
masm.unboxDouble(R0, FloatReg0);
// N.B. -0 === 0, so convert -0 to a 0 int32.

View File

@ -73,7 +73,7 @@ CheckFrame(StackFrame *fp)
static bool
IsJSDEnabled(JSContext *cx)
{
return cx->compartment->debugMode() && cx->runtime->debugHooks.callHook;
return cx->compartment()->debugMode() && cx->runtime()->debugHooks.callHook;
}
static IonExecStatus
@ -83,7 +83,7 @@ EnterBaseline(JSContext *cx, StackFrame *fp, void *jitcode, bool osr)
JS_ASSERT(ion::IsBaselineEnabled(cx));
JS_ASSERT(CheckFrame(fp));
EnterIonCode enter = cx->compartment->ionCompartment()->enterBaselineJIT();
EnterIonCode enter = cx->compartment()->ionCompartment()->enterBaselineJIT();
// maxArgc is the maximum of arguments between the number of actual
// arguments and the number of formal arguments. It accounts for |this|.
@ -128,14 +128,14 @@ EnterBaseline(JSContext *cx, StackFrame *fp, void *jitcode, bool osr)
uint32_t numStackValues = osr ? fp->script()->nfixed + cx->regs().stackDepth() : 0;
JS_ASSERT_IF(osr, !IsJSDEnabled(cx));
AutoFlushInhibitor afi(cx->compartment->ionCompartment());
AutoFlushInhibitor afi(cx->compartment()->ionCompartment());
// Single transition point from Interpreter to Baseline.
enter(jitcode, maxArgc, maxArgv, osr ? fp : NULL, calleeToken, scopeChain, numStackValues,
result.address());
}
JS_ASSERT(fp == cx->fp());
JS_ASSERT(!cx->runtime->hasIonReturnOverride());
JS_ASSERT(!cx->runtime()->hasIonReturnOverride());
// The trampoline wrote the return value but did not set the HAS_RVAL flag.
fp->setReturnValue(result);
@ -145,7 +145,7 @@ EnterBaseline(JSContext *cx, StackFrame *fp, void *jitcode, bool osr)
fp->setReturnValue(ObjectValue(fp->constructorThis()));
// Release temporary buffer used for OSR into Ion.
cx->runtime->getIonRuntime(cx)->freeOsrTempData();
cx->runtime()->getIonRuntime(cx)->freeOsrTempData();
JS_ASSERT_IF(result.isMagic(), result.isMagic(JS_ION_ERROR));
return result.isMagic() ? IonExec_Error : IonExec_Ok;
@ -170,7 +170,7 @@ ion::EnterBaselineAtBranch(JSContext *cx, StackFrame *fp, jsbytecode *pc)
// Skip debug breakpoint/trap handler, the interpreter already handled it
// for the current op.
if (cx->compartment->debugMode())
if (cx->compartment()->debugMode())
jitcode += MacroAssembler::ToggledCallSize();
return EnterBaseline(cx, fp, jitcode, /* osr = */true);
@ -194,7 +194,7 @@ BaselineCompile(JSContext *cx, HandleScript script)
if (!compiler.init())
return Method_Error;
AutoFlushCache afc("BaselineJIT", cx->runtime->ionRuntime());
AutoFlushCache afc("BaselineJIT", cx->runtime()->ionRuntime());
MethodStatus status = compiler.compile();
JS_ASSERT_IF(status == Method_Compiled, script->hasBaselineScript());
@ -233,7 +233,7 @@ ion::CanEnterBaselineJIT(JSContext *cx, JSScript *scriptArg, StackFrame *fp, boo
if (!CheckFrame(fp))
return Method_CantCompile;
if (!cx->compartment->ensureIonCompartmentExists(cx))
if (!cx->compartment()->ensureIonCompartmentExists(cx))
return Method_Error;
if (script->hasBaselineScript())

View File

@ -2355,7 +2355,7 @@ CodeGenerator::maybeCreateScriptCounts()
CompileInfo *outerInfo = &gen->info();
JSScript *script = outerInfo->script();
if (cx->runtime->profilingScripts) {
if (cx->runtime()->profilingScripts) {
if (script && !script->hasScriptCounts && !script->initScriptCounts(cx))
return NULL;
} else if (!script) {
@ -5234,7 +5234,7 @@ CodeGenerator::link()
// Check to make sure we didn't have a mid-build invalidation. If so, we
// will trickle to ion::Compile() and return Method_Skipped.
if (cx->compartment->types.compiledInfo.compilerOutput(cx)->isInvalidated())
if (cx->compartment()->types.compiledInfo.compilerOutput(cx)->isInvalidated())
return true;
// List of possible scripts that this graph may call. Currently this is

View File

@ -109,9 +109,9 @@ ion::MaybeGetIonContext()
}
IonContext::IonContext(JSContext *cx, TempAllocator *temp)
: runtime(cx->runtime),
: runtime(cx->runtime()),
cx(cx),
compartment(cx->compartment),
compartment(cx->compartment()),
temp(temp),
prev_(CurrentIonContext()),
assemblerCount_(0)
@ -192,18 +192,18 @@ IonRuntime::initialize(JSContext *cx)
IonContext ictx(cx, NULL);
AutoFlushCache afc("IonRuntime::initialize");
execAlloc_ = cx->runtime->getExecAlloc(cx);
execAlloc_ = cx->runtime()->getExecAlloc(cx);
if (!execAlloc_)
return false;
if (!cx->compartment->ensureIonCompartmentExists(cx))
if (!cx->compartment()->ensureIonCompartmentExists(cx))
return false;
functionWrappers_ = cx->new_<VMWrapperMap>(cx);
if (!functionWrappers_ || !functionWrappers_->init())
return false;
if (cx->runtime->jitSupportsFloatingPoint) {
if (cx->runtime()->jitSupportsFloatingPoint) {
// Initialize some Ion-only stubs that require floating-point support.
if (!bailoutTables_.reserve(FrameSizeClass::ClassLimit().classId()))
return false;
@ -410,7 +410,7 @@ IonCompartment::getVMWrapper(const VMFunction &f)
IonActivation::IonActivation(JSContext *cx, StackFrame *fp)
: cx_(cx),
compartment_(cx->compartment),
compartment_(cx->compartment()),
prev_(cx->mainThread().ionActivation),
entryfp_(fp),
prevIonTop_(cx->mainThread().ionTop),
@ -685,7 +685,7 @@ IonScript::New(JSContext *cx, uint32_t frameSlots, uint32_t frameSize, size_t sn
script->frameSlots_ = frameSlots;
script->frameSize_ = frameSize;
script->recompileInfo_ = cx->compartment->types.compiledInfo;
script->recompileInfo_ = cx->compartment()->types.compiledInfo;
return script;
}
@ -1257,11 +1257,11 @@ void
AttachFinishedCompilations(JSContext *cx)
{
#ifdef JS_THREADSAFE
IonCompartment *ion = cx->compartment->ionCompartment();
if (!ion || !cx->runtime->workerThreadState)
IonCompartment *ion = cx->compartment()->ionCompartment();
if (!ion || !cx->runtime()->workerThreadState)
return;
AutoLockWorkerThreadState lock(cx->runtime);
AutoLockWorkerThreadState lock(cx->runtime());
OffThreadCompilationVector &compilations = ion->finishedOffThreadCompilations();
@ -1290,7 +1290,7 @@ AttachFinishedCompilations(JSContext *cx)
{
// Release the worker thread lock and root the compiler for GC.
AutoTempAllocatorRooter root(cx, &builder->temp());
AutoUnlockWorkerThreadState unlock(cx->runtime);
AutoUnlockWorkerThreadState unlock(cx->runtime());
AutoFlushCache afc("AttachFinishedCompilations");
success = codegen->link();
}
@ -1326,9 +1326,9 @@ OffThreadCompilationAvailable(JSContext *cx)
// stores strings in the spsProfiler data structure, which is not protected
// by a lock.
return OffThreadCompilationEnabled(cx)
&& cx->runtime->gcIncrementalState == gc::NO_INCREMENTAL
&& !cx->runtime->profilingScripts
&& !cx->runtime->spsProfiler.enabled();
&& cx->runtime()->gcIncrementalState == gc::NO_INCREMENTAL
&& !cx->runtime()->profilingScripts
&& !cx->runtime()->spsProfiler.enabled();
}
static AbortReason
@ -1360,10 +1360,10 @@ IonCompile(JSContext *cx, JSScript *script,
types::AutoEnterAnalysis enter(cx);
if (!cx->compartment->ensureIonCompartmentExists(cx))
if (!cx->compartment()->ensureIonCompartmentExists(cx))
return AbortReason_Alloc;
if (!cx->compartment->ionCompartment()->ensureIonStubsExist(cx))
if (!cx->compartment()->ionCompartment()->ensureIonStubsExist(cx))
return AbortReason_Alloc;
MIRGraph *graph = alloc->new_<MIRGraph>(temp);
@ -1508,7 +1508,7 @@ CheckScriptSize(JSContext *cx, JSScript* script)
// in these cases (except when profiling scripts, as compilations
// occurring with profiling should reflect those without), but do
// not forbid compilation so that the script may be compiled later.
if (!OffThreadCompilationAvailable(cx) && !cx->runtime->profilingScripts) {
if (!OffThreadCompilationAvailable(cx) && !cx->runtime()->profilingScripts) {
IonSpew(IonSpew_Abort, "Script too large for main thread, skipping (%u bytes)", script->length);
return Method_Skipped;
}
@ -1547,7 +1547,7 @@ Compile(JSContext *cx, HandleScript script, AbstractFramePtr fp, jsbytecode *osr
if (executionMode == SequentialExecution && !script->hasBaselineScript())
return Method_Skipped;
if (cx->compartment->debugMode()) {
if (cx->compartment()->debugMode()) {
IonSpew(IonSpew_Abort, "debugging");
return Method_CantCompile;
}
@ -1754,7 +1754,7 @@ ion::CanEnterInParallel(JSContext *cx, HandleScript script)
// This can GC, so afterward, script->parallelIon is
// not guaranteed to be valid.
if (!cx->compartment->ionCompartment()->enterJIT())
if (!cx->compartment()->ionCompartment()->enterJIT())
return Method_Error;
// Subtle: it is possible for GC to occur during
@ -1787,11 +1787,11 @@ ion::CanEnterUsingFastInvoke(JSContext *cx, HandleScript script, uint32_t numAct
if (numActualArgs < script->function()->nargs)
return Method_Skipped;
if (!cx->compartment->ensureIonCompartmentExists(cx))
if (!cx->compartment()->ensureIonCompartmentExists(cx))
return Method_Error;
// This can GC, so afterward, script->ion is not guaranteed to be valid.
if (!cx->compartment->ionCompartment()->enterJIT())
if (!cx->compartment()->ionCompartment()->enterJIT())
return Method_Error;
if (!script->hasIonScript())
@ -1808,7 +1808,7 @@ EnterIon(JSContext *cx, StackFrame *fp, void *jitcode)
JS_ASSERT(CheckFrame(fp));
JS_ASSERT(!fp->script()->ionScript()->bailoutExpected());
EnterIonCode enter = cx->compartment->ionCompartment()->enterJIT();
EnterIonCode enter = cx->compartment()->ionCompartment()->enterJIT();
// maxArgc is the maximum of arguments between the number of actual
// arguments and the number of formal arguments. It accounts for |this|.
@ -1838,14 +1838,14 @@ EnterIon(JSContext *cx, StackFrame *fp, void *jitcode)
IonContext ictx(cx, NULL);
IonActivation activation(cx, fp);
JSAutoResolveFlags rf(cx, RESOLVE_INFER);
AutoFlushInhibitor afi(cx->compartment->ionCompartment());
AutoFlushInhibitor afi(cx->compartment()->ionCompartment());
// Single transition point from Interpreter to Ion.
enter(jitcode, maxArgc, maxArgv, fp, calleeToken, /* scopeChain = */ NULL, 0,
result.address());
}
JS_ASSERT(fp == cx->fp());
JS_ASSERT(!cx->runtime->hasIonReturnOverride());
JS_ASSERT(!cx->runtime()->hasIonReturnOverride());
// The trampoline wrote the return value but did not set the HAS_RVAL flag.
fp->setReturnValue(result);
@ -1925,7 +1925,7 @@ ion::FastInvoke(JSContext *cx, HandleFunction fun, CallArgs &args)
activation.setPrevPc(cx->regs().pc);
EnterIonCode enter = cx->compartment->ionCompartment()->enterJIT();
EnterIonCode enter = cx->compartment()->ionCompartment()->enterJIT();
void *calleeToken = CalleeToToken(fun);
RootedValue result(cx, Int32Value(args.length()));
@ -1939,7 +1939,7 @@ ion::FastInvoke(JSContext *cx, HandleFunction fun, CallArgs &args)
fp->clearCallingIntoIon();
JS_ASSERT(fp == cx->fp());
JS_ASSERT(!cx->runtime->hasIonReturnOverride());
JS_ASSERT(!cx->runtime()->hasIonReturnOverride());
args.rval().set(result);
@ -2178,7 +2178,7 @@ ion::Invalidate(types::TypeCompartment &types, FreeOp *fop,
void
ion::Invalidate(JSContext *cx, const Vector<types::RecompileInfo> &invalid, bool resetUses)
{
ion::Invalidate(cx->compartment->types, cx->runtime->defaultFreeOp(), invalid, resetUses);
ion::Invalidate(cx->compartment()->types, cx->runtime()->defaultFreeOp(), invalid, resetUses);
}
bool
@ -2265,7 +2265,7 @@ ion::ForbidCompilation(JSContext *cx, JSScript *script, ExecutionMode mode)
IonSpew(IonSpew_Abort, "Disabling Ion mode %d compilation of script %s:%d",
mode, script->filename(), script->lineno);
CancelOffThreadIonCompile(cx->compartment, script);
CancelOffThreadIonCompile(cx->compartment(), script);
switch (mode) {
case SequentialExecution:

View File

@ -36,9 +36,9 @@ using mozilla::DebugOnly;
IonBuilder::IonBuilder(JSContext *cx, TempAllocator *temp, MIRGraph *graph,
BaselineInspector *inspector, CompileInfo *info, AbstractFramePtr fp,
size_t inliningDepth, uint32_t loopDepth)
: MIRGenerator(cx->compartment, temp, graph, info),
: MIRGenerator(cx->compartment(), temp, graph, info),
backgroundCodegen_(NULL),
recompileInfo(cx->compartment->types.compiledInfo),
recompileInfo(cx->compartment()->types.compiledInfo),
cx(cx),
fp(fp),
abortReason_(AbortReason_Disable),
@ -4742,7 +4742,7 @@ TestShouldDOMCall(JSContext *cx, types::TypeSet *inTypes, HandleFunction func,
// property, we can bake in a call to the bottom half of the DOM
// accessor
DOMInstanceClassMatchesProto instanceChecker =
GetDOMCallbacks(cx->runtime)->instanceClassMatchesProto;
GetDOMCallbacks(cx->runtime())->instanceClassMatchesProto;
const JSJitInfo *jinfo = func->jitInfo();
if (jinfo->type != opType)
@ -5933,9 +5933,9 @@ IonBuilder::getStaticName(HandleObject staticObject, HandlePropertyName name, bo
if (name == cx->names().undefined)
return pushConstant(UndefinedValue());
if (name == cx->names().NaN)
return pushConstant(cx->runtime->NaNValue);
return pushConstant(cx->runtime()->NaNValue);
if (name == cx->names().Infinity)
return pushConstant(cx->runtime->positiveInfinityValue);
return pushConstant(cx->runtime()->positiveInfinityValue);
}
RootedId id(cx, NameToId(name));

View File

@ -364,7 +364,7 @@ HandleException(JSContext *cx, const IonFrameIterator &frame, ResumeFromExceptio
jsbytecode *pc;
frame.baselineScriptAndPc(script.address(), &pc);
if (cx->isExceptionPending() && cx->compartment->debugMode()) {
if (cx->isExceptionPending() && cx->compartment()->debugMode()) {
BaselineFrame *baselineFrame = frame.baselineFrame();
JSTrapStatus status = DebugExceptionUnwind(cx, baselineFrame, pc);
switch (status) {
@ -462,8 +462,8 @@ HandleException(ResumeFromException *rfe)
// This may happen if a callVM function causes an invalidation (setting the
// override), and then fails, bypassing the bailout handlers that would
// otherwise clear the return override.
if (cx->runtime->hasIonReturnOverride())
cx->runtime->takeIonReturnOverride();
if (cx->runtime()->hasIonReturnOverride())
cx->runtime()->takeIonReturnOverride();
IonFrameIterator iter(cx->mainThread().ionTop);
while (!iter.isEntry()) {
@ -486,7 +486,7 @@ HandleException(ResumeFromException *rfe)
IonScript *ionScript = NULL;
if (iter.checkInvalidation(&ionScript))
ionScript->decref(cx->runtime->defaultFreeOp());
ionScript->decref(cx->runtime()->defaultFreeOp());
} else if (iter.isBaselineJS()) {
// It's invalid to call DebugEpilogue twice for the same frame.
@ -504,7 +504,7 @@ HandleException(ResumeFromException *rfe)
// it doesn't try to pop the SPS frame again.
iter.baselineFrame()->unsetPushedSPSFrame();
if (cx->compartment->debugMode() && !calledDebugEpilogue) {
if (cx->compartment()->debugMode() && !calledDebugEpilogue) {
// If DebugEpilogue returns |true|, we have to perform a forced
// return, e.g. return frame->returnValue() to the caller.
BaselineFrame *frame = iter.baselineFrame();
@ -1023,7 +1023,7 @@ GetPcScript(JSContext *cx, JSScript **scriptRes, jsbytecode **pcRes)
JS_ASSERT(cx->fp()->beginsIonActivation());
IonSpew(IonSpew_Snapshots, "Recover PC & Script from the last frame.");
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
// Recover the return address.
IonFrameIterator it(rt->mainThread.ionTop);

View File

@ -69,7 +69,7 @@ class Linker
}
IonCode *newCode(JSContext *cx, JSC::CodeKind kind) {
return newCode(cx, cx->compartment->ionCompartment(), kind);
return newCode(cx, cx->compartment()->ionCompartment(), kind);
}
};

View File

@ -147,7 +147,7 @@ IonBuilder::inlineMathFunction(CallInfo &callInfo, MMathFunction::Function funct
callInfo.unwrapArgs();
MathCache *cache = cx->runtime->getMathCache(cx);
MathCache *cache = cx->runtime()->getMathCache(cx);
if (!cache)
return InliningStatus_Error;
@ -811,7 +811,7 @@ IonBuilder::inlineStringObject(CallInfo &callInfo)
callInfo.unwrapArgs();
RootedString emptyString(cx, cx->runtime->emptyString);
RootedString emptyString(cx, cx->runtime()->emptyString);
RootedObject templateObj(cx, StringObject::create(cx, emptyString, TenuredObject));
if (!templateObj)
return InliningStatus_Error;

View File

@ -101,7 +101,7 @@ CheckOverRecursed(JSContext *cx)
// CheckOverRecursed.
JS_CHECK_RECURSION(cx, return false);
if (cx->runtime->interrupt)
if (cx->runtime()->interrupt)
return InterruptCheck(cx);
return true;
@ -380,7 +380,7 @@ StringFromCharCode(JSContext *cx, int32_t code)
jschar c = jschar(code);
if (StaticStrings::hasUnit(c))
return cx->runtime->staticStrings.getUnit(c);
return cx->runtime()->staticStrings.getUnit(c);
return js_NewStringCopyN<CanGC>(cx, &c, 1);
}
@ -448,13 +448,13 @@ NewStringObject(JSContext *cx, HandleString str)
bool
SPSEnter(JSContext *cx, HandleScript script)
{
return cx->runtime->spsProfiler.enter(cx, script, script->function());
return cx->runtime()->spsProfiler.enter(cx, script, script->function());
}
bool
SPSExit(JSContext *cx, HandleScript script)
{
cx->runtime->spsProfiler.exit(cx, script, script->function());
cx->runtime()->spsProfiler.exit(cx, script, script->function());
return true;
}
@ -645,7 +645,7 @@ DebugEpilogue(JSContext *cx, BaselineFrame *frame, JSBool ok)
// If the frame has a pushed SPS frame, make sure to pop it.
if (frame->hasPushedSPSFrame()) {
cx->runtime->spsProfiler.exit(cx, frame->script(), frame->maybeFun());
cx->runtime()->spsProfiler.exit(cx, frame->script(), frame->maybeFun());
// Unset the pushedSPSFrame flag because DebugEpilogue may get called before
// Probes::exitScript in baseline during exception handling, and we don't
// want to double-pop SPS frames.
@ -731,16 +731,16 @@ HandleDebugTrap(JSContext *cx, BaselineFrame *frame, uint8_t *retAddr, JSBool *m
RootedScript script(cx, frame->script());
jsbytecode *pc = script->baselineScript()->icEntryFromReturnAddress(retAddr).pc(script);
JS_ASSERT(cx->compartment->debugMode());
JS_ASSERT(cx->compartment()->debugMode());
JS_ASSERT(script->stepModeEnabled() || script->hasBreakpointsAt(pc));
RootedValue rval(cx);
JSTrapStatus status = JSTRAP_CONTINUE;
JSInterruptHook hook = cx->runtime->debugHooks.interruptHook;
JSInterruptHook hook = cx->runtime()->debugHooks.interruptHook;
if (hook || script->stepModeEnabled()) {
if (hook)
status = hook(cx, script, pc, rval.address(), cx->runtime->debugHooks.interruptHookData);
status = hook(cx, script, pc, rval.address(), cx->runtime()->debugHooks.interruptHookData);
if (status == JSTRAP_CONTINUE && script->stepModeEnabled())
status = Debugger::onSingleStep(cx, &rval);
}
@ -780,8 +780,8 @@ OnDebuggerStatement(JSContext *cx, BaselineFrame *frame, jsbytecode *pc, JSBool
JSTrapStatus status = JSTRAP_CONTINUE;
RootedValue rval(cx);
if (JSDebuggerHandler handler = cx->runtime->debugHooks.debuggerHandler)
status = handler(cx, script, pc, rval.address(), cx->runtime->debugHooks.debuggerHandlerData);
if (JSDebuggerHandler handler = cx->runtime()->debugHooks.debuggerHandler)
status = handler(cx, script, pc, rval.address(), cx->runtime()->debugHooks.debuggerHandlerData);
if (status == JSTRAP_CONTINUE)
status = Debugger::onDebuggerStatement(cx, &rval);

View File

@ -521,7 +521,7 @@ class AutoDetectInvalidation
~AutoDetectInvalidation() {
if (!disabled_ && ionScript_->invalidated())
cx_->runtime->setIonReturnOverride(*rval_);
cx_->runtime()->setIonReturnOverride(*rval_);
}
};

View File

@ -87,7 +87,7 @@ IonRuntime::generateEnterJIT(JSContext *cx, EnterJitType type)
JS_ASSERT(OsrFrameReg == reg_frame);
MacroAssembler masm(cx);
AutoFlushCache afc("GenerateEnterJIT", cx->runtime->ionRuntime());
AutoFlushCache afc("GenerateEnterJIT", cx->runtime()->ionRuntime());
Assembler *aasm = &masm;
// Save non-volatile registers. These must be saved by the trampoline,
@ -745,7 +745,7 @@ IonRuntime::generatePreBarrier(JSContext *cx, MIRType type)
MacroAssembler masm(cx);
RegisterSet save;
if (cx->runtime->jitSupportsFloatingPoint) {
if (cx->runtime()->jitSupportsFloatingPoint) {
save = RegisterSet(GeneralRegisterSet(Registers::VolatileMask),
FloatRegisterSet(FloatRegisters::VolatileMask));
} else {
@ -755,7 +755,7 @@ IonRuntime::generatePreBarrier(JSContext *cx, MIRType type)
masm.PushRegsInMask(save);
JS_ASSERT(PreBarrierReg == r1);
masm.movePtr(ImmWord(cx->runtime), r0);
masm.movePtr(ImmWord(cx->runtime()), r0);
masm.setupUnalignedABICall(2, r2);
masm.passABIArg(r0);
@ -795,7 +795,7 @@ IonRuntime::generateDebugTrapHandler(JSContext *cx)
masm.movePtr(ImmWord((void *)NULL), BaselineStubReg);
EmitEnterStubFrame(masm, scratch2);
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(HandleDebugTrapInfo);
if (!code)
return NULL;

View File

@ -17,7 +17,7 @@ BaselineCompilerShared::BaselineCompilerShared(JSContext *cx, HandleScript scrip
pc(script->code),
ionCompileable_(ion::IsEnabled(cx) && CanIonCompileScript(cx, script, false)),
ionOSRCompileable_(ion::IsEnabled(cx) && CanIonCompileScript(cx, script, true)),
debugMode_(cx->compartment->debugMode()),
debugMode_(cx->compartment()->debugMode()),
analysis_(script),
frame(cx, script, masm),
stubSpace_(),
@ -32,7 +32,7 @@ BaselineCompilerShared::BaselineCompilerShared(JSContext *cx, HandleScript scrip
bool
BaselineCompilerShared::callVM(const VMFunction &fun)
{
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(fun);
if (!code)
return false;

View File

@ -647,7 +647,7 @@ IonRuntime::generatePreBarrier(JSContext *cx, MIRType type)
masm.PushRegsInMask(regs);
JS_ASSERT(PreBarrierReg == rdx);
masm.mov(ImmWord(cx->runtime), rcx);
masm.mov(ImmWord(cx->runtime()), rcx);
masm.setupUnalignedABICall(2, rax);
masm.passABIArg(rcx);
@ -691,7 +691,7 @@ IonRuntime::generateDebugTrapHandler(JSContext *cx)
masm.movePtr(ImmWord((void *)NULL), BaselineStubReg);
EmitEnterStubFrame(masm, scratch3);
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(HandleDebugTrapInfo);
if (!code)
return NULL;

View File

@ -665,7 +665,7 @@ IonRuntime::generatePreBarrier(JSContext *cx, MIRType type)
MacroAssembler masm;
RegisterSet save;
if (cx->runtime->jitSupportsFloatingPoint) {
if (cx->runtime()->jitSupportsFloatingPoint) {
save = RegisterSet(GeneralRegisterSet(Registers::VolatileMask),
FloatRegisterSet(FloatRegisters::VolatileMask));
} else {
@ -675,7 +675,7 @@ IonRuntime::generatePreBarrier(JSContext *cx, MIRType type)
masm.PushRegsInMask(save);
JS_ASSERT(PreBarrierReg == edx);
masm.movl(ImmWord(cx->runtime), ecx);
masm.movl(ImmWord(cx->runtime()), ecx);
masm.setupUnalignedABICall(2, eax);
masm.passABIArg(ecx);
@ -720,7 +720,7 @@ IonRuntime::generateDebugTrapHandler(JSContext *cx)
masm.movePtr(ImmWord((void *)NULL), BaselineStubReg);
EmitEnterStubFrame(masm, scratch3);
IonCompartment *ion = cx->compartment->ionCompartment();
IonCompartment *ion = cx->compartment()->ionCompartment();
IonCode *code = ion->getVMWrapper(HandleDebugTrapInfo);
if (!code)
return NULL;

View File

@ -13,7 +13,7 @@ using namespace js;
void *
TempAllocPolicy::onOutOfMemory(void *p, size_t nbytes)
{
return cx_->runtime->onOutOfMemory(p, nbytes, cx_);
return cx_->runtime()->onOutOfMemory(p, nbytes, cx_);
}
void

View File

@ -100,7 +100,7 @@ ScriptAnalysis::addJump(JSContext *cx, unsigned offset,
void
ScriptAnalysis::analyzeBytecode(JSContext *cx)
{
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
JS_ASSERT(!ranBytecode());
LifoAlloc &alloc = cx->analysisLifoAlloc();
@ -146,13 +146,13 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
* If the script is in debug mode, JS_SetFrameReturnValue can be called at
* any safe point.
*/
if (cx->compartment->debugMode())
if (cx->compartment()->debugMode())
usesReturnValue_ = true;
bool heavyweight = script_->function() && script_->function()->isHeavyweight();
isIonInlineable = true;
if (heavyweight || cx->compartment->debugMode())
if (heavyweight || cx->compartment()->debugMode())
isIonInlineable = false;
modifiesArguments_ = false;
@ -589,7 +589,7 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
void
ScriptAnalysis::analyzeLifetimes(JSContext *cx)
{
JS_ASSERT(cx->compartment->activeAnalysis && !ranLifetimes() && !failed());
JS_ASSERT(cx->compartment()->activeAnalysis && !ranLifetimes() && !failed());
if (!ranBytecode()) {
analyzeBytecode(cx);
@ -1078,7 +1078,7 @@ ScriptAnalysis::ensureVariable(LifetimeVariable &var, unsigned until)
void
ScriptAnalysis::analyzeSSA(JSContext *cx)
{
JS_ASSERT(cx->compartment->activeAnalysis && !ranSSA() && !failed());
JS_ASSERT(cx->compartment()->activeAnalysis && !ranSSA() && !failed());
if (!ranLifetimes()) {
analyzeLifetimes(cx);
@ -1764,7 +1764,7 @@ ScriptAnalysis::needsArgsObj(JSContext *cx, SeenVector &seen, const SSAValue &v)
return false;
}
if (!seen.append(v)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return true;
}
@ -1827,7 +1827,7 @@ ScriptAnalysis::needsArgsObj(JSContext *cx)
* Always construct arguments objects when in debug mode and for generator
* scripts (generators can be suspended when speculation fails).
*/
if (cx->compartment->debugMode() || script_->isGenerator)
if (cx->compartment()->debugMode() || script_->isGenerator)
return true;
/*

View File

@ -239,7 +239,7 @@ END_TEST(testDebugger_newScriptHook)
BEGIN_TEST(testDebugger_singleStepThrow)
{
CHECK(JS_SetDebugModeForCompartment(cx, cx->compartment, true));
CHECK(JS_SetDebugModeForCompartment(cx, cx->compartment(), true));
CHECK(JS_SetInterrupt(rt, onStep, NULL));
CHECK(JS_DefineFunction(cx, global, "setStepMode", setStepMode, 0, 0));

View File

@ -63,7 +63,7 @@ BEGIN_TEST(testIndexToString)
CHECK(str);
if (!js::StaticStrings::hasUint(u))
CHECK(cx->compartment->dtoaCache.lookup(10, u) == str);
CHECK(cx->compartment()->dtoaCache.lookup(10, u) == str);
JSBool match = JS_FALSE;
CHECK(JS_StringEqualsAscii(cx, str, tests[i].expected, &match));

View File

@ -21,9 +21,9 @@ reset(JSContext *cx)
{
psize = max_stack = 0;
memset(pstack, 0, sizeof(pstack));
cx->runtime->spsProfiler.stringsReset();
cx->runtime->spsProfiler.enableSlowAssertions(true);
js::EnableRuntimeProfilingStack(cx->runtime, true);
cx->runtime()->spsProfiler.stringsReset();
cx->runtime()->spsProfiler.enableSlowAssertions(true);
js::EnableRuntimeProfilingStack(cx->runtime(), true);
}
static JSClass ptestClass = {
@ -49,14 +49,14 @@ test_fn2(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
enable(JSContext *cx, unsigned argc, jsval *vp)
{
js::EnableRuntimeProfilingStack(cx->runtime, true);
js::EnableRuntimeProfilingStack(cx->runtime(), true);
return JS_TRUE;
}
static JSBool
disable(JSContext *cx, unsigned argc, jsval *vp)
{
js::EnableRuntimeProfilingStack(cx->runtime, false);
js::EnableRuntimeProfilingStack(cx->runtime(), false);
return JS_TRUE;
}
@ -81,7 +81,7 @@ static const JSFunctionSpec ptestFunctions[] = {
static JSObject*
initialize(JSContext *cx)
{
js::SetRuntimeProfilingStack(cx->runtime, pstack, &psize, 10);
js::SetRuntimeProfilingStack(cx->runtime(), pstack, &psize, 10);
JS::RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
return JS_InitClass(cx, global, NULL, &ptestClass, Prof, 0,
NULL, ptestFunctions, NULL, NULL);
@ -108,24 +108,24 @@ BEGIN_TEST(testProfileStrings_isCalledWithInterpreter)
CHECK(JS_CallFunctionName(cx, global, "check", 0, NULL, rval.address()));
CHECK(psize == 0);
CHECK(max_stack >= 8);
CHECK(cx->runtime->spsProfiler.stringsCount() == 8);
CHECK(cx->runtime()->spsProfiler.stringsCount() == 8);
/* Make sure the stack resets and we added no new entries */
max_stack = 0;
CHECK(JS_CallFunctionName(cx, global, "check", 0, NULL, rval.address()));
CHECK(psize == 0);
CHECK(max_stack >= 8);
CHECK(cx->runtime->spsProfiler.stringsCount() == 8);
CHECK(cx->runtime()->spsProfiler.stringsCount() == 8);
}
reset(cx);
{
JS::RootedValue rval(cx);
CHECK(JS_CallFunctionName(cx, global, "check2", 0, NULL, rval.address()));
CHECK(cx->runtime->spsProfiler.stringsCount() == 5);
CHECK(cx->runtime()->spsProfiler.stringsCount() == 5);
CHECK(max_stack >= 6);
CHECK(psize == 0);
}
js::EnableRuntimeProfilingStack(cx->runtime, false);
js::SetRuntimeProfilingStack(cx->runtime, pstack, &psize, 3);
js::EnableRuntimeProfilingStack(cx->runtime(), false);
js::SetRuntimeProfilingStack(cx->runtime(), pstack, &psize, 3);
reset(cx);
{
JS::RootedValue rval(cx);
@ -163,16 +163,16 @@ BEGIN_TEST(testProfileStrings_isCalledWithJIT)
CHECK(max_stack >= 8);
/* Make sure the stack resets and we added no new entries */
uint32_t cnt = cx->runtime->spsProfiler.stringsCount();
uint32_t cnt = cx->runtime()->spsProfiler.stringsCount();
max_stack = 0;
CHECK(JS_CallFunctionName(cx, global, "check", 0, NULL, rval.address()));
CHECK(psize == 0);
CHECK(cx->runtime->spsProfiler.stringsCount() == cnt);
CHECK(cx->runtime()->spsProfiler.stringsCount() == cnt);
CHECK(max_stack >= 8);
}
js::EnableRuntimeProfilingStack(cx->runtime, false);
js::SetRuntimeProfilingStack(cx->runtime, pstack, &psize, 3);
js::EnableRuntimeProfilingStack(cx->runtime(), false);
js::SetRuntimeProfilingStack(cx->runtime(), pstack, &psize, 3);
reset(cx);
{
/* Limit the size of the stack and make sure we don't overflow */
@ -202,7 +202,7 @@ BEGIN_TEST(testProfileStrings_isCalledWhenError)
JSBool ok = JS_CallFunctionName(cx, global, "check2", 0, NULL, rval.address());
CHECK(!ok);
CHECK(psize == 0);
CHECK(cx->runtime->spsProfiler.stringsCount() == 1);
CHECK(cx->runtime()->spsProfiler.stringsCount() == 1);
JS_ClearPendingException(cx);
}
@ -218,14 +218,14 @@ BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
EXEC("function b(p) { p.test_fn(); }");
EXEC("function a() { var p = new Prof(); p.enable(); b(p); }");
reset(cx);
js::EnableRuntimeProfilingStack(cx->runtime, false);
js::EnableRuntimeProfilingStack(cx->runtime(), false);
{
/* enable it in the middle of JS and make sure things check out */
JS::RootedValue rval(cx);
JS_CallFunctionName(cx, global, "a", 0, NULL, rval.address());
CHECK(psize == 0);
CHECK(max_stack >= 1);
CHECK(cx->runtime->spsProfiler.stringsCount() == 1);
CHECK(cx->runtime()->spsProfiler.stringsCount() == 1);
}
EXEC("function d(p) { p.disable(); }");
@ -252,7 +252,7 @@ BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
EXEC("function g(p) { p.disable(); for (var i = 0; i < 100; i++) i++; }");
EXEC("function f() { g(new Prof()); }");
reset(cx);
cx->runtime->spsProfiler.enableSlowAssertions(false);
cx->runtime()->spsProfiler.enableSlowAssertions(false);
{
JS::RootedValue rval(cx);
/* disable, and make sure that if we try to re-enter the JIT the pop

View File

@ -203,25 +203,25 @@ JS_Now()
JS_PUBLIC_API(jsval)
JS_GetNaNValue(JSContext *cx)
{
return cx->runtime->NaNValue;
return cx->runtime()->NaNValue;
}
JS_PUBLIC_API(jsval)
JS_GetNegativeInfinityValue(JSContext *cx)
{
return cx->runtime->negativeInfinityValue;
return cx->runtime()->negativeInfinityValue;
}
JS_PUBLIC_API(jsval)
JS_GetPositiveInfinityValue(JSContext *cx)
{
return cx->runtime->positiveInfinityValue;
return cx->runtime()->positiveInfinityValue;
}
JS_PUBLIC_API(jsval)
JS_GetEmptyStringValue(JSContext *cx)
{
return STRING_TO_JSVAL(cx->runtime->emptyString);
return STRING_TO_JSVAL(cx->runtime()->emptyString);
}
JS_PUBLIC_API(JSString *)
@ -240,7 +240,7 @@ AssertHeapIsIdle(JSRuntime *rt)
static void
AssertHeapIsIdle(JSContext *cx)
{
AssertHeapIsIdle(cx->runtime);
AssertHeapIsIdle(cx->runtime());
}
static void
@ -252,7 +252,7 @@ AssertHeapIsIdleOrIterating(JSRuntime *rt)
static void
AssertHeapIsIdleOrIterating(JSContext *cx)
{
AssertHeapIsIdleOrIterating(cx->runtime);
AssertHeapIsIdleOrIterating(cx->runtime());
}
static void
@ -262,7 +262,7 @@ AssertHeapIsIdleOrStringIsFlat(JSContext *cx, JSString *str)
* We allow some functions to be called during a GC as long as the argument
* is a flat string, since that will not cause allocation.
*/
JS_ASSERT_IF(cx->runtime->isHeapBusy(), str->isFlat());
JS_ASSERT_IF(cx->runtime()->isHeapBusy(), str->isFlat());
}
JS_PUBLIC_API(JSBool)
@ -1204,7 +1204,7 @@ JS_SetRuntimePrivate(JSRuntime *rt, void *data)
static void
StartRequest(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
rt->assertValidThread();
if (rt->requestDepth) {
@ -1221,7 +1221,7 @@ StartRequest(JSContext *cx)
static void
StopRequest(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
rt->assertValidThread();
JS_ASSERT(rt->requestDepth != 0);
if (rt->requestDepth != 1) {
@ -1321,7 +1321,7 @@ JS_SetSecondContextPrivate(JSContext *cx, void *data)
JS_PUBLIC_API(JSRuntime *)
JS_GetRuntime(JSContext *cx)
{
return cx->runtime;
return cx->runtime();
}
JS_PUBLIC_API(JSContext *)
@ -1476,7 +1476,7 @@ JS_EnterCompartment(JSContext *cx, JSObject *target)
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
JSCompartment *oldCompartment = cx->compartment;
JSCompartment *oldCompartment = cx->compartment();
cx->enterCompartment(target->compartment());
return oldCompartment;
}
@ -1500,7 +1500,7 @@ JS_LeaveCompartment(JSContext *cx, JSCompartment *oldCompartment)
JSAutoCompartment::JSAutoCompartment(JSContext *cx, JSObject *target)
: cx_(cx),
oldCompartment_(cx->compartment)
oldCompartment_(cx->compartment())
{
AssertHeapIsIdleOrIterating(cx_);
cx_->enterCompartment(target->compartment());
@ -1508,7 +1508,7 @@ JSAutoCompartment::JSAutoCompartment(JSContext *cx, JSObject *target)
JSAutoCompartment::JSAutoCompartment(JSContext *cx, JSScript *target)
: cx_(cx),
oldCompartment_(cx->compartment)
oldCompartment_(cx->compartment())
{
AssertHeapIsIdleOrIterating(cx_);
cx_->enterCompartment(target->compartment());
@ -1538,7 +1538,7 @@ JS_WrapObject(JSContext *cx, JSObject **objp)
CHECK_REQUEST(cx);
if (*objp)
JS::ExposeGCThingToActiveJS(*objp, JSTRACE_OBJECT);
return cx->compartment->wrap(cx, objp);
return cx->compartment()->wrap(cx, objp);
}
JS_PUBLIC_API(JSBool)
@ -1549,7 +1549,7 @@ JS_WrapValue(JSContext *cx, jsval *vp)
if (vp)
JS::ExposeValueToActiveJS(*vp);
RootedValue value(cx, *vp);
bool ok = cx->compartment->wrap(cx, &value);
bool ok = cx->compartment()->wrap(cx, &value);
*vp = value.get();
return ok;
}
@ -1566,7 +1566,7 @@ JS_WrapId(JSContext *cx, jsid *idp)
else if (JSID_IS_OBJECT(id))
JS::ExposeGCThingToActiveJS(JSID_TO_OBJECT(id), JSTRACE_OBJECT);
}
return cx->compartment->wrapId(cx, idp);
return cx->compartment()->wrapId(cx, idp);
}
/*
@ -1611,7 +1611,7 @@ JS_TransplantObject(JSContext *cx, JSObject *origobjArg, JSObject *targetArg)
JS_ASSERT(!IsCrossCompartmentWrapper(target));
AutoMaybeTouchDeadZones agc(cx);
AutoDisableProxyCheck adpc(cx->runtime);
AutoDisableProxyCheck adpc(cx->runtime());
JSCompartment *destination = target->compartment();
RootedValue origv(cx, ObjectValue(*origobj));
@ -1685,7 +1685,7 @@ js_TransplantObjectWithWrapper(JSContext *cx,
RootedObject targetwrapper(cx, targetwrapperArg);
AutoMaybeTouchDeadZones agc(cx);
AutoDisableProxyCheck adpc(cx->runtime);
AutoDisableProxyCheck adpc(cx->runtime());
AssertHeapIsIdle(cx);
JS_ASSERT(!IsCrossCompartmentWrapper(origobj));
@ -1781,7 +1781,7 @@ JS_PUBLIC_API(JSBool)
JS_InitStandardClasses(JSContext *cx, JSObject *objArg)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -1807,7 +1807,7 @@ typedef struct JSStdName {
static Handle<PropertyName*>
StdNameToPropertyName(JSContext *cx, JSStdName *stdn)
{
return OFFSET_TO_NAME(cx->runtime, stdn->atomOffset);
return OFFSET_TO_NAME(cx->runtime(), stdn->atomOffset);
}
/*
@ -1939,7 +1939,7 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *objArg, jsid id, JSBool *resolv
assertSameCompartment(cx, obj, id);
*resolved = false;
rt = cx->runtime;
rt = cx->runtime();
if (!rt->hasContexts() || !JSID_IS_ATOM(id))
return true;
@ -2122,7 +2122,7 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *objArg, JSIdArray *
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, ida);
rt = cx->runtime;
rt = cx->runtime();
if (ida) {
i = ida->length;
} else {
@ -2315,7 +2315,7 @@ JS_GetDefaultFreeOp(JSRuntime *rt)
JS_PUBLIC_API(void)
JS_updateMallocCounter(JSContext *cx, size_t nbytes)
{
return cx->runtime->updateMallocCounter(cx->zone(), nbytes);
return cx->runtime()->updateMallocCounter(cx->zone(), nbytes);
}
JS_PUBLIC_API(char *)
@ -2410,28 +2410,28 @@ JS_PUBLIC_API(void)
JS_RemoveValueRoot(JSContext *cx, jsval *vp)
{
CHECK_REQUEST(cx);
js_RemoveRoot(cx->runtime, (void *)vp);
js_RemoveRoot(cx->runtime(), (void *)vp);
}
JS_PUBLIC_API(void)
JS_RemoveStringRoot(JSContext *cx, JSString **rp)
{
CHECK_REQUEST(cx);
js_RemoveRoot(cx->runtime, (void *)rp);
js_RemoveRoot(cx->runtime(), (void *)rp);
}
JS_PUBLIC_API(void)
JS_RemoveObjectRoot(JSContext *cx, JSObject **rp)
{
CHECK_REQUEST(cx);
js_RemoveRoot(cx->runtime, (void *)rp);
js_RemoveRoot(cx->runtime(), (void *)rp);
}
JS_PUBLIC_API(void)
JS_RemoveScriptRoot(JSContext *cx, JSScript **rp)
{
CHECK_REQUEST(cx);
js_RemoveRoot(cx->runtime, (void *)rp);
js_RemoveRoot(cx->runtime(), (void *)rp);
}
JS_PUBLIC_API(void)
@ -3164,7 +3164,7 @@ JS_IdArrayGet(JSContext *cx, JSIdArray *ida, int index)
JS_PUBLIC_API(void)
JS_DestroyIdArray(JSContext *cx, JSIdArray *ida)
{
DestroyIdArray(cx->runtime->defaultFreeOp(), ida);
DestroyIdArray(cx->runtime()->defaultFreeOp(), ida);
}
JS_PUBLIC_API(JSBool)
@ -3431,9 +3431,9 @@ JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
Zone *zone;
if (zoneSpec == JS::SystemZone)
@ -3454,7 +3454,7 @@ JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::
AutoHoldZone hold(compartment->zone());
JSCompartment *saved = cx->compartment;
JSCompartment *saved = cx->compartment();
cx->setCompartment(compartment);
Rooted<GlobalObject *> global(cx, GlobalObject::create(cx, Valueify(clasp)));
cx->setCompartment(saved);
@ -3472,7 +3472,7 @@ JS_NewObject(JSContext *cx, JSClass *jsclasp, JSObject *protoArg, JSObject *pare
{
RootedObject proto(cx, protoArg);
RootedObject parent(cx, parentArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, proto, parent);
@ -3502,7 +3502,7 @@ JS_NewObjectWithGivenProto(JSContext *cx, JSClass *jsclasp, JSObject *protoArg,
{
RootedObject proto(cx, protoArg);
RootedObject parent(cx, parentArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, proto, parent);
@ -4773,7 +4773,7 @@ JS_NewArrayObject(JSContext *cx, int length, jsval *vector)
{
AutoArrayRooter tvr(cx, length, vector);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -4871,7 +4871,7 @@ JS_NewFunction(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
JSObject *parentArg, const char *name)
{
RootedObject parent(cx, parentArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -4894,7 +4894,7 @@ JS_NewFunctionById(JSContext *cx, JSNative native, unsigned nargs, unsigned flag
{
RootedObject parent(cx, parentArg);
JS_ASSERT(JSID_IS_STRING(id));
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, parent);
@ -5043,7 +5043,7 @@ js_generic_native_method_dispatcher(JSContext *cx, unsigned argc, Value *vp)
JS_PUBLIC_API(JSBool)
JS_DefineFunctions(JSContext *cx, JSObject *objArg, const JSFunctionSpec *fs)
{
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, objArg);
@ -5099,7 +5099,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *objArg, const JSFunctionSpec *fs)
* in. Self-hosted functions can access each other via their names,
* but not via the builtin classes they get installed into.
*/
if (cx->runtime->isSelfHostingGlobal(cx->global()))
if (cx->runtime()->isSelfHostingGlobal(cx->global()))
continue;
RootedAtom shAtom(cx, Atomize(cx, fs->selfHostedName, strlen(fs->selfHostedName)));
@ -5107,7 +5107,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *objArg, const JSFunctionSpec *fs)
return JS_FALSE;
RootedPropertyName shName(cx, shAtom->asPropertyName());
RootedValue funVal(cx);
if (!cx->runtime->maybeWrappedSelfHostedFunction(cx, shName, &funVal))
if (!cx->runtime()->maybeWrappedSelfHostedFunction(cx, shName, &funVal))
return JS_FALSE;
if (!funVal.isUndefined()) {
if (!JSObject::defineProperty(cx, obj, atom->asPropertyName(), funVal,
@ -5143,7 +5143,7 @@ JS_DefineFunction(JSContext *cx, JSObject *objArg, const char *name, JSNative ca
unsigned nargs, unsigned attrs)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -5160,7 +5160,7 @@ JS_DefineUCFunction(JSContext *cx, JSObject *objArg,
unsigned nargs, unsigned attrs)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -5177,7 +5177,7 @@ JS_DefineFunctionById(JSContext *cx, JSObject *objArg, jsid id_, JSNative call,
{
RootedObject obj(cx, objArg);
RootedId id(cx, id_);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -5318,11 +5318,11 @@ JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
options.version = mava.ref().version();
}
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
JS_ASSERT_IF(options.principals, cx->compartment->principals == options.principals);
JS_ASSERT_IF(options.principals, cx->compartment()->principals == options.principals);
AutoLastFrameCheck lfc(cx);
return frontend::CompileScript(cx, obj, NullPtr(), options, chars, length);
@ -5477,11 +5477,11 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, CompileOptions options,
options.version = mava.ref().version();
}
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
JS_ASSERT_IF(options.principals, cx->compartment->principals == options.principals);
JS_ASSERT_IF(options.principals, cx->compartment()->principals == options.principals);
AutoLastFrameCheck lfc(cx);
RootedAtom funAtom(cx);
@ -5577,7 +5577,7 @@ JS_CompileFunction(JSContext *cx, JSObject *objArg, const char *name,
JS_PUBLIC_API(JSString *)
JS_DecompileScript(JSContext *cx, JSScript *scriptArg, const char *name, unsigned indent)
{
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -5594,7 +5594,7 @@ JS_DecompileScript(JSContext *cx, JSScript *scriptArg, const char *name, unsigne
JS_PUBLIC_API(JSString *)
JS_DecompileFunction(JSContext *cx, JSFunction *funArg, unsigned indent)
{
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, funArg);
@ -5605,7 +5605,7 @@ JS_DecompileFunction(JSContext *cx, JSFunction *funArg, unsigned indent)
JS_PUBLIC_API(JSString *)
JS_DecompileFunctionBody(JSContext *cx, JSFunction *funArg, unsigned indent)
{
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, funArg);
@ -5619,11 +5619,11 @@ JS_ExecuteScript(JSContext *cx, JSObject *objArg, JSScript *scriptArg, jsval *rv
RootedObject obj(cx, objArg);
RootedScript script(cx, scriptArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
if (cx->compartment != obj->compartment())
if (cx->compartment() != obj->compartment())
*(volatile int *) 0 = 0xf0;
AutoLastFrameCheck lfc(cx);
@ -5668,11 +5668,11 @@ JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
options.version = mava.ref().version();
}
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
JS_ASSERT_IF(options.principals, cx->compartment->principals == options.principals);
JS_ASSERT_IF(options.principals, cx->compartment()->principals == options.principals);
AutoLastFrameCheck lfc(cx);
@ -5698,7 +5698,7 @@ JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
if (script->length > LARGE_SCRIPT_LENGTH) {
script = NULL;
PrepareZoneForGC(cx->zone());
GC(cx->runtime, GC_NORMAL, gcreason::FINISH_LARGE_EVALUTE);
GC(cx->runtime(), GC_NORMAL, gcreason::FINISH_LARGE_EVALUTE);
}
return result;
@ -5841,7 +5841,7 @@ JS_CallFunction(JSContext *cx, JSObject *objArg, JSFunction *fun, unsigned argc,
jsval *rval)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, fun, JSValueArray(argv, argc));
@ -5855,7 +5855,7 @@ JS_CallFunctionName(JSContext *cx, JSObject *objArg, const char *name, unsigned
jsval *rval)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, JSValueArray(argv, argc));
@ -5876,7 +5876,7 @@ JS_CallFunctionValue(JSContext *cx, JSObject *objArg, jsval fval, unsigned argc,
jsval *rval)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, fval, JSValueArray(argv, argc));
@ -6011,7 +6011,7 @@ JS_NewStringCopyZ(JSContext *cx, const char *s)
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (!s || !*s)
return cx->runtime->emptyString;
return cx->runtime()->emptyString;
n = strlen(s);
js = InflateString(cx, s, &n);
if (!js)
@ -6091,7 +6091,7 @@ JS_NewUCStringCopyZ(JSContext *cx, const jschar *s)
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (!s)
return cx->runtime->emptyString;
return cx->runtime()->emptyString;
return js_NewStringCopyZ<CanGC>(cx, s);
}
@ -6128,7 +6128,7 @@ JS_PUBLIC_API(const jschar *)
JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *plength)
{
/*
* Don't require |cx->compartment| to be |str|'s compartment. We don't need
* Don't require |cx->compartment()| to be |str|'s compartment. We don't need
* it, and it's annoying for callers.
*/
JS_ASSERT(plength);
@ -6406,7 +6406,7 @@ JS_ReadStructuredClone(JSContext *cx, uint64_t *buf, size_t nbytes,
const JSStructuredCloneCallbacks *callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime->structuredCloneCallbacks;
cx->runtime()->structuredCloneCallbacks;
return ReadStructuredClone(cx, buf, nbytes, vp, callbacks, closure);
}
@ -6423,7 +6423,7 @@ JS_WriteStructuredClone(JSContext *cx, jsval valueArg, uint64_t **bufp, size_t *
const JSStructuredCloneCallbacks *callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime->structuredCloneCallbacks;
cx->runtime()->structuredCloneCallbacks;
return WriteStructuredClone(cx, value, (uint64_t **) bufp, nbytesp,
callbacks, closure, transferable);
}
@ -6459,7 +6459,7 @@ JS_StructuredClone(JSContext *cx, jsval valueArg, jsval *vp,
const JSStructuredCloneCallbacks *callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime->structuredCloneCallbacks;
cx->runtime()->structuredCloneCallbacks;
JSAutoStructuredCloneBuffer buf;
return buf.write(cx, value, callbacks, closure) &&
buf.read(cx, vp, callbacks, closure);
@ -6767,7 +6767,7 @@ JS_ClearDateCaches(JSContext *cx)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
cx->runtime->dateTimeInfo.updateTimeZoneAdjustment();
cx->runtime()->dateTimeInfo.updateTimeZoneAdjustment();
}
/************************************************************************/
@ -7105,13 +7105,13 @@ JS_AbortIfWrongThread(JSRuntime *rt)
JS_PUBLIC_API(void)
JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency)
{
SetGCZeal(cx->runtime, zeal, frequency);
SetGCZeal(cx->runtime(), zeal, frequency);
}
JS_PUBLIC_API(void)
JS_ScheduleGC(JSContext *cx, uint32_t count)
{
cx->runtime->gcNextScheduled = count;
cx->runtime()->gcNextScheduled = count;
}
#endif
@ -7220,7 +7220,7 @@ JS_CallOnce(JSCallOnceType *once, JSInitCallback func)
}
AutoGCRooter::AutoGCRooter(JSContext *cx, ptrdiff_t tag)
: down(cx->runtime->autoGCRooters), tag_(tag), stackTop(&cx->runtime->autoGCRooters)
: down(cx->runtime()->autoGCRooters), tag_(tag), stackTop(&cx->runtime()->autoGCRooters)
{
JS_ASSERT(this != *stackTop);
*stackTop = this;

View File

@ -824,7 +824,7 @@ array_toSource_impl(JSContext *cx, CallArgs args)
/* Get element's character string. */
JSString *str;
if (hole) {
str = cx->runtime->emptyString;
str = cx->runtime()->emptyString;
} else {
str = ValueToSource(cx, elt);
if (!str)
@ -2886,11 +2886,11 @@ NewArray(JSContext *cx, uint32_t length, JSObject *protoArg, NewObjectKind newKi
JS_ASSERT(CanBeFinalizedInBackground(allocKind, &ArrayClass));
allocKind = GetBackgroundAllocKind(allocKind);
NewObjectCache &cache = cx->runtime->newObjectCache;
NewObjectCache &cache = cx->runtime()->newObjectCache;
NewObjectCache::EntryIndex entry = -1;
if (newKind == GenericObject &&
!cx->compartment->objectMetadataCallback &&
!cx->compartment()->objectMetadataCallback &&
cache.lookupGlobal(&ArrayClass, cx->global(), allocKind, &entry))
{
RootedObject obj(cx, cache.newObjectFromHit(cx, entry, GetInitialHeap(newKind, &ArrayClass)));

View File

@ -154,16 +154,16 @@ js::InitCommonNames(JSContext *cx)
#undef COMMON_NAME_INFO
};
FixedHeapPtr<PropertyName> *names = &cx->runtime->firstCachedName;
FixedHeapPtr<PropertyName> *names = &cx->runtime()->firstCachedName;
for (size_t i = 0; i < ArrayLength(cachedNames); i++, names++) {
JSAtom *atom = Atomize(cx, cachedNames[i].str, cachedNames[i].length, InternAtom);
if (!atom)
return false;
names->init(atom->asPropertyName());
}
JS_ASSERT(uintptr_t(names) == uintptr_t(&cx->runtime->atomState + 1));
JS_ASSERT(uintptr_t(names) == uintptr_t(&cx->runtime()->atomState + 1));
cx->runtime->emptyString = cx->names().empty;
cx->runtime()->emptyString = cx->names().empty;
return true;
}
@ -214,7 +214,7 @@ AtomIsInterned(JSContext *cx, JSAtom *atom)
if (StaticStrings::isStatic(atom))
return true;
AtomSet::Ptr p = cx->runtime->atoms.lookup(atom);
AtomSet::Ptr p = cx->runtime()->atoms.lookup(atom);
if (!p)
return false;
@ -238,7 +238,7 @@ AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBeh
{
JS_ASSERT(tbchars[length] == 0);
if (JSAtom *s = cx->runtime->staticStrings.lookup(tbchars, length)) {
if (JSAtom *s = cx->runtime()->staticStrings.lookup(tbchars, length)) {
js_free(tbchars);
return s;
}
@ -249,7 +249,7 @@ AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBeh
* unchanged, we need to re-lookup the table position because a last-ditch
* GC will potentially free some table entries.
*/
AtomSet& atoms = cx->runtime->atoms;
AtomSet& atoms = cx->runtime()->atoms;
AtomSet::AddPtr p = atoms.lookupForAdd(AtomHasher::Lookup(tbchars, length));
SkipRoot skipHash(cx, &p); /* Prevent the hash from being poisoned. */
if (p) {
@ -284,7 +284,7 @@ JS_ALWAYS_INLINE
static JSAtom *
AtomizeAndCopyChars(JSContext *cx, const jschar *tbchars, size_t length, InternBehavior ib)
{
if (JSAtom *s = cx->runtime->staticStrings.lookup(tbchars, length))
if (JSAtom *s = cx->runtime()->staticStrings.lookup(tbchars, length))
return s;
/*
@ -294,7 +294,7 @@ AtomizeAndCopyChars(JSContext *cx, const jschar *tbchars, size_t length, InternB
* GC will potentially free some table entries.
*/
AtomSet& atoms = cx->runtime->atoms;
AtomSet& atoms = cx->runtime()->atoms;
AtomSet::AddPtr p = atoms.lookupForAdd(AtomHasher::Lookup(tbchars, length));
SkipRoot skipHash(cx, &p); /* Prevent the hash from being poisoned. */
if (p) {
@ -330,7 +330,7 @@ js::AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib /* = js::D
if (ib != InternAtom || js::StaticStrings::isStatic(&atom))
return &atom;
AtomSet::Ptr p = cx->runtime->atoms.lookup(AtomHasher::Lookup(&atom));
AtomSet::Ptr p = cx->runtime()->atoms.lookup(AtomHasher::Lookup(&atom));
JS_ASSERT(p); /* Non-static atom must exist in atom state set. */
JS_ASSERT(p->asPtr() == &atom);
JS_ASSERT(ib == InternAtom);
@ -476,7 +476,7 @@ js::XDRAtom(XDRState<mode> *xdr, MutableHandleAtom atomp)
* most allocations here will be bigger than tempLifoAlloc's default
* chunk size.
*/
chars = cx->runtime->pod_malloc<jschar>(nchars);
chars = cx->runtime()->pod_malloc<jschar>(nchars);
if (!chars)
return false;
}

View File

@ -184,7 +184,7 @@ TypeName(JSType type, JSRuntime *rt)
inline Handle<PropertyName*>
TypeName(JSType type, JSContext *cx)
{
return TypeName(type, cx->runtime);
return TypeName(type, cx->runtime());
}
inline Handle<PropertyName*>
@ -195,7 +195,7 @@ ClassName(JSProtoKey key, JSContext *cx)
JSProto_LIMIT * sizeof(FixedHeapPtr<PropertyName>) <=
sizeof(JSAtomState));
JS_STATIC_ASSERT(JSProto_Null == 0);
return (&cx->runtime->atomState.Null)[key];
return (&cx->runtime()->atomState.Null)[key];
}
} // namespace js

View File

@ -184,7 +184,7 @@ js_InitBooleanClass(JSContext *cx, HandleObject obj)
JSString *
js_BooleanToString(JSContext *cx, JSBool b)
{
return b ? cx->runtime->atomState.true_ : cx->runtime->atomState.false_;
return b ? cx->runtime()->atomState.true_ : cx->runtime()->atomState.false_;
}
JS_PUBLIC_API(bool)
@ -203,7 +203,7 @@ js::BooleanGetPrimitiveValueSlow(JSContext *cx, HandleObject obj, Value *vp)
InvokeArgsGuard ag;
if (!cx->stack.pushInvokeArgs(cx, 0, &ag))
return false;
ag.setCallee(cx->compartment->maybeGlobal()->booleanValueOf());
ag.setCallee(cx->compartment()->maybeGlobal()->booleanValueOf());
ag.setThis(ObjectValue(*obj));
if (!Invoke(cx, ag))
return false;

View File

@ -167,7 +167,7 @@ JSC::ExecutableAllocator *
JSRuntime::createExecutableAllocator(JSContext *cx)
{
JS_ASSERT(!execAlloc_);
JS_ASSERT(cx->runtime == this);
JS_ASSERT(cx->runtime() == this);
JSC::AllocationBehavior randomize =
jitHardening ? JSC::AllocationCanRandomize : JSC::AllocationDeterministic;
@ -181,7 +181,7 @@ WTF::BumpPointerAllocator *
JSRuntime::createBumpPointerAllocator(JSContext *cx)
{
JS_ASSERT(!bumpAlloc_);
JS_ASSERT(cx->runtime == this);
JS_ASSERT(cx->runtime() == this);
bumpAlloc_ = js_new<WTF::BumpPointerAllocator>();
if (!bumpAlloc_)
@ -193,7 +193,7 @@ MathCache *
JSRuntime::createMathCache(JSContext *cx)
{
JS_ASSERT(!mathCache_);
JS_ASSERT(cx->runtime == this);
JS_ASSERT(cx->runtime() == this);
MathCache *newMathCache = js_new<MathCache>();
if (!newMathCache) {
@ -229,7 +229,7 @@ js::CloneFunctionAtCallsite(JSContext *cx, HandleFunction fun, HandleScript scri
typedef CallsiteCloneKey Key;
typedef CallsiteCloneTable Table;
Table &table = cx->compartment->callsiteClones;
Table &table = cx->compartment()->callsiteClones;
if (!table.initialized() && !table.init())
return NULL;
@ -333,7 +333,7 @@ js::NewContext(JSRuntime *rt, size_t stackChunkSize)
void
js::DestroyContext(JSContext *cx, DestroyContextMode mode)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
JS_AbortIfWrongThread(rt);
#ifdef JS_THREADSAFE
@ -429,7 +429,7 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
if (!JS_IsRunning(cx) ||
!js_ErrorToException(cx, message, reportp, callback, userRef)) {
js_ReportErrorAgain(cx, message, reportp);
} else if (JSDebugErrorHook hook = cx->runtime->debugHooks.debugErrorHook) {
} else if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
/*
* If we've already chewed up all the C stack, don't call into the
* error reporter since this may trigger an infinite recursion where
@ -440,7 +440,7 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
return;
if (cx->errorReporter)
hook(cx, message, reportp, cx->runtime->debugHooks.debugErrorHookData);
hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData);
}
}
@ -476,7 +476,7 @@ PopulateReportBlame(JSContext *cx, JSErrorReport *report)
void
js_ReportOutOfMemory(JSContext *cx)
{
cx->runtime->hadOutOfMemory = true;
cx->runtime()->hadOutOfMemory = true;
if (JS_IsRunning(cx)) {
cx->setPendingException(StringValue(cx->names().outOfMemory));
@ -961,8 +961,8 @@ js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *reportp)
* sending the error on to the regular ErrorReporter.
*/
if (onError) {
JSDebugErrorHook hook = cx->runtime->debugHooks.debugErrorHook;
if (hook && !hook(cx, message, reportp, cx->runtime->debugHooks.debugErrorHookData))
JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook;
if (hook && !hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData))
onError = NULL;
}
if (onError)
@ -1071,7 +1071,7 @@ js_InvokeOperationCallback(JSContext *cx)
{
JS_ASSERT_REQUEST_DEPTH(cx);
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
JS_ASSERT(rt->interrupt != 0);
/*
@ -1113,7 +1113,7 @@ JSBool
js_HandleExecutionInterrupt(JSContext *cx)
{
JSBool result = JS_TRUE;
if (cx->runtime->interrupt)
if (cx->runtime()->interrupt)
result = js_InvokeOperationCallback(cx) && result;
return result;
}
@ -1223,7 +1223,7 @@ JSContext::wrapPendingException()
{
RootedValue value(this, getPendingException());
clearPendingException();
if (compartment->wrap(this, &value))
if (compartment()->wrap(this, &value))
setPendingException(value);
}
@ -1248,7 +1248,7 @@ JSContext::leaveGenerator(JSGenerator *gen)
bool
JSContext::runningWithTrustedPrincipals() const
{
return !compartment || compartment->principals == runtime->trustedPrincipals();
return !compartment() || compartment()->principals == runtime()->trustedPrincipals();
}
bool
@ -1257,7 +1257,7 @@ JSContext::saveFrameChain()
if (!stack.saveFrameChain())
return false;
if (!savedFrameChains_.append(SavedFrameChain(compartment, enterCompartmentDepth_))) {
if (!savedFrameChains_.append(SavedFrameChain(compartment(), enterCompartmentDepth_))) {
stack.restoreFrameChain();
return false;
}
@ -1463,15 +1463,15 @@ JSContext::mark(JSTracer *trc)
JS::AutoCheckRequestDepth::AutoCheckRequestDepth(JSContext *cx)
: cx(cx)
{
JS_ASSERT(cx->runtime->requestDepth || cx->runtime->isHeapBusy());
cx->runtime->assertValidThread();
cx->runtime->checkRequestDepth++;
JS_ASSERT(cx->runtime()->requestDepth || cx->runtime()->isHeapBusy());
cx->runtime()->assertValidThread();
cx->runtime()->checkRequestDepth++;
}
JS::AutoCheckRequestDepth::~AutoCheckRequestDepth()
{
JS_ASSERT(cx->runtime->checkRequestDepth != 0);
cx->runtime->checkRequestDepth--;
JS_ASSERT(cx->runtime()->checkRequestDepth != 0);
cx->runtime()->checkRequestDepth--;
}
#endif

View File

@ -1511,8 +1511,11 @@ struct JSContext : js::ContextFriendFields,
JSContext *thisDuringConstruction() { return this; }
~JSContext();
JSRuntime *runtime() const { return runtime_; }
JSCompartment *compartment() const { return compartment_; }
inline JS::Zone *zone() const;
js::PerThreadData &mainThread() { return runtime->mainThread; }
js::PerThreadData &mainThread() { return runtime()->mainThread; }
private:
/* See JSContext::findVersion. */
@ -1694,13 +1697,13 @@ struct JSContext : js::ContextFriendFields,
bool hasStrictOption() const { return hasOption(JSOPTION_STRICT); }
bool hasWErrorOption() const { return hasOption(JSOPTION_WERROR); }
js::LifoAlloc &tempLifoAlloc() { return runtime->tempLifoAlloc; }
js::LifoAlloc &tempLifoAlloc() { return runtime()->tempLifoAlloc; }
inline js::LifoAlloc &analysisLifoAlloc();
inline js::LifoAlloc &typeLifoAlloc();
inline js::PropertyTree &propertyTree();
js::PropertyCache &propertyCache() { return runtime->propertyCache; }
js::PropertyCache &propertyCache() { return runtime()->propertyCache; }
#ifdef JS_THREADSAFE
unsigned outstandingRequests;/* number of JS_BeginRequest calls
@ -1742,7 +1745,7 @@ struct JSContext : js::ContextFriendFields,
void leaveGenerator(JSGenerator *gen);
void *onOutOfMemory(void *p, size_t nbytes) {
return runtime->onOutOfMemory(p, nbytes, this);
return runtime()->onOutOfMemory(p, nbytes, this);
}
void updateMallocCounter(size_t nbytes);
void reportAllocationOverflow() {
@ -1765,7 +1768,7 @@ struct JSContext : js::ContextFriendFields,
exception.setUndefined();
}
JSAtomState & names() { return runtime->atomState; }
JSAtomState & names() { return runtime()->atomState; }
#ifdef DEBUG
/*
@ -2083,7 +2086,7 @@ js_ReportValueErrorFlags(JSContext *cx, unsigned flags, const unsigned errorNumb
extern const JSErrorFormatString js_ErrorFormatString[JSErr_Limit];
#ifdef JS_THREADSAFE
# define JS_ASSERT_REQUEST_DEPTH(cx) JS_ASSERT((cx)->runtime->requestDepth >= 1)
# define JS_ASSERT_REQUEST_DEPTH(cx) JS_ASSERT((cx)->runtime()->requestDepth >= 1)
#else
# define JS_ASSERT_REQUEST_DEPTH(cx) ((void) 0)
#endif
@ -2107,7 +2110,7 @@ static MOZ_ALWAYS_INLINE bool
JS_CHECK_OPERATION_LIMIT(JSContext *cx)
{
JS_ASSERT_REQUEST_DEPTH(cx);
return !cx->runtime->interrupt || js_InvokeOperationCallback(cx);
return !cx->runtime()->interrupt || js_InvokeOperationCallback(cx);
}
namespace js {
@ -2312,7 +2315,7 @@ class RuntimeAllocPolicy
public:
RuntimeAllocPolicy(JSRuntime *rt) : runtime(rt) {}
RuntimeAllocPolicy(JSContext *cx) : runtime(cx->runtime) {}
RuntimeAllocPolicy(JSContext *cx) : runtime(cx->runtime()) {}
void *malloc_(size_t bytes) { return runtime->malloc_(bytes); }
void *calloc_(size_t bytes) { return runtime->calloc_(bytes); }
void *realloc_(void *p, size_t bytes) { return runtime->realloc_(p, bytes); }

View File

@ -111,7 +111,7 @@ inline JSObject *
NewObjectCache::newObjectFromHit(JSContext *cx, EntryIndex entry_, js::gc::InitialHeap heap)
{
// The new object cache does not account for metadata attached via callbacks.
JS_ASSERT(!cx->compartment->objectMetadataCallback);
JS_ASSERT(!cx->compartment()->objectMetadataCallback);
JS_ASSERT(unsigned(entry_) < mozilla::ArrayLength(entries));
Entry *entry = &entries[entry_];
@ -153,7 +153,7 @@ class CompartmentChecker
public:
explicit CompartmentChecker(JSContext *cx)
: context(cx), compartment(cx->compartment)
: context(cx), compartment(cx->compartment())
{}
/*
@ -179,7 +179,7 @@ class CompartmentChecker
}
void check(JSCompartment *c) {
if (c && c != context->runtime->atomsCompartment) {
if (c && c != context->runtime()->atomsCompartment) {
if (!compartment)
compartment = c;
else if (c != compartment)
@ -265,8 +265,8 @@ class CompartmentChecker
* depends on other objects not having been swept yet.
*/
#define START_ASSERT_SAME_COMPARTMENT() \
JS_ASSERT(cx->compartment->zone() == cx->zone()); \
if (cx->runtime->isHeapBusy()) \
JS_ASSERT(cx->compartment()->zone() == cx->zone()); \
if (cx->runtime()->isHeapBusy()) \
return; \
CompartmentChecker c(cx)
@ -505,7 +505,7 @@ JSContext::maybeOverrideVersion(JSVersion newVersion)
inline js::LifoAlloc &
JSContext::analysisLifoAlloc()
{
return compartment->analysisLifoAlloc;
return compartment()->analysisLifoAlloc;
}
inline js::LifoAlloc &
@ -525,7 +525,7 @@ JSContext::setPendingException(js::Value v) {
inline js::PropertyTree&
JSContext::propertyTree()
{
return compartment->propertyTree;
return compartment()->propertyTree;
}
inline void
@ -570,7 +570,7 @@ JSContext::leaveCompartment(JSCompartment *oldCompartment)
JS_ASSERT(hasEnteredCompartment());
enterCompartmentDepth_--;
compartment->leave();
compartment()->leave();
/*
* Before we entered the current compartment, 'compartment' was
@ -592,21 +592,21 @@ JSContext::leaveCompartment(JSCompartment *oldCompartment)
inline JS::Zone *
JSContext::zone() const
{
JS_ASSERT_IF(!compartment, !zone_);
JS_ASSERT_IF(compartment, compartment->zone() == zone_);
JS_ASSERT_IF(!compartment(), !zone_);
JS_ASSERT_IF(compartment(), compartment()->zone() == zone_);
return zone_;
}
inline void
JSContext::updateMallocCounter(size_t nbytes)
{
runtime->updateMallocCounter(zone(), nbytes);
runtime()->updateMallocCounter(zone(), nbytes);
}
inline void
JSContext::setCompartment(JSCompartment *comp)
{
compartment = comp;
compartment_ = comp;
zone_ = comp ? comp->zone() : NULL;
}

View File

@ -88,7 +88,7 @@ JSCompartment::init(JSContext *cx)
* (unless they also create tons of iframes, which seems unlikely).
*/
if (cx)
cx->runtime->dateTimeInfo.updateTimeZoneAdjustment();
cx->runtime()->dateTimeInfo.updateTimeZoneAdjustment();
activeAnalysis = false;
@ -118,9 +118,9 @@ JSRuntime::createIonRuntime(JSContext *cx)
js_delete(ionRuntime_);
ionRuntime_ = NULL;
if (cx->runtime->atomsCompartment->ionCompartment_) {
js_delete(cx->runtime->atomsCompartment->ionCompartment_);
cx->runtime->atomsCompartment->ionCompartment_ = NULL;
if (cx->runtime()->atomsCompartment->ionCompartment_) {
js_delete(cx->runtime()->atomsCompartment->ionCompartment_);
cx->runtime()->atomsCompartment->ionCompartment_ = NULL;
}
return NULL;
@ -136,7 +136,7 @@ JSCompartment::ensureIonCompartmentExists(JSContext *cx)
if (ionCompartment_)
return true;
IonRuntime *ionRuntime = cx->runtime->getIonRuntime(cx);
IonRuntime *ionRuntime = cx->runtime()->getIonRuntime(cx);
if (!ionRuntime)
return false;
@ -159,13 +159,13 @@ JSCompartment::ensureIonCompartmentExists(JSContext *cx)
static bool
WrapForSameCompartment(JSContext *cx, HandleObject obj, MutableHandleValue vp)
{
JS_ASSERT(cx->compartment == obj->compartment());
if (!cx->runtime->sameCompartmentWrapObjectCallback) {
JS_ASSERT(cx->compartment() == obj->compartment());
if (!cx->runtime()->sameCompartmentWrapObjectCallback) {
vp.setObject(*obj);
return true;
}
JSObject *wrapped = cx->runtime->sameCompartmentWrapObjectCallback(cx, obj);
JSObject *wrapped = cx->runtime()->sameCompartmentWrapObjectCallback(cx, obj);
if (!wrapped)
return false;
vp.setObject(*wrapped);
@ -187,8 +187,8 @@ JSCompartment::putWrapper(const CrossCompartmentKey &wrapped, const js::Value &w
bool
JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingArg)
{
JS_ASSERT(cx->compartment == this);
JS_ASSERT_IF(existingArg, existingArg->compartment() == cx->compartment);
JS_ASSERT(cx->compartment() == this);
JS_ASSERT_IF(existingArg, existingArg->compartment() == cx->compartment());
JS_ASSERT_IF(existingArg, vp.isObject());
JS_ASSERT_IF(existingArg, IsDeadProxyObject(existingArg));
@ -211,7 +211,7 @@ JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingA
/* If the string is an atom, we don't have to copy. */
if (str->isAtom()) {
JS_ASSERT(str->zone() == cx->runtime->atomsCompartment->zone());
JS_ASSERT(str->zone() == cx->runtime()->atomsCompartment->zone());
return true;
}
}
@ -242,8 +242,8 @@ JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingA
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj, vp);
if (cx->runtime->preWrapObjectCallback) {
obj = cx->runtime->preWrapObjectCallback(cx, global, obj, flags);
if (cx->runtime()->preWrapObjectCallback) {
obj = cx->runtime()->preWrapObjectCallback(cx, global, obj, flags);
if (!obj)
return false;
}
@ -321,7 +321,7 @@ JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingA
* to the object.
*/
RootedObject wrapper(cx);
wrapper = cx->runtime->wrapObjectCallback(cx, existing, obj, proto, global, flags);
wrapper = cx->runtime()->wrapObjectCallback(cx, existing, obj, proto, global, flags);
if (!wrapper)
return false;
@ -641,7 +641,7 @@ JSCompartment::setDebugModeFromC(JSContext *cx, bool b, AutoDebugModeGC &dmgc)
debugModeBits = (debugModeBits & ~unsigned(DebugFromC)) | (b ? DebugFromC : 0);
JS_ASSERT(debugMode() == enabledAfter);
if (enabledBefore != enabledAfter) {
updateForDebugMode(cx->runtime->defaultFreeOp(), dmgc);
updateForDebugMode(cx->runtime()->defaultFreeOp(), dmgc);
if (!enabledAfter)
DebugScopes::onCompartmentLeaveDebugMode(this);
}
@ -652,7 +652,7 @@ void
JSCompartment::updateForDebugMode(FreeOp *fop, AutoDebugModeGC &dmgc)
{
for (ContextIter acx(rt); !acx.done(); acx.next()) {
if (acx->compartment == this)
if (acx->compartment() == this)
acx->updateJITEnabled();
}
@ -681,7 +681,7 @@ JSCompartment::updateForDebugMode(FreeOp *fop, AutoDebugModeGC &dmgc)
bool
JSCompartment::addDebuggee(JSContext *cx, js::GlobalObject *global)
{
AutoDebugModeGC dmgc(cx->runtime);
AutoDebugModeGC dmgc(cx->runtime());
return addDebuggee(cx, global, dmgc);
}
@ -697,7 +697,7 @@ JSCompartment::addDebuggee(JSContext *cx,
}
debugModeBits |= DebugFromJS;
if (!wasEnabled) {
updateForDebugMode(cx->runtime->defaultFreeOp(), dmgc);
updateForDebugMode(cx->runtime()->defaultFreeOp(), dmgc);
}
return true;
}

View File

@ -411,7 +411,7 @@ class js::AutoDebugModeGC
inline bool
JSContext::typeInferenceEnabled() const
{
return compartment->zone()->types.inferenceEnabled;
return compartment()->zone()->types.inferenceEnabled;
}
inline js::Handle<js::GlobalObject*>
@ -423,7 +423,7 @@ JSContext::global() const
* barrier on it. Once the compartment is popped, the handle is no longer
* safe to use.
*/
return js::Handle<js::GlobalObject*>::fromMarkedLocation(compartment->global_.unsafeGet());
return js::Handle<js::GlobalObject*>::fromMarkedLocation(compartment()->global_.unsafeGet());
}
namespace js {
@ -433,13 +433,13 @@ class AssertCompartmentUnchanged
public:
AssertCompartmentUnchanged(JSContext *cx
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: cx(cx), oldCompartment(cx->compartment)
: cx(cx), oldCompartment(cx->compartment())
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
~AssertCompartmentUnchanged() {
JS_ASSERT(cx->compartment == oldCompartment);
JS_ASSERT(cx->compartment() == oldCompartment);
}
protected:

View File

@ -26,7 +26,7 @@ JSCompartment::maybeGlobal() const
js::AutoCompartment::AutoCompartment(JSContext *cx, JSObject *target)
: cx_(cx),
origin_(cx->compartment)
origin_(cx->compartment())
{
cx_->enterCompartment(target->compartment());
}
@ -77,9 +77,9 @@ class AutoEnterAtomsCompartment
public:
AutoEnterAtomsCompartment(JSContext *cx)
: cx(cx),
oldCompartment(cx->compartment)
oldCompartment(cx->compartment())
{
cx->setCompartment(cx->runtime->atomsCompartment);
cx->setCompartment(cx->runtime()->atomsCompartment);
}
~AutoEnterAtomsCompartment()

View File

@ -1219,7 +1219,7 @@ date_parse(JSContext *cx, unsigned argc, Value *vp)
return false;
double result;
if (!date_parseString(linearStr, &result, &cx->runtime->dateTimeInfo)) {
if (!date_parseString(linearStr, &result, &cx->runtime()->dateTimeInfo)) {
vp->setDouble(js_NaN);
return true;
}
@ -1439,7 +1439,7 @@ date_getYear_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
Value yearVal = thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_YEAR);
if (yearVal.isInt32()) {
@ -1466,7 +1466,7 @@ date_getFullYear_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_YEAR));
return true;
@ -1505,7 +1505,7 @@ date_getMonth_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_MONTH));
return true;
@ -1541,7 +1541,7 @@ date_getDate_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_DATE));
return true;
@ -1580,7 +1580,7 @@ date_getDay_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_DAY));
return true;
@ -1619,7 +1619,7 @@ date_getHours_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_HOURS));
return true;
@ -1658,7 +1658,7 @@ date_getMinutes_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_MINUTES));
return true;
@ -1699,7 +1699,7 @@ date_getUTCSeconds_impl(JSContext *cx, CallArgs args)
JS_ASSERT(IsDate(args.thisv()));
JSObject *thisObj = &args.thisv().toObject();
FillLocalTimeSlots(&cx->runtime->dateTimeInfo, thisObj);
FillLocalTimeSlots(&cx->runtime()->dateTimeInfo, thisObj);
args.rval().set(thisObj->getSlot(JSObject::JSSLOT_DATE_LOCAL_SECONDS));
return true;
@ -1741,7 +1741,7 @@ date_getTimezoneOffset_impl(JSContext *cx, CallArgs args)
JSObject *thisObj = &args.thisv().toObject();
double utctime = thisObj->getDateUTCTime().toNumber();
double localtime = GetCachedLocalTime(&cx->runtime->dateTimeInfo, thisObj);
double localtime = GetCachedLocalTime(&cx->runtime()->dateTimeInfo, thisObj);
/*
* Return the time zone offset in minutes for the current locale that is
@ -1825,7 +1825,7 @@ date_setMilliseconds_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime->dateTimeInfo);
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime()->dateTimeInfo);
/* Step 2. */
double milli;
@ -1834,7 +1834,7 @@ date_setMilliseconds_impl(JSContext *cx, CallArgs args)
double time = MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), milli);
/* Step 3. */
double u = TimeClip(UTC(MakeDate(Day(t), time), &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(MakeDate(Day(t), time), &cx->runtime()->dateTimeInfo));
/* Steps 4-5. */
SetUTCTime(thisObj, u, args.rval().address());
@ -1889,7 +1889,7 @@ date_setSeconds_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime->dateTimeInfo);
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime()->dateTimeInfo);
/* Step 2. */
double s;
@ -1905,7 +1905,7 @@ date_setSeconds_impl(JSContext *cx, CallArgs args)
double date = MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, milli));
/* Step 5. */
double u = TimeClip(UTC(date, &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(date, &cx->runtime()->dateTimeInfo));
/* Steps 6-7. */
SetUTCTime(thisObj, u, args.rval().address());
@ -1967,7 +1967,7 @@ date_setMinutes_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime->dateTimeInfo);
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime()->dateTimeInfo);
/* Step 2. */
double m;
@ -1988,7 +1988,7 @@ date_setMinutes_impl(JSContext *cx, CallArgs args)
double date = MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli));
/* Step 6. */
double u = TimeClip(UTC(date, &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(date, &cx->runtime()->dateTimeInfo));
/* Steps 7-8. */
SetUTCTime(thisObj, u, args.rval().address());
@ -2055,7 +2055,7 @@ date_setHours_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime->dateTimeInfo);
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime()->dateTimeInfo);
/* Step 2. */
double h;
@ -2081,7 +2081,7 @@ date_setHours_impl(JSContext *cx, CallArgs args)
double date = MakeDate(Day(t), MakeTime(h, m, s, milli));
/* Step 6. */
double u = TimeClip(UTC(date, &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(date, &cx->runtime()->dateTimeInfo));
/* Steps 7-8. */
SetUTCTime(thisObj, u, args.rval().address());
@ -2153,7 +2153,7 @@ date_setDate_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime->dateTimeInfo);
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime()->dateTimeInfo);
/* Step 2. */
double dt;
@ -2164,7 +2164,7 @@ date_setDate_impl(JSContext *cx, CallArgs args)
double newDate = MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), TimeWithinDay(t));
/* Step 4. */
double u = TimeClip(UTC(newDate, &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(newDate, &cx->runtime()->dateTimeInfo));
/* Steps 5-6. */
SetUTCTime(thisObj, u, args.rval().address());
@ -2241,7 +2241,7 @@ date_setMonth_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime->dateTimeInfo);
double t = LocalTime(thisObj->getDateUTCTime().toNumber(), &cx->runtime()->dateTimeInfo);
/* Step 2. */
double m;
@ -2257,7 +2257,7 @@ date_setMonth_impl(JSContext *cx, CallArgs args)
double newDate = MakeDate(MakeDay(YearFromTime(t), m, dt), TimeWithinDay(t));
/* Step 5. */
double u = TimeClip(UTC(newDate, &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(newDate, &cx->runtime()->dateTimeInfo));
/* Steps 6-7. */
SetUTCTime(thisObj, u, args.rval().address());
@ -2335,7 +2335,7 @@ date_setFullYear_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = ThisLocalTimeOrZero(thisObj, &cx->runtime->dateTimeInfo);
double t = ThisLocalTimeOrZero(thisObj, &cx->runtime()->dateTimeInfo);
/* Step 2. */
double y;
@ -2356,7 +2356,7 @@ date_setFullYear_impl(JSContext *cx, CallArgs args)
double newDate = MakeDate(MakeDay(y, m, dt), TimeWithinDay(t));
/* Step 6. */
double u = TimeClip(UTC(newDate, &cx->runtime->dateTimeInfo));
double u = TimeClip(UTC(newDate, &cx->runtime()->dateTimeInfo));
/* Steps 7-8. */
SetUTCTime(thisObj, u, args.rval().address());
@ -2423,7 +2423,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
RootedObject thisObj(cx, &args.thisv().toObject());
/* Step 1. */
double t = ThisLocalTimeOrZero(thisObj, &cx->runtime->dateTimeInfo);
double t = ThisLocalTimeOrZero(thisObj, &cx->runtime()->dateTimeInfo);
/* Step 2. */
double y;
@ -2445,7 +2445,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
double day = MakeDay(yint, MonthFromTime(t), DateFromTime(t));
/* Step 6. */
double u = UTC(MakeDate(day, TimeWithinDay(t)), &cx->runtime->dateTimeInfo);
double u = UTC(MakeDate(day, TimeWithinDay(t)), &cx->runtime()->dateTimeInfo);
/* Steps 7-8. */
SetUTCTime(thisObj, TimeClip(u), args.rval().address());
@ -2648,11 +2648,11 @@ date_format(JSContext *cx, double date, formatspec format, MutableHandleValue rv
} else {
JS_ASSERT(TimeClip(date) == date);
double local = LocalTime(date, &cx->runtime->dateTimeInfo);
double local = LocalTime(date, &cx->runtime()->dateTimeInfo);
/* offset from GMT in minutes. The offset includes daylight savings,
if it applies. */
int minutes = (int) floor(AdjustTime(date, &cx->runtime->dateTimeInfo) / msPerMinute);
int minutes = (int) floor(AdjustTime(date, &cx->runtime()->dateTimeInfo) / msPerMinute);
/* map 510 minutes to 0830 hours */
int offset = (minutes / 60) * 100 + minutes % 60;
@ -2668,7 +2668,7 @@ date_format(JSContext *cx, double date, formatspec format, MutableHandleValue rv
/* get a timezone string from the OS to include as a
comment. */
new_explode(date, &split, &cx->runtime->dateTimeInfo);
new_explode(date, &split, &cx->runtime()->dateTimeInfo);
if (PRMJ_FormatTime(tzbuf, sizeof tzbuf, "(%Z)", &split) != 0) {
/* Decide whether to use the resulting timezone string.
@ -2758,9 +2758,9 @@ ToLocaleFormatHelper(JSContext *cx, HandleObject obj, const char *format, Mutabl
JS_snprintf(buf, sizeof buf, js_NaN_date_str);
} else {
int result_len;
double local = LocalTime(utctime, &cx->runtime->dateTimeInfo);
double local = LocalTime(utctime, &cx->runtime()->dateTimeInfo);
PRMJTime split;
new_explode(local, &split, &cx->runtime->dateTimeInfo);
new_explode(local, &split, &cx->runtime()->dateTimeInfo);
/* Let PRMJTime format it. */
result_len = PRMJ_FormatTime(buf, sizeof buf, format, &split);
@ -2784,8 +2784,8 @@ ToLocaleFormatHelper(JSContext *cx, HandleObject obj, const char *format, Mutabl
}
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeToUnicode)
return cx->runtime->localeCallbacks->localeToUnicode(cx, buf, rval);
if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeToUnicode)
return cx->runtime()->localeCallbacks->localeToUnicode(cx, buf, rval);
JSString *str = JS_NewStringCopyZ(cx, buf);
if (!str)
@ -3107,7 +3107,7 @@ js_Date(JSContext *cx, unsigned argc, Value *vp)
if (!linearStr)
return false;
if (!date_parseString(linearStr, &d, &cx->runtime->dateTimeInfo))
if (!date_parseString(linearStr, &d, &cx->runtime()->dateTimeInfo))
d = js_NaN;
else
d = TimeClip(d);
@ -3123,7 +3123,7 @@ js_Date(JSContext *cx, unsigned argc, Value *vp)
return false;
if (IsFinite(msec_time)) {
msec_time = UTC(msec_time, &cx->runtime->dateTimeInfo);
msec_time = UTC(msec_time, &cx->runtime()->dateTimeInfo);
msec_time = TimeClip(msec_time);
}
d = msec_time;
@ -3199,7 +3199,7 @@ js_NewDateObject(JSContext *cx, int year, int mon, int mday,
{
JS_ASSERT(mon < 12);
double msec_time = date_msecFromDate(year, mon, mday, hour, min, sec, 0);
return js_NewDateObjectMsec(cx, UTC(msec_time, &cx->runtime->dateTimeInfo));
return js_NewDateObjectMsec(cx, UTC(msec_time, &cx->runtime()->dateTimeInfo));
}
JS_FRIEND_API(JSBool)
@ -3213,7 +3213,7 @@ js_DateGetYear(JSContext *cx, JSObject *obj)
{
/* Preserve legacy API behavior of returning 0 for invalid dates. */
JS_ASSERT(obj);
double localtime = GetCachedLocalTime(&cx->runtime->dateTimeInfo, obj);
double localtime = GetCachedLocalTime(&cx->runtime()->dateTimeInfo, obj);
if (IsNaN(localtime))
return 0;
@ -3224,7 +3224,7 @@ JS_FRIEND_API(int)
js_DateGetMonth(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj);
double localtime = GetCachedLocalTime(&cx->runtime->dateTimeInfo, obj);
double localtime = GetCachedLocalTime(&cx->runtime()->dateTimeInfo, obj);
if (IsNaN(localtime))
return 0;
@ -3235,7 +3235,7 @@ JS_FRIEND_API(int)
js_DateGetDate(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj);
double localtime = GetCachedLocalTime(&cx->runtime->dateTimeInfo, obj);
double localtime = GetCachedLocalTime(&cx->runtime()->dateTimeInfo, obj);
if (IsNaN(localtime))
return 0;
@ -3246,7 +3246,7 @@ JS_FRIEND_API(int)
js_DateGetHours(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj);
double localtime = GetCachedLocalTime(&cx->runtime->dateTimeInfo, obj);
double localtime = GetCachedLocalTime(&cx->runtime()->dateTimeInfo, obj);
if (IsNaN(localtime))
return 0;
@ -3257,7 +3257,7 @@ JS_FRIEND_API(int)
js_DateGetMinutes(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj);
double localtime = GetCachedLocalTime(&cx->runtime->dateTimeInfo, obj);
double localtime = GetCachedLocalTime(&cx->runtime()->dateTimeInfo, obj);
if (IsNaN(localtime))
return 0;

View File

@ -50,13 +50,13 @@ using mozilla::PodZero;
JS_PUBLIC_API(JSBool)
JS_GetDebugMode(JSContext *cx)
{
return cx->compartment->debugMode();
return cx->compartment()->debugMode();
}
JS_PUBLIC_API(JSBool)
JS_SetDebugMode(JSContext *cx, JSBool debug)
{
return JS_SetDebugModeForCompartment(cx, cx->compartment, debug);
return JS_SetDebugModeForCompartment(cx, cx->compartment(), debug);
}
JS_PUBLIC_API(void)
@ -80,13 +80,13 @@ js::ScriptDebugPrologue(JSContext *cx, AbstractFramePtr frame)
if (!frame.script()->selfHosted) {
if (frame.isFramePushedByExecute()) {
if (JSInterpreterHook hook = cx->runtime->debugHooks.executeHook)
if (JSInterpreterHook hook = cx->runtime()->debugHooks.executeHook)
frame.setHookData(hook(cx, Jsvalify(frame), IsTopFrameConstructing(cx, frame),
true, 0, cx->runtime->debugHooks.executeHookData));
true, 0, cx->runtime()->debugHooks.executeHookData));
} else {
if (JSInterpreterHook hook = cx->runtime->debugHooks.callHook)
if (JSInterpreterHook hook = cx->runtime()->debugHooks.callHook)
frame.setHookData(hook(cx, Jsvalify(frame), IsTopFrameConstructing(cx, frame),
true, 0, cx->runtime->debugHooks.callHookData));
true, 0, cx->runtime()->debugHooks.callHookData));
}
}
@ -119,10 +119,10 @@ js::ScriptDebugEpilogue(JSContext *cx, AbstractFramePtr frame, bool okArg)
// We don't add hook data for self-hosted scripts, so we don't need to check for them, here.
if (void *hookData = frame.maybeHookData()) {
if (frame.isFramePushedByExecute()) {
if (JSInterpreterHook hook = cx->runtime->debugHooks.executeHook)
if (JSInterpreterHook hook = cx->runtime()->debugHooks.executeHook)
hook(cx, Jsvalify(frame), IsTopFrameConstructing(cx, frame), false, &ok, hookData);
} else {
if (JSInterpreterHook hook = cx->runtime->debugHooks.callHook)
if (JSInterpreterHook hook = cx->runtime()->debugHooks.callHook)
hook(cx, Jsvalify(frame), IsTopFrameConstructing(cx, frame), false, &ok, hookData);
}
}
@ -133,18 +133,18 @@ js::ScriptDebugEpilogue(JSContext *cx, AbstractFramePtr frame, bool okArg)
JSTrapStatus
js::DebugExceptionUnwind(JSContext *cx, AbstractFramePtr frame, jsbytecode *pc)
{
JS_ASSERT(cx->compartment->debugMode());
JS_ASSERT(cx->compartment()->debugMode());
if (!cx->runtime->debugHooks.throwHook && cx->compartment->getDebuggees().empty())
if (!cx->runtime()->debugHooks.throwHook && cx->compartment()->getDebuggees().empty())
return JSTRAP_CONTINUE;
/* Call debugger throw hook if set. */
RootedValue rval(cx);
JSTrapStatus status = Debugger::onExceptionUnwind(cx, &rval);
if (status == JSTRAP_CONTINUE) {
if (JSThrowHook handler = cx->runtime->debugHooks.throwHook) {
if (JSThrowHook handler = cx->runtime()->debugHooks.throwHook) {
RootedScript script(cx, frame.script());
status = handler(cx, script, pc, rval.address(), cx->runtime->debugHooks.throwHookData);
status = handler(cx, script, pc, rval.address(), cx->runtime()->debugHooks.throwHookData);
}
}
@ -175,9 +175,9 @@ js::DebugExceptionUnwind(JSContext *cx, AbstractFramePtr frame, jsbytecode *pc)
JS_FRIEND_API(JSBool)
JS_SetDebugModeForAllCompartments(JSContext *cx, JSBool debug)
{
AutoDebugModeGC dmgc(cx->runtime);
AutoDebugModeGC dmgc(cx->runtime());
for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) {
for (CompartmentsIter c(cx->runtime()); !c.done(); c.next()) {
// Ignore special compartments (atoms, JSD compartments)
if (c->principals) {
if (!c->setDebugModeFromC(cx, !!debug, dmgc))
@ -190,7 +190,7 @@ JS_SetDebugModeForAllCompartments(JSContext *cx, JSBool debug)
JS_FRIEND_API(JSBool)
JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug)
{
AutoDebugModeGC dmgc(cx->runtime);
AutoDebugModeGC dmgc(cx->runtime());
return comp->setDebugModeFromC(cx, !!debug, dmgc);
}
@ -235,7 +235,7 @@ JS_SetTrap(JSContext *cx, JSScript *scriptArg, jsbytecode *pc, JSTrapHandler han
BreakpointSite *site = script->getOrCreateBreakpointSite(cx, pc);
if (!site)
return false;
site->setTrap(cx->runtime->defaultFreeOp(), handler, closure);
site->setTrap(cx->runtime()->defaultFreeOp(), handler, closure);
return true;
}
@ -244,7 +244,7 @@ JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
JSTrapHandler *handlerp, jsval *closurep)
{
if (BreakpointSite *site = script->getBreakpointSite(pc)) {
site->clearTrap(cx->runtime->defaultFreeOp(), handlerp, closurep);
site->clearTrap(cx->runtime()->defaultFreeOp(), handlerp, closurep);
} else {
if (handlerp)
*handlerp = NULL;
@ -256,13 +256,13 @@ JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
JS_PUBLIC_API(void)
JS_ClearScriptTraps(JSContext *cx, JSScript *script)
{
script->clearTraps(cx->runtime->defaultFreeOp());
script->clearTraps(cx->runtime()->defaultFreeOp());
}
JS_PUBLIC_API(void)
JS_ClearAllTrapsForCompartment(JSContext *cx)
{
cx->compartment->clearTraps(cx->runtime->defaultFreeOp());
cx->compartment()->clearTraps(cx->runtime()->defaultFreeOp());
}
JS_PUBLIC_API(JSBool)
@ -339,14 +339,14 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj_, jsid id_,
types::MarkTypePropertyConfigured(cx, obj, propid);
WatchpointMap *wpmap = cx->compartment->watchpointMap;
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
if (!wpmap) {
wpmap = cx->runtime->new_<WatchpointMap>();
wpmap = cx->runtime()->new_<WatchpointMap>();
if (!wpmap || !wpmap->init()) {
js_ReportOutOfMemory(cx);
return false;
}
cx->compartment->watchpointMap = wpmap;
cx->compartment()->watchpointMap = wpmap;
}
return wpmap->watch(cx, obj, propid, handler, closure);
}
@ -357,7 +357,7 @@ JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
{
assertSameCompartment(cx, obj, id);
if (WatchpointMap *wpmap = cx->compartment->watchpointMap)
if (WatchpointMap *wpmap = cx->compartment()->watchpointMap)
wpmap->unwatch(obj, id, handlerp, closurep);
return true;
}
@ -367,7 +367,7 @@ JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj)
{
assertSameCompartment(cx, obj);
if (WatchpointMap *wpmap = cx->compartment->watchpointMap)
if (WatchpointMap *wpmap = cx->compartment()->watchpointMap)
wpmap->unwatchObject(obj);
return true;
}
@ -375,7 +375,7 @@ JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj)
JS_PUBLIC_API(JSBool)
JS_ClearAllWatchPoints(JSContext *cx)
{
if (JSCompartment *comp = cx->compartment) {
if (JSCompartment *comp = cx->compartment()) {
if (WatchpointMap *wpmap = comp->watchpointMap)
wpmap->clear();
}
@ -765,10 +765,10 @@ JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda)
pd = pda->array;
for (i = 0; i < pda->length; i++) {
js_RemoveRoot(cx->runtime, &pd[i].id);
js_RemoveRoot(cx->runtime, &pd[i].value);
js_RemoveRoot(cx->runtime(), &pd[i].id);
js_RemoveRoot(cx->runtime(), &pd[i].value);
if (pd[i].flags & JSPD_ALIAS)
js_RemoveRoot(cx->runtime, &pd[i].alias);
js_RemoveRoot(cx->runtime(), &pd[i].alias);
}
js_free(pd);
pda->array = NULL;
@ -892,7 +892,7 @@ JS_PUBLIC_API(void)
JS_DumpCompartmentBytecode(JSContext *cx)
{
ScriptsToDump scripts;
IterateScripts(cx->runtime, cx->compartment, &scripts, DumpBytecodeScriptCallback);
IterateScripts(cx->runtime(), cx->compartment(), &scripts, DumpBytecodeScriptCallback);
for (size_t i = 0; i < scripts.length(); i++) {
if (scripts[i]->enclosingScriptsCompiledSuccessfully())
@ -905,7 +905,7 @@ JS_DumpCompartmentPCCounts(JSContext *cx)
{
for (CellIter i(cx->zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
JSScript *script = i.get<JSScript>();
if (script->compartment() != cx->compartment)
if (script->compartment() != cx->compartment())
continue;
if (script->hasScriptCounts && script->enclosingScriptsCompiledSuccessfully())
@ -916,7 +916,7 @@ JS_DumpCompartmentPCCounts(JSContext *cx)
for (unsigned thingKind = FINALIZE_OBJECT0; thingKind < FINALIZE_OBJECT_LIMIT; thingKind++) {
for (CellIter i(cx->zone(), (AllocKind) thingKind); !i.done(); i.next()) {
JSObject *obj = i.get<JSObject>();
if (obj->compartment() != cx->compartment)
if (obj->compartment() != cx->compartment())
continue;
if (IsAsmJSModuleObject(obj)) {

View File

@ -252,7 +252,7 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
JS_ASSERT(exnObject->isError());
JS_ASSERT(!exnObject->getPrivate());
JSCheckAccessOp checkAccess = cx->runtime->securityCallbacks->checkObjectAccess;
JSCheckAccessOp checkAccess = cx->runtime()->securityCallbacks->checkObjectAccess;
Vector<JSStackTraceStackElem> frames(cx);
{
@ -274,7 +274,7 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
if (i.isNonEvalFunctionFrame()) {
JSAtom *atom = i.callee()->displayAtom();
if (atom == NULL)
atom = cx->runtime->emptyString;
atom = cx->runtime()->emptyString;
frame.funName = atom;
} else {
frame.funName = NULL;
@ -579,7 +579,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
return false;
args[1].setString(filename);
} else {
filename = cx->runtime->emptyString;
filename = cx->runtime()->emptyString;
if (!iter.done()) {
if (const char *cfilename = script->filename()) {
filename = FilenameToString(cx, cfilename);
@ -645,7 +645,7 @@ exn_toString(JSContext *cx, unsigned argc, Value *vp)
/* Step 6. */
RootedString message(cx);
if (msgVal.isUndefined()) {
message = cx->runtime->emptyString;
message = cx->runtime()->emptyString;
} else {
message = ToString<CanGC>(cx, msgVal);
if (!message)
@ -791,7 +791,7 @@ InitErrorClass(JSContext *cx, Handle<GlobalObject*> global, int type, HandleObje
RootedValue nameValue(cx, StringValue(name));
RootedValue zeroValue(cx, Int32Value(0));
RootedValue empty(cx, StringValue(cx->runtime->emptyString));
RootedValue empty(cx, StringValue(cx->runtime()->emptyString));
RootedId nameId(cx, NameToId(cx->names().name));
RootedId messageId(cx, NameToId(cx->names().message));
RootedId fileNameId(cx, NameToId(cx->names().fileName));
@ -865,9 +865,9 @@ js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *locale,
{
const JSErrorFormatString *errorString = NULL;
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeGetErrorMessage) {
errorString = cx->runtime->localeCallbacks
->localeGetErrorMessage(userRef, locale, errorNumber);
if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeGetErrorMessage) {
errorString = cx->runtime()->localeCallbacks
->localeGetErrorMessage(userRef, locale, errorNumber);
}
if (!errorString)
errorString = js_GetErrorMessage(userRef, locale, errorNumber);
@ -1160,11 +1160,11 @@ js_CopyErrorObject(JSContext *cx, HandleObject errobj, HandleObject scope)
ScopedJSFreePtr<JSErrorReport> autoFreeErrorReport(copy->errorReport);
copy->message.init(priv->message);
if (!cx->compartment->wrap(cx, &copy->message))
if (!cx->compartment()->wrap(cx, &copy->message))
return NULL;
JS::Anchor<JSString *> messageAnchor(copy->message);
copy->filename.init(priv->filename);
if (!cx->compartment->wrap(cx, &copy->filename))
if (!cx->compartment()->wrap(cx, &copy->filename))
return NULL;
JS::Anchor<JSString *> filenameAnchor(copy->filename);
copy->lineno = priv->lineno;

View File

@ -241,13 +241,13 @@ JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals
JS_FRIEND_API(JSBool)
JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc)
{
return cx->compartment->wrap(cx, desc);
return cx->compartment()->wrap(cx, desc);
}
JS_FRIEND_API(JSBool)
JS_WrapAutoIdVector(JSContext *cx, js::AutoIdVector &props)
{
return cx->compartment->wrap(cx, props);
return cx->compartment()->wrap(cx, props);
}
JS_FRIEND_API(void)
@ -272,7 +272,7 @@ JS_FRIEND_API(bool)
JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *objArg, const JSFunctionSpecWithHelp *fs)
{
RootedObject obj(cx, objArg);
JS_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -302,7 +302,7 @@ JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *objArg, const JSFunctionSpec
AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx(cx), oldCompartment(cx->compartment)
: cx(cx), oldCompartment(cx->compartment())
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx->setCompartment(newCompartment);
@ -310,7 +310,7 @@ AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSCompartment *newCo
AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSHandleObject target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx(cx), oldCompartment(cx->compartment)
: cx(cx), oldCompartment(cx->compartment())
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx->setCompartment(target->compartment());
@ -385,7 +385,7 @@ js::GetObjectSlotSpan(JSObject *obj)
JS_FRIEND_API(bool)
js::IsObjectInContextCompartment(JSObject *obj, const JSContext *cx)
{
return obj->compartment() == cx->compartment;
return obj->compartment() == cx->compartment();
}
JS_FRIEND_API(bool)
@ -418,7 +418,7 @@ js::DefineFunctionWithReserved(JSContext *cx, JSObject *objArg, const char *name
unsigned nargs, unsigned attrs)
{
RootedObject obj(cx, objArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
JSAtom *atom = Atomize(cx, name, strlen(name));
@ -433,7 +433,7 @@ js::NewFunctionWithReserved(JSContext *cx, JSNative native, unsigned nargs, unsi
JSObject *parentArg, const char *name)
{
RootedObject parent(cx, parentArg);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
CHECK_REQUEST(cx);
assertSameCompartment(cx, parent);
@ -456,7 +456,7 @@ js::NewFunctionByIdWithReserved(JSContext *cx, JSNative native, unsigned nargs,
{
RootedObject parent(cx, parentArg);
JS_ASSERT(JSID_IS_STRING(id));
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
CHECK_REQUEST(cx);
assertSameCompartment(cx, parent);
@ -744,23 +744,23 @@ js::DumpHeapComplete(JSRuntime *rt, FILE *fp)
JS_FRIEND_API(const JSStructuredCloneCallbacks *)
js::GetContextStructuredCloneCallbacks(JSContext *cx)
{
return cx->runtime->structuredCloneCallbacks;
return cx->runtime()->structuredCloneCallbacks;
}
JS_FRIEND_API(bool)
js::CanCallContextDebugHandler(JSContext *cx)
{
return !!cx->runtime->debugHooks.debuggerHandler;
return !!cx->runtime()->debugHooks.debuggerHandler;
}
JS_FRIEND_API(JSTrapStatus)
js::CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval)
{
if (!cx->runtime->debugHooks.debuggerHandler)
if (!cx->runtime()->debugHooks.debuggerHandler)
return JSTRAP_RETURN;
return cx->runtime->debugHooks.debuggerHandler(cx, script, bc, rval,
cx->runtime->debugHooks.debuggerHandlerData);
return cx->runtime()->debugHooks.debuggerHandler(cx, script, bc, rval,
cx->runtime()->debugHooks.debuggerHandlerData);
}
#ifdef JS_THREADSAFE
@ -888,7 +888,7 @@ JS::IsIncrementalBarrierNeeded(JSRuntime *rt)
JS_FRIEND_API(bool)
JS::IsIncrementalBarrierNeeded(JSContext *cx)
{
return IsIncrementalBarrierNeeded(cx->runtime);
return IsIncrementalBarrierNeeded(cx->runtime());
}
JS_FRIEND_API(void)
@ -1049,7 +1049,7 @@ js::AutoCTypesActivityCallback::AutoCTypesActivityCallback(JSContext *cx,
js::CTypesActivityType beginType,
js::CTypesActivityType endType
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx(cx), callback(cx->runtime->ctypesActivityCallback), endType(endType)
: cx(cx), callback(cx->runtime()->ctypesActivityCallback), endType(endType)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
@ -1062,9 +1062,9 @@ js::SetObjectMetadataCallback(JSContext *cx, ObjectMetadataCallback callback)
{
// Clear any jitcode in the runtime, which behaves differently depending on
// whether there is a creation callback.
ReleaseAllJITCode(cx->runtime->defaultFreeOp());
ReleaseAllJITCode(cx->runtime()->defaultFreeOp());
cx->compartment->objectMetadataCallback = callback;
cx->compartment()->objectMetadataCallback = callback;
}
JS_FRIEND_API(bool)
@ -1085,7 +1085,7 @@ js_DefineOwnProperty(JSContext *cx, JSObject *objArg, jsid idArg,
{
RootedObject obj(cx, objArg);
RootedId id(cx, idArg);
JS_ASSERT(cx->runtime->heapState == js::Idle);
JS_ASSERT(cx->runtime()->heapState == js::Idle);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id, descriptor.value);
if (descriptor.attrs & JSPROP_GETTER)

View File

@ -192,13 +192,13 @@ extern mozilla::ThreadLocal<PerThreadData *> TlsPerThreadData;
inline JSRuntime *
GetRuntime(const JSContext *cx)
{
return ContextFriendFields::get(cx)->runtime;
return ContextFriendFields::get(cx)->runtime_;
}
inline JSCompartment *
GetContextCompartment(const JSContext *cx)
{
return ContextFriendFields::get(cx)->compartment;
return ContextFriendFields::get(cx)->compartment_;
}
inline JS::Zone *

View File

@ -123,7 +123,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
else
vp.set(iter.calleev());
if (!cx->compartment->wrap(cx, vp))
if (!cx->compartment()->wrap(cx, vp))
return false;
/*
@ -181,7 +181,7 @@ fun_enumerate(JSContext *cx, HandleObject obj)
for (unsigned i = 0; i < ArrayLength(poisonPillProps); i++) {
const uint16_t offset = poisonPillProps[i];
id = NameToId(OFFSET_TO_NAME(cx->runtime, offset));
id = NameToId(OFFSET_TO_NAME(cx->runtime(), offset));
if (!JSObject::hasProperty(cx, obj, id, &found, 0))
return false;
}
@ -278,7 +278,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
uint16_t ndefaults = fun->hasScript() ? fun->nonLazyScript()->ndefaults : 0;
v.setInt32(fun->nargs - ndefaults - fun->hasRest());
} else {
v.setString(fun->atom() == NULL ? cx->runtime->emptyString : fun->atom());
v.setString(fun->atom() == NULL ? cx->runtime()->emptyString : fun->atom());
}
if (!DefineNativeProperty(cx, fun, id, v, JS_PropertyStub, JS_StrictPropertyStub,
@ -292,7 +292,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
for (unsigned i = 0; i < ArrayLength(poisonPillProps); i++) {
const uint16_t offset = poisonPillProps[i];
if (JSID_IS_ATOM(id, OFFSET_TO_NAME(cx->runtime, offset))) {
if (JSID_IS_ATOM(id, OFFSET_TO_NAME(cx->runtime(), offset))) {
JS_ASSERT(!IsInternalFunctionObject(fun));
PropertyOp getter;
@ -518,7 +518,7 @@ FindBody(JSContext *cx, HandleFunction fun, StableCharPtr chars, size_t length,
CompileOptions options(cx);
options.setFileAndLine("internal-findBody", 0)
.setVersion(fun->nonLazyScript()->getVersion());
AutoKeepAtoms keepAtoms(cx->runtime);
AutoKeepAtoms keepAtoms(cx->runtime());
TokenStream ts(cx, options, chars.get(), length, NULL, keepAtoms);
int nest = 0;
bool onward = true;
@ -1107,7 +1107,7 @@ JSFunction::createScriptForLazilyInterpretedFunction(JSContext *cx, HandleFuncti
if (!funAtom)
return false;
Rooted<PropertyName *> funName(cx, funAtom->asPropertyName());
return cx->runtime->cloneSelfHostedFunctionScript(cx, funName, fun);
return cx->runtime()->cloneSelfHostedFunctionScript(cx, funName, fun);
}
/* ES5 15.3.4.5.1 and 15.3.4.5.2. */
@ -1293,7 +1293,7 @@ js::Function(JSContext *cx, unsigned argc, Value *vp)
return false;
}
AutoKeepAtoms keepAtoms(cx->runtime);
AutoKeepAtoms keepAtoms(cx->runtime());
AutoNameVector formals(cx);
bool hasRest = false;
@ -1443,7 +1443,7 @@ js::Function(JSContext *cx, unsigned argc, Value *vp)
RootedString str(cx);
if (!args.length())
str = cx->runtime->emptyString;
str = cx->runtime()->emptyString;
else
str = ToString<CanGC>(cx, args.handleAt(args.length() - 1));
if (!str)
@ -1537,7 +1537,7 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
JS_ASSERT(parent);
JS_ASSERT(!fun->isBoundFunction());
bool useSameScript = cx->compartment == fun->compartment() &&
bool useSameScript = cx->compartment() == fun->compartment() &&
!fun->hasSingletonType() &&
!types::UseNewTypeForClone(fun);
@ -1567,7 +1567,7 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
if (allocKind == JSFunction::ExtendedFinalizeKind) {
clone->flags |= JSFunction::EXTENDED;
if (fun->isExtended() && fun->compartment() == cx->compartment) {
if (fun->isExtended() && fun->compartment() == cx->compartment()) {
for (unsigned i = 0; i < FunctionExtended::NUM_EXTENDED_SLOTS; i++)
clone->initExtendedSlot(i, fun->getExtendedSlot(i));
} else {

View File

@ -1031,7 +1031,7 @@ template <typename T>
static bool
AddRoot(JSContext *cx, T *rp, const char *name, JSGCRootType rootType)
{
bool ok = AddRoot(cx->runtime, rp, name, rootType);
bool ok = AddRoot(cx->runtime(), rp, name, rootType);
if (!ok)
JS_ReportOutOfMemory(cx);
return ok;
@ -1471,7 +1471,7 @@ RunLastDitchGC(JSContext *cx, JS::Zone *zone, AllocKind thingKind)
PrepareZoneForGC(zone);
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
/* The last ditch GC preserves all atoms. */
AutoKeepAtoms keep(rt);
@ -1958,7 +1958,7 @@ js::TriggerZoneGC(Zone *zone, JS::gcreason::Reason reason)
void
js::MaybeGC(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
rt->assertValidThread();
if (rt->gcZeal() == ZealAllocValue || rt->gcZeal() == ZealPokeValue) {
@ -4701,7 +4701,7 @@ AutoPrepareForTracing::AutoPrepareForTracing(JSRuntime *rt)
JSCompartment *
js::NewCompartment(JSContext *cx, Zone *zone, JSPrincipals *principals)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
JS_AbortIfWrongThread(rt);
ScopedJSDeletePtr<Zone> zoneHolder;
@ -4748,12 +4748,12 @@ void
gc::RunDebugGC(JSContext *cx)
{
#ifdef JS_GC_ZEAL
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (rt->mainThread.suppressGC)
return;
PrepareForDebugGC(cx->runtime);
PrepareForDebugGC(cx->runtime());
int type = rt->gcZeal();
if (type == ZealIncrementalRootsThenFinish ||
@ -4790,7 +4790,7 @@ gc::RunDebugGC(JSContext *cx)
rt->gcIncrementalLimit = rt->gcZealFrequency / 2;
}
} else if (type == ZealPurgeAnalysisValue) {
cx->compartment->types.maybePurgeAnalysis(cx, /* force = */ true);
cx->compartment()->types.maybePurgeAnalysis(cx, /* force = */ true);
} else {
Collect(rt, false, SliceBudget::Unlimited, GC_NORMAL, JS::gcreason::DEBUG_GC);
}
@ -4802,7 +4802,7 @@ void
gc::SetDeterministicGC(JSContext *cx, bool enabled)
{
#ifdef JS_GC_ZEAL
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
rt->gcDeterministicOnly = enabled;
#endif
}
@ -4810,14 +4810,14 @@ gc::SetDeterministicGC(JSContext *cx, bool enabled)
void
gc::SetValidateGC(JSContext *cx, bool enabled)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
rt->gcValidate = enabled;
}
void
gc::SetFullCompartmentChecks(JSContext *cx, bool enabled)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
rt->gcFullCompartmentChecks = enabled;
}
@ -4906,7 +4906,7 @@ ReleaseScriptCounts(FreeOp *fop)
JS_FRIEND_API(void)
js::StartPCCountProfiling(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (rt->profilingScripts)
return;
@ -4922,7 +4922,7 @@ js::StartPCCountProfiling(JSContext *cx)
JS_FRIEND_API(void)
js::StopPCCountProfiling(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (!rt->profilingScripts)
return;
@ -4954,7 +4954,7 @@ js::StopPCCountProfiling(JSContext *cx)
JS_FRIEND_API(void)
js::PurgePCCounts(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (!rt->scriptAndCountsVector)
return;
@ -5036,7 +5036,7 @@ ArenaLists::containsArena(JSRuntime *rt, ArenaHeader *needle)
AutoMaybeTouchDeadZones::AutoMaybeTouchDeadZones(JSContext *cx)
: runtime(cx->runtime),
: runtime(cx->runtime()),
markCount(runtime->gcObjectsMarkedInDeadZones),
inIncremental(JS::IsIncrementalGCInProgress(runtime)),
manipulatingDeadZones(runtime->gcManipulatingDeadZones)
@ -5064,7 +5064,7 @@ AutoMaybeTouchDeadZones::~AutoMaybeTouchDeadZones()
}
AutoSuppressGC::AutoSuppressGC(JSContext *cx)
: suppressGC_(cx->runtime->mainThread.suppressGC)
: suppressGC_(cx->runtime()->mainThread.suppressGC)
{
suppressGC_++;
}

View File

@ -504,18 +504,18 @@ inline T *
NewGCThing(JSContext *cx, AllocKind kind, size_t thingSize, InitialHeap heap)
{
JS_ASSERT(thingSize == js::gc::Arena::thingSize(kind));
JS_ASSERT_IF(cx->compartment == cx->runtime->atomsCompartment,
JS_ASSERT_IF(cx->compartment() == cx->runtime()->atomsCompartment,
kind == FINALIZE_STRING ||
kind == FINALIZE_SHORT_STRING ||
kind == FINALIZE_IONCODE);
JS_ASSERT(!cx->runtime->isHeapBusy());
JS_ASSERT(!cx->runtime->noGCOrAllocationCheck);
JS_ASSERT(!cx->runtime()->isHeapBusy());
JS_ASSERT(!cx->runtime()->noGCOrAllocationCheck);
/* For testing out of memory conditions */
JS_OOM_POSSIBLY_FAIL_REPORT(cx);
#ifdef JS_GC_ZEAL
if (cx->runtime->needZealousGC() && allowGC)
if (cx->runtime()->needZealousGC() && allowGC)
js::gc::RunDebugGC(cx);
#endif
@ -523,7 +523,7 @@ NewGCThing(JSContext *cx, AllocKind kind, size_t thingSize, InitialHeap heap)
MaybeCheckStackRoots(cx);
#if defined(JSGC_GENERATIONAL)
if (ShouldNurseryAllocate(cx->runtime->gcNursery, kind, heap)) {
if (ShouldNurseryAllocate(cx->runtime()->gcNursery, kind, heap)) {
T *t = TryNewNurseryGCThing<T, allowGC>(cx, thingSize);
if (t)
return t;

View File

@ -258,7 +258,7 @@ types::TypeHasProperty(JSContext *cx, TypeObject *obj, jsid id, const Value &val
* middle of resolving a standard class and the type sets will not be updated
* until the outer TypeSet::add finishes.
*/
if (cx->compartment->types.pendingCount)
if (cx->compartment()->types.pendingCount)
return true;
Type type = GetValueType(cx, value);
@ -306,7 +306,7 @@ types::TypeFailure(JSContext *cx, const char *fmt, ...)
JS_snprintf(msgbuf, sizeof(msgbuf), "[infer failure] %s", errbuf);
/* Dump type state, even if INFERFLAGS is unset. */
cx->compartment->types.print(cx, true);
cx->compartment()->types.print(cx, true);
MOZ_ReportAssertionFailure(msgbuf, __FILE__, __LINE__);
MOZ_CRASH();
@ -426,21 +426,21 @@ TypeSet::addTypesToConstraint(JSContext *cx, TypeConstraint *constraint)
/* If any type is possible, there's no need to worry about specifics. */
if (flags & TYPE_FLAG_UNKNOWN) {
if (!types.append(Type::UnknownType()))
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
} else {
/* Enqueue type set members stored as bits. */
for (TypeFlags flag = 1; flag < TYPE_FLAG_ANYOBJECT; flag <<= 1) {
if (flags & flag) {
Type type = Type::PrimitiveType(TypeFlagPrimitive(flag));
if (!types.append(type))
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
}
}
/* If any object is possible, skip specifics. */
if (flags & TYPE_FLAG_ANYOBJECT) {
if (!types.append(Type::AnyObjectType()))
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
} else {
/* Enqueue specific object types. */
unsigned count = getObjectCount();
@ -448,7 +448,7 @@ TypeSet::addTypesToConstraint(JSContext *cx, TypeConstraint *constraint)
TypeObjectKey *object = getObject(i);
if (object) {
if (!types.append(Type::ObjectType(object)))
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
}
}
}
@ -463,11 +463,11 @@ TypeSet::add(JSContext *cx, TypeConstraint *constraint, bool callExisting)
{
if (!constraint) {
/* OOM failure while constructing the constraint. */
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
InferSpew(ISpewOps, "addConstraint: %sT%p%s %sC%p%s %s",
InferSpewColor(this), this, InferSpewColorReset(),
@ -534,11 +534,11 @@ TypeSet::print()
StackTypeSet *
StackTypeSet::make(JSContext *cx, const char *name)
{
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
StackTypeSet *res = cx->analysisLifoAlloc().new_<StackTypeSet>();
if (!res) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return NULL;
}
@ -1005,9 +1005,9 @@ void ScriptAnalysis::breakTypeBarriers(JSContext *cx, uint32_t offset, bool all)
{
pruneTypeBarriers(cx, offset);
bool resetResolving = !cx->compartment->types.resolving;
bool resetResolving = !cx->compartment()->types.resolving;
if (resetResolving)
cx->compartment->types.resolving = true;
cx->compartment()->types.resolving = true;
TypeBarrier **pbarrier = &getCode(offset).typeBarriers;
while (*pbarrier) {
@ -1036,8 +1036,8 @@ void ScriptAnalysis::breakTypeBarriers(JSContext *cx, uint32_t offset, bool all)
}
if (resetResolving) {
cx->compartment->types.resolving = false;
cx->compartment->types.resolvePending(cx);
cx->compartment()->types.resolving = false;
cx->compartment()->types.resolvePending(cx);
}
}
@ -1134,7 +1134,7 @@ GetPropertyObject(JSContext *cx, HandleScript script, Type type)
}
if (!object)
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return object;
}
@ -1324,7 +1324,7 @@ TypeConstraintProp<access>::newType(JSContext *cx, TypeSet *source, Type type)
* need to be monitored.
*/
if (access == PROPERTY_WRITE)
cx->compartment->types.monitorBytecode(cx, script, pc - script->code);
cx->compartment()->types.monitorBytecode(cx, script, pc - script->code);
else
MarkPropertyAccessUnknown(cx, script, pc, target);
return;
@ -1361,14 +1361,14 @@ TypeConstraintCallProp<access>::newType(JSContext *cx, TypeSet *source, Type typ
*/
if (UnknownPropertyAccess(script, type)) {
cx->compartment->types.monitorBytecode(cx, script, callpc - script->code);
cx->compartment()->types.monitorBytecode(cx, script, callpc - script->code);
return;
}
TypeObject *object = GetPropertyObject(cx, script, type);
if (object) {
if (object->unknownProperties()) {
cx->compartment->types.monitorBytecode(cx, script, callpc - script->code);
cx->compartment()->types.monitorBytecode(cx, script, callpc - script->code);
} else {
TypeSet *types = object->getProperty(cx, id, false);
if (!types)
@ -1425,7 +1425,7 @@ TypeConstraintCall::newType(JSContext *cx, TypeSet *source, Type type)
if (type.isUnknown() || type.isAnyObject()) {
/* Monitor calls on unknown functions. */
cx->compartment->types.monitorBytecode(cx, script, pc - script->code);
cx->compartment()->types.monitorBytecode(cx, script, pc - script->code);
return;
}
@ -1446,7 +1446,7 @@ TypeConstraintCall::newType(JSContext *cx, TypeSet *source, Type type)
* specialized inline code or stub calls for a specific natives and
* knows about the behavior of that native.
*/
cx->compartment->types.monitorBytecode(cx, script, pc - script->code, true);
cx->compartment()->types.monitorBytecode(cx, script, pc - script->code, true);
/*
* Add type constraints capturing the possible behavior of
@ -1584,7 +1584,7 @@ TypeConstraintPropagateThis::newType(JSContext *cx, TypeSet *source, Type type)
* CALLPROP, for other calls we are past the type barrier and a
* TypeConstraintCall will also monitor the call.
*/
cx->compartment->types.monitorBytecode(cx, script, callpc - script->code);
cx->compartment()->types.monitorBytecode(cx, script, callpc - script->code);
return;
}
@ -1728,7 +1728,7 @@ TypeConstraintTransformThis::newType(JSContext *cx, TypeSet *source, Type type)
}
if (!object) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -1760,7 +1760,7 @@ class TypeConstraintFreeze : public TypeConstraint
return;
typeAdded = true;
cx->compartment->types.addPendingRecompile(cx, info);
cx->compartment()->types.addPendingRecompile(cx, info);
}
};
@ -1768,7 +1768,7 @@ void
HeapTypeSet::addFreeze(JSContext *cx)
{
add(cx, cx->typeLifoAlloc().new_<TypeConstraintFreeze>(
cx->compartment->types.compiledInfo), false);
cx->compartment()->types.compiledInfo), false);
}
static inline JSValueType
@ -1884,7 +1884,7 @@ class TypeConstraintFreezeObjectFlags : public TypeConstraint
{
if (!marked && (object->hasAnyFlags(flags) || (!flags && force))) {
marked = true;
cx->compartment->types.addPendingRecompile(cx, info);
cx->compartment()->types.addPendingRecompile(cx, info);
}
}
};
@ -1923,7 +1923,7 @@ StackTypeSet::hasObjectFlags(JSContext *cx, TypeObjectFlags flags)
if (!types)
return true;
types->add(cx, cx->typeLifoAlloc().new_<TypeConstraintFreezeObjectFlags>(
cx->compartment->types.compiledInfo, flags), false);
cx->compartment()->types.compiledInfo, flags), false);
}
return false;
@ -1939,7 +1939,7 @@ HeapTypeSet::HasObjectFlags(JSContext *cx, TypeObject *object, TypeObjectFlags f
if (!types)
return true;
types->add(cx, cx->typeLifoAlloc().new_<TypeConstraintFreezeObjectFlags>(
cx->compartment->types.compiledInfo, flags), false);
cx->compartment()->types.compiledInfo, flags), false);
return false;
}
@ -1978,7 +1978,7 @@ HeapTypeSet::WatchObjectStateChange(JSContext *cx, TypeObject *obj)
* called, which will set 'force' to true.
*/
types->add(cx, cx->typeLifoAlloc().new_<TypeConstraintFreezeObjectFlags>(
cx->compartment->types.compiledInfo,
cx->compartment()->types.compiledInfo,
0));
}
@ -2004,7 +2004,7 @@ class TypeConstraintFreezeOwnProperty : public TypeConstraint
return;
if (source->ownProperty(configurable)) {
updated = true;
cx->compartment->types.addPendingRecompile(cx, info);
cx->compartment()->types.addPendingRecompile(cx, info);
}
}
};
@ -2036,7 +2036,7 @@ HeapTypeSet::isOwnProperty(JSContext *cx, TypeObject *object, bool configurable)
return true;
add(cx, cx->typeLifoAlloc().new_<TypeConstraintFreezeOwnProperty>(
cx->compartment->types.compiledInfo,
cx->compartment()->types.compiledInfo,
configurable), false);
return false;
}
@ -2366,18 +2366,18 @@ AddPendingRecompile(JSContext *cx, JSScript *script, jsbytecode *pc,
* compiled with the specified information.
*/
if (!JITCodeHasCheck(script, pc, kind))
cx->compartment->types.addPendingRecompile(cx, script, pc);
cx->compartment()->types.addPendingRecompile(cx, script, pc);
/*
* Remind Ion not to save the compile code if generating type
* inference information mid-compilation causes an invalidation of the
* script being compiled.
*/
RecompileInfo& info = cx->compartment->types.compiledInfo;
RecompileInfo& info = cx->compartment()->types.compiledInfo;
if (info.outputIndex != RecompileInfo::NoCompilerRunning) {
CompilerOutput *co = info.compilerOutput(cx);
if (!co) {
if (script->compartment() != cx->compartment)
if (script->compartment() != cx->compartment())
MOZ_CRASH();
return;
}
@ -2441,7 +2441,7 @@ TypeZone::init(JSContext *cx)
{
if (!cx ||
!cx->hasOption(JSOPTION_TYPE_INFERENCE) ||
!cx->runtime->jitSupportsFloatingPoint)
!cx->runtime()->jitSupportsFloatingPoint)
{
return;
}
@ -2452,7 +2452,7 @@ TypeZone::init(JSContext *cx)
TypeObject *
TypeCompartment::newTypeObject(JSContext *cx, Class *clasp, Handle<TaggedProto> proto, bool unknown)
{
JS_ASSERT_IF(proto.isObject(), cx->compartment == proto.toObject()->compartment());
JS_ASSERT_IF(proto.isObject(), cx->compartment() == proto.toObject()->compartment());
TypeObject *object = gc::NewGCThing<TypeObject, CanGC>(cx, gc::FINALIZE_TYPE_OBJECT,
sizeof(TypeObject), gc::TenuredHeap);
@ -2549,7 +2549,7 @@ TypeCompartment::addAllocationSiteTypeObject(JSContext *cx, AllocationSiteKey ke
if (!allocationSiteTable) {
allocationSiteTable = cx->new_<AllocationSiteTable>();
if (!allocationSiteTable || !allocationSiteTable->init()) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return NULL;
}
}
@ -2573,7 +2573,7 @@ TypeCompartment::addAllocationSiteTypeObject(JSContext *cx, AllocationSiteKey ke
nkey.offset = prev - key.script->code;
nkey.kind = JSProto_Array;
AllocationSiteTable::Ptr p = cx->compartment->types.allocationSiteTable->lookup(nkey);
AllocationSiteTable::Ptr p = cx->compartment()->types.allocationSiteTable->lookup(nkey);
if (p)
res = p->value;
}
@ -2586,7 +2586,7 @@ TypeCompartment::addAllocationSiteTypeObject(JSContext *cx, AllocationSiteKey ke
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
res = newTypeObject(cx, GetClassForProtoKey(key.kind), tagged);
if (!res) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return NULL;
}
key.script = keyScript;
@ -2605,7 +2605,7 @@ TypeCompartment::addAllocationSiteTypeObject(JSContext *cx, AllocationSiteKey ke
}
if (!allocationSiteTable->add(p, key, res)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return NULL;
}
@ -2767,7 +2767,7 @@ TypeCompartment::growPendingArray(JSContext *cx)
unsigned newCapacity = js::Max(unsigned(100), pendingCapacity * 2);
PendingWork *newArray = js_pod_calloc<PendingWork>(newCapacity);
if (!newArray) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return false;
}
@ -2813,7 +2813,7 @@ TypeCompartment::setPendingNukeTypes(JSContext *cx)
{
TypeZone *zone = &compartment()->zone()->types;
if (!zone->pendingNukeTypes) {
if (cx->compartment)
if (cx->compartment())
js_ReportOutOfMemory(cx);
zone->pendingNukeTypes = true;
}
@ -2875,7 +2875,7 @@ TypeCompartment::addPendingRecompile(JSContext *cx, const RecompileInfo &info)
return;
if (co->isValid())
CancelOffThreadIonCompile(cx->compartment, co->script);
CancelOffThreadIonCompile(cx->compartment(), co->script);
if (!co->isValid()) {
JS_ASSERT(co->script == NULL);
@ -2892,7 +2892,7 @@ TypeCompartment::addPendingRecompile(JSContext *cx, const RecompileInfo &info)
if (!pendingRecompiles) {
pendingRecompiles = cx->new_< Vector<RecompileInfo> >(cx);
if (!pendingRecompiles) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
}
@ -2905,7 +2905,7 @@ TypeCompartment::addPendingRecompile(JSContext *cx, const RecompileInfo &info)
#endif
if (!pendingRecompiles->append(info)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -2922,7 +2922,7 @@ TypeCompartment::addPendingRecompile(JSContext *cx, JSScript *script, jsbytecode
return;
#ifdef JS_ION
CancelOffThreadIonCompile(cx->compartment, script);
CancelOffThreadIonCompile(cx->compartment(), script);
// Let the script warm up again before attempting another compile.
if (ion::IsBaselineEnabled(cx))
@ -2971,7 +2971,7 @@ TypeCompartment::monitorBytecode(JSContext *cx, JSScript *script, uint32_t offse
void
TypeCompartment::markSetsUnknown(JSContext *cx, TypeObject *target)
{
JS_ASSERT(this == &cx->compartment->types);
JS_ASSERT(this == &cx->compartment()->types);
JS_ASSERT(!(target->flags & OBJECT_FLAG_SETS_MARKED_UNKNOWN));
JS_ASSERT(!target->singleton);
JS_ASSERT(target->unknownProperties());
@ -2997,7 +2997,7 @@ TypeCompartment::markSetsUnknown(JSContext *cx, TypeObject *target)
Property *prop = object->getProperty(i);
if (prop && prop->types.hasType(Type::ObjectType(target))) {
if (!pending.append(&prop->types))
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
}
}
}
@ -3093,7 +3093,7 @@ ScriptAnalysis::addTypeBarrier(JSContext *cx, const jsbytecode *pc, TypeSet *tar
barrier = cx->analysisLifoAlloc().new_<TypeBarrier>(target, type, (JSObject *) NULL, JSID_VOID);
if (!barrier) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -3124,7 +3124,7 @@ ScriptAnalysis::addSingletonTypeBarrier(JSContext *cx, const jsbytecode *pc, Typ
singleton, singletonId);
if (!barrier) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -3232,7 +3232,7 @@ TypeCompartment::fixArrayType(JSContext *cx, JSObject *obj)
arrayTypeTable = cx->new_<ArrayTypeTable>();
if (!arrayTypeTable || !arrayTypeTable->init()) {
arrayTypeTable = NULL;
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
}
@ -3274,7 +3274,7 @@ TypeCompartment::fixArrayType(JSContext *cx, JSObject *obj)
RootedObject objProto(cx, obj->getProto());
Rooted<TypeObject*> objType(cx, newTypeObject(cx, &ArrayClass, objProto));
if (!objType) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
obj->setType(objType);
@ -3293,7 +3293,7 @@ TypeCompartment::fixArrayType(JSContext *cx, JSObject *obj)
}
if (!arrayTypeTable->relookupOrAdd(p, key, objType)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
}
@ -3381,7 +3381,7 @@ TypeCompartment::fixObjectType(JSContext *cx, JSObject *obj)
objectTypeTable = cx->new_<ObjectTypeTable>();
if (!objectTypeTable || !objectTypeTable->init()) {
objectTypeTable = NULL;
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
}
@ -3397,7 +3397,7 @@ TypeCompartment::fixObjectType(JSContext *cx, JSObject *obj)
Vector<IdValuePair> properties(cx);
if (!properties.resize(obj->slotSpan())) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -3425,7 +3425,7 @@ TypeCompartment::fixObjectType(JSContext *cx, JSObject *obj)
Rooted<TaggedProto> objProto(cx, obj->getTaggedProto());
TypeObject *objType = newTypeObject(cx, &ObjectClass, objProto);
if (!objType || !objType->addDefiniteProperties(cx, obj)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -3434,13 +3434,13 @@ TypeCompartment::fixObjectType(JSContext *cx, JSObject *obj)
jsid *ids = cx->pod_calloc<jsid>(properties.length());
if (!ids) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
Type *types = cx->pod_calloc<Type>(properties.length());
if (!types) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -3464,7 +3464,7 @@ TypeCompartment::fixObjectType(JSContext *cx, JSObject *obj)
p = objectTypeTable->lookupForAdd(lookup);
if (!objectTypeTable->add(p, key, entry)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -3480,7 +3480,7 @@ TypeCompartment::newTypedObject(JSContext *cx, IdValuePair *properties, size_t n
objectTypeTable = cx->new_<ObjectTypeTable>();
if (!objectTypeTable || !objectTypeTable->init()) {
objectTypeTable = NULL;
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return NULL;
}
}
@ -3599,7 +3599,7 @@ TypeObject::addProperty(JSContext *cx, jsid id, Property **pprop)
JS_ASSERT(!*pprop);
Property *base = cx->typeLifoAlloc().new_<Property>(id);
if (!base) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return false;
}
@ -3744,7 +3744,7 @@ TypeObject::addPropertyType(JSContext *cx, const char *name, Type type)
JSAtom *atom = Atomize(cx, name, strlen(name));
if (!atom) {
AutoEnterAnalysis enter(cx);
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
id = AtomToId(atom);
@ -3813,7 +3813,7 @@ TypeObject::markUnknown(JSContext *cx)
{
AutoEnterAnalysis enter(cx);
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
JS_ASSERT(!unknownProperties());
if (!(flags & OBJECT_FLAG_NEW_SCRIPT_CLEARED))
@ -4277,7 +4277,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset, TypeInferen
case JSOP_SETNAME:
case JSOP_SETINTRINSIC:
case JSOP_SETCONST:
cx->compartment->types.monitorBytecode(cx, script, offset);
cx->compartment()->types.monitorBytecode(cx, script, offset);
poppedTypes(pc, 0)->addSubset(cx, &pushed[0]);
break;
@ -4482,7 +4482,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset, TypeInferen
}
case JSOP_DEFFUN:
cx->compartment->types.monitorBytecode(cx, script, offset);
cx->compartment()->types.monitorBytecode(cx, script, offset);
break;
case JSOP_DEFVAR:
@ -4501,7 +4501,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset, TypeInferen
TypeCallsite *callsite = cx->analysisLifoAlloc().new_<TypeCallsite>(
cx, script, pc, op == JSOP_NEW, argCount);
if (!callsite || (argCount && !callsite->argumentTypes)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
break;
}
callsite->thisTypes = poppedTypes(pc, argCount);
@ -4516,7 +4516,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset, TypeInferen
* callee's argument types are checked on entry.
*/
if (op == JSOP_FUNCALL || op == JSOP_FUNAPPLY)
cx->compartment->types.monitorBytecode(cx, script, pc - script->code);
cx->compartment()->types.monitorBytecode(cx, script, pc - script->code);
StackTypeSet *calleeTypes = poppedTypes(pc, argCount + 1);
@ -4634,7 +4634,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset, TypeInferen
if (!types)
return false;
if (id == id___proto__(cx) || id == id_prototype(cx))
cx->compartment->types.monitorBytecode(cx, script, offset);
cx->compartment()->types.monitorBytecode(cx, script, offset);
else if (op == JSOP_INITPROP_GETTER || op == JSOP_INITPROP_SETTER)
types->addType(cx, Type::UnknownType());
else
@ -4700,7 +4700,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset, TypeInferen
case JSOP_ENUMELEM:
case JSOP_ENUMCONSTELEM:
case JSOP_ARRAYPUSH:
cx->compartment->types.monitorBytecode(cx, script, offset);
cx->compartment()->types.monitorBytecode(cx, script, offset);
break;
case JSOP_THROW:
@ -4760,7 +4760,7 @@ ScriptAnalysis::analyzeTypes(JSContext *cx)
JS_ASSERT(!ranInference());
if (OOM()) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -4794,7 +4794,7 @@ ScriptAnalysis::analyzeTypes(JSContext *cx)
HeapTypeSet *typeArray =
(HeapTypeSet*) cx->typeLifoAlloc().alloc(sizeof(HeapTypeSet) * numPropertyReads());
if (!typeArray) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
script_->types->propertyReadTypes = typeArray;
@ -4811,7 +4811,7 @@ ScriptAnalysis::analyzeTypes(JSContext *cx)
undefinedTypeSet = cx->analysisLifoAlloc().new_<StackTypeSet>();
if (!undefinedTypeSet) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
undefinedTypeSet->addType(cx, Type::UndefinedType());
@ -4823,7 +4823,7 @@ ScriptAnalysis::analyzeTypes(JSContext *cx)
jsbytecode *pc = script_->code + offset;
if (code && !analyzeTypesBytecode(cx, offset, state)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -5001,7 +5001,7 @@ AnalyzeNewScriptProperties(JSContext *cx, TypeObject *type, HandleFunction fun,
RootedScript script(cx, fun->nonLazyScript());
if (!script->ensureRanAnalysis(cx) || !script->ensureRanInference(cx)) {
state.baseobj = NULL;
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return false;
}
@ -5123,7 +5123,7 @@ AnalyzePoppedThis(JSContext *cx, SSAUseChain *use,
if (!DefineNativeProperty(cx, state.baseobj, id, value, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, DNP_SKIP_TYPE))
{
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
state.baseobj = NULL;
return false;
}
@ -5140,7 +5140,7 @@ AnalyzePoppedThis(JSContext *cx, SSAUseChain *use,
TypeNewScript::Initializer setprop(TypeNewScript::Initializer::SETPROP, use->offset);
if (!state.initializerList.append(setprop)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
state.baseobj = NULL;
return false;
}
@ -5169,7 +5169,7 @@ AnalyzePoppedThis(JSContext *cx, SSAUseChain *use,
if (IdToTypeId(id) != id)
return false;
if (!state.baseobj->nativeLookup(cx, id) && !state.accessedProperties.append(id.get())) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
state.baseobj = NULL;
return false;
}
@ -5254,7 +5254,7 @@ AnalyzePoppedThis(JSContext *cx, SSAUseChain *use,
TypeNewScript::Initializer pushframe(TypeNewScript::Initializer::FRAME_PUSH, use->offset);
if (!state.initializerList.append(pushframe)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
state.baseobj = NULL;
return false;
}
@ -5264,7 +5264,7 @@ AnalyzePoppedThis(JSContext *cx, SSAUseChain *use,
TypeNewScript::Initializer popframe(TypeNewScript::Initializer::FRAME_POP, 0);
if (!state.initializerList.append(popframe)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
state.baseobj = NULL;
return false;
}
@ -5299,7 +5299,7 @@ CheckNewScriptProperties(JSContext *cx, HandleTypeObject type, HandleFunction fu
if (!state.baseobj) {
if (type->newScript)
type->clearNewScript(cx);
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -5341,7 +5341,7 @@ CheckNewScriptProperties(JSContext *cx, HandleTypeObject type, HandleFunction fu
if (!state.baseobj ||
!type->addDefiniteProperties(cx, state.baseobj) ||
!state.initializerList.append(done)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -5359,7 +5359,7 @@ CheckNewScriptProperties(JSContext *cx, HandleTypeObject type, HandleFunction fu
#endif
if (!type->newScript) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -5543,7 +5543,7 @@ types::MarkIteratorUnknownSlow(JSContext *cx)
result = cx->new_<TypeResult>(UINT32_MAX, Type::UnknownType());
if (!result) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
result->next = script->types->dynamicList;
@ -5612,7 +5612,7 @@ types::TypeDynamicResult(JSContext *cx, JSScript *script, jsbytecode *pc, Type t
/* Directly update associated type sets for applicable bytecodes. */
if (js_CodeSpec[*pc].format & JOF_TYPESET) {
if (!script->ensureHasBytecodeTypeMap(cx)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
TypeSet *types = TypeScript::BytecodeTypes(script, pc);
@ -5656,7 +5656,7 @@ types::TypeDynamicResult(JSContext *cx, JSScript *script, jsbytecode *pc, Type t
TypeResult *result = cx->new_<TypeResult>(pc - script->code, type);
if (!result) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
result->next = script->types->dynamicList;
@ -5718,7 +5718,7 @@ types::TypeMonitorResult(JSContext *cx, JSScript *script, jsbytecode *pc, const
AutoEnterAnalysis enter(cx);
if (!script->ensureHasBytecodeTypeMap(cx)) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
@ -5829,7 +5829,7 @@ JSScript::makeTypes(JSContext *cx)
types = (TypeScript *) cx->calloc_(sizeof(TypeScript) + (sizeof(TypeSet) * count));
if (!types) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return false;
}
@ -5952,7 +5952,7 @@ JSFunction::setTypeForScriptedFunction(JSContext *cx, HandleFunction fun, bool s
return false;
} else {
RootedObject funProto(cx, fun->getProto());
TypeObject *type = cx->compartment->types.newTypeObject(cx, &FunctionClass, funProto);
TypeObject *type = cx->compartment()->types.newTypeObject(cx, &FunctionClass, funProto);
if (!type)
return false;
@ -5986,7 +5986,7 @@ JSObject::shouldSplicePrototype(JSContext *cx)
bool
JSObject::splicePrototype(JSContext *cx, Class *clasp, Handle<TaggedProto> proto)
{
JS_ASSERT(cx->compartment == compartment());
JS_ASSERT(cx->compartment() == compartment());
RootedObject self(cx, this);
@ -6016,7 +6016,7 @@ JSObject::splicePrototype(JSContext *cx, Class *clasp, Handle<TaggedProto> proto
}
if (!cx->typeInferenceEnabled()) {
TypeObject *type = cx->compartment->getNewType(cx, clasp, proto);
TypeObject *type = cx->compartment()->getNewType(cx, clasp, proto);
if (!type)
return false;
self->type_ = type;
@ -6050,7 +6050,7 @@ JSObject::splicePrototype(JSContext *cx, Class *clasp, Handle<TaggedProto> proto
JSObject::makeLazyType(JSContext *cx, HandleObject obj)
{
JS_ASSERT(obj->hasLazyType());
JS_ASSERT(cx->compartment == obj->compartment());
JS_ASSERT(cx->compartment() == obj->compartment());
/* De-lazification of functions can GC, so we need to do it up here. */
if (obj->isFunction() && obj->toFunction()->isInterpretedLazy()) {
@ -6059,10 +6059,10 @@ JSObject::makeLazyType(JSContext *cx, HandleObject obj)
return NULL;
}
Rooted<TaggedProto> proto(cx, obj->getTaggedProto());
TypeObject *type = cx->compartment->types.newTypeObject(cx, obj->getClass(), proto);
TypeObject *type = cx->compartment()->types.newTypeObject(cx, obj->getClass(), proto);
if (!type) {
if (cx->typeInferenceEnabled())
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return obj->type_;
}
@ -6144,7 +6144,7 @@ JSObject::setNewTypeUnknown(JSContext *cx, Class *clasp, HandleObject obj)
* not have the SETS_MARKED_UNKNOWN bit set, so may require a type set
* crawl if prototypes of the object change dynamically in the future.
*/
TypeObjectSet &table = cx->compartment->newTypeObjects;
TypeObjectSet &table = cx->compartment()->newTypeObjects;
if (table.initialized()) {
if (TypeObjectSet::Ptr p = table.lookup(TypeObjectSet::Lookup(clasp, obj.get())))
MarkTypeObjectUnknownProperties(cx, *p);
@ -6157,7 +6157,7 @@ TypeObject *
JSCompartment::getNewType(JSContext *cx, Class *clasp, TaggedProto proto_, JSFunction *fun_)
{
JS_ASSERT_IF(fun_, proto_.isObject());
JS_ASSERT_IF(proto_.isObject(), cx->compartment == proto_.toObject()->compartment());
JS_ASSERT_IF(proto_.isObject(), cx->compartment() == proto_.toObject()->compartment());
if (!newTypeObjects.initialized() && !newTypeObjects.init())
return NULL;
@ -6247,18 +6247,18 @@ JSCompartment::getNewType(JSContext *cx, Class *clasp, TaggedProto proto_, JSFun
TypeObject *
JSObject::getNewType(JSContext *cx, Class *clasp, JSFunction *fun)
{
return cx->compartment->getNewType(cx, clasp, this, fun);
return cx->compartment()->getNewType(cx, clasp, this, fun);
}
TypeObject *
JSCompartment::getLazyType(JSContext *cx, Class *clasp, TaggedProto proto)
{
JS_ASSERT(cx->compartment == this);
JS_ASSERT_IF(proto.isObject(), cx->compartment == proto.toObject()->compartment());
JS_ASSERT(cx->compartment() == this);
JS_ASSERT_IF(proto.isObject(), cx->compartment() == proto.toObject()->compartment());
AutoEnterAnalysis enter(cx);
TypeObjectSet &table = cx->compartment->lazyTypeObjects;
TypeObjectSet &table = cx->compartment()->lazyTypeObjects;
if (!table.initialized() && !table.init())
return NULL;
@ -6272,7 +6272,7 @@ JSCompartment::getLazyType(JSContext *cx, Class *clasp, TaggedProto proto)
}
Rooted<TaggedProto> protoRoot(cx, proto);
TypeObject *type = cx->compartment->types.newTypeObject(cx, clasp, protoRoot, false);
TypeObject *type = cx->compartment()->types.newTypeObject(cx, clasp, protoRoot, false);
if (!type)
return NULL;
@ -6756,14 +6756,14 @@ TypeCompartment::maybePurgeAnalysis(JSContext *cx, bool force)
// FIXME bug 781657
return;
JS_ASSERT(this == &cx->compartment->types);
JS_ASSERT(!cx->compartment->activeAnalysis);
JS_ASSERT(this == &cx->compartment()->types);
JS_ASSERT(!cx->compartment()->activeAnalysis);
if (!cx->typeInferenceEnabled())
return;
size_t triggerBytes = cx->runtime->analysisPurgeTriggerBytes;
size_t beforeUsed = cx->compartment->analysisLifoAlloc.used();
size_t triggerBytes = cx->runtime()->analysisPurgeTriggerBytes;
size_t beforeUsed = cx->compartment()->analysisLifoAlloc.used();
if (!force) {
if (!triggerBytes || triggerBytes >= beforeUsed)
@ -6773,20 +6773,20 @@ TypeCompartment::maybePurgeAnalysis(JSContext *cx, bool force)
AutoEnterAnalysis enter(cx);
/* Reset the analysis pool, making its memory available for reuse. */
cx->compartment->analysisLifoAlloc.releaseAll();
cx->compartment()->analysisLifoAlloc.releaseAll();
uint64_t start = PRMJ_Now();
for (gc::CellIter i(cx->zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
RootedScript script(cx, i.get<JSScript>());
if (script->compartment() == cx->compartment)
if (script->compartment() == cx->compartment())
TypeScript::Purge(cx, script);
}
uint64_t done = PRMJ_Now();
if (cx->runtime->analysisPurgeCallback) {
size_t afterUsed = cx->compartment->analysisLifoAlloc.used();
if (cx->runtime()->analysisPurgeCallback) {
size_t afterUsed = cx->compartment()->analysisLifoAlloc.used();
size_t typeUsed = cx->typeLifoAlloc().used();
char buf[1000];
@ -6803,7 +6803,7 @@ TypeCompartment::maybePurgeAnalysis(JSContext *cx, bool force)
}
JS::Rooted<JSFlatString*> flat(cx, &desc->asFlat());
cx->runtime->analysisPurgeCallback(cx->runtime, flat);
cx->runtime()->analysisPurgeCallback(cx->runtime(), flat);
}
}

View File

@ -160,7 +160,7 @@ RecompileInfo::compilerOutput(TypeCompartment &types) const
inline CompilerOutput*
RecompileInfo::compilerOutput(JSContext *cx) const
{
return compilerOutput(cx->compartment->types);
return compilerOutput(cx->compartment()->types);
}
/////////////////////////////////////////////////////////////////////
@ -338,7 +338,7 @@ struct AutoEnterAnalysis
AutoEnterAnalysis(JSContext *cx)
: suppressGC(cx)
{
init(cx->runtime->defaultFreeOp(), cx->compartment);
init(cx->runtime()->defaultFreeOp(), cx->compartment());
}
AutoEnterAnalysis(FreeOp *fop, JSCompartment *comp)
@ -387,10 +387,10 @@ struct AutoEnterCompilation
AutoEnterCompilation(JSContext *cx, CompilerOutput::Kind kind)
: cx(cx),
info(cx->compartment->types.compiledInfo),
info(cx->compartment()->types.compiledInfo),
kind(kind)
{
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
JS_ASSERT(info.outputIndex == RecompileInfo::NoCompilerRunning);
}
@ -411,7 +411,7 @@ struct AutoEnterCompilation
co.pendingRecompilation = true;
JS_ASSERT(!co.isValid());
TypeCompartment &types = cx->compartment->types;
TypeCompartment &types = cx->compartment()->types;
if (!types.constrainedOutputs) {
types.constrainedOutputs = cx->new_< Vector<CompilerOutput> >(cx);
if (!types.constrainedOutputs) {
@ -445,7 +445,7 @@ struct AutoEnterCompilation
if (info.outputIndex >= RecompileInfo::NoCompilerRunning)
return;
JS_ASSERT(info.outputIndex < cx->compartment->types.constrainedOutputs->length());
JS_ASSERT(info.outputIndex < cx->compartment()->types.constrainedOutputs->length());
CompilerOutput *co = info.compilerOutput(cx);
co->pendingRecompilation = false;
if (!co->isValid())
@ -651,7 +651,7 @@ MarkTypeObjectUnknownProperties(JSContext *cx, TypeObject *obj,
if (!obj->unknownProperties())
obj->markUnknown(cx);
if (markSetsUnknown && !(obj->flags & OBJECT_FLAG_SETS_MARKED_UNKNOWN))
cx->compartment->types.markSetsUnknown(cx, obj);
cx->compartment()->types.markSetsUnknown(cx, obj);
}
}
@ -685,14 +685,14 @@ inline void
FixArrayType(JSContext *cx, HandleObject obj)
{
if (cx->typeInferenceEnabled())
cx->compartment->types.fixArrayType(cx, obj);
cx->compartment()->types.fixArrayType(cx, obj);
}
inline void
FixObjectType(JSContext *cx, HandleObject obj)
{
if (cx->typeInferenceEnabled())
cx->compartment->types.fixObjectType(cx, obj);
cx->compartment()->types.fixObjectType(cx, obj);
}
/* Interface helpers for JSScript*. */
@ -916,14 +916,14 @@ TypeScript::InitObject(JSContext *cx, JSScript *script, jsbytecode *pc, JSProtoK
key.offset = offset;
key.kind = kind;
if (!cx->compartment->types.allocationSiteTable)
return cx->compartment->types.addAllocationSiteTypeObject(cx, key);
if (!cx->compartment()->types.allocationSiteTable)
return cx->compartment()->types.addAllocationSiteTypeObject(cx, key);
AllocationSiteTable::Ptr p = cx->compartment->types.allocationSiteTable->lookup(key);
AllocationSiteTable::Ptr p = cx->compartment()->types.allocationSiteTable->lookup(key);
if (p)
return p->value;
return cx->compartment->types.addAllocationSiteTypeObject(cx, key);
return cx->compartment()->types.addAllocationSiteTypeObject(cx, key);
}
/* Set the type to use for obj according to the site it was allocated at. */
@ -1111,8 +1111,8 @@ TypeCompartment::compartment()
inline void
TypeCompartment::addPending(JSContext *cx, TypeConstraint *constraint, TypeSet *source, Type type)
{
JS_ASSERT(this == &cx->compartment->types);
JS_ASSERT(!cx->runtime->isHeapBusy());
JS_ASSERT(this == &cx->compartment()->types);
JS_ASSERT(!cx->runtime()->isHeapBusy());
InferSpew(ISpewOps, "pending: %sC%p%s %s",
InferSpewColor(constraint), constraint, InferSpewColorReset(),
@ -1130,7 +1130,7 @@ TypeCompartment::addPending(JSContext *cx, TypeConstraint *constraint, TypeSet *
inline void
TypeCompartment::resolvePending(JSContext *cx)
{
JS_ASSERT(this == &cx->compartment->types);
JS_ASSERT(this == &cx->compartment()->types);
if (resolving) {
/* There is an active call further up resolving the worklist. */
@ -1385,7 +1385,7 @@ TypeSet::clearObjects()
inline void
TypeSet::addType(JSContext *cx, Type type)
{
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
if (unknown())
return;
@ -1411,14 +1411,14 @@ TypeSet::addType(JSContext *cx, Type type)
goto unknownObject;
LifoAlloc &alloc =
purged() ? cx->compartment->analysisLifoAlloc : cx->typeLifoAlloc();
purged() ? cx->compartment()->analysisLifoAlloc : cx->typeLifoAlloc();
uint32_t objectCount = baseObjectCount();
TypeObjectKey *object = type.objectKey();
TypeObjectKey **pentry = HashSetInsert<TypeObjectKey *,TypeObjectKey,TypeObjectKey>
(alloc, objectSet, objectCount, object);
if (!pentry) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return;
}
if (*pentry)
@ -1460,11 +1460,11 @@ TypeSet::addType(JSContext *cx, Type type)
/* Propagate the type to all constraints. */
TypeConstraint *constraint = constraintList;
while (constraint) {
cx->compartment->types.addPending(cx, constraint, this, type);
cx->compartment()->types.addPending(cx, constraint, this, type);
constraint = constraint->next;
}
cx->compartment->types.resolvePending(cx);
cx->compartment()->types.resolvePending(cx);
}
inline void
@ -1523,7 +1523,7 @@ TypeSet::getTypeObject(unsigned i) const
inline TypeObject *
TypeSet::getTypeOrSingleObject(JSContext *cx, unsigned i) const
{
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
TypeObject *type = getTypeObject(i);
if (!type) {
JSObject *singleton = getSingleObject(i);
@ -1531,7 +1531,7 @@ TypeSet::getTypeOrSingleObject(JSContext *cx, unsigned i) const
return NULL;
type = singleton->getType(cx);
if (!type)
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
}
return type;
}
@ -1589,7 +1589,7 @@ TypeObject::setBasePropertyCount(uint32_t count)
inline HeapTypeSet *
TypeObject::getProperty(JSContext *cx, jsid id, bool own)
{
JS_ASSERT(cx->compartment->activeAnalysis);
JS_ASSERT(cx->compartment()->activeAnalysis);
JS_ASSERT(JSID_IS_VOID(id) || JSID_IS_EMPTY(id) || JSID_IS_STRING(id));
JS_ASSERT_IF(!JSID_IS_EMPTY(id), id == IdToTypeId(id));
@ -1599,7 +1599,7 @@ TypeObject::getProperty(JSContext *cx, jsid id, bool own)
Property **pprop = HashSetInsert<jsid,Property,Property>
(cx->typeLifoAlloc(), propertySet, propertyCount, id);
if (!pprop) {
cx->compartment->types.setPendingNukeTypes(cx);
cx->compartment()->types.setPendingNukeTypes(cx);
return NULL;
}

View File

@ -373,7 +373,7 @@ static inline PropertyIteratorObject *
NewPropertyIteratorObject(JSContext *cx, unsigned flags)
{
if (flags & JSITER_ENUMERATE) {
RootedTypeObject type(cx, cx->compartment->getNewType(cx, &PropertyIteratorObject::class_, NULL));
RootedTypeObject type(cx, cx->compartment()->getNewType(cx, &PropertyIteratorObject::class_, NULL));
if (!type)
return NULL;
@ -451,7 +451,7 @@ RegisterEnumerator(JSContext *cx, PropertyIteratorObject *iterobj, NativeIterato
{
/* Register non-escaping native enumerators (for-in) with the current context. */
if (ni->flags & JSITER_ENUMERATE) {
ni->link(cx->compartment->enumerators);
ni->link(cx->compartment()->enumerators);
JS_ASSERT(!(ni->flags & JSITER_ACTIVE));
ni->flags |= JSITER_ACTIVE;
@ -610,7 +610,7 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa
* objects here, as they are not inserted into the cache and
* will result in a miss.
*/
PropertyIteratorObject *last = cx->runtime->nativeIterCache.last;
PropertyIteratorObject *last = cx->runtime()->nativeIterCache.last;
if (last) {
NativeIterator *lastni = last->getNativeIterator();
if (!(lastni->flags & (JSITER_ACTIVE|JSITER_UNREUSABLE)) &&
@ -657,7 +657,7 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa
} while (pobj);
}
PropertyIteratorObject *iterobj = cx->runtime->nativeIterCache.get(key);
PropertyIteratorObject *iterobj = cx->runtime()->nativeIterCache.get(key);
if (iterobj) {
NativeIterator *ni = iterobj->getNativeIterator();
if (!(ni->flags & (JSITER_ACTIVE|JSITER_UNREUSABLE)) &&
@ -669,7 +669,7 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa
UpdateNativeIterator(ni, obj);
RegisterEnumerator(cx, iterobj, ni);
if (shapes.length() == 2)
cx->runtime->nativeIterCache.last = iterobj;
cx->runtime()->nativeIterCache.last = iterobj;
return true;
}
}
@ -708,10 +708,10 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa
/* Cache the iterator object if possible. */
if (shapes.length())
cx->runtime->nativeIterCache.set(key, iterobj);
cx->runtime()->nativeIterCache.set(key, iterobj);
if (shapes.length() == 2)
cx->runtime->nativeIterCache.last = iterobj;
cx->runtime()->nativeIterCache.last = iterobj;
return true;
}
@ -913,7 +913,7 @@ ElementIteratorObject::next_impl(JSContext *cx, CallArgs args)
// Get target[i].
JS_ASSERT(i + 1 > i);
if (target.isString()) {
JSString *c = cx->runtime->staticStrings.getUnitStringForElement(cx, target.toString(), i);
JSString *c = cx->runtime()->staticStrings.getUnitStringForElement(cx, target.toString(), i);
if (!c)
goto close;
args.rval().setString(c);
@ -1069,7 +1069,7 @@ template<typename StringPredicate>
static bool
SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate predicate)
{
NativeIterator *enumeratorList = cx->compartment->enumerators;
NativeIterator *enumeratorList = cx->compartment()->enumerators;
NativeIterator *ni = enumeratorList->next();
while (ni != enumeratorList) {

View File

@ -149,7 +149,7 @@ js::math_acos(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_acos_impl(mathCache, x);
@ -178,7 +178,7 @@ js::math_asin(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_asin_impl(mathCache, x);
@ -203,7 +203,7 @@ js::math_atan(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_atan_impl(mathCache, x);
@ -300,7 +300,7 @@ js::math_cos(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_cos_impl(mathCache, x);
@ -333,7 +333,7 @@ js::math_exp(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_exp_impl(mathCache, x);
@ -402,7 +402,7 @@ js::math_log(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_log_impl(mathCache, x);
@ -627,7 +627,7 @@ random_next(uint64_t *rngState, int bits)
static inline double
random_nextDouble(JSContext *cx)
{
uint64_t *rng = &cx->compartment->rngState;
uint64_t *rng = &cx->compartment()->rngState;
return double((random_next(rng, 26) << 27) + random_next(rng, 27)) / RNG_DSCALE;
}
@ -693,7 +693,7 @@ js::math_sin(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_sin_impl(mathCache, x);
@ -712,7 +712,7 @@ js_math_sqrt(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = mathCache->lookup(sqrt, x);
@ -737,7 +737,7 @@ js::math_tan(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
MathCache *mathCache = cx->runtime->getMathCache(cx);
MathCache *mathCache = cx->runtime()->getMathCache(cx);
if (!mathCache)
return JS_FALSE;
z = math_tan_impl(mathCache, x);

View File

@ -75,7 +75,7 @@ ComputeAccurateDecimalInteger(JSContext *cx, const jschar *start, const jschar *
char *estr;
int err = 0;
*dp = js_strtod_harder(cx->runtime->dtoaState, cstr, &estr, &err);
*dp = js_strtod_harder(cx->runtime()->dtoaState, cstr, &estr, &err);
if (err == JS_DTOA_ENOMEM) {
JS_ReportOutOfMemory(cx);
js_free(cstr);
@ -511,14 +511,14 @@ js::Int32ToString(JSContext *cx, int32_t si)
uint32_t ui;
if (si >= 0) {
if (StaticStrings::hasInt(si))
return cx->runtime->staticStrings.getInt(si);
return cx->runtime()->staticStrings.getInt(si);
ui = si;
} else {
ui = uint32_t(-si);
JS_ASSERT_IF(si == INT32_MIN, ui == uint32_t(INT32_MAX) + 1);
}
JSCompartment *c = cx->compartment;
JSCompartment *c = cx->compartment();
if (JSFlatString *str = c->dtoaCache.lookup(10, si))
return str;
@ -664,7 +664,7 @@ num_toLocaleString_impl(JSContext *cx, CallArgs args)
return true;
}
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
size_t thousandsLength = strlen(rt->thousandsSeparator);
size_t decimalLength = strlen(rt->decimalSeparator);
@ -732,9 +732,9 @@ num_toLocaleString_impl(JSContext *cx, CallArgs args)
strcpy(tmpDest, nint);
}
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeToUnicode) {
if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeToUnicode) {
Rooted<Value> v(cx, StringValue(str));
bool ok = !!cx->runtime->localeCallbacks->localeToUnicode(cx, buf, &v);
bool ok = !!cx->runtime()->localeCallbacks->localeToUnicode(cx, buf, &v);
if (ok)
args.rval().set(v);
js_free(buf);
@ -797,7 +797,7 @@ static bool
DToStrResult(JSContext *cx, double d, JSDToStrMode mode, int precision, CallArgs args)
{
char buf[DTOSTR_VARIABLE_BUFFER_SIZE(MAX_PRECISION + 1)];
char *numStr = js_dtostr(cx->runtime->dtoaState, buf, sizeof buf, mode, precision, d);
char *numStr = js_dtostr(cx->runtime()->dtoaState, buf, sizeof buf, mode, precision, d);
if (!numStr) {
JS_ReportOutOfMemory(cx);
return false;
@ -1161,8 +1161,8 @@ js_InitNumberClass(JSContext *cx, HandleObject obj)
if (!JS_DefineFunctions(cx, global, number_functions))
return NULL;
RootedValue valueNaN(cx, cx->runtime->NaNValue);
RootedValue valueInfinity(cx, cx->runtime->positiveInfinityValue);
RootedValue valueNaN(cx, cx->runtime()->NaNValue);
RootedValue valueInfinity(cx, cx->runtime()->positiveInfinityValue);
/* ES5 15.1.1.1, 15.1.1.2 */
if (!DefineNativeProperty(cx, global, cx->names().NaN, valueNaN,
@ -1206,7 +1206,7 @@ FracNumberToCString(JSContext *cx, ToCStringBuf *cbuf, double d, int base = 10)
converter.ToShortest(d, &builder);
numStr = builder.Finalize();
} else {
numStr = cbuf->dbuf = js_dtobasestr(cx->runtime->dtoaState, base, d);
numStr = cbuf->dbuf = js_dtobasestr(cx->runtime()->dtoaState, base, d);
}
return numStr;
}
@ -1235,18 +1235,18 @@ js_NumberToStringWithBase(JSContext *cx, double d, int base)
if (base < 2 || base > 36)
return NULL;
JSCompartment *c = cx->compartment;
JSCompartment *c = cx->compartment();
int32_t i;
if (mozilla::DoubleIsInt32(d, &i)) {
if (base == 10 && StaticStrings::hasInt(i))
return cx->runtime->staticStrings.getInt(i);
return cx->runtime()->staticStrings.getInt(i);
if (unsigned(i) < unsigned(base)) {
if (i < 10)
return cx->runtime->staticStrings.getInt(i);
return cx->runtime()->staticStrings.getInt(i);
jschar c = 'a' + i - 10;
JS_ASSERT(StaticStrings::hasUnit(c));
return cx->runtime->staticStrings.getUnit(c);
return cx->runtime()->staticStrings.getUnit(c);
}
if (JSFlatString *str = c->dtoaCache.lookup(base, d))
@ -1299,9 +1299,9 @@ JSFlatString *
js::IndexToString(JSContext *cx, uint32_t index)
{
if (StaticStrings::hasUint(index))
return cx->runtime->staticStrings.getUint(index);
return cx->runtime()->staticStrings.getUint(index);
JSCompartment *c = cx->compartment;
JSCompartment *c = cx->compartment();
if (JSFlatString *str = c->dtoaCache.lookup(10, index))
return str;
@ -1613,7 +1613,7 @@ js_strtod(JSContext *cx, const jschar *s, const jschar *send,
estr = istr + 8;
} else {
int err;
d = js_strtod_harder(cx->runtime->dtoaState, cstr, &estr, &err);
d = js_strtod_harder(cx->runtime()->dtoaState, cstr, &estr, &err);
if (d == HUGE_VAL)
d = js_PositiveInfinity;
else if (d == -HUGE_VAL)

View File

@ -1242,7 +1242,7 @@ NewObject(JSContext *cx, Class *clasp, types::TypeObject *type_, JSObject *paren
JS_ASSERT(clasp != &ArrayClass);
JS_ASSERT_IF(clasp == &FunctionClass,
kind == JSFunction::FinalizeKind || kind == JSFunction::ExtendedFinalizeKind);
JS_ASSERT_IF(parent, &parent->global() == cx->compartment->maybeGlobal());
JS_ASSERT_IF(parent, &parent->global() == cx->compartment()->maybeGlobal());
RootedTypeObject type(cx, type_);
@ -1268,7 +1268,7 @@ NewObject(JSContext *cx, Class *clasp, types::TypeObject *type_, JSObject *paren
* slices, and it will prevent any future incremental GCs.
*/
if (clasp->trace && !(clasp->flags & JSCLASS_IMPLEMENTS_BARRIERS))
cx->runtime->gcIncrementalEnabled = false;
cx->runtime()->gcIncrementalEnabled = false;
Probes::createObject(cx, obj);
return obj;
@ -1285,12 +1285,12 @@ js::NewObjectWithGivenProto(JSContext *cx, js::Class *clasp,
if (CanBeFinalizedInBackground(allocKind, clasp))
allocKind = GetBackgroundAllocKind(allocKind);
NewObjectCache &cache = cx->runtime->newObjectCache;
NewObjectCache &cache = cx->runtime()->newObjectCache;
NewObjectCache::EntryIndex entry = -1;
if (proto.isObject() &&
newKind == GenericObject &&
!cx->compartment->objectMetadataCallback &&
!cx->compartment()->objectMetadataCallback &&
(!parent || parent == proto.toObject()->getParent()) && !proto.toObject()->isGlobal())
{
if (cache.lookupProto(clasp, proto.toObject(), allocKind, &entry)) {
@ -1300,7 +1300,7 @@ js::NewObjectWithGivenProto(JSContext *cx, js::Class *clasp,
}
}
types::TypeObject *type = cx->compartment->getNewType(cx, clasp, proto, NULL);
types::TypeObject *type = cx->compartment()->getNewType(cx, clasp, proto, NULL);
if (!type)
return NULL;
@ -1345,13 +1345,13 @@ js::NewObjectWithClassProtoCommon(JSContext *cx, js::Class *clasp, JSObject *pro
*/
JSProtoKey protoKey = GetClassProtoKey(clasp);
NewObjectCache &cache = cx->runtime->newObjectCache;
NewObjectCache &cache = cx->runtime()->newObjectCache;
NewObjectCache::EntryIndex entry = -1;
if (parentArg->isGlobal() &&
protoKey != JSProto_Null &&
newKind == GenericObject &&
!cx->compartment->objectMetadataCallback)
!cx->compartment()->objectMetadataCallback)
{
if (cache.lookupGlobal(clasp, &parentArg->asGlobal(), allocKind, &entry)) {
JSObject *obj = cache.newObjectFromHit(cx, entry, GetInitialHeap(newKind, clasp));
@ -1391,12 +1391,12 @@ js::NewObjectWithType(JSContext *cx, HandleTypeObject type, JSObject *parent, gc
if (CanBeFinalizedInBackground(allocKind, &ObjectClass))
allocKind = GetBackgroundAllocKind(allocKind);
NewObjectCache &cache = cx->runtime->newObjectCache;
NewObjectCache &cache = cx->runtime()->newObjectCache;
NewObjectCache::EntryIndex entry = -1;
if (parent == type->proto->getParent() &&
newKind == GenericObject &&
!cx->compartment->objectMetadataCallback)
!cx->compartment()->objectMetadataCallback)
{
if (cache.lookupType(&ObjectClass, type, allocKind, &entry)) {
JSObject *obj = cache.newObjectFromHit(cx, entry, GetInitialHeap(newKind, &ObjectClass));
@ -1643,7 +1643,7 @@ JSObject::nonNativeSetProperty(JSContext *cx, HandleObject obj,
HandleId id, MutableHandleValue vp, JSBool strict)
{
if (JS_UNLIKELY(obj->watched())) {
WatchpointMap *wpmap = cx->compartment->watchpointMap;
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp))
return false;
}
@ -1659,7 +1659,7 @@ JSObject::nonNativeSetElement(JSContext *cx, HandleObject obj,
if (!IndexToId(cx, index, &id))
return false;
WatchpointMap *wpmap = cx->compartment->watchpointMap;
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp))
return false;
}
@ -1716,12 +1716,12 @@ JS_CopyPropertiesFrom(JSContext *cx, JSObject *targetArg, JSObject *objArg)
PropertyOp getter = shape->getter();
StrictPropertyOp setter = shape->setter();
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
if ((attrs & JSPROP_GETTER) && !cx->compartment->wrap(cx, &getter))
if ((attrs & JSPROP_GETTER) && !cx->compartment()->wrap(cx, &getter))
return false;
if ((attrs & JSPROP_SETTER) && !cx->compartment->wrap(cx, &setter))
if ((attrs & JSPROP_SETTER) && !cx->compartment()->wrap(cx, &setter))
return false;
v = shape->hasSlot() ? obj->getSlot(shape->slot()) : UndefinedValue();
if (!cx->compartment->wrap(cx, &v))
if (!cx->compartment()->wrap(cx, &v))
return false;
id = shape->propid();
if (!JSObject::defineGeneric(cx, target, id, v, getter, setter, attrs))
@ -1749,7 +1749,7 @@ CopySlots(JSContext *cx, HandleObject from, HandleObject to)
RootedValue v(cx);
for (; n < span; ++n) {
v = from->getSlot(n);
if (!cx->compartment->wrap(cx, &v))
if (!cx->compartment()->wrap(cx, &v))
return false;
to->setSlot(n, v);
}
@ -1994,8 +1994,8 @@ JSObject::TradeGuts(JSContext *cx, JSObject *a, JSObject *b, TradeGutsReserved &
* below, in common with the other case.
*/
for (size_t i = 0; i < a->numFixedSlots(); ++i) {
HeapSlot::writeBarrierPost(cx->runtime, a, HeapSlot::Slot, i);
HeapSlot::writeBarrierPost(cx->runtime, b, HeapSlot::Slot, i);
HeapSlot::writeBarrierPost(cx->runtime(), a, HeapSlot::Slot, i);
HeapSlot::writeBarrierPost(cx->runtime(), b, HeapSlot::Slot, i);
}
#endif
} else {
@ -2436,7 +2436,7 @@ static HeapSlot *
AllocateSlots(JSContext *cx, JSObject *obj, uint32_t nslots)
{
#ifdef JSGC_GENERATIONAL
return cx->runtime->gcNursery.allocateSlots(cx, obj, nslots);
return cx->runtime()->gcNursery.allocateSlots(cx, obj, nslots);
#else
return cx->pod_malloc<HeapSlot>(nslots);
#endif
@ -2447,7 +2447,7 @@ ReallocateSlots(JSContext *cx, JSObject *obj, HeapSlot *oldSlots,
uint32_t oldCount, uint32_t newCount)
{
#ifdef JSGC_GENERATIONAL
return cx->runtime->gcNursery.reallocateSlots(cx, obj, oldSlots, oldCount, newCount);
return cx->runtime()->gcNursery.reallocateSlots(cx, obj, oldSlots, oldCount, newCount);
#else
return (HeapSlot *)cx->realloc_(oldSlots, oldCount * sizeof(HeapSlot),
newCount * sizeof(HeapSlot));
@ -2519,7 +2519,7 @@ static void
FreeSlots(JSContext *cx, HeapSlot *slots)
{
#ifdef JSGC_GENERATIONAL
if (!cx->runtime->gcNursery.isInside(slots))
if (!cx->runtime()->gcNursery.isInside(slots))
#endif
js_free(slots);
}
@ -2754,7 +2754,7 @@ AllocateElements(JSObject::MaybeContext maybecx, JSObject *obj, uint32_t nelems)
{
if (JSContext *cx = maybecx.context) {
#ifdef JSGC_GENERATIONAL
return cx->runtime->gcNursery.allocateElements(cx, obj, nelems);
return cx->runtime()->gcNursery.allocateElements(cx, obj, nelems);
#else
return static_cast<js::ObjectElements *>(cx->malloc_(nelems * sizeof(HeapValue)));
#endif
@ -2770,7 +2770,7 @@ ReallocateElements(JSObject::MaybeContext maybecx, JSObject *obj, ObjectElements
{
if (JSContext *cx = maybecx.context) {
#ifdef JSGC_GENERATIONAL
return cx->runtime->gcNursery.reallocateElements(cx, obj, oldHeader, oldCount, newCount);
return cx->runtime()->gcNursery.reallocateElements(cx, obj, oldHeader, oldCount, newCount);
#else
return static_cast<js::ObjectElements *>(cx->realloc_(oldHeader,
oldCount * sizeof(HeapValue),
@ -2961,7 +2961,7 @@ js::SetClassAndProto(JSContext *cx, HandleObject obj,
return false;
}
TypeObject *type = cx->compartment->getNewType(cx, clasp, proto);
TypeObject *type = cx->compartment()->getNewType(cx, clasp, proto);
if (!type)
return false;
@ -3863,7 +3863,7 @@ js_NativeSet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> receiver,
RootedValue ovp(cx, vp);
uint32_t sample = cx->runtime->propertyRemovals;
uint32_t sample = cx->runtime()->propertyRemovals;
if (!shape->set(cx, obj, receiver, strict, vp))
return false;
@ -3872,7 +3872,7 @@ js_NativeSet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> receiver,
* unless the setter deleted the shape.
*/
if (shape->hasSlot() &&
(JS_LIKELY(cx->runtime->propertyRemovals == sample) ||
(JS_LIKELY(cx->runtime()->propertyRemovals == sample) ||
obj->nativeContains(cx, shape)))
{
AddTypePropertyId(cx, obj, shape->propid(), ovp);
@ -4256,7 +4256,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
if (JS_UNLIKELY(obj->watched())) {
/* Fire watchpoints, if any. */
WatchpointMap *wpmap = cx->compartment->watchpointMap;
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp))
return false;
}
@ -4527,7 +4527,7 @@ baseops::DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, JSBool *suc
return CallJSDeletePropertyOp(cx, obj->getClass()->delProperty, obj, id, succeeded);
}
GCPoke(cx->runtime);
GCPoke(cx->runtime());
if (IsImplicitDenseElement(shape)) {
if (!CallJSDeletePropertyOp(cx, obj->getClass()->delProperty, obj, id, succeeded))
@ -4790,7 +4790,7 @@ js::CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
*/
JSCheckAccessOp check = pobj->getClass()->checkAccess;
if (!check)
check = cx->runtime->securityCallbacks->checkObjectAccess;
check = cx->runtime()->securityCallbacks->checkObjectAccess;
return !check || check(cx, pobj, id, mode, vp);
}

View File

@ -740,12 +740,13 @@ JSObject::setDateUTCTime(const js::Value &time)
/* static */ inline bool
JSObject::setSingletonType(JSContext *cx, js::HandleObject obj)
{
JS_ASSERT(!IsInsideNursery(cx->runtime, obj.get()));
JS_ASSERT(!IsInsideNursery(cx->runtime(), obj.get()));
if (!cx->typeInferenceEnabled())
return true;
js::types::TypeObject *type = cx->compartment->getLazyType(cx, obj->getClass(), obj->getTaggedProto());
js::types::TypeObject *type =
cx->compartment()->getLazyType(cx, obj->getClass(), obj->getTaggedProto());
if (!type)
return false;
@ -756,10 +757,10 @@ JSObject::setSingletonType(JSContext *cx, js::HandleObject obj)
inline js::types::TypeObject*
JSObject::getType(JSContext *cx)
{
JS_ASSERT(cx->compartment == compartment());
JS_ASSERT(cx->compartment() == compartment());
if (hasLazyType()) {
JS::RootedObject self(cx, this);
if (cx->compartment != compartment())
if (cx->compartment() != compartment())
MOZ_CRASH();
return makeLazyType(cx, self);
}
@ -770,9 +771,9 @@ JSObject::getType(JSContext *cx)
JSObject::clearType(JSContext *cx, js::HandleObject obj)
{
JS_ASSERT(!obj->hasSingletonType());
JS_ASSERT(cx->compartment == obj->compartment());
JS_ASSERT(cx->compartment() == obj->compartment());
js::types::TypeObject *type = cx->compartment->getNewType(cx, obj->getClass(), NULL);
js::types::TypeObject *type = cx->compartment()->getNewType(cx, obj->getClass(), NULL);
if (!type)
return false;
@ -977,7 +978,7 @@ JSObject::create(JSContext *cx, js::gc::AllocKind kind, js::gc::InitialHeap heap
}
#ifdef JSGC_GENERATIONAL
cx->runtime->gcNursery.notifyInitialSlots(obj, slots);
cx->runtime()->gcNursery.notifyInitialSlots(obj, slots);
#endif
obj->shape_.init(shape);
@ -1803,9 +1804,11 @@ NewObjectMetadata(JSContext *cx)
{
// The metadata callback is invoked before each created object, except when
// analysis is active as the callback may reenter JS.
if (JS_UNLIKELY((size_t)cx->compartment->objectMetadataCallback) && !cx->compartment->activeAnalysis) {
if (JS_UNLIKELY((size_t)cx->compartment()->objectMetadataCallback) &&
!cx->compartment()->activeAnalysis)
{
gc::AutoSuppressGC suppress(cx);
return cx->compartment->objectMetadataCallback(cx);
return cx->compartment()->objectMetadataCallback(cx);
}
return NULL;
}

View File

@ -524,7 +524,7 @@ JSONParser::createFinishedObject(PropertyVector &properties)
* properties.
*/
if (cx->typeInferenceEnabled()) {
JSObject *obj = cx->compartment->types.newTypedObject(cx, properties.begin(),
JSObject *obj = cx->compartment()->types.newTypedObject(cx, properties.begin(),
properties.length());
if (obj)
return obj;
@ -559,7 +559,7 @@ JSONParser::createFinishedObject(PropertyVector &properties)
* object's final shape.
*/
if (cx->typeInferenceEnabled())
cx->compartment->types.fixObjectType(cx, obj);
cx->compartment()->types.fixObjectType(cx, obj);
return obj;
}
@ -591,7 +591,7 @@ JSONParser::finishArray(MutableHandleValue vp, ElementVector &elements)
/* Try to assign a new type to the array according to its elements. */
if (cx->typeInferenceEnabled())
cx->compartment->types.fixArrayType(cx, obj);
cx->compartment()->types.fixArrayType(cx, obj);
vp.setObject(*obj);
if (!freeElements.append(&elements))

View File

@ -462,7 +462,7 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
return true;
}
if (cx->runtime->isHeapBusy() || cx->runtime->noGCOrAllocationCheck) {
if (cx->runtime()->isHeapBusy() || cx->runtime()->noGCOrAllocationCheck) {
char *source = JS_sprintf_append(NULL, "<value>");
if (!source)
return false;
@ -600,7 +600,7 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
case JOF_OBJECT: {
/* Don't call obj.toSource if analysis/inference is active. */
if (cx->compartment->activeAnalysis) {
if (cx->compartment()->activeAnalysis) {
Sprint(sp, " object");
break;
}
@ -2057,7 +2057,7 @@ js::IsValidBytecodeOffset(JSContext *cx, JSScript *script, size_t offset)
JS_FRIEND_API(size_t)
js::GetPCCountScriptCount(JSContext *cx)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (!rt->scriptAndCountsVector)
return 0;
@ -2094,7 +2094,7 @@ AppendArrayJSONProperties(JSContext *cx, StringBuffer &buf,
JS_FRIEND_API(JSString *)
js::GetPCCountScriptSummary(JSContext *cx, size_t index)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (!rt->scriptAndCountsVector || index >= rt->scriptAndCountsVector->length()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BUFFER_TOO_SMALL);
@ -2357,7 +2357,7 @@ GetPCCountJSON(JSContext *cx, const ScriptAndCounts &sac, StringBuffer &buf)
JS_FRIEND_API(JSString *)
js::GetPCCountScriptContents(JSContext *cx, size_t index)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (!rt->scriptAndCountsVector || index >= rt->scriptAndCountsVector->length()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BUFFER_TOO_SMALL);

View File

@ -21,7 +21,7 @@ PropertyCacheEntry *
PropertyCache::fill(JSContext *cx, JSObject *obj, JSObject *pobj, Shape *shape)
{
JS_ASSERT(this == &cx->propertyCache());
JS_ASSERT(!cx->runtime->isHeapBusy());
JS_ASSERT(!cx->runtime()->isHeapBusy());
/*
* Don't cache entries on indexed properties. Indexes can be added or

View File

@ -60,7 +60,7 @@ PropertyTree::insertChild(JSContext *cx, Shape *parent, Shape *child)
JS_ASSERT(!parent->inDictionary());
JS_ASSERT(!child->parent);
JS_ASSERT(!child->inDictionary());
JS_ASSERT(cx->compartment == compartment);
JS_ASSERT(cx->compartment() == compartment);
JS_ASSERT(child->compartment() == parent->compartment());
KidsPointer *kidp = &parent->kids;

View File

@ -71,8 +71,8 @@ js::AutoEnterPolicy::recordEnter(JSContext *cx, HandleObject proxy, HandleId id)
context = cx;
enteredProxy.construct(proxy);
enteredId.construct(id);
prev = cx->runtime->enteredPolicy;
cx->runtime->enteredPolicy = this;
prev = cx->runtime()->enteredPolicy;
cx->runtime()->enteredPolicy = this;
}
}
@ -80,8 +80,8 @@ void
js::AutoEnterPolicy::recordLeave()
{
if (!enteredProxy.empty()) {
JS_ASSERT(context->runtime->enteredPolicy == this);
context->runtime->enteredPolicy = prev;
JS_ASSERT(context->runtime()->enteredPolicy == this);
context->runtime()->enteredPolicy = prev;
}
}
@ -89,9 +89,9 @@ JS_FRIEND_API(void)
js::assertEnteredPolicy(JSContext *cx, JSObject *proxy, jsid id)
{
MOZ_ASSERT(proxy->isProxy());
MOZ_ASSERT(cx->runtime->enteredPolicy);
MOZ_ASSERT(cx->runtime->enteredPolicy->enteredProxy.ref().get() == proxy);
MOZ_ASSERT(cx->runtime->enteredPolicy->enteredId.ref().get() == id);
MOZ_ASSERT(cx->runtime()->enteredPolicy);
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredProxy.ref().get() == proxy);
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredId.ref().get() == id);
}
#endif
@ -1175,7 +1175,7 @@ NormalizePropertyDescriptor(JSContext *cx, MutableHandleValue vp, bool complete
RootedId id(cx, props[i]);
if (JSID_IS_ATOM(id)) {
JSAtom *atom = JSID_TO_ATOM(id);
const JSAtomState &atomState = cx->runtime->atomState;
const JSAtomState &atomState = cx->runtime()->atomState;
if (atom == atomState.value || atom == atomState.writable ||
atom == atomState.get || atom == atomState.set ||
atom == atomState.enumerable || atom == atomState.configurable)
@ -3247,8 +3247,8 @@ NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, Tagge
Rooted<TaggedProto> proto(cx, proto_);
RootedObject parent(cx, parent_);
JS_ASSERT_IF(proto.isObject(), cx->compartment == proto.toObject()->compartment());
JS_ASSERT_IF(parent, cx->compartment == parent->compartment());
JS_ASSERT_IF(proto.isObject(), cx->compartment() == proto.toObject()->compartment());
JS_ASSERT_IF(parent, cx->compartment() == parent->compartment());
Class *clasp;
if (callable)
clasp = &FunctionProxyClass;
@ -3297,8 +3297,8 @@ NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, JSObj
RootedObject call(cx, call_);
RootedObject construct(cx, construct_);
JS_ASSERT_IF(construct, cx->compartment == construct->compartment());
JS_ASSERT_IF(call && cx->compartment != call->compartment(), priv == ObjectValue(*call));
JS_ASSERT_IF(construct, cx->compartment() == construct->compartment());
JS_ASSERT_IF(call && cx->compartment() != call->compartment(), priv == ObjectValue(*call));
JSObject *proxy = NewProxyObject(cx, handler, priv, TaggedProto(proto_), parent_,
call || construct ? ProxyIsCallable : ProxyNotCallable);

View File

@ -270,17 +270,20 @@ template <> struct RootKind<JSScript *> : SpecificRootKind<JSScript *, THING_ROO
template <> struct RootKind<jsid> : SpecificRootKind<jsid, THING_ROOT_ID> {};
template <> struct RootKind<JS::Value> : SpecificRootKind<JS::Value, THING_ROOT_VALUE> {};
struct ContextFriendFields {
JSRuntime *const runtime;
struct ContextFriendFields
{
protected:
JSRuntime *const runtime_;
/* The current compartment. */
JSCompartment *compartment;
JSCompartment *compartment_;
/* The current zone. */
JS::Zone *zone_;
public:
explicit ContextFriendFields(JSRuntime *rt)
: runtime(rt), compartment(NULL), zone_(NULL)
: runtime_(rt), compartment_(NULL), zone_(NULL)
{ }
static const ContextFriendFields *get(const JSContext *cx) {
@ -310,6 +313,10 @@ struct ContextFriendFields {
*/
SkipRoot *skipGCRooters;
#endif
friend JSRuntime *GetRuntime(const JSContext *cx);
friend JSCompartment *GetContextCompartment(const JSContext *cx);
friend JS::Zone *GetContextZone(const JSContext *cx);
};
class PerThreadData;

View File

@ -118,7 +118,7 @@ Bindings::initWithTemporaryStorage(JSContext *cx, InternalBindingsHandle self,
return false;
#endif
StackBaseShape base(cx->compartment, &CallClass, cx->global(), NULL,
StackBaseShape base(cx->compartment(), &CallClass, cx->global(), NULL,
BaseShape::VAROBJ | BaseShape::DELEGATE);
UnownedBaseShape *nbase = BaseShape::getUnowned(cx, base);
@ -844,7 +844,7 @@ JSScript::initScriptCounts(JSContext *cx)
/* Enable interrupts in any interpreter frames running on this script. */
InterpreterFrames *frames;
for (frames = cx->runtime->interpreterFrames; frames; frames = frames->older)
for (frames = cx->runtime()->interpreterFrames; frames; frames = frames->older)
frames->enableInterruptsIfRunning(this);
return true;
@ -1127,7 +1127,7 @@ SourceCompressorThread::waitOnCompression(SourceCompressionToken *userTok)
// Update memory accounting.
if (!saveTok->oom)
saveTok->cx->runtime->updateMallocCounter(NULL, saveTok->ss->computedSizeOfData());
saveTok->cx->runtime()->updateMallocCounter(NULL, saveTok->ss->computedSizeOfData());
saveTok->ss = NULL;
saveTok->chars = NULL;
@ -1169,11 +1169,11 @@ JSScript::loadSource(JSContext *cx, HandleScript script, bool *worked)
{
JS_ASSERT(!script->scriptSource()->hasSourceData());
*worked = false;
if (!cx->runtime->sourceHook || !script->scriptSource()->sourceRetrievable())
if (!cx->runtime()->sourceHook || !script->scriptSource()->sourceRetrievable())
return true;
jschar *src = NULL;
uint32_t length;
if (!cx->runtime->sourceHook(cx, script, &src, &length))
if (!cx->runtime()->sourceHook(cx, script, &src, &length))
return false;
if (!src)
return true;
@ -1231,11 +1231,11 @@ ScriptSource::chars(JSContext *cx)
#endif
#ifdef JS_THREADSAFE
if (!ready())
return cx->runtime->sourceCompressorThread.currentChars();
return cx->runtime()->sourceCompressorThread.currentChars();
#endif
#ifdef USE_ZLIB
if (compressed()) {
cached = cx->runtime->sourceDataCache.lookup(this);
cached = cx->runtime()->sourceDataCache.lookup(this);
if (!cached) {
const size_t nbytes = sizeof(jschar) * (length_ + 1);
jschar *decompressed = static_cast<jschar *>(cx->malloc_(nbytes));
@ -1253,7 +1253,7 @@ ScriptSource::chars(JSContext *cx)
js_free(decompressed);
return NULL;
}
cx->runtime->sourceDataCache.put(this, cached);
cx->runtime()->sourceDataCache.put(this, cached);
}
return cached->chars().get();
}
@ -1285,10 +1285,10 @@ ScriptSource::setSourceCopy(JSContext *cx, const jschar *src, uint32_t length,
argumentsNotIncluded_ = argumentsNotIncluded;
#ifdef JS_THREADSAFE
if (tok && cx->runtime->useHelperThreads()) {
if (tok && cx->runtime()->useHelperThreads()) {
tok->ss = this;
tok->chars = src;
cx->runtime->sourceCompressorThread.compress(tok);
cx->runtime()->sourceCompressorThread.compress(tok);
} else
#endif
{
@ -1315,7 +1315,7 @@ SourceCompressionToken::complete()
JS_ASSERT_IF(!ss, !chars);
#ifdef JS_THREADSAFE
if (active()) {
cx->runtime->sourceCompressorThread.waitOnCompression(this);
cx->runtime()->sourceCompressorThread.waitOnCompression(this);
JS_ASSERT(!active());
}
if (oom) {
@ -1331,7 +1331,7 @@ SourceCompressionToken::abort()
{
JS_ASSERT(active());
#ifdef JS_THREADSAFE
cx->runtime->sourceCompressorThread.abort(this);
cx->runtime()->sourceCompressorThread.abort(this);
#endif
}
@ -1512,7 +1512,7 @@ js::SaveSharedScriptData(JSContext *cx, Handle<JSScript *> script, SharedScriptD
ASSERT(script != NULL);
ASSERT(ssd != NULL);
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
ScriptBytecodeHasher::Lookup l(ssd);
ScriptDataTable::AddPtr p = rt->scriptDataTable.lookupForAdd(l);
@ -1697,11 +1697,11 @@ JSScript::Create(JSContext *cx, HandleObject enclosingScope, bool savedCallerFun
script->enclosingScopeOrOriginalFunction_ = enclosingScope;
script->savedCallerFun = savedCallerFun;
script->compartment_ = cx->compartment;
script->compartment_ = cx->compartment();
/* Establish invariant: principals implies originPrincipals. */
if (options.principals) {
JS_ASSERT(options.principals == cx->compartment->principals);
JS_ASSERT(options.principals == cx->compartment()->principals);
script->originPrincipals
= options.originPrincipals ? options.originPrincipals : options.principals;
JS_HoldPrincipals(script->originPrincipals);
@ -2001,10 +2001,10 @@ js::CallNewScriptHook(JSContext *cx, HandleScript script, HandleFunction fun)
return;
JS_ASSERT(!script->isActiveEval);
if (JSNewScriptHook hook = cx->runtime->debugHooks.newScriptHook) {
AutoKeepAtoms keep(cx->runtime);
if (JSNewScriptHook hook = cx->runtime()->debugHooks.newScriptHook) {
AutoKeepAtoms keep(cx->runtime());
hook(cx, script->filename(), script->lineno, script, fun,
cx->runtime->debugHooks.newScriptHookData);
cx->runtime()->debugHooks.newScriptHookData);
}
}
@ -2064,7 +2064,7 @@ GSNCache::purge()
jssrcnote *
js_GetSrcNote(JSContext *cx, JSScript *script, jsbytecode *pc)
{
GSNCache *cache = &cx->runtime->gsnCache;
GSNCache *cache = &cx->runtime()->gsnCache;
cx = NULL; // nulling |cx| ensures GC can't be triggered, so |JSScript *script| is safe
size_t target = pc - script->code;
@ -2366,7 +2366,7 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
/* Now that all fallible allocation is complete, create the GC thing. */
CompileOptions options(cx);
options.setPrincipals(cx->compartment->principals)
options.setPrincipals(cx->compartment()->principals)
.setOriginPrincipals(src->originPrincipals)
.setCompileAndGo(src->compileAndGo)
.setSelfHostingMode(src->selfHosted)
@ -2463,7 +2463,7 @@ js::CloneFunctionScript(JSContext *cx, HandleFunction original, HandleFunction c
RootedScript script(cx, clone->nonLazyScript());
JS_ASSERT(script);
JS_ASSERT(script->compartment() == original->compartment());
JS_ASSERT_IF(script->compartment() != cx->compartment,
JS_ASSERT_IF(script->compartment() != cx->compartment(),
!script->enclosingStaticScope());
RootedObject scope(cx, script->enclosingStaticScope());
@ -2563,7 +2563,7 @@ JSScript::ensureHasDebugScript(JSContext *cx)
* debug state is destroyed.
*/
InterpreterFrames *frames;
for (frames = cx->runtime->interpreterFrames; frames; frames = frames->older)
for (frames = cx->runtime()->interpreterFrames; frames; frames = frames->older)
frames->enableInterruptsIfRunning(this);
return true;
@ -2589,7 +2589,7 @@ JSScript::tryNewStepMode(JSContext *cx, uint32_t newValue)
if (!prior != !newValue) {
/* Step mode has been enabled or disabled. Alert the methodjit. */
recompileForStepMode(cx->runtime->defaultFreeOp());
recompileForStepMode(cx->runtime()->defaultFreeOp());
if (!stepModeEnabled() && !debug->numSites)
js_free(releaseDebugScript());
@ -2615,7 +2615,7 @@ JSScript::changeStepModeCount(JSContext *cx, int delta)
return false;
assertSameCompartment(cx, this);
JS_ASSERT_IF(delta > 0, cx->compartment->debugMode());
JS_ASSERT_IF(delta > 0, cx->compartment()->debugMode());
DebugScript *debug = debugScript();
uint32_t count = debug->stepMode & stepCountMask;
@ -2637,7 +2637,7 @@ JSScript::getOrCreateBreakpointSite(JSContext *cx, jsbytecode *pc)
BreakpointSite *&site = debug->breakpoints[pc - code];
if (!site) {
site = cx->runtime->new_<BreakpointSite>(this, pc);
site = cx->runtime()->new_<BreakpointSite>(this, pc);
if (!site) {
js_ReportOutOfMemory(cx);
return NULL;
@ -2885,7 +2885,7 @@ JSScript::argumentsOptimizationFailed(JSContext *cx, HandleScript script)
* assumption of !script->needsArgsObj();
* - type inference data for the script assuming script->needsArgsObj
*/
for (AllFramesIter i(cx->runtime); !i.done(); ++i) {
for (AllFramesIter i(cx->runtime()); !i.done(); ++i) {
/*
* We cannot reliably create an arguments object for Ion activations of
* this script. To maintain the invariant that "script->needsArgsObj

View File

@ -403,7 +403,7 @@ str_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
int32_t slot = JSID_TO_INT(id);
if ((size_t)slot < str->length()) {
JSString *str1 = cx->runtime->staticStrings.getUnitStringForElement(cx, str, size_t(slot));
JSString *str1 = cx->runtime()->staticStrings.getUnitStringForElement(cx, str, size_t(slot));
if (!str1)
return false;
RootedValue value(cx, StringValue(str1));
@ -733,13 +733,13 @@ str_toLocaleLowerCase(JSContext *cx, unsigned argc, Value *vp)
* Forcefully ignore the first (or any) argument and return toLowerCase(),
* ECMA has reserved that argument, presumably for defining the locale.
*/
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeToLowerCase) {
if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeToLowerCase) {
RootedString str(cx, ThisToStringForStringProto(cx, args));
if (!str)
return false;
RootedValue result(cx);
if (!cx->runtime->localeCallbacks->localeToLowerCase(cx, str, &result))
if (!cx->runtime()->localeCallbacks->localeToLowerCase(cx, str, &result))
return false;
args.rval().set(result);
@ -800,13 +800,13 @@ str_toLocaleUpperCase(JSContext *cx, unsigned argc, Value *vp)
* Forcefully ignore the first (or any) argument and return toUpperCase(),
* ECMA has reserved that argument, presumably for defining the locale.
*/
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeToUpperCase) {
if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeToUpperCase) {
RootedString str(cx, ThisToStringForStringProto(cx, args));
if (!str)
return false;
RootedValue result(cx);
if (!cx->runtime->localeCallbacks->localeToUpperCase(cx, str, &result))
if (!cx->runtime()->localeCallbacks->localeToUpperCase(cx, str, &result))
return false;
args.rval().set(result);
@ -829,9 +829,9 @@ str_localeCompare(JSContext *cx, unsigned argc, Value *vp)
if (!thatStr)
return false;
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeCompare) {
if (cx->runtime()->localeCallbacks && cx->runtime()->localeCallbacks->localeCompare) {
RootedValue result(cx);
if (!cx->runtime->localeCallbacks->localeCompare(cx, str, thatStr, &result))
if (!cx->runtime()->localeCallbacks->localeCompare(cx, str, thatStr, &result))
return false;
args.rval().set(result);
@ -873,14 +873,14 @@ js_str_charAt(JSContext *cx, unsigned argc, Value *vp)
i = size_t(d);
}
str = cx->runtime->staticStrings.getUnitStringForElement(cx, str, i);
str = cx->runtime()->staticStrings.getUnitStringForElement(cx, str, i);
if (!str)
return false;
args.rval().setString(str);
return true;
out_of_range:
args.rval().setString(cx->runtime->emptyString);
args.rval().setString(cx->runtime()->emptyString);
return true;
}
@ -1651,7 +1651,7 @@ class StringRegExpGuard
return false;
} else {
if (convertVoid && !args.hasDefined(0)) {
fm.patstr = cx->runtime->emptyString;
fm.patstr = cx->runtime()->emptyString;
return true;
}
@ -1735,7 +1735,7 @@ class StringRegExpGuard
}
JS_ASSERT(patstr);
return cx->compartment->regExps.get(cx, patstr, opt, &re_);
return cx->compartment()->regExps.get(cx, patstr, opt, &re_);
}
RegExpShared &regExp() { return *re_; }
@ -2566,7 +2566,7 @@ str_replace_regexp_remove(JSContext *cx, CallArgs args, HandleString str, RegExp
/* Handle the empty string before calling .begin(). */
if (ranges.empty()) {
args.rval().setString(cx->runtime->emptyString);
args.rval().setString(cx->runtime()->emptyString);
return true;
}
@ -3134,7 +3134,7 @@ str_substr(JSContext *cx, unsigned argc, Value *vp)
return false;
if (begin >= length) {
args.rval().setString(cx->runtime->emptyString);
args.rval().setString(cx->runtime()->emptyString);
return true;
}
if (begin < 0) {
@ -3148,7 +3148,7 @@ str_substr(JSContext *cx, unsigned argc, Value *vp)
return false;
if (len <= 0) {
args.rval().setString(cx->runtime->emptyString);
args.rval().setString(cx->runtime()->emptyString);
return true;
}
@ -3215,10 +3215,10 @@ str_slice(JSContext *cx, unsigned argc, Value *vp)
if (begin <= end) {
size_t length = end - begin;
if (length == 0) {
str = cx->runtime->emptyString;
str = cx->runtime()->emptyString;
} else {
str = (length == 1)
? cx->runtime->staticStrings.getUnitStringForElement(cx, str, begin)
? cx->runtime()->staticStrings.getUnitStringForElement(cx, str, begin)
: js_NewDependentString(cx, str, begin, length);
if (!str)
return false;
@ -3510,7 +3510,7 @@ js_String(JSContext *cx, unsigned argc, Value *vp)
if (!str)
return false;
} else {
str = cx->runtime->emptyString;
str = cx->runtime()->emptyString;
}
if (IsConstructing(args)) {
@ -3536,7 +3536,7 @@ js::str_fromCharCode(JSContext *cx, unsigned argc, Value *vp)
if (!ToUint16(cx, args[0], &code))
return JS_FALSE;
if (StaticStrings::hasUnit(code)) {
args.rval().setString(cx->runtime->staticStrings.getUnit(code));
args.rval().setString(cx->runtime()->staticStrings.getUnit(code));
return JS_TRUE;
}
args[0].setInt32(code);
@ -3590,7 +3590,7 @@ js_InitStringClass(JSContext *cx, HandleObject obj)
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
Rooted<JSString*> empty(cx, cx->runtime->emptyString);
Rooted<JSString*> empty(cx, cx->runtime()->emptyString);
RootedObject proto(cx, global->createBlankPrototype(cx, &StringClass));
if (!proto || !proto->asString().init(cx, empty))
return NULL;
@ -3640,7 +3640,7 @@ JSLinearString *
js_NewDependentString(JSContext *cx, JSString *baseArg, size_t start, size_t length)
{
if (length == 0)
return cx->runtime->emptyString;
return cx->runtime()->emptyString;
JSLinearString *base = baseArg->ensureLinear(cx);
if (!base)
@ -3651,7 +3651,7 @@ js_NewDependentString(JSContext *cx, JSString *baseArg, size_t start, size_t len
const jschar *chars = base->chars() + start;
if (JSLinearString *staticStr = cx->runtime->staticStrings.lookup(chars, length))
if (JSLinearString *staticStr = cx->runtime()->staticStrings.lookup(chars, length))
return staticStr;
return JSDependentString::new_(cx, base, chars, length);
@ -4344,7 +4344,7 @@ Encode(JSContext *cx, Handle<JSLinearString*> str, const jschar *unescapedSet,
size_t length = str->length();
if (length == 0) {
rval.setString(cx->runtime->emptyString);
rval.setString(cx->runtime()->emptyString);
return true;
}
@ -4402,7 +4402,7 @@ Decode(JSContext *cx, Handle<JSLinearString*> str, const jschar *reservedSet, Mu
{
size_t length = str->length();
if (length == 0) {
rval.setString(cx->runtime->emptyString);
rval.setString(cx->runtime()->emptyString);
return true;
}

View File

@ -27,7 +27,7 @@ class RopeBuilder {
public:
RopeBuilder(JSContext *cx)
: cx(cx), res(cx, cx->runtime->emptyString)
: cx(cx), res(cx, cx->runtime()->emptyString)
{}
inline bool append(HandleString str) {

View File

@ -1923,7 +1923,7 @@ class TypedArrayTemplate
RootedId id(cx, NameToId(name));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
JSObject *getter = NewFunction(cx, NullPtr(), Getter<ValueGetter>, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
@ -2170,7 +2170,7 @@ class TypedArrayTemplate
if (!cx->stack.pushInvokeArgs(cx, 3, &ag))
return NULL;
ag.setCallee(cx->compartment->maybeGlobal()->createArrayFromBuffer<NativeType>());
ag.setCallee(cx->compartment()->maybeGlobal()->createArrayFromBuffer<NativeType>());
ag.setThis(ObjectValue(*bufobj));
ag[0] = NumberValue(byteOffset);
ag[1] = Int32Value(lengthInt);
@ -2768,7 +2768,7 @@ DataViewObject::class_constructor(JSContext *cx, unsigned argc, Value *vp)
return false;
if (bufobj->isWrapper() && UncheckedUnwrap(bufobj)->isArrayBuffer()) {
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
Rooted<JSObject*> proto(cx, global->getOrCreateDataViewPrototype(cx));
if (!proto)
return false;
@ -3535,7 +3535,7 @@ template<class ArrayType>
static inline JSObject *
InitTypedArrayClass(JSContext *cx)
{
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
RootedObject proto(cx, global->createBlankPrototype(cx, ArrayType::protoClass()));
if (!proto)
return NULL;
@ -3639,7 +3639,7 @@ js::IsTypedArrayThisCheck(JS::IsAcceptableThis test)
static JSObject *
InitArrayBufferClass(JSContext *cx)
{
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
RootedObject arrayBufferProto(cx, global->createBlankPrototype(cx, &ArrayBufferObject::protoClass));
if (!arrayBufferProto)
return NULL;
@ -3755,7 +3755,7 @@ DataViewObject::defineGetter(JSContext *cx, PropertyName *name, HandleObject pro
RootedId id(cx, NameToId(name));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
JSObject *getter = NewFunction(cx, NullPtr(), DataViewObject::getter<ValueGetter>, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
@ -3770,7 +3770,7 @@ DataViewObject::defineGetter(JSContext *cx, PropertyName *name, HandleObject pro
JSObject *
DataViewObject::initClass(JSContext *cx)
{
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
RootedObject proto(cx, global->createBlankPrototype(cx, &DataViewObject::protoClass));
if (!proto)
return NULL;

View File

@ -92,7 +92,7 @@ WatchpointMap::watch(JSContext *cx, HandleObject obj, HandleId id,
js_ReportOutOfMemory(cx);
return false;
}
WatchpointWriteBarrierPost(cx->runtime, &map, WatchKey(obj, id), w);
WatchpointWriteBarrierPost(cx->runtime(), &map, WatchKey(obj, id), w);
return true;
}

View File

@ -267,8 +267,8 @@ TryPreserveReflector(JSContext *cx, HandleObject obj)
(obj->getClass()->flags & JSCLASS_IS_DOMJSCLASS) ||
(obj->isProxy() && GetProxyHandler(obj)->family() == GetDOMProxyHandlerFamily()))
{
JS_ASSERT(cx->runtime->preserveWrapperCallback);
if (!cx->runtime->preserveWrapperCallback(cx, obj)) {
JS_ASSERT(cx->runtime()->preserveWrapperCallback);
if (!cx->runtime()->preserveWrapperCallback(cx, obj)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_WEAKMAP_KEY);
return false;
}
@ -320,7 +320,7 @@ WeakMap_set_impl(JSContext *cx, CallArgs args)
JS_ReportOutOfMemory(cx);
return false;
}
HashTableWriteBarrierPost(cx->runtime, map, key.get());
HashTableWriteBarrierPost(cx->runtime(), map, key.get());
args.rval().setUndefined();
return true;

View File

@ -134,7 +134,7 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
typedef typename Base::Range Range;
explicit WeakMap(JSContext *cx, JSObject *memOf=NULL)
: Base(cx), WeakMapBase(memOf, cx->compartment) { }
: Base(cx), WeakMapBase(memOf, cx->compartment()) { }
private:
bool markValue(JSTracer *trc, Value *x) {

View File

@ -43,14 +43,14 @@ bool
js::StartOffThreadAsmJSCompile(JSContext *cx, AsmJSParallelTask *asmData)
{
// Threads already initialized by the AsmJS compiler.
JS_ASSERT(cx->runtime->workerThreadState);
JS_ASSERT(cx->runtime()->workerThreadState);
JS_ASSERT(asmData->mir);
JS_ASSERT(asmData->lir == NULL);
WorkerThreadState &state = *cx->runtime->workerThreadState;
WorkerThreadState &state = *cx->runtime()->workerThreadState;
JS_ASSERT(state.numThreads);
AutoLockWorkerThreadState lock(cx->runtime);
AutoLockWorkerThreadState lock(cx->runtime());
// Don't append this task if another failed.
if (state.asmJSWorkerFailed())
@ -66,11 +66,11 @@ js::StartOffThreadAsmJSCompile(JSContext *cx, AsmJSParallelTask *asmData)
bool
js::StartOffThreadIonCompile(JSContext *cx, ion::IonBuilder *builder)
{
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (!EnsureParallelCompilationInitialized(rt))
return false;
WorkerThreadState &state = *cx->runtime->workerThreadState;
WorkerThreadState &state = *cx->runtime()->workerThreadState;
JS_ASSERT(state.numThreads);
AutoLockWorkerThreadState lock(rt);

View File

@ -166,8 +166,8 @@ OffThreadCompilationEnabled(JSContext *cx)
{
#ifdef JS_PARALLEL_COMPILATION
return ion::js_IonOptions.parallelCompilation
&& cx->runtime->useHelperThreads()
&& cx->runtime->helperThreadCount() != 0;
&& cx->runtime()->useHelperThreads()
&& cx->runtime()->helperThreadCount() != 0;
#else
return false;
#endif

View File

@ -136,7 +136,7 @@ js::TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject
ErrorCopier::~ErrorCopier()
{
JSContext *cx = ac.ref().context();
if (ac.ref().origin() != cx->compartment && cx->isExceptionPending()) {
if (ac.ref().origin() != cx->compartment() && cx->isExceptionPending()) {
RootedValue exc(cx, cx->getPendingException());
if (exc.isObject() && exc.toObject().isError() && exc.toObject().getPrivate()) {
cx->clearPendingException();
@ -216,9 +216,9 @@ CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapp
{
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, idCopy.address()),
cx->compartment()->wrapId(cx, idCopy.address()),
Wrapper::getPropertyDescriptor(cx, wrapper, idCopy, desc, flags),
cx->compartment->wrap(cx, desc));
cx->compartment()->wrap(cx, desc));
}
bool
@ -228,9 +228,9 @@ CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wr
{
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, idCopy.address()),
cx->compartment()->wrapId(cx, idCopy.address()),
Wrapper::getOwnPropertyDescriptor(cx, wrapper, idCopy, desc, flags),
cx->compartment->wrap(cx, desc));
cx->compartment()->wrap(cx, desc));
}
bool
@ -240,7 +240,7 @@ CrossCompartmentWrapper::defineProperty(JSContext *cx, HandleObject wrapper, Han
RootedId idCopy(cx, id);
AutoPropertyDescriptorRooter desc2(cx, desc);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, idCopy.address()) && cx->compartment->wrap(cx, &desc2),
cx->compartment()->wrapId(cx, idCopy.address()) && cx->compartment()->wrap(cx, &desc2),
Wrapper::defineProperty(cx, wrapper, idCopy, &desc2),
NOTHING);
}
@ -252,7 +252,7 @@ CrossCompartmentWrapper::getOwnPropertyNames(JSContext *cx, HandleObject wrapper
PIERCE(cx, wrapper,
NOTHING,
Wrapper::getOwnPropertyNames(cx, wrapper, props),
cx->compartment->wrap(cx, props));
cx->compartment()->wrap(cx, props));
}
bool
@ -260,7 +260,7 @@ CrossCompartmentWrapper::delete_(JSContext *cx, HandleObject wrapper, HandleId i
{
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, idCopy.address()),
cx->compartment()->wrapId(cx, idCopy.address()),
Wrapper::delete_(cx, wrapper, idCopy, bp),
NOTHING);
}
@ -271,7 +271,7 @@ CrossCompartmentWrapper::enumerate(JSContext *cx, HandleObject wrapper, AutoIdVe
PIERCE(cx, wrapper,
NOTHING,
Wrapper::enumerate(cx, wrapper, props),
cx->compartment->wrap(cx, props));
cx->compartment()->wrap(cx, props));
}
bool
@ -279,7 +279,7 @@ CrossCompartmentWrapper::has(JSContext *cx, HandleObject wrapper, HandleId id, b
{
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, idCopy.address()),
cx->compartment()->wrapId(cx, idCopy.address()),
Wrapper::has(cx, wrapper, idCopy, bp),
NOTHING);
}
@ -289,7 +289,7 @@ CrossCompartmentWrapper::hasOwn(JSContext *cx, HandleObject wrapper, HandleId id
{
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrapId(cx, idCopy.address()),
cx->compartment()->wrapId(cx, idCopy.address()),
Wrapper::hasOwn(cx, wrapper, idCopy, bp),
NOTHING);
}
@ -302,8 +302,8 @@ CrossCompartmentWrapper::get(JSContext *cx, HandleObject wrapper, HandleObject r
RootedId idCopy(cx, id);
{
AutoCompartment call(cx, wrappedObject(wrapper));
if (!cx->compartment->wrap(cx, receiverCopy.address()) ||
!cx->compartment->wrapId(cx, idCopy.address()))
if (!cx->compartment()->wrap(cx, receiverCopy.address()) ||
!cx->compartment()->wrapId(cx, idCopy.address()))
{
return false;
}
@ -311,7 +311,7 @@ CrossCompartmentWrapper::get(JSContext *cx, HandleObject wrapper, HandleObject r
if (!Wrapper::get(cx, wrapper, receiverCopy, idCopy, vp))
return false;
}
return cx->compartment->wrap(cx, vp);
return cx->compartment()->wrap(cx, vp);
}
bool
@ -321,9 +321,9 @@ CrossCompartmentWrapper::set(JSContext *cx, HandleObject wrapper, HandleObject r
RootedObject receiverCopy(cx, receiver);
RootedId idCopy(cx, id);
PIERCE(cx, wrapper,
cx->compartment->wrap(cx, receiverCopy.address()) &&
cx->compartment->wrapId(cx, idCopy.address()) &&
cx->compartment->wrap(cx, vp),
cx->compartment()->wrap(cx, receiverCopy.address()) &&
cx->compartment()->wrapId(cx, idCopy.address()) &&
cx->compartment()->wrap(cx, vp),
Wrapper::set(cx, wrapper, receiverCopy, idCopy, strict, vp),
NOTHING);
}
@ -334,7 +334,7 @@ CrossCompartmentWrapper::keys(JSContext *cx, HandleObject wrapper, AutoIdVector
PIERCE(cx, wrapper,
NOTHING,
Wrapper::keys(cx, wrapper, props),
cx->compartment->wrap(cx, props));
cx->compartment()->wrap(cx, props));
}
/*
@ -423,8 +423,8 @@ CrossCompartmentWrapper::iterate(JSContext *cx, HandleObject wrapper, unsigned f
}
if (CanReify(vp))
return Reify(cx, cx->compartment, vp);
return cx->compartment->wrap(cx, vp);
return Reify(cx, cx->compartment(), vp);
return cx->compartment()->wrap(cx, vp);
}
bool
@ -436,11 +436,11 @@ CrossCompartmentWrapper::call(JSContext *cx, HandleObject wrapper, const CallArg
AutoCompartment call(cx, wrapped);
args.setCallee(ObjectValue(*wrapped));
if (!cx->compartment->wrap(cx, args.mutableThisv()))
if (!cx->compartment()->wrap(cx, args.mutableThisv()))
return false;
for (size_t n = 0; n < args.length(); ++n) {
if (!cx->compartment->wrap(cx, args.handleAt(n)))
if (!cx->compartment()->wrap(cx, args.handleAt(n)))
return false;
}
@ -448,7 +448,7 @@ CrossCompartmentWrapper::call(JSContext *cx, HandleObject wrapper, const CallArg
return false;
}
return cx->compartment->wrap(cx, args.rval());
return cx->compartment()->wrap(cx, args.rval());
}
bool
@ -459,13 +459,13 @@ CrossCompartmentWrapper::construct(JSContext *cx, HandleObject wrapper, const Ca
AutoCompartment call(cx, wrapped);
for (size_t n = 0; n < args.length(); ++n) {
if (!cx->compartment->wrap(cx, args.handleAt(n)))
if (!cx->compartment()->wrap(cx, args.handleAt(n)))
return false;
}
if (!Wrapper::construct(cx, wrapper, args))
return false;
}
return cx->compartment->wrap(cx, args.rval());
return cx->compartment()->wrap(cx, args.rval());
}
bool
@ -490,7 +490,7 @@ CrossCompartmentWrapper::nativeCall(JSContext *cx, IsAcceptableThis test, Native
RootedValue source(cx);
for (; src < srcend; ++src, ++dst) {
source = *src;
if (!cx->compartment->wrap(cx, &source))
if (!cx->compartment()->wrap(cx, &source))
return false;
*dst = source.get();
@ -515,7 +515,7 @@ CrossCompartmentWrapper::nativeCall(JSContext *cx, IsAcceptableThis test, Native
srcArgs.rval().set(dstArgs.rval());
dstArgs.pop();
}
return cx->compartment->wrap(cx, srcArgs.rval());
return cx->compartment()->wrap(cx, srcArgs.rval());
}
bool
@ -523,7 +523,7 @@ CrossCompartmentWrapper::hasInstance(JSContext *cx, HandleObject wrapper, Mutabl
bool *bp)
{
AutoCompartment call(cx, wrappedObject(wrapper));
if (!cx->compartment->wrap(cx, v))
if (!cx->compartment()->wrap(cx, v))
return false;
return Wrapper::hasInstance(cx, wrapper, v, bp);
}
@ -545,7 +545,7 @@ CrossCompartmentWrapper::fun_toString(JSContext *cx, HandleObject wrapper, unsig
if (!str)
return NULL;
}
if (!cx->compartment->wrap(cx, str.address()))
if (!cx->compartment()->wrap(cx, str.address()))
return NULL;
return str;
}
@ -564,7 +564,7 @@ CrossCompartmentWrapper::defaultValue(JSContext *cx, HandleObject wrapper, JSTyp
PIERCE(cx, wrapper,
NOTHING,
Wrapper::defaultValue(cx, wrapper, hint, vp),
cx->compartment->wrap(cx, vp));
cx->compartment()->wrap(cx, vp));
}
bool
@ -585,7 +585,7 @@ CrossCompartmentWrapper::getPrototypeOf(JSContext *cx, HandleObject wrapper,
protop->setDelegate(cx);
}
return cx->compartment->wrap(cx, protop.address());
return cx->compartment()->wrap(cx, protop.address());
}
CrossCompartmentWrapper CrossCompartmentWrapper::singleton(0u);
@ -889,7 +889,7 @@ js::NukeCrossCompartmentWrappers(JSContext* cx,
js::NukeReferencesToWindow nukeReferencesToWindow)
{
CHECK_REQUEST(cx);
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
// Iterate through scopes looking for system cross compartment wrappers
// that point to an object that shares a global with obj.
@ -939,7 +939,7 @@ js::RemapWrapper(JSContext *cx, JSObject *wobjArg, JSObject *newTargetArg)
Value origv = ObjectValue(*origTarget);
JSCompartment *wcompartment = wobj->compartment();
AutoDisableProxyCheck adpc(cx->runtime);
AutoDisableProxyCheck adpc(cx->runtime());
// If we're mapping to a different target (as opposed to just recomputing
// for the same target), we must not have an existing wrapper for the new
@ -998,10 +998,10 @@ js::RemapAllWrappersForObject(JSContext *cx, JSObject *oldTargetArg,
RootedObject newTarget(cx, newTargetArg);
AutoWrapperVector toTransplant(cx);
if (!toTransplant.reserve(cx->runtime->numCompartments))
if (!toTransplant.reserve(cx->runtime()->numCompartments))
return false;
for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) {
for (CompartmentsIter c(cx->runtime()); !c.done(); c.next()) {
if (WrapperMap::Ptr wp = c->lookupWrapper(origv)) {
// We found a wrapper. Remember and root it.
toTransplant.infallibleAppend(WrapperValue(wp));
@ -1026,7 +1026,7 @@ js::RecomputeWrappers(JSContext *cx, const CompartmentFilter &sourceFilter,
AutoWrapperVector toRecompute(cx);
for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) {
for (CompartmentsIter c(cx->runtime()); !c.done(); c.next()) {
// Filter by source compartment.
if (!sourceFilter.match(c))
continue;

View File

@ -495,7 +495,7 @@ ReadEvalPrintLoop(JSContext *cx, Handle<JSObject*> global, FILE *in, FILE *out,
typedef Vector<char, 32, ContextAllocPolicy> CharBuffer;
CharBuffer buffer(cx);
do {
ScheduleWatchdog(cx->runtime, -1);
ScheduleWatchdog(cx->runtime(), -1);
gTimedOut = false;
errno = 0;
@ -513,7 +513,7 @@ ReadEvalPrintLoop(JSContext *cx, Handle<JSObject*> global, FILE *in, FILE *out,
return;
lineno++;
if (!ScheduleWatchdog(cx->runtime, gTimeoutInterval)) {
if (!ScheduleWatchdog(cx->runtime(), gTimeoutInterval)) {
hitEOF = true;
break;
}
@ -1605,7 +1605,7 @@ SetDebuggerHandler(JSContext *cx, unsigned argc, jsval *vp)
if (!str)
return false;
JS_SetDebuggerHandler(cx->runtime, DebuggerAndThrowHandler, str);
JS_SetDebuggerHandler(cx->runtime(), DebuggerAndThrowHandler, str);
args.rval().setUndefined();
return true;
}
@ -1625,7 +1625,7 @@ SetThrowHook(JSContext *cx, unsigned argc, jsval *vp)
if (!str)
return false;
JS_SetThrowHook(cx->runtime, DebuggerAndThrowHandler, str);
JS_SetThrowHook(cx->runtime(), DebuggerAndThrowHandler, str);
args.rval().setUndefined();
return true;
}
@ -2326,7 +2326,7 @@ Clone(JSContext *cx, unsigned argc, jsval *vp)
funobj = JS_GetFunctionObject(fun);
}
}
if (funobj->compartment() != cx->compartment) {
if (funobj->compartment() != cx->compartment()) {
JSFunction *fun = funobj->toFunction();
if (fun->hasScript() && fun->nonLazyScript()->compileAndGo) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE,
@ -2502,7 +2502,7 @@ NewSandbox(JSContext *cx, bool lazy)
return NULL;
}
if (!cx->compartment->wrap(cx, obj.address()))
if (!cx->compartment()->wrap(cx, obj.address()))
return NULL;
return obj;
}
@ -2570,7 +2570,7 @@ EvalInContext(JSContext *cx, unsigned argc, jsval *vp)
}
}
if (!cx->compartment->wrap(cx, &rval))
if (!cx->compartment()->wrap(cx, &rval))
return false;
JS_SET_RVAL(cx, vp, rval);
@ -3033,7 +3033,7 @@ SetTimeoutValue(JSContext *cx, double t)
return false;
}
gTimeoutInterval = t;
if (!ScheduleWatchdog(cx->runtime, t)) {
if (!ScheduleWatchdog(cx->runtime(), t)) {
JS_ReportError(cx, "Failed to create the watchdog");
return false;
}
@ -3210,7 +3210,7 @@ SyntaxParse(JSContext *cx, unsigned argc, jsval *vp)
if (!succeeded && !parser.hadAbortedSyntaxParse()) {
// If no exception is posted, either there was an OOM or a language
// feature unhandled by the syntax parser was encountered.
JS_ASSERT(cx->runtime->hadOutOfMemory);
JS_ASSERT(cx->runtime()->hadOutOfMemory);
return false;
}
@ -3356,7 +3356,7 @@ DecompileThisScript(JSContext *cx, unsigned argc, Value *vp)
CallArgs args = CallArgsFromVp(argc, vp);
RootedScript script (cx);
if (!JS_DescribeScriptedCaller(cx, script.address(), NULL)) {
args.rval().setString(cx->runtime->emptyString);
args.rval().setString(cx->runtime()->emptyString);
return true;
}
JSString *result = JS_DecompileScript(cx, script, "test", 0);
@ -3372,7 +3372,7 @@ ThisFilename(JSContext *cx, unsigned argc, Value *vp)
CallArgs args = CallArgsFromVp(argc, vp);
RootedScript script (cx);
if (!JS_DescribeScriptedCaller(cx, script.address(), NULL) || !script->filename()) {
args.rval().setString(cx->runtime->emptyString);
args.rval().setString(cx->runtime()->emptyString);
return true;
}
JSString *filename = JS_NewStringCopyZ(cx, script->filename());
@ -3557,7 +3557,7 @@ GetSelfHostedValue(JSContext *cx, unsigned argc, jsval *vp)
if (!srcAtom)
return false;
RootedPropertyName srcName(cx, srcAtom->asPropertyName());
return cx->runtime->cloneSelfHostedValue(cx, srcName, args.rval());
return cx->runtime()->cloneSelfHostedValue(cx, srcName, args.rval());
}
static JSFunctionSpecWithHelp shell_functions[] = {
@ -4861,7 +4861,7 @@ NewGlobalObject(JSContext *cx, JSObject *sameZoneAs)
static js::DOMCallbacks DOMcallbacks = {
InstanceClassHasProtoAtDepth
};
SetDOMCallbacks(cx->runtime, &DOMcallbacks);
SetDOMCallbacks(cx->runtime(), &DOMcallbacks);
RootedObject domProto(cx, JS_InitClass(cx, glob, NULL, &dom_class, dom_constructor, 0,
dom_props, dom_methods, NULL, NULL));
@ -4950,7 +4950,7 @@ ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
#ifdef JS_THREADSAFE
int32_t threadCount = op->getIntOption("thread-count");
if (threadCount >= 0)
cx->runtime->requestHelperThreadCount(threadCount);
cx->runtime()->requestHelperThreadCount(threadCount);
#endif /* JS_THREADSAFE */
#if defined(JS_ION)
@ -5061,7 +5061,7 @@ ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
#ifdef JS_THREADSAFE
if (const char *str = op->getStringOption("ion-parallel-compile")) {
if (strcmp(str, "on") == 0) {
if (cx->runtime->helperThreadCount() == 0) {
if (cx->runtime()->helperThreadCount() == 0) {
fprintf(stderr, "Parallel compilation not available without helper threads");
return EXIT_FAILURE;
}

View File

@ -484,7 +484,7 @@ ReferenceFinder::addReferrer(jsval referrerArg, Path *path)
{
RootedValue referrer(context, referrerArg);
if (!context->compartment->wrap(context, &referrer))
if (!context->compartment()->wrap(context, &referrer))
return false;
ScopedJSFreePtr<char> pathName(path->computeName(context));

View File

@ -17,7 +17,7 @@ js::Debugger::onLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool ok)
/* Traps must be cleared from eval frames, see slowPathOnLeaveFrame. */
bool evalTraps = frame.isEvalFrame() &&
frame.script()->hasAnyBreakpointsOrStepMode();
if (!cx->compartment->getDebuggees().empty() || evalTraps)
if (!cx->compartment()->getDebuggees().empty() || evalTraps)
ok = slowPathOnLeaveFrame(cx, frame, ok);
return ok;
}

View File

@ -371,7 +371,7 @@ Debugger::Debugger(JSContext *cx, JSObject *dbg)
{
assertSameCompartment(cx, dbg);
cx->runtime->debuggerList.insertBack(this);
cx->runtime()->debuggerList.insertBack(this);
JS_INIT_CLIST(&breakpoints);
JS_INIT_CLIST(&onNewGlobalObjectWatchersLink);
}
@ -576,7 +576,7 @@ Debugger::slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool frame
* At this point, we are back in the debuggee compartment, and any error has
* been wrapped up as a completion value.
*/
JS_ASSERT(cx->compartment == global->compartment());
JS_ASSERT(cx->compartment() == global->compartment());
JS_ASSERT(!cx->isExceptionPending());
/* JSTRAP_CONTINUE means "make no change". */
@ -597,7 +597,7 @@ Debugger::slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool frame
Debugger *dbg = r.frontDebugger();
JS_ASSERT(dbg == Debugger::fromChildJSObject(frameobj));
DebuggerFrame_freeScriptFrameIterData(cx->runtime->defaultFreeOp(), frameobj);
DebuggerFrame_freeScriptFrameIterData(cx->runtime()->defaultFreeOp(), frameobj);
/* If this frame had an onStep handler, adjust the script's count. */
if (!frameobj->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER).isUndefined() &&
@ -616,7 +616,7 @@ Debugger::slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool frame
*/
if (frame.isEvalFrame()) {
RootedScript script(cx, frame.script());
script->clearBreakpointsIn(cx->runtime->defaultFreeOp(), NULL, NULL);
script->clearBreakpointsIn(cx->runtime()->defaultFreeOp(), NULL, NULL);
}
/* Establish (status, value) as our resumption value. */
@ -717,7 +717,7 @@ Debugger::wrapDebuggeeValue(JSContext *cx, MutableHandleValue vp)
vp.setObject(*dobj);
}
} else if (!cx->compartment->wrap(cx, vp)) {
} else if (!cx->compartment()->wrap(cx, vp)) {
vp.setUndefined();
return false;
}
@ -907,7 +907,7 @@ Debugger::parseResumptionValue(Maybe<AutoCompartment> &ac, bool ok, const Value
return handleUncaughtException(ac, &v, callHook);
ac.destroy();
if (!cx->compartment->wrap(cx, &v)) {
if (!cx->compartment()->wrap(cx, &v)) {
vp.setUndefined();
return JSTRAP_ERROR;
}
@ -1323,7 +1323,7 @@ Debugger::fireNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global, Muta
bool
Debugger::slowPathOnNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global)
{
JS_ASSERT(!JS_CLIST_IS_EMPTY(&cx->runtime->onNewGlobalObjectWatchers));
JS_ASSERT(!JS_CLIST_IS_EMPTY(&cx->runtime()->onNewGlobalObjectWatchers));
/*
* Make a copy of the runtime's onNewGlobalObjectWatchers before running the
@ -1331,8 +1331,8 @@ Debugger::slowPathOnNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global
* can be mutated while we're walking it.
*/
AutoObjectVector watchers(cx);
for (JSCList *link = JS_LIST_HEAD(&cx->runtime->onNewGlobalObjectWatchers);
link != &cx->runtime->onNewGlobalObjectWatchers;
for (JSCList *link = JS_LIST_HEAD(&cx->runtime()->onNewGlobalObjectWatchers);
link != &cx->runtime()->onNewGlobalObjectWatchers;
link = JS_NEXT_LINK(link)) {
Debugger *dbg = fromOnNewGlobalObjectWatchersLink(link);
JS_ASSERT(dbg->observesNewGlobalObject());
@ -1724,9 +1724,9 @@ Debugger::setEnabled(JSContext *cx, unsigned argc, Value *vp)
if (enabled != dbg->enabled) {
for (Breakpoint *bp = dbg->firstBreakpoint(); bp; bp = bp->nextInDebugger()) {
if (enabled)
bp->site->inc(cx->runtime->defaultFreeOp());
bp->site->inc(cx->runtime()->defaultFreeOp());
else
bp->site->dec(cx->runtime->defaultFreeOp());
bp->site->dec(cx->runtime()->defaultFreeOp());
}
/*
@ -1738,7 +1738,7 @@ Debugger::setEnabled(JSContext *cx, unsigned argc, Value *vp)
/* If we were not enabled, the link should be a singleton list. */
JS_ASSERT(JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
JS_APPEND_LINK(&dbg->onNewGlobalObjectWatchersLink,
&cx->runtime->onNewGlobalObjectWatchers);
&cx->runtime()->onNewGlobalObjectWatchers);
} else {
/* If we were enabled, the link should be inserted in the list. */
JS_ASSERT(!JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
@ -1852,7 +1852,7 @@ Debugger::setOnNewGlobalObject(JSContext *cx, unsigned argc, Value *vp)
/* If we didn't have a hook, the link should be a singleton list. */
JS_ASSERT(JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
JS_APPEND_LINK(&dbg->onNewGlobalObjectWatchersLink,
&cx->runtime->onNewGlobalObjectWatchers);
&cx->runtime()->onNewGlobalObjectWatchers);
} else if (oldHook && !newHook) {
/* If we did have a hook, the link should be inserted in the list. */
JS_ASSERT(!JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
@ -1951,8 +1951,8 @@ JSBool
Debugger::addAllGlobalsAsDebuggees(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGGER(cx, argc, vp, "addAllGlobalsAsDebuggees", args, dbg);
AutoDebugModeGC dmgc(cx->runtime);
for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) {
AutoDebugModeGC dmgc(cx->runtime());
for (CompartmentsIter c(cx->runtime()); !c.done(); c.next()) {
if (c == dbg->object->compartment())
continue;
c->zone()->scheduledForDestruction = false;
@ -1977,7 +1977,7 @@ Debugger::removeDebuggee(JSContext *cx, unsigned argc, Value *vp)
if (!global)
return false;
if (dbg->debuggees.has(global))
dbg->removeDebuggeeGlobal(cx->runtime->defaultFreeOp(), global, NULL, NULL);
dbg->removeDebuggeeGlobal(cx->runtime()->defaultFreeOp(), global, NULL, NULL);
args.rval().setUndefined();
return true;
}
@ -1986,9 +1986,9 @@ JSBool
Debugger::removeAllDebuggees(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGGER(cx, argc, vp, "removeAllDebuggees", args, dbg);
AutoDebugModeGC dmgc(cx->runtime);
AutoDebugModeGC dmgc(cx->runtime());
for (GlobalObjectSet::Enum e(dbg->debuggees); !e.empty(); e.popFront())
dbg->removeDebuggeeGlobal(cx->runtime->defaultFreeOp(), e.front(), dmgc, NULL, &e);
dbg->removeDebuggeeGlobal(cx->runtime()->defaultFreeOp(), e.front(), dmgc, NULL, &e);
args.rval().setUndefined();
return true;
}
@ -2033,7 +2033,7 @@ Debugger::getNewestFrame(JSContext *cx, unsigned argc, Value *vp)
* cx->fp() would return the topmost frame in the current context.
* Since there may be multiple contexts, use AllFramesIter instead.
*/
for (AllFramesIter i(cx->runtime); !i.done(); ++i) {
for (AllFramesIter i(cx->runtime()); !i.done(); ++i) {
/*
* Debug-mode currently disables Ion compilation in the compartment of
* the debuggee.
@ -2056,7 +2056,7 @@ Debugger::clearAllBreakpoints(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGGER(cx, argc, vp, "clearAllBreakpoints", args, dbg);
for (GlobalObjectSet::Range r = dbg->debuggees.all(); !r.empty(); r.popFront())
r.front()->compartment()->clearBreakpointsIn(cx->runtime->defaultFreeOp(), dbg, NULL);
r.front()->compartment()->clearBreakpointsIn(cx->runtime()->defaultFreeOp(), dbg, NULL);
return true;
}
@ -2119,7 +2119,7 @@ Debugger::construct(JSContext *cx, unsigned argc, Value *vp)
bool
Debugger::addDebuggeeGlobal(JSContext *cx, Handle<GlobalObject*> global)
{
AutoDebugModeGC dmgc(cx->runtime);
AutoDebugModeGC dmgc(cx->runtime());
return addDebuggeeGlobal(cx, global, dmgc);
}
@ -2390,7 +2390,7 @@ class Debugger::ScriptQuery {
/* Search each compartment for debuggee scripts. */
vector = v;
oom = false;
IterateScripts(cx->runtime, NULL, this, considerScript);
IterateScripts(cx->runtime(), NULL, this, considerScript);
if (oom) {
js_ReportOutOfMemory(cx);
return false;
@ -2619,7 +2619,7 @@ Debugger::findAllGlobals(JSContext *cx, unsigned argc, Value *vp)
if (!result)
return false;
for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) {
for (CompartmentsIter c(cx->runtime()); !c.done(); c.next()) {
c->zone()->scheduledForDestruction = false;
GlobalObject *global = c->maybeGlobal();
@ -2731,7 +2731,7 @@ JSObject *
Debugger::wrapScript(JSContext *cx, HandleScript script)
{
assertSameCompartment(cx, object.get());
JS_ASSERT(cx->compartment != script->compartment());
JS_ASSERT(cx->compartment() != script->compartment());
ScriptWeakMap::AddPtr p = scripts.lookupForAdd(script);
if (!p) {
JSObject *scriptobj = newDebuggerScript(cx, script);
@ -3394,7 +3394,7 @@ Debugger::handleBaselineOsr(JSContext *cx, StackFrame *from, ion::BaselineFrame
JS_ASSERT(dbg == Debugger::fromChildJSObject(frameobj));
// Update frame object's ScriptFrameIter::data pointer.
DebuggerFrame_freeScriptFrameIterData(cx->runtime->defaultFreeOp(), frameobj);
DebuggerFrame_freeScriptFrameIterData(cx->runtime()->defaultFreeOp(), frameobj);
ScriptFrameIter::Data *data = iter.copyData();
if (!data)
return false;
@ -3437,13 +3437,13 @@ DebuggerScript_setBreakpoint(JSContext *cx, unsigned argc, Value *vp)
BreakpointSite *site = script->getOrCreateBreakpointSite(cx, pc);
if (!site)
return false;
site->inc(cx->runtime->defaultFreeOp());
if (cx->runtime->new_<Breakpoint>(dbg, site, handler)) {
site->inc(cx->runtime()->defaultFreeOp());
if (cx->runtime()->new_<Breakpoint>(dbg, site, handler)) {
args.rval().setUndefined();
return true;
}
site->dec(cx->runtime->defaultFreeOp());
site->destroyIfEmpty(cx->runtime->defaultFreeOp());
site->dec(cx->runtime()->defaultFreeOp());
site->destroyIfEmpty(cx->runtime()->defaultFreeOp());
return false;
}
@ -3494,7 +3494,7 @@ DebuggerScript_clearBreakpoint(JSContext *cx, unsigned argc, Value *vp)
if (!handler)
return false;
script->clearBreakpointsIn(cx->runtime->defaultFreeOp(), dbg, handler);
script->clearBreakpointsIn(cx->runtime()->defaultFreeOp(), dbg, handler);
args.rval().setUndefined();
return true;
}
@ -3504,7 +3504,7 @@ DebuggerScript_clearAllBreakpoints(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "clearAllBreakpoints", args, obj, script);
Debugger *dbg = Debugger::fromChildJSObject(obj);
script->clearBreakpointsIn(cx->runtime->defaultFreeOp(), dbg, NULL);
script->clearBreakpointsIn(cx->runtime()->defaultFreeOp(), dbg, NULL);
args.rval().setUndefined();
return true;
}
@ -3597,7 +3597,7 @@ JSObject *
Debugger::wrapSource(JSContext *cx, JS::HandleScriptSource source)
{
assertSameCompartment(cx, object.get());
JS_ASSERT(cx->compartment != source->compartment());
JS_ASSERT(cx->compartment() != source->compartment());
SourceWeakMap::AddPtr p = sources.lookupForAdd(source);
if (!p) {
JSObject *sourceobj = newDebuggerSource(cx, source);
@ -4232,7 +4232,7 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName,
for (size_t i = 0; i < keys.length(); i++) {
id = keys[i];
MutableHandleValue val = values.handleAt(i);
if (!cx->compartment->wrap(cx, val) ||
if (!cx->compartment()->wrap(cx, val) ||
!DefineNativeProperty(cx, env, id, val, NULL, NULL, 0, 0, 0))
{
return false;
@ -4581,7 +4581,7 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
{
Maybe<AutoCompartment> ac;
ac.construct(cx, obj);
if (!cx->compartment->wrapId(cx, id.address()))
if (!cx->compartment()->wrapId(cx, id.address()))
return false;
ErrorCopier ec(ac, dbg->toJSObject());
@ -4640,7 +4640,7 @@ DebuggerObject_getOwnPropertyNames(JSContext *cx, unsigned argc, Value *vp)
vals[i].setString(str);
} else if (JSID_IS_ATOM(id)) {
vals[i].setString(JSID_TO_STRING(id));
if (!cx->compartment->wrap(cx, vals.handleAt(i)))
if (!cx->compartment()->wrap(cx, vals.handleAt(i)))
return false;
} else {
vals[i].setObject(*JSID_TO_OBJECT(id));
@ -4771,7 +4771,7 @@ DebuggerObject_deleteProperty(JSContext *cx, unsigned argc, Value *vp)
Maybe<AutoCompartment> ac;
ac.construct(cx, obj);
if (!cx->compartment->wrap(cx, &nameArg))
if (!cx->compartment()->wrap(cx, &nameArg))
return false;
JSBool succeeded;
@ -4930,13 +4930,13 @@ ApplyOrCall(JSContext *cx, unsigned argc, Value *vp, ApplyOrCallMode mode)
*/
Maybe<AutoCompartment> ac;
ac.construct(cx, obj);
if (!cx->compartment->wrap(cx, &calleev) || !cx->compartment->wrap(cx, &thisv))
if (!cx->compartment()->wrap(cx, &calleev) || !cx->compartment()->wrap(cx, &thisv))
return false;
RootedValue arg(cx);
for (unsigned i = 0; i < callArgc; i++) {
arg = callArgv[i];
if (!cx->compartment->wrap(cx, &arg))
if (!cx->compartment()->wrap(cx, &arg))
return false;
callArgv[i] = arg;
}
@ -4976,7 +4976,7 @@ DebuggerObject_makeDebuggeeValue(JSContext *cx, unsigned argc, Value *vp)
// argument as appropriate for references from there.
{
AutoCompartment ac(cx, referent);
if (!cx->compartment->wrap(cx, &arg0))
if (!cx->compartment()->wrap(cx, &arg0))
return false;
}
@ -5059,7 +5059,7 @@ DebuggerObject_unsafeDereference(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, "unsafeDereference", args, referent);
args.rval().setObject(*referent);
return cx->compartment->wrap(cx, args.rval());
return cx->compartment()->wrap(cx, args.rval());
}
static const JSPropertySpec DebuggerObject_properties[] = {
@ -5289,7 +5289,7 @@ DebuggerEnv_names(JSContext *cx, unsigned argc, Value *vp)
for (size_t i = 0, len = keys.length(); i < len; i++) {
id = keys[i];
if (JSID_IS_ATOM(id) && IsIdentifier(JSID_TO_ATOM(id))) {
if (!cx->compartment->wrapId(cx, id.address()))
if (!cx->compartment()->wrapId(cx, id.address()))
return false;
if (!js_NewbornArrayPush(cx, arr, StringValue(JSID_TO_STRING(id))))
return false;
@ -5312,7 +5312,7 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp)
{
Maybe<AutoCompartment> ac;
ac.construct(cx, env);
if (!cx->compartment->wrapId(cx, id.address()))
if (!cx->compartment()->wrapId(cx, id.address()))
return false;
/* This can trigger resolve hooks. */
@ -5344,7 +5344,7 @@ DebuggerEnv_getVariable(JSContext *cx, unsigned argc, Value *vp)
{
Maybe<AutoCompartment> ac;
ac.construct(cx, env);
if (!cx->compartment->wrapId(cx, id.address()))
if (!cx->compartment()->wrapId(cx, id.address()))
return false;
/* This can trigger getters. */
@ -5376,7 +5376,7 @@ DebuggerEnv_setVariable(JSContext *cx, unsigned argc, Value *vp)
{
Maybe<AutoCompartment> ac;
ac.construct(cx, env);
if (!cx->compartment->wrapId(cx, id.address()) || !cx->compartment->wrap(cx, &v))
if (!cx->compartment()->wrapId(cx, id.address()) || !cx->compartment()->wrap(cx, &v))
return false;
/* This can trigger setters. */

View File

@ -433,7 +433,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
bool wrapEnvironment(JSContext *cx, Handle<Env*> env, MutableHandleValue vp);
/*
* Like cx->compartment->wrap(cx, vp), but for the debugger compartment.
* Like cx->compartment()->wrap(cx, vp), but for the debugger compartment.
*
* Preconditions: *vp is a value from a debuggee compartment; cx is in the
* debugger's compartment.
@ -462,7 +462,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
* When passing values from the debugger to the debuggee:
* call unwrapDebuggeeValue; // debugger-unwrapping
* enter debuggee compartment;
* call cx->compartment->wrap; // compartment-rewrapping
* call cx->compartment()->wrap; // compartment-rewrapping
*
* (Extreme nerd sidebar: Unwrapping happens in two steps because there are
* two different kinds of symmetry at work: regardless of which direction
@ -655,7 +655,7 @@ Debugger::observesGlobal(GlobalObject *global) const
JSTrapStatus
Debugger::onEnterFrame(JSContext *cx, AbstractFramePtr frame, MutableHandleValue vp)
{
if (cx->compartment->getDebuggees().empty())
if (cx->compartment()->getDebuggees().empty())
return JSTRAP_CONTINUE;
return slowPathOnEnterFrame(cx, frame, vp);
}
@ -663,7 +663,7 @@ Debugger::onEnterFrame(JSContext *cx, AbstractFramePtr frame, MutableHandleValue
JSTrapStatus
Debugger::onDebuggerStatement(JSContext *cx, MutableHandleValue vp)
{
return cx->compartment->getDebuggees().empty()
return cx->compartment()->getDebuggees().empty()
? JSTRAP_CONTINUE
: dispatchHook(cx, vp, OnDebuggerStatement);
}
@ -671,7 +671,7 @@ Debugger::onDebuggerStatement(JSContext *cx, MutableHandleValue vp)
JSTrapStatus
Debugger::onExceptionUnwind(JSContext *cx, MutableHandleValue vp)
{
return cx->compartment->getDebuggees().empty()
return cx->compartment()->getDebuggees().empty()
? JSTRAP_CONTINUE
: dispatchHook(cx, vp, OnExceptionUnwind);
}
@ -688,7 +688,7 @@ Debugger::onNewScript(JSContext *cx, HandleScript script, GlobalObject *compileA
bool
Debugger::onNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global)
{
if (JS_CLIST_IS_EMPTY(&cx->runtime->onNewGlobalObjectWatchers))
if (JS_CLIST_IS_EMPTY(&cx->runtime()->onNewGlobalObjectWatchers))
return true;
return Debugger::slowPathOnNewGlobalObject(cx, global);
}

View File

@ -155,7 +155,7 @@ ExecuteSequentially(JSContext *cx, HandleValue funVal, bool *complete)
args.setThis(UndefinedValue());
args[0].setInt32(i);
args[1].setInt32(numSlices);
args[2].setBoolean(!!cx->runtime->parallelWarmup);
args[2].setBoolean(!!cx->runtime()->parallelWarmup);
if (!fig.invoke(cx))
return false;
allComplete = allComplete & args.rval().toBoolean();
@ -373,7 +373,7 @@ class ForkJoinShared : public TaskExecutor, public Monitor
// Requests that computation abort.
void setAbortFlag(bool fatal);
JSRuntime *runtime() { return cx_->runtime; }
JSRuntime *runtime() { return cx_->runtime(); }
JSContext *acquireContext() { PR_Lock(cxLock_); return cx_; }
void releaseContext() { PR_Unlock(cxLock_); }
@ -1040,7 +1040,7 @@ js::ParallelDo::warmupExecution(ExecutionStatus *status)
Spew(SpewOps, "Executing warmup.");
AutoEnterWarmup warmup(cx_->runtime);
AutoEnterWarmup warmup(cx_->runtime());
RootedValue funVal(cx_, ObjectValue(*fun_));
bool complete;
if (!ExecuteSequentially(cx_, funVal, &complete)) {
@ -1079,14 +1079,14 @@ class AutoEnterParallelSection
// a minor GC to ensure no cross-generation pointers get
// created:
if (JS::IsIncrementalGCInProgress(cx->runtime)) {
JS::PrepareForIncrementalGC(cx->runtime);
JS::FinishIncrementalGC(cx->runtime, JS::gcreason::API);
if (JS::IsIncrementalGCInProgress(cx->runtime())) {
JS::PrepareForIncrementalGC(cx->runtime());
JS::FinishIncrementalGC(cx->runtime(), JS::gcreason::API);
}
MinorGC(cx->runtime, JS::gcreason::API);
MinorGC(cx->runtime(), JS::gcreason::API);
cx->runtime->gcHelperThread.waitBackgroundSweepEnd();
cx->runtime()->gcHelperThread.waitBackgroundSweepEnd();
}
~AutoEnterParallelSection() {
@ -1107,7 +1107,7 @@ js::ParallelDo::parallelExecution(ExecutionStatus *status)
AutoEnterParallelSection enter(cx_);
ThreadPool *threadPool = &cx_->runtime->threadPool;
ThreadPool *threadPool = &cx_->runtime()->threadPool;
uint32_t numSlices = ForkJoinSlices(cx_);
RootedObject rootedFun(cx_, fun_);
@ -1268,7 +1268,7 @@ ForkJoinShared::init()
return false;
for (unsigned i = 0; i < numSlices_; i++) {
Allocator *allocator = cx_->runtime->new_<Allocator>(cx_->zone());
Allocator *allocator = cx_->runtime()->new_<Allocator>(cx_->zone());
if (!allocator)
return false;
@ -1298,7 +1298,7 @@ ForkJoinShared::execute()
// Sometimes a GC request occurs *just before* we enter into the
// parallel section. Rather than enter into the parallel section
// and then abort, we just check here and abort early.
if (cx_->runtime->interrupt)
if (cx_->runtime()->interrupt)
return TP_RETRY_SEQUENTIALLY;
AutoLockMonitor lock(*this);
@ -1332,13 +1332,13 @@ ForkJoinShared::execute()
void
ForkJoinShared::transferArenasToCompartmentAndProcessGCRequests()
{
JSCompartment *comp = cx_->compartment;
JSCompartment *comp = cx_->compartment();
for (unsigned i = 0; i < numSlices_; i++)
comp->adoptWorkerAllocator(allocators_[i]);
if (gcRequested_) {
if (!gcZone_)
TriggerGC(cx_->runtime, gcReason_);
TriggerGC(cx_->runtime(), gcReason_);
else
TriggerZoneGC(gcZone_, gcReason_);
gcRequested_ = false;
@ -1351,7 +1351,7 @@ ForkJoinShared::executeFromWorker(uint32_t workerId, uintptr_t stackLimit)
{
JS_ASSERT(workerId < numSlices_ - 1);
PerThreadData thisThread(cx_->runtime);
PerThreadData thisThread(cx_->runtime());
TlsPerThreadData.set(&thisThread);
// Don't use setIonStackLimit() because that acquires the ionStackLimitLock, and the
// lock has not been initialized in these cases.
@ -1391,7 +1391,7 @@ ForkJoinShared::executePortion(PerThreadData *perThread,
// Make a new IonContext for the slice, which is needed if we need to
// re-enter the VM.
IonContext icx(cx_->compartment, NULL);
IonContext icx(cx_->compartment(), NULL);
JS_ASSERT(slice.bailoutRecord->topScript == NULL);
@ -1408,7 +1408,7 @@ ForkJoinShared::executePortion(PerThreadData *perThread,
NULL, NULL, NULL);
setAbortFlag(false);
} else {
ParallelIonInvoke<3> fii(cx_->compartment, callee, 3);
ParallelIonInvoke<3> fii(cx_->compartment(), callee, 3);
fii.args[0] = Int32Value(slice.sliceId);
fii.args[1] = Int32Value(slice.numSlices);
@ -1426,19 +1426,19 @@ ForkJoinShared::executePortion(PerThreadData *perThread,
bool
ForkJoinShared::check(ForkJoinSlice &slice)
{
JS_ASSERT(cx_->runtime->interrupt);
JS_ASSERT(cx_->runtime()->interrupt);
if (abort_)
return false;
if (slice.isMainThread()) {
JS_ASSERT(!cx_->runtime->gcIsNeeded);
JS_ASSERT(!cx_->runtime()->gcIsNeeded);
if (cx_->runtime->interrupt) {
if (cx_->runtime()->interrupt) {
// The GC Needed flag should not be set during parallel
// execution. Instead, one of the requestGC() or
// requestZoneGC() methods should be invoked.
JS_ASSERT(!cx_->runtime->gcIsNeeded);
JS_ASSERT(!cx_->runtime()->gcIsNeeded);
// If interrupt is requested, bring worker threads to a halt,
// service the interrupt, then let them start back up again.
@ -1489,7 +1489,7 @@ ForkJoinShared::initiateRendezvous(ForkJoinSlice &slice)
JS_ASSERT(slice.isMainThread());
JS_ASSERT(!rendezvous_ && blocked_ == 0);
JS_ASSERT(cx_->runtime->interrupt);
JS_ASSERT(cx_->runtime()->interrupt);
AutoLockMonitor lock(*this);
@ -1545,7 +1545,7 @@ ForkJoinShared::setAbortFlag(bool fatal)
abort_ = true;
fatal_ = fatal_ || fatal;
cx_->runtime->triggerOperationCallback();
cx_->runtime()->triggerOperationCallback();
}
void
@ -1657,7 +1657,7 @@ uint32_t
js::ForkJoinSlices(JSContext *cx)
{
// Parallel workers plus this main thread.
return cx->runtime->threadPool.numWorkers() + 1;
return cx->runtime()->threadPool.numWorkers() + 1;
}
//////////////////////////////////////////////////////////////////////////////
@ -2061,7 +2061,7 @@ js::ParallelTestsShouldPass(JSContext *cx)
ion::IsBaselineEnabled(cx) &&
!ion::js_IonOptions.eagerCompilation &&
ion::js_IonOptions.baselineUsesBeforeCompile != 0 &&
cx->runtime->gcZeal() == 0;
cx->runtime()->gcZeal() == 0;
}
#endif // JS_THREADSAFE && JS_ION

View File

@ -210,7 +210,7 @@ GlobalObject::setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue v
{
#ifdef DEBUG
RootedObject self(cx, this);
JS_ASSERT(cx->runtime->isSelfHostingGlobal(self));
JS_ASSERT(cx->runtime()->isSelfHostingGlobal(self));
#endif
RootedObject holder(cx, intrinsicsHolder());
RootedValue valCopy(cx, value);

View File

@ -174,7 +174,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
{
Rooted<GlobalObject*> self(cx, this);
JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment);
JS_ASSERT(isNative());
cx->setDefaultCompartmentObjectIfUnset(self);
@ -377,7 +377,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
self->setThrowTypeError(throwTypeError);
RootedObject intrinsicsHolder(cx);
if (cx->runtime->isSelfHostingGlobal(self)) {
if (cx->runtime()->isSelfHostingGlobal(self)) {
intrinsicsHolder = self;
} else {
intrinsicsHolder = NewObjectWithClassProto(cx, &ObjectClass, NULL, self, TenuredObject);
@ -426,7 +426,7 @@ GlobalObject::create(JSContext *cx, Class *clasp)
Rooted<GlobalObject *> global(cx, &obj->asGlobal());
cx->compartment->initGlobal(*global);
cx->compartment()->initGlobal(*global);
if (!global->setVarObj(cx))
return NULL;
@ -489,7 +489,7 @@ GlobalObject::isRuntimeCodeGenEnabled(JSContext *cx, Handle<GlobalObject*> globa
* If there are callbacks, make sure that the CSP callback is installed
* and that it permits runtime code generation, then cache the result.
*/
JSCSPEvalChecker allows = cx->runtime->securityCallbacks->contentSecurityPolicyAllows;
JSCSPEvalChecker allows = cx->runtime()->securityCallbacks->contentSecurityPolicyAllows;
Value boolValue = BooleanValue(!allows || allows(cx));
v.set(global, HeapSlot::Slot, RUNTIME_CODEGEN_ENABLED, boolValue);
}
@ -618,7 +618,7 @@ GlobalObject::addDebugger(JSContext *cx, Handle<GlobalObject*> global, Debugger
if (debuggers->empty() && !global->compartment()->addDebuggee(cx, global))
return false;
if (!debuggers->append(dbg)) {
global->compartment()->removeDebuggee(cx->runtime->defaultFreeOp(), global);
global->compartment()->removeDebuggee(cx->runtime()->defaultFreeOp(), global);
return false;
}
return true;

View File

@ -385,7 +385,7 @@ class GlobalObject : public JSObject
RootedId id(cx, NameToId(name));
if (HasDataProperty(cx, holder, id, value.address()))
return true;
if (!cx->runtime->cloneSelfHostedValue(cx, name, value))
if (!cx->runtime()->cloneSelfHostedValue(cx, name, value))
return false;
mozilla::DebugOnly<bool> ok = JS_DefinePropertyById(cx, holder, id, value, NULL, NULL, 0);
JS_ASSERT(ok);

View File

@ -857,7 +857,7 @@ GetElementOperation(JSContext *cx, JSOp op, MutableHandleValue lref, HandleValue
if (lref.isString() && IsDefinitelyIndex(rref, &index)) {
JSString *str = lref.toString();
if (index < str->length()) {
str = cx->runtime->staticStrings.getUnitStringForElement(cx, str, index);
str = cx->runtime()->staticStrings.getUnitStringForElement(cx, str, index);
if (!str)
return false;
res.setString(str);

View File

@ -318,7 +318,7 @@ js::RunScript(JSContext *cx, StackFrame *fp)
} check(cx);
#endif
SPSEntryMarker marker(cx->runtime);
SPSEntryMarker marker(cx->runtime());
#ifdef JS_ION
if (ion::IsEnabled(cx)) {
@ -356,7 +356,7 @@ bool
js::Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct)
{
JS_ASSERT(args.length() <= StackSpace::ARGS_LENGTH_MAX);
JS_ASSERT(!cx->compartment->activeAnalysis);
JS_ASSERT(!cx->compartment()->activeAnalysis);
/* We should never enter a new script while cx->iterValue is live. */
JS_ASSERT(cx->iterValue.isMagic(JS_NO_ITER_VALUE));
@ -900,13 +900,13 @@ inline InterpreterFrames::InterpreterFrames(JSContext *cx, FrameRegs *regs,
const InterruptEnablerBase &enabler)
: context(cx), regs(regs), enabler(enabler)
{
older = cx->runtime->interpreterFrames;
cx->runtime->interpreterFrames = this;
older = cx->runtime()->interpreterFrames;
cx->runtime()->interpreterFrames = this;
}
inline InterpreterFrames::~InterpreterFrames()
{
context->runtime->interpreterFrames = older;
context->runtime()->interpreterFrames = older;
}
#if defined(DEBUG) && !defined(JS_THREADSAFE) && !defined(JSGC_ROOT_ANALYSIS)
@ -917,7 +917,7 @@ js::AssertValidPropertyCacheHit(JSContext *cx, JSObject *start,
jsbytecode *pc;
JSScript *script = cx->stack.currentScript(&pc);
uint64_t sample = cx->runtime->gcNumber;
uint64_t sample = cx->runtime()->gcNumber;
PropertyName *name = GetNameFromBytecode(cx, script, pc, JSOp(*pc));
JSObject *pobj;
@ -928,7 +928,7 @@ js::AssertValidPropertyCacheHit(JSContext *cx, JSObject *start,
JS_ASSERT(entry->prop == prop);
}
JS_ASSERT(cx->runtime->gcNumber == sample);
JS_ASSERT(cx->runtime()->gcNumber == sample);
}
#endif /* DEBUG && !JS_THREADSAFE */
@ -994,7 +994,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
if (interpMode == JSINTERP_NORMAL)
gc::MaybeVerifyBarriers(cx, true);
JS_ASSERT(!cx->compartment->activeAnalysis);
JS_ASSERT(!cx->compartment()->activeAnalysis);
#define CHECK_PCCOUNT_INTERRUPTS() JS_ASSERT_IF(script->hasScriptCounts, switchMask == -1)
@ -1043,7 +1043,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
*/
#define CHECK_BRANCH() \
JS_BEGIN_MACRO \
if (cx->runtime->interrupt && !js_HandleExecutionInterrupt(cx)) \
if (cx->runtime()->interrupt && !js_HandleExecutionInterrupt(cx)) \
goto error; \
JS_END_MACRO
@ -1076,7 +1076,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
InterpreterFrames interpreterFrame(cx, &regs, interrupts);
/* Copy in hot values that change infrequently. */
JSRuntime *const rt = cx->runtime;
JSRuntime *const rt = cx->runtime();
RootedScript script(cx);
SET_SCRIPT(regs.fp()->script());
@ -1136,7 +1136,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
} else {
Probes::enterScript(cx, script, script->function(), fp);
}
if (cx->compartment->debugMode()) {
if (cx->compartment()->debugMode()) {
JSTrapStatus status = ScriptDebugPrologue(cx, fp);
switch (status) {
case JSTRAP_CONTINUE:
@ -1174,7 +1174,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
int32_t len;
len = 0;
if (rt->profilingScripts || cx->runtime->debugHooks.interruptHook)
if (rt->profilingScripts || cx->runtime()->debugHooks.interruptHook)
interrupts.enable();
DO_NEXT_OP(len);
@ -1199,7 +1199,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
{
bool moreInterrupts = false;
if (cx->runtime->profilingScripts) {
if (cx->runtime()->profilingScripts) {
if (!script->hasScriptCounts)
script->initScriptCounts(cx);
moreInterrupts = true;
@ -1211,12 +1211,12 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode, bool
moreInterrupts = true;
}
JSInterruptHook hook = cx->runtime->debugHooks.interruptHook;
JSInterruptHook hook = cx->runtime()->debugHooks.interruptHook;
if (hook || script->stepModeEnabled()) {
RootedValue rval(cx);
JSTrapStatus status = JSTRAP_CONTINUE;
if (hook)
status = hook(cx, script, regs.pc, rval.address(), cx->runtime->debugHooks.interruptHookData);
status = hook(cx, script, regs.pc, rval.address(), cx->runtime()->debugHooks.interruptHookData);
if (status == JSTRAP_CONTINUE && script->stepModeEnabled())
status = Debugger::onSingleStep(cx, &rval);
switch (status) {
@ -1420,7 +1420,7 @@ BEGIN_CASE(JSOP_STOP)
if (entryFrame != regs.fp())
inline_return:
{
if (cx->compartment->debugMode())
if (cx->compartment()->debugMode())
interpReturnOK = ScriptDebugEpilogue(cx, regs.fp(), interpReturnOK);
if (!regs.fp()->isYielding())
@ -2176,7 +2176,7 @@ BEGIN_CASE(JSOP_CALL)
BEGIN_CASE(JSOP_FUNCALL)
{
if (regs.fp()->hasPushedSPSFrame())
cx->runtime->spsProfiler.updatePC(script, regs.pc);
cx->runtime()->spsProfiler.updatePC(script, regs.pc);
JS_ASSERT(regs.stackDepth() >= 2 + GET_ARGC(regs.pc));
CallArgs args = CallArgsFromSp(GET_ARGC(regs.pc), regs.sp);
@ -2260,7 +2260,7 @@ BEGIN_CASE(JSOP_FUNCALL)
if (!regs.fp()->prologue(cx))
goto error;
if (cx->compartment->debugMode()) {
if (cx->compartment()->debugMode()) {
switch (ScriptDebugPrologue(cx, regs.fp())) {
case JSTRAP_CONTINUE:
break;
@ -2890,8 +2890,8 @@ BEGIN_CASE(JSOP_DEBUGGER)
{
JSTrapStatus st = JSTRAP_CONTINUE;
RootedValue rval(cx);
if (JSDebuggerHandler handler = cx->runtime->debugHooks.debuggerHandler)
st = handler(cx, script, regs.pc, rval.address(), cx->runtime->debugHooks.debuggerHandlerData);
if (JSDebuggerHandler handler = cx->runtime()->debugHooks.debuggerHandler)
st = handler(cx, script, regs.pc, rval.address(), cx->runtime()->debugHooks.debuggerHandlerData);
if (st == JSTRAP_CONTINUE)
st = Debugger::onDebuggerStatement(cx, &rval);
switch (st) {
@ -3024,7 +3024,7 @@ END_CASE(JSOP_ARRAYPUSH)
if (cx->isExceptionPending()) {
/* Call debugger throw hooks. */
if (cx->compartment->debugMode()) {
if (cx->compartment()->debugMode()) {
JSTrapStatus status = DebugExceptionUnwind(cx, regs.fp(), regs.pc);
switch (status) {
case JSTRAP_ERROR:
@ -3128,7 +3128,7 @@ END_CASE(JSOP_ARRAYPUSH)
goto inline_return;
exit:
if (cx->compartment->debugMode())
if (cx->compartment()->debugMode())
interpReturnOK = ScriptDebugEpilogue(cx, regs.fp(), interpReturnOK);
if (!regs.fp()->isYielding())
regs.fp()->epilogue(cx);
@ -3340,7 +3340,7 @@ js::GetAndClearException(JSContext *cx, MutableHandleValue res)
{
// Check the interrupt flag to allow interrupting deeply nested exception
// handling.
if (cx->runtime->interrupt && !js_HandleExecutionInterrupt(cx))
if (cx->runtime()->interrupt && !js_HandleExecutionInterrupt(cx))
return false;
res.set(cx->getPendingException());

View File

@ -131,7 +131,7 @@ PropDesc::wrapInto(JSContext *cx, HandleObject obj, const jsid &id, jsid *wrappe
{
MOZ_ASSERT(!isUndefined());
JSCompartment *comp = cx->compartment;
JSCompartment *comp = cx->compartment();
*wrappedId = id;
if (!comp->wrapId(cx, wrappedId))

View File

@ -56,7 +56,7 @@ Probes::enterScript(JSContext *cx, JSScript *script, JSFunction *maybeFun,
cx->doFunctionCallback(maybeFun, script, 1);
#endif
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
if (rt->spsProfiler.enabled()) {
rt->spsProfiler.enter(cx, script, maybeFun);
JS_ASSERT_IF(!fp->isGeneratorFrame(), !fp->hasPushedSPSFrame());
@ -80,7 +80,7 @@ Probes::exitScript(JSContext *cx, JSScript *script, JSFunction *maybeFun,
cx->doFunctionCallback(maybeFun, script, 0);
#endif
JSRuntime *rt = cx->runtime;
JSRuntime *rt = cx->runtime();
/*
* Coming from IonMonkey, the fp might not be known (fp == NULL), but
* IonMonkey will only call exitScript() when absolutely necessary, so it is

View File

@ -27,7 +27,7 @@ bool Probes::ProfilingActive = true;
Probes::JITReportGranularity
Probes::JITGranularityRequested(JSContext *cx)
{
if (cx->runtime->spsProfiler.enabled())
if (cx->runtime()->spsProfiler.enabled())
return JITREPORT_GRANULARITY_LINE;
return JITREPORT_GRANULARITY_NONE;
}

View File

@ -123,7 +123,7 @@ RegExpToShared(JSContext *cx, HandleObject obj, RegExpGuard *g)
inline void
RegExpShared::prepareForUse(JSContext *cx)
{
gcNumberWhenUsed = cx->runtime->gcNumber;
gcNumberWhenUsed = cx->runtime()->gcNumber;
}
RegExpGuard::RegExpGuard(JSContext *cx)

View File

@ -263,7 +263,7 @@ RegExpObject::createShared(JSContext *cx, RegExpGuard *g)
Rooted<RegExpObject*> self(cx, this);
JS_ASSERT(!maybeShared());
if (!cx->compartment->regExps.get(cx, getSource(), getFlags(), g))
if (!cx->compartment()->regExps.get(cx, getSource(), getFlags(), g))
return false;
self->setShared(cx, **g);
@ -479,7 +479,7 @@ RegExpShared::compile(JSContext *cx, JSLinearString &pattern, bool matchOnly)
#if ENABLE_YARR_JIT
if (isJITRuntimeEnabled(cx) && !yarrPattern.m_containsBackreferences) {
JSC::ExecutableAllocator *execAlloc = cx->runtime->getExecAlloc(cx);
JSC::ExecutableAllocator *execAlloc = cx->runtime()->getExecAlloc(cx);
if (!execAlloc)
return false;
@ -496,7 +496,7 @@ RegExpShared::compile(JSContext *cx, JSLinearString &pattern, bool matchOnly)
codeBlock.setFallBack(true);
#endif
WTF::BumpPointerAllocator *bumpAlloc = cx->runtime->getBumpPointerAllocator(cx);
WTF::BumpPointerAllocator *bumpAlloc = cx->runtime()->getBumpPointerAllocator(cx);
if (!bumpAlloc) {
js_ReportOutOfMemory(cx);
return false;
@ -687,7 +687,7 @@ RegExpCompartment::get(JSContext *cx, JSAtom *source, RegExpFlag flags, RegExpGu
return true;
}
ScopedJSDeletePtr<RegExpShared> shared(cx->new_<RegExpShared>(cx->runtime, source, flags));
ScopedJSDeletePtr<RegExpShared> shared(cx->new_<RegExpShared>(cx->runtime(), source, flags));
if (!shared)
return false;

View File

@ -232,7 +232,7 @@ inline bool
RegExpStatics::createPendingInput(JSContext *cx, MutableHandleValue out)
{
/* Lazy evaluation need not be resolved to return the input. */
out.setString(pendingInput ? pendingInput.get() : cx->runtime->emptyString);
out.setString(pendingInput ? pendingInput.get() : cx->runtime()->emptyString);
return true;
}
@ -249,7 +249,7 @@ RegExpStatics::makeMatch(JSContext *cx, size_t checkValidIndex, size_t pairNum,
if (matches.empty() || checkPair >= matches.pairCount() ||
(checkWhich ? matches[checkPair].limit : matches[checkPair].start) < 0)
{
out.setString(cx->runtime->emptyString);
out.setString(cx->runtime()->emptyString);
return true;
}
const MatchPair &pair = matches[pairNum];
@ -271,12 +271,12 @@ RegExpStatics::createLastParen(JSContext *cx, MutableHandleValue out)
return false;
if (matches.empty() || matches.pairCount() == 1) {
out.setString(cx->runtime->emptyString);
out.setString(cx->runtime()->emptyString);
return true;
}
const MatchPair &pair = matches[matches.pairCount() - 1];
if (pair.start == -1) {
out.setString(cx->runtime->emptyString);
out.setString(cx->runtime()->emptyString);
return true;
}
JS_ASSERT(pair.start >= 0 && pair.limit >= 0);
@ -292,7 +292,7 @@ RegExpStatics::createParen(JSContext *cx, size_t pairNum, MutableHandleValue out
return false;
if (matches.empty() || pairNum >= matches.pairCount()) {
out.setString(cx->runtime->emptyString);
out.setString(cx->runtime()->emptyString);
return true;
}
return makeMatch(cx, pairNum * 2, pairNum, out);
@ -305,7 +305,7 @@ RegExpStatics::createLeftContext(JSContext *cx, MutableHandleValue out)
return false;
if (matches.empty()) {
out.setString(cx->runtime->emptyString);
out.setString(cx->runtime()->emptyString);
return true;
}
if (matches[0].start < 0) {
@ -322,7 +322,7 @@ RegExpStatics::createRightContext(JSContext *cx, MutableHandleValue out)
return false;
if (matches.empty()) {
out.setString(cx->runtime->emptyString);
out.setString(cx->runtime()->emptyString);
return true;
}
if (matches[0].limit < 0) {

View File

@ -79,7 +79,7 @@ RegExpStatics::executeLazy(JSContext *cx)
/* Retrieve or create the RegExpShared in this compartment. */
RegExpGuard g(cx);
if (!cx->compartment->regExps.get(cx, lazySource, lazyFlags, &g))
if (!cx->compartment()->regExps.get(cx, lazySource, lazyFlags, &g))
return false;
/*

View File

@ -207,7 +207,7 @@ SPSProfiler::pop()
const char*
SPSProfiler::allocProfileString(JSContext *cx, JSScript *script, JSFunction *maybeFun)
{
DebugOnly<uint64_t> gcBefore = cx->runtime->gcNumber;
DebugOnly<uint64_t> gcBefore = cx->runtime()->gcNumber;
StringBuffer buf(cx);
bool hasAtom = maybeFun != NULL && maybeFun->displayAtom() != NULL;
if (hasAtom) {
@ -239,7 +239,7 @@ SPSProfiler::allocProfileString(JSContext *cx, JSScript *script, JSFunction *may
cstr[i] = ptr[i];
cstr[len] = 0;
JS_ASSERT(gcBefore == cx->runtime->gcNumber);
JS_ASSERT(gcBefore == cx->runtime()->gcNumber);
return cstr;
}

View File

@ -137,7 +137,7 @@ js::ScopeCoordinateName(JSContext *cx, JSScript *script, jsbytecode *pc)
/* Beware nameless destructuring formal. */
if (!JSID_IS_ATOM(id))
return cx->runtime->atomState.empty;
return cx->runtime()->atomState.empty;
return JSID_TO_ATOM(id)->asPropertyName();
}
@ -198,7 +198,7 @@ CallObject::createTemplateObject(JSContext *cx, HandleScript script, gc::Initial
RootedShape shape(cx, script->bindings.callObjShape());
JS_ASSERT(shape->getObjectClass() == &CallClass);
RootedTypeObject type(cx, cx->compartment->getNewType(cx, &CallClass, NULL));
RootedTypeObject type(cx, cx->compartment()->getNewType(cx, &CallClass, NULL));
if (!type)
return NULL;
@ -328,7 +328,7 @@ Class js::DeclEnvClass = {
DeclEnvObject *
DeclEnvObject::createTemplateObject(JSContext *cx, HandleFunction fun, gc::InitialHeap heap)
{
RootedTypeObject type(cx, cx->compartment->getNewType(cx, &DeclEnvClass, NULL));
RootedTypeObject type(cx, cx->compartment()->getNewType(cx, &DeclEnvClass, NULL));
if (!type)
return NULL;
@ -705,7 +705,7 @@ ClonedBlockObject::copyUnaliasedValues(AbstractFramePtr frame)
StaticBlockObject *
StaticBlockObject::create(JSContext *cx)
{
RootedTypeObject type(cx, cx->compartment->getNewType(cx, &BlockClass, NULL));
RootedTypeObject type(cx, cx->compartment()->getNewType(cx, &BlockClass, NULL));
if (!type)
return NULL;
@ -810,7 +810,7 @@ js::XDRStaticBlockObject(XDRState<mode> *xdr, HandleObject enclosingScope, Handl
return false;
/* The empty string indicates an int id. */
RootedId id(cx, atom != cx->runtime->emptyString
RootedId id(cx, atom != cx->runtime()->emptyString
? AtomToId(atom)
: INT_TO_JSID(i));
@ -855,7 +855,7 @@ js::XDRStaticBlockObject(XDRState<mode> *xdr, HandleObject enclosingScope, Handl
/* The empty string indicates an int id. */
atom = JSID_IS_ATOM(propid)
? JSID_TO_ATOM(propid)
: cx->runtime->emptyString;
: cx->runtime()->emptyString;
if (!XDRAtom(xdr, &atom))
return false;
@ -1079,7 +1079,7 @@ ScopeIter::settle()
type_ = Call;
hasScopeObject_ = false;
}
} else if (frame_.isNonStrictDirectEvalFrame() && cur_ == frame_.evalPrevScopeChain(cx->runtime)) {
} else if (frame_.isNonStrictDirectEvalFrame() && cur_ == frame_.evalPrevScopeChain(cx->runtime())) {
if (block_) {
JS_ASSERT(!block_->needsClone());
type_ = Block;
@ -1091,7 +1091,7 @@ ScopeIter::settle()
JS_ASSERT(cur_ == frame_.fun()->environment());
frame_ = NullFramePtr();
} else if (frame_.isStrictEvalFrame() && !frame_.hasCallObj()) {
JS_ASSERT(cur_ == frame_.evalPrevScopeChain(cx->runtime));
JS_ASSERT(cur_ == frame_.evalPrevScopeChain(cx->runtime()));
frame_ = NullFramePtr();
} else if (cur_->isWith()) {
JS_ASSERT_IF(frame_.isFunctionFrame(), frame_.fun()->isHeavyweight());
@ -1527,7 +1527,7 @@ DebugScopeProxy DebugScopeProxy::singleton;
/* static */ DebugScopeObject *
DebugScopeObject::create(JSContext *cx, ScopeObject &scope, HandleObject enclosing)
{
JS_ASSERT(scope.compartment() == cx->compartment);
JS_ASSERT(scope.compartment() == cx->compartment());
RootedValue priv(cx, ObjectValue(scope));
JSObject *obj = NewProxyObject(cx, &DebugScopeProxy::singleton, priv,
NULL /* proto */, &scope.global(), ProxyNotCallable);
@ -1664,13 +1664,13 @@ DebugScopes::sweep(JSRuntime *rt)
static bool
CanUseDebugScopeMaps(JSContext *cx)
{
return cx->compartment->debugMode();
return cx->compartment()->debugMode();
}
DebugScopes *
DebugScopes::ensureCompartmentData(JSContext *cx)
{
JSCompartment *c = cx->compartment;
JSCompartment *c = cx->compartment();
if (c->debugScopes)
return c->debugScopes;
@ -1700,8 +1700,8 @@ DebugScopes::hasDebugScope(JSContext *cx, ScopeObject &scope)
bool
DebugScopes::addDebugScope(JSContext *cx, ScopeObject &scope, DebugScopeObject &debugScope)
{
JS_ASSERT(cx->compartment == scope.compartment());
JS_ASSERT(cx->compartment == debugScope.compartment());
JS_ASSERT(cx->compartment() == scope.compartment());
JS_ASSERT(cx->compartment() == debugScope.compartment());
if (!CanUseDebugScopeMaps(cx))
return true;
@ -1716,7 +1716,7 @@ DebugScopes::addDebugScope(JSContext *cx, ScopeObject &scope, DebugScopeObject &
return false;
}
HashTableWriteBarrierPost(cx->runtime, &scopes->proxiedScopes, &scope);
HashTableWriteBarrierPost(cx->runtime(), &scopes->proxiedScopes, &scope);
return true;
}
@ -1725,7 +1725,7 @@ DebugScopes::hasDebugScope(JSContext *cx, const ScopeIter &si)
{
JS_ASSERT(!si.hasScopeObject());
DebugScopes *scopes = cx->compartment->debugScopes;
DebugScopes *scopes = cx->compartment()->debugScopes;
if (!scopes)
return NULL;
@ -1740,7 +1740,7 @@ bool
DebugScopes::addDebugScope(JSContext *cx, const ScopeIter &si, DebugScopeObject &debugScope)
{
JS_ASSERT(!si.hasScopeObject());
JS_ASSERT(cx->compartment == debugScope.compartment());
JS_ASSERT(cx->compartment() == debugScope.compartment());
if (!CanUseDebugScopeMaps(cx))
return true;
@ -1760,7 +1760,7 @@ DebugScopes::addDebugScope(JSContext *cx, const ScopeIter &si, DebugScopeObject
js_ReportOutOfMemory(cx);
return false;
}
HashTableWriteBarrierPost(cx->runtime, &scopes->liveScopes, &debugScope.scope());
HashTableWriteBarrierPost(cx->runtime(), &scopes->liveScopes, &debugScope.scope());
return true;
}
@ -1771,7 +1771,7 @@ DebugScopes::onPopCall(AbstractFramePtr frame, JSContext *cx)
JS_ASSERT(!frame.isYielding());
assertSameCompartment(cx, frame);
DebugScopes *scopes = cx->compartment->debugScopes;
DebugScopes *scopes = cx->compartment()->debugScopes;
if (!scopes)
return;
@ -1849,7 +1849,7 @@ DebugScopes::onPopBlock(JSContext *cx, AbstractFramePtr frame)
{
assertSameCompartment(cx, frame);
DebugScopes *scopes = cx->compartment->debugScopes;
DebugScopes *scopes = cx->compartment()->debugScopes;
if (!scopes)
return;
@ -1908,17 +1908,17 @@ DebugScopes::onGeneratorFrameChange(AbstractFramePtr from, AbstractFramePtr to,
* scope while it is suspended, we can find its frame (which would
* otherwise not be found by AllFramesIter).
*/
JS_ASSERT(toIter.scope().compartment() == cx->compartment);
JS_ASSERT(toIter.scope().compartment() == cx->compartment());
LiveScopeMap::AddPtr livePtr = scopes->liveScopes.lookupForAdd(&toIter.scope());
if (livePtr) {
livePtr->value = to;
} else {
scopes->liveScopes.add(livePtr, &toIter.scope(), to); // OOM here?
HashTableWriteBarrierPost(cx->runtime, &scopes->liveScopes, &toIter.scope());
HashTableWriteBarrierPost(cx->runtime(), &scopes->liveScopes, &toIter.scope());
}
} else {
ScopeIter si(toIter, from, cx);
JS_ASSERT(si.frame().scopeChain()->compartment() == cx->compartment);
JS_ASSERT(si.frame().scopeChain()->compartment() == cx->compartment());
if (MissingScopeMap::Ptr p = scopes->missingScopes.lookup(si)) {
DebugScopeObject &debugScope = *p->value;
scopes->liveScopes.lookup(&debugScope.scope())->value = to;
@ -1956,7 +1956,7 @@ DebugScopes::updateLiveScopes(JSContext *cx)
* to date' bit for fp->prev() in fp, simply popping fp effectively clears
* the flag for us, at exactly the time when execution resumes fp->prev().
*/
for (AllFramesIter i(cx->runtime); !i.done(); ++i) {
for (AllFramesIter i(cx->runtime()); !i.done(); ++i) {
/*
* Debug-mode currently disables Ion compilation in the compartment of
* the debuggee.
@ -1965,18 +1965,18 @@ DebugScopes::updateLiveScopes(JSContext *cx)
continue;
AbstractFramePtr frame = i.abstractFramePtr();
if (frame.scopeChain()->compartment() != cx->compartment)
if (frame.scopeChain()->compartment() != cx->compartment())
continue;
for (ScopeIter si(frame, cx); !si.done(); ++si) {
if (si.hasScopeObject()) {
JS_ASSERT(si.scope().compartment() == cx->compartment);
JS_ASSERT(si.scope().compartment() == cx->compartment());
DebugScopes *scopes = ensureCompartmentData(cx);
if (!scopes)
return false;
if (!scopes->liveScopes.put(&si.scope(), frame))
return false;
HashTableWriteBarrierPost(cx->runtime, &scopes->liveScopes, &si.scope());
HashTableWriteBarrierPost(cx->runtime(), &scopes->liveScopes, &si.scope());
}
}
@ -2161,7 +2161,7 @@ JSObject *
js::GetDebugScopeForFunction(JSContext *cx, HandleFunction fun)
{
assertSameCompartment(cx, fun);
JS_ASSERT(cx->compartment->debugMode());
JS_ASSERT(cx->compartment()->debugMode());
if (!DebugScopes::updateLiveScopes(cx))
return NULL;
return GetDebugScope(cx, *fun->environment());

View File

@ -420,7 +420,7 @@ js::intrinsic_ShouldForceSequential(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
#ifdef JS_THREADSAFE
args.rval().setBoolean(cx->runtime->parallelWarmup ||
args.rval().setBoolean(cx->runtime()->parallelWarmup ||
InParallelSection());
#else
args.rval().setBoolean(true);
@ -437,7 +437,7 @@ intrinsic_RuntimeDefaultLocale(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
const char *locale = cx->runtime->getDefaultLocale();
const char *locale = cx->runtime()->getDefaultLocale();
if (!locale) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEFAULT_LOCALE_ERROR);
return false;
@ -614,7 +614,7 @@ CloneObject(JSContext *cx, HandleObject srcObj, CloneMemory &clonedObjects)
if (srcObj->isFunction()) {
if (srcObj->toFunction()->isWrappable()) {
clone = srcObj;
if (!cx->compartment->wrap(cx, clone.address()))
if (!cx->compartment()->wrap(cx, clone.address()))
return NULL;
} else {
RootedFunction fun(cx, srcObj->toFunction());
@ -743,5 +743,5 @@ JSRuntime::maybeWrappedSelfHostedFunction(JSContext *cx, Handle<PropertyName*> n
return true;
}
return cx->compartment->wrap(cx, funVal);
return cx->compartment()->wrap(cx, funVal);
}

Some files were not shown because too many files have changed in this diff Show More