зеркало из https://github.com/mozilla/gecko-dev.git
Bug 960040 - Part 1: Prune unused interfaces and code from ScriptAnalysis. r=jandem
This commit is contained in:
Родитель
f7b7cbccf3
Коммит
c5d338f7ab
|
@ -453,10 +453,8 @@ class InlineFrameIteratorMaybeGC
|
|||
|
||||
// scopeChain
|
||||
Value v = s.read();
|
||||
if (v.isObject()) {
|
||||
JS_ASSERT_IF(script()->hasAnalysis(), script()->analysis()->usesScopeChain());
|
||||
if (v.isObject())
|
||||
return &v.toObject();
|
||||
}
|
||||
|
||||
return callee()->environment();
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ ScriptAnalysis::addJump(JSContext *cx, unsigned offset,
|
|||
code->jumpTarget = true;
|
||||
|
||||
if (offset < *currentOffset) {
|
||||
hasLoops_ = true;
|
||||
|
||||
if (!code->analyzed) {
|
||||
/*
|
||||
* Backedge in a while/for loop, whose body has not been analyzed
|
||||
|
@ -226,28 +224,10 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
|
|||
|
||||
switch (op) {
|
||||
|
||||
case JSOP_RETURN:
|
||||
case JSOP_RETRVAL:
|
||||
numReturnSites_++;
|
||||
break;
|
||||
|
||||
case JSOP_NAME:
|
||||
case JSOP_CALLNAME:
|
||||
case JSOP_BINDNAME:
|
||||
case JSOP_SETNAME:
|
||||
case JSOP_DELNAME:
|
||||
case JSOP_GETALIASEDVAR:
|
||||
case JSOP_CALLALIASEDVAR:
|
||||
case JSOP_SETALIASEDVAR:
|
||||
case JSOP_LAMBDA:
|
||||
usesScopeChain_ = true;
|
||||
break;
|
||||
|
||||
case JSOP_DEFFUN:
|
||||
case JSOP_DEFVAR:
|
||||
case JSOP_DEFCONST:
|
||||
case JSOP_SETCONST:
|
||||
usesScopeChain_ = true; // Requires access to VarObj via ScopeChain.
|
||||
canTrackVars = false;
|
||||
break;
|
||||
|
||||
|
@ -334,18 +314,6 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
|
|||
break;
|
||||
}
|
||||
|
||||
case JSOP_GETPROP:
|
||||
case JSOP_CALLPROP:
|
||||
case JSOP_LENGTH:
|
||||
case JSOP_GETELEM:
|
||||
case JSOP_CALLELEM:
|
||||
numPropertyReads_++;
|
||||
break;
|
||||
|
||||
case JSOP_FINALLY:
|
||||
hasTryFinally_ = true;
|
||||
break;
|
||||
|
||||
case JSOP_PUSHBLOCKSCOPE:
|
||||
localsAliasStack_ = true;
|
||||
break;
|
||||
|
|
|
@ -606,7 +606,6 @@ class ScriptAnalysis
|
|||
Bytecode **codeArray;
|
||||
|
||||
uint32_t numSlots;
|
||||
uint32_t numPropertyReads_;
|
||||
|
||||
bool outOfMemory;
|
||||
bool hadFailure;
|
||||
|
@ -625,21 +624,15 @@ class ScriptAnalysis
|
|||
|
||||
/* --------- Bytecode analysis --------- */
|
||||
|
||||
bool usesScopeChain_:1;
|
||||
bool localsAliasStack_:1;
|
||||
bool canTrackVars:1;
|
||||
bool hasLoops_:1;
|
||||
bool hasTryFinally_:1;
|
||||
bool argumentsContentsObserved_:1;
|
||||
|
||||
uint32_t numReturnSites_;
|
||||
|
||||
/* --------- Lifetime analysis --------- */
|
||||
|
||||
LifetimeVariable *lifetimes;
|
||||
|
||||
public:
|
||||
|
||||
ScriptAnalysis(JSScript *script) {
|
||||
mozilla::PodZero(this);
|
||||
this->script_ = script;
|
||||
|
@ -649,37 +642,26 @@ class ScriptAnalysis
|
|||
}
|
||||
|
||||
bool ranBytecode() { return ranBytecode_; }
|
||||
bool ranSSA() { return ranSSA_; }
|
||||
bool ranLifetimes() { return ranLifetimes_; }
|
||||
|
||||
void analyzeBytecode(JSContext *cx);
|
||||
void analyzeSSA(JSContext *cx);
|
||||
void analyzeLifetimes(JSContext *cx);
|
||||
|
||||
bool OOM() const { return outOfMemory; }
|
||||
bool failed() const { return hadFailure; }
|
||||
|
||||
/* Whether the script has a |finally| block. */
|
||||
bool hasTryFinally() const { return hasTryFinally_; }
|
||||
|
||||
/* Number of property read opcodes in the script. */
|
||||
uint32_t numPropertyReads() const { return numPropertyReads_; }
|
||||
|
||||
/* Whether there are NAME bytecodes which can access the frame's scope chain. */
|
||||
bool usesScopeChain() const { return usesScopeChain_; }
|
||||
|
||||
uint32_t numReturnSites() const { return numReturnSites_; }
|
||||
|
||||
bool hasLoops() const { return hasLoops_; }
|
||||
|
||||
/*
|
||||
* True if there are any LOCAL opcodes aliasing values on the stack (above
|
||||
* script_->nfixed).
|
||||
*/
|
||||
bool localsAliasStack() { return localsAliasStack_; }
|
||||
|
||||
/* Accessors for bytecode information. */
|
||||
bool isReachable(const jsbytecode *pc) { return maybeCode(pc); }
|
||||
|
||||
private:
|
||||
bool ranSSA() { return ranSSA_; }
|
||||
bool ranLifetimes() { return ranLifetimes_; }
|
||||
void analyzeSSA(JSContext *cx);
|
||||
void analyzeLifetimes(JSContext *cx);
|
||||
|
||||
/* Accessors for bytecode information. */
|
||||
Bytecode& getCode(uint32_t offset) {
|
||||
JS_ASSERT(offset < script_->length());
|
||||
JS_ASSERT(codeArray[offset]);
|
||||
|
@ -699,11 +681,6 @@ class ScriptAnalysis
|
|||
}
|
||||
bool jumpTarget(const jsbytecode *pc) { return jumpTarget(script_->pcToOffset(pc)); }
|
||||
|
||||
bool popGuaranteed(jsbytecode *pc) {
|
||||
jsbytecode *next = pc + GetBytecodeLength(pc);
|
||||
return JSOp(*next) == JSOP_POP && !jumpTarget(next);
|
||||
}
|
||||
|
||||
inline const SSAValue &poppedValue(uint32_t offset, uint32_t which);
|
||||
|
||||
inline const SSAValue &poppedValue(const jsbytecode *pc, uint32_t which);
|
||||
|
@ -763,7 +740,6 @@ class ScriptAnalysis
|
|||
void printSSA(JSContext *cx);
|
||||
void printTypes(JSContext *cx);
|
||||
|
||||
private:
|
||||
void setOOM(JSContext *cx) {
|
||||
if (!outOfMemory)
|
||||
js_ReportOutOfMemory(cx);
|
||||
|
@ -823,8 +799,12 @@ class ScriptAnalysis
|
|||
public:
|
||||
#ifdef DEBUG
|
||||
void assertMatchingDebugMode();
|
||||
void assertMatchingStackDepthAtOffset(uint32_t offset, uint32_t stackDepth) {
|
||||
JS_ASSERT_IF(maybeCode(offset), getCode(offset).stackDepth == stackDepth);
|
||||
}
|
||||
#else
|
||||
void assertMatchingDebugMode() { }
|
||||
void assertMatchingStackDepthAtOffset(uint32_t offset, uint32_t stackDepth) { }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -1874,13 +1874,13 @@ static inline jsbytecode *
|
|||
PreviousOpcode(HandleScript script, jsbytecode *pc)
|
||||
{
|
||||
ScriptAnalysis *analysis = script->analysis();
|
||||
JS_ASSERT(analysis->maybeCode(pc));
|
||||
JS_ASSERT(analysis->isReachable(pc));
|
||||
|
||||
if (pc == script->code())
|
||||
return nullptr;
|
||||
|
||||
for (pc--;; pc--) {
|
||||
if (analysis->maybeCode(pc))
|
||||
if (analysis->isReachable(pc))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1897,7 +1897,7 @@ FindPreviousInnerInitializer(HandleScript script, jsbytecode *initpc)
|
|||
if (!script->hasAnalysis())
|
||||
return nullptr;
|
||||
|
||||
if (!script->analysis()->maybeCode(initpc))
|
||||
if (!script->analysis()->isReachable(initpc))
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
|
|
|
@ -304,8 +304,8 @@ AssertStackDepth(JSScript *script, uint32_t offset, uint32_t stackDepth) {
|
|||
*
|
||||
* call js_DumpScriptDepth(cx, script, pc)
|
||||
*/
|
||||
JS_ASSERT_IF(script->hasAnalysis() && script->analysis()->maybeCode(offset),
|
||||
script->analysis()->getCode(offset).stackDepth == stackDepth);
|
||||
if (script->hasAnalysis())
|
||||
script->analysis()->assertMatchingStackDepthAtOffset(offset, stackDepth);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
Загрузка…
Ссылка в новой задаче