Bug 1118107 - Convert ThreadSafeContext -> JSContext and remove PJS paths in FrameIters. (r=lth)

This commit is contained in:
Shu-yu Guo 2015-01-09 00:06:03 -08:00
parent c931a16608
commit d7cd863cee
8 changed files with 33 additions and 66 deletions

View File

@ -93,7 +93,6 @@ class JitFrameIterator
FrameType type_;
uint8_t *returnAddressToFp_;
size_t frameSize_;
ExecutionMode mode_;
private:
mutable const SafepointIndex *cachedSafepointIndex_;
@ -103,7 +102,7 @@ class JitFrameIterator
public:
explicit JitFrameIterator();
explicit JitFrameIterator(ThreadSafeContext *cx);
explicit JitFrameIterator(JSContext *cx);
explicit JitFrameIterator(const ActivationIterator &activations);
// Current frame information.
@ -605,9 +604,9 @@ class InlineFrameIterator
bool *hasCallObj = nullptr) const;
public:
InlineFrameIterator(ThreadSafeContext *cx, const JitFrameIterator *iter);
InlineFrameIterator(JSContext *cx, const JitFrameIterator *iter);
InlineFrameIterator(JSRuntime *rt, const JitFrameIterator *iter);
InlineFrameIterator(ThreadSafeContext *cx, const InlineFrameIterator *iter);
InlineFrameIterator(JSContext *cx, const InlineFrameIterator *iter);
bool more() const {
return frame_ && framesRead_ < frameCount_;
@ -643,7 +642,7 @@ class InlineFrameIterator
}
template <class ArgOp, class LocalOp>
void readFrameArgsAndLocals(ThreadSafeContext *cx, ArgOp &argOp, LocalOp &localOp,
void readFrameArgsAndLocals(JSContext *cx, ArgOp &argOp, LocalOp &localOp,
JSObject **scopeChain, bool *hasCallObj, Value *rval,
ArgumentsObject **argsObj, Value *thisv,
ReadFrameArgsBehavior behavior,

View File

@ -92,18 +92,16 @@ JitFrameIterator::JitFrameIterator()
type_(JitFrame_Exit),
returnAddressToFp_(nullptr),
frameSize_(0),
mode_(SequentialExecution),
cachedSafepointIndex_(nullptr),
activation_(nullptr)
{
}
JitFrameIterator::JitFrameIterator(ThreadSafeContext *cx)
JitFrameIterator::JitFrameIterator(JSContext *cx)
: current_(cx->perThreadData->jitTop),
type_(JitFrame_Exit),
returnAddressToFp_(nullptr),
frameSize_(0),
mode_(cx->isForkJoinContext() ? ParallelExecution : SequentialExecution),
cachedSafepointIndex_(nullptr),
activation_(cx->perThreadData->activation()->asJit())
{
@ -119,8 +117,6 @@ JitFrameIterator::JitFrameIterator(const ActivationIterator &activations)
type_(JitFrame_Exit),
returnAddressToFp_(nullptr),
frameSize_(0),
mode_(activations->asJit()->cx()->isForkJoinContext() ? ParallelExecution
: SequentialExecution),
cachedSafepointIndex_(nullptr),
activation_(activations->asJit())
{
@ -150,14 +146,8 @@ JitFrameIterator::checkInvalidation(IonScript **ionScriptOut) const
uint8_t *returnAddr = returnAddressToFp();
// N.B. the current IonScript is not the same as the frame's
// IonScript if the frame has since been invalidated.
bool invalidated;
if (mode_ == ParallelExecution) {
// Parallel execution does not have invalidating bailouts.
invalidated = false;
} else {
invalidated = !script->hasIonScript() ||
!script->ionScript()->containsReturnAddress(returnAddr);
}
bool invalidated = !script->hasIonScript() ||
!script->ionScript()->containsReturnAddress(returnAddr);
if (!invalidated)
return false;
@ -2187,15 +2177,7 @@ JitFrameIterator::ionScriptFromCalleeToken() const
{
MOZ_ASSERT(isIonJS());
MOZ_ASSERT(!checkInvalidation());
switch (mode_) {
case SequentialExecution:
return script()->ionScript();
case ParallelExecution:
return script()->parallelIonScript();
default:
MOZ_CRASH("No such execution mode");
}
return script()->ionScript();
}
const SafepointIndex *
@ -2224,7 +2206,7 @@ JitFrameIterator::osiIndex() const
return ionScript()->getOsiIndex(reader.osiReturnPointOffset());
}
InlineFrameIterator::InlineFrameIterator(ThreadSafeContext *cx, const JitFrameIterator *iter)
InlineFrameIterator::InlineFrameIterator(JSContext *cx, const JitFrameIterator *iter)
: calleeTemplate_(cx),
calleeRVA_(),
script_(cx)
@ -2240,7 +2222,7 @@ InlineFrameIterator::InlineFrameIterator(JSRuntime *rt, const JitFrameIterator *
resetOn(iter);
}
InlineFrameIterator::InlineFrameIterator(ThreadSafeContext *cx, const InlineFrameIterator *iter)
InlineFrameIterator::InlineFrameIterator(JSContext *cx, const InlineFrameIterator *iter)
: frame_(iter ? iter->frame_ : nullptr),
framesRead_(0),
frameCount_(iter ? iter->frameCount_ : UINT32_MAX),

View File

@ -288,7 +288,7 @@ MakeFrameDescriptor(uint32_t frameSize, FrameType type)
// Returns the JSScript associated with the topmost JIT frame.
inline JSScript *
GetTopJitJSScript(ThreadSafeContext *cx, void **returnAddrOut = nullptr)
GetTopJitJSScript(JSContext *cx, void **returnAddrOut = nullptr)
{
JitFrameIterator iter(cx);
MOZ_ASSERT(iter.type() == JitFrame_Exit);

View File

@ -1283,7 +1283,6 @@ class ParallelIonInvoke
}
bool invoke(ForkJoinContext *cx) {
JitActivation activation(cx);
Value result = Int32Value(argc_);
CALL_GENERATED_CODE(enter_, jitcode_, argc_ + 1, argv_ + 1, nullptr, calleeToken_,
nullptr, 0, &result);

View File

@ -477,8 +477,7 @@ void DisableExtraThreads();
* Encapsulates portions of the runtime/context that are tied to a
* single active thread. Instances of this structure can occur for
* the main thread as |JSRuntime::mainThread|, for select operations
* performed off thread, such as parsing, and for Parallel JS worker
* threads.
* performed off thread, such as parsing.
*/
class PerThreadData : public PerThreadDataFriendFields
{

View File

@ -805,9 +805,9 @@ AbstractFramePtr::popWith(JSContext *cx) const
asBaselineFrame()->popWith(cx);
}
Activation::Activation(ThreadSafeContext *cx, Kind kind)
Activation::Activation(JSContext *cx, Kind kind)
: cx_(cx),
compartment_(cx->compartment_),
compartment_(cx->compartment()),
prev_(cx->perThreadData->activation_),
prevProfiling_(prev_ ? prev_->mostRecentProfiling() : nullptr),
savedFrameChain_(0),

View File

@ -583,7 +583,7 @@ FrameIter::settleOnActivation()
}
}
FrameIter::Data::Data(ThreadSafeContext *cx, SavedOption savedOption,
FrameIter::Data::Data(JSContext *cx, SavedOption savedOption,
ContextOption contextOption, JSPrincipals *principals)
: cx_(cx),
savedOption_(savedOption),
@ -613,7 +613,7 @@ FrameIter::Data::Data(const FrameIter::Data &other)
{
}
FrameIter::FrameIter(ThreadSafeContext *cx, SavedOption savedOption)
FrameIter::FrameIter(JSContext *cx, SavedOption savedOption)
: data_(cx, savedOption, CURRENT_CONTEXT, nullptr),
ionInlineFrames_(cx, (js::jit::JitFrameIterator*) nullptr)
{
@ -622,7 +622,7 @@ FrameIter::FrameIter(ThreadSafeContext *cx, SavedOption savedOption)
settleOnActivation();
}
FrameIter::FrameIter(ThreadSafeContext *cx, ContextOption contextOption,
FrameIter::FrameIter(JSContext *cx, ContextOption contextOption,
SavedOption savedOption)
: data_(cx, savedOption, contextOption, nullptr),
ionInlineFrames_(cx, (js::jit::JitFrameIterator*) nullptr)
@ -1396,18 +1396,6 @@ jit::JitActivation::JitActivation(JSContext *cx, bool active)
}
}
jit::JitActivation::JitActivation(ForkJoinContext *cx)
: Activation(cx, Jit),
active_(true),
rematerializedFrames_(nullptr),
ionRecovery_(cx),
bailoutData_(nullptr)
{
prevJitTop_ = cx->perThreadData->jitTop;
prevJitJSContext_ = cx->perThreadData->jitJSContext;
cx->perThreadData->jitJSContext = nullptr;
}
jit::JitActivation::~JitActivation()
{
if (active_) {

View File

@ -1040,7 +1040,7 @@ namespace jit {
class Activation
{
protected:
ThreadSafeContext *cx_;
JSContext *cx_;
JSCompartment *compartment_;
Activation *prev_;
Activation *prevProfiling_;
@ -1061,11 +1061,11 @@ class Activation
enum Kind { Interpreter, Jit, ForkJoin, AsmJS };
Kind kind_;
inline Activation(ThreadSafeContext *cx, Kind kind_);
inline Activation(JSContext *cx, Kind kind_);
inline ~Activation();
public:
ThreadSafeContext *cx() const {
JSContext *cx() const {
return cx_;
}
JSCompartment *compartment() const {
@ -1286,7 +1286,6 @@ class JitActivation : public Activation
public:
explicit JitActivation(JSContext *cx, bool active = true);
explicit JitActivation(ForkJoinContext *cx);
~JitActivation();
bool isActive() const {
@ -1530,7 +1529,7 @@ class FrameIter
// the heap, so this structure should not contain any GC things.
struct Data
{
ThreadSafeContext * cx_;
JSContext * cx_;
SavedOption savedOption_;
ContextOption contextOption_;
JSPrincipals * principals_;
@ -1546,13 +1545,13 @@ class FrameIter
unsigned ionInlineFrameNo_;
AsmJSFrameIterator asmJSFrames_;
Data(ThreadSafeContext *cx, SavedOption savedOption, ContextOption contextOption,
Data(JSContext *cx, SavedOption savedOption, ContextOption contextOption,
JSPrincipals *principals);
Data(const Data &other);
};
MOZ_IMPLICIT FrameIter(ThreadSafeContext *cx, SavedOption = STOP_AT_SAVED);
FrameIter(ThreadSafeContext *cx, ContextOption, SavedOption);
MOZ_IMPLICIT FrameIter(JSContext *cx, SavedOption = STOP_AT_SAVED);
FrameIter(JSContext *cx, ContextOption, SavedOption);
FrameIter(JSContext *cx, ContextOption, SavedOption, JSPrincipals *);
FrameIter(const FrameIter &iter);
MOZ_IMPLICIT FrameIter(const Data &data);
@ -1686,13 +1685,13 @@ class ScriptFrameIter : public FrameIter
}
public:
explicit ScriptFrameIter(ThreadSafeContext *cx, SavedOption savedOption = STOP_AT_SAVED)
explicit ScriptFrameIter(JSContext *cx, SavedOption savedOption = STOP_AT_SAVED)
: FrameIter(cx, savedOption)
{
settle();
}
ScriptFrameIter(ThreadSafeContext *cx,
ScriptFrameIter(JSContext *cx,
ContextOption cxOption,
SavedOption savedOption)
: FrameIter(cx, cxOption, savedOption)
@ -1736,14 +1735,14 @@ class NonBuiltinFrameIter : public FrameIter
void settle();
public:
explicit NonBuiltinFrameIter(ThreadSafeContext *cx,
explicit NonBuiltinFrameIter(JSContext *cx,
FrameIter::SavedOption opt = FrameIter::STOP_AT_SAVED)
: FrameIter(cx, opt)
{
settle();
}
NonBuiltinFrameIter(ThreadSafeContext *cx,
NonBuiltinFrameIter(JSContext *cx,
FrameIter::ContextOption contextOption,
FrameIter::SavedOption savedOption)
: FrameIter(cx, contextOption, savedOption)
@ -1777,14 +1776,15 @@ class NonBuiltinScriptFrameIter : public ScriptFrameIter
void settle();
public:
explicit NonBuiltinScriptFrameIter(ThreadSafeContext *cx,
ScriptFrameIter::SavedOption opt = ScriptFrameIter::STOP_AT_SAVED)
explicit NonBuiltinScriptFrameIter(JSContext *cx,
ScriptFrameIter::SavedOption opt =
ScriptFrameIter::STOP_AT_SAVED)
: ScriptFrameIter(cx, opt)
{
settle();
}
NonBuiltinScriptFrameIter(ThreadSafeContext *cx,
NonBuiltinScriptFrameIter(JSContext *cx,
ScriptFrameIter::ContextOption contextOption,
ScriptFrameIter::SavedOption savedOption)
: ScriptFrameIter(cx, contextOption, savedOption)
@ -1819,7 +1819,7 @@ class NonBuiltinScriptFrameIter : public ScriptFrameIter
class AllFramesIter : public ScriptFrameIter
{
public:
explicit AllFramesIter(ThreadSafeContext *cx)
explicit AllFramesIter(JSContext *cx)
: ScriptFrameIter(cx, ScriptFrameIter::ALL_CONTEXTS, ScriptFrameIter::GO_THROUGH_SAVED)
{}
};