Bug 960040 - Part 1: Prune unused interfaces and code from ScriptAnalysis. r=jandem

This commit is contained in:
Andy Wingo 2014-01-21 11:47:08 +01:00
Родитель f7b7cbccf3
Коммит c5d338f7ab
5 изменённых файлов: 18 добавлений и 72 удалений

Просмотреть файл

@ -453,10 +453,8 @@ class InlineFrameIteratorMaybeGC
// scopeChain // scopeChain
Value v = s.read(); Value v = s.read();
if (v.isObject()) { if (v.isObject())
JS_ASSERT_IF(script()->hasAnalysis(), script()->analysis()->usesScopeChain());
return &v.toObject(); return &v.toObject();
}
return callee()->environment(); return callee()->environment();
} }

Просмотреть файл

@ -67,8 +67,6 @@ ScriptAnalysis::addJump(JSContext *cx, unsigned offset,
code->jumpTarget = true; code->jumpTarget = true;
if (offset < *currentOffset) { if (offset < *currentOffset) {
hasLoops_ = true;
if (!code->analyzed) { if (!code->analyzed) {
/* /*
* Backedge in a while/for loop, whose body has not been analyzed * Backedge in a while/for loop, whose body has not been analyzed
@ -226,28 +224,10 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
switch (op) { 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_DEFFUN:
case JSOP_DEFVAR: case JSOP_DEFVAR:
case JSOP_DEFCONST: case JSOP_DEFCONST:
case JSOP_SETCONST: case JSOP_SETCONST:
usesScopeChain_ = true; // Requires access to VarObj via ScopeChain.
canTrackVars = false; canTrackVars = false;
break; break;
@ -334,18 +314,6 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
break; 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: case JSOP_PUSHBLOCKSCOPE:
localsAliasStack_ = true; localsAliasStack_ = true;
break; break;

Просмотреть файл

@ -606,7 +606,6 @@ class ScriptAnalysis
Bytecode **codeArray; Bytecode **codeArray;
uint32_t numSlots; uint32_t numSlots;
uint32_t numPropertyReads_;
bool outOfMemory; bool outOfMemory;
bool hadFailure; bool hadFailure;
@ -625,21 +624,15 @@ class ScriptAnalysis
/* --------- Bytecode analysis --------- */ /* --------- Bytecode analysis --------- */
bool usesScopeChain_:1;
bool localsAliasStack_:1; bool localsAliasStack_:1;
bool canTrackVars:1; bool canTrackVars:1;
bool hasLoops_:1;
bool hasTryFinally_:1;
bool argumentsContentsObserved_:1; bool argumentsContentsObserved_:1;
uint32_t numReturnSites_;
/* --------- Lifetime analysis --------- */ /* --------- Lifetime analysis --------- */
LifetimeVariable *lifetimes; LifetimeVariable *lifetimes;
public: public:
ScriptAnalysis(JSScript *script) { ScriptAnalysis(JSScript *script) {
mozilla::PodZero(this); mozilla::PodZero(this);
this->script_ = script; this->script_ = script;
@ -649,37 +642,26 @@ class ScriptAnalysis
} }
bool ranBytecode() { return ranBytecode_; } bool ranBytecode() { return ranBytecode_; }
bool ranSSA() { return ranSSA_; }
bool ranLifetimes() { return ranLifetimes_; }
void analyzeBytecode(JSContext *cx); void analyzeBytecode(JSContext *cx);
void analyzeSSA(JSContext *cx);
void analyzeLifetimes(JSContext *cx);
bool OOM() const { return outOfMemory; } bool OOM() const { return outOfMemory; }
bool failed() const { return hadFailure; } 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 * True if there are any LOCAL opcodes aliasing values on the stack (above
* script_->nfixed). * script_->nfixed).
*/ */
bool localsAliasStack() { return localsAliasStack_; } 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) { Bytecode& getCode(uint32_t offset) {
JS_ASSERT(offset < script_->length()); JS_ASSERT(offset < script_->length());
JS_ASSERT(codeArray[offset]); JS_ASSERT(codeArray[offset]);
@ -699,11 +681,6 @@ class ScriptAnalysis
} }
bool jumpTarget(const jsbytecode *pc) { return jumpTarget(script_->pcToOffset(pc)); } 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(uint32_t offset, uint32_t which);
inline const SSAValue &poppedValue(const jsbytecode *pc, uint32_t which); inline const SSAValue &poppedValue(const jsbytecode *pc, uint32_t which);
@ -763,7 +740,6 @@ class ScriptAnalysis
void printSSA(JSContext *cx); void printSSA(JSContext *cx);
void printTypes(JSContext *cx); void printTypes(JSContext *cx);
private:
void setOOM(JSContext *cx) { void setOOM(JSContext *cx) {
if (!outOfMemory) if (!outOfMemory)
js_ReportOutOfMemory(cx); js_ReportOutOfMemory(cx);
@ -823,8 +799,12 @@ class ScriptAnalysis
public: public:
#ifdef DEBUG #ifdef DEBUG
void assertMatchingDebugMode(); void assertMatchingDebugMode();
void assertMatchingStackDepthAtOffset(uint32_t offset, uint32_t stackDepth) {
JS_ASSERT_IF(maybeCode(offset), getCode(offset).stackDepth == stackDepth);
}
#else #else
void assertMatchingDebugMode() { } void assertMatchingDebugMode() { }
void assertMatchingStackDepthAtOffset(uint32_t offset, uint32_t stackDepth) { }
#endif #endif
}; };

Просмотреть файл

@ -1874,13 +1874,13 @@ static inline jsbytecode *
PreviousOpcode(HandleScript script, jsbytecode *pc) PreviousOpcode(HandleScript script, jsbytecode *pc)
{ {
ScriptAnalysis *analysis = script->analysis(); ScriptAnalysis *analysis = script->analysis();
JS_ASSERT(analysis->maybeCode(pc)); JS_ASSERT(analysis->isReachable(pc));
if (pc == script->code()) if (pc == script->code())
return nullptr; return nullptr;
for (pc--;; pc--) { for (pc--;; pc--) {
if (analysis->maybeCode(pc)) if (analysis->isReachable(pc))
break; break;
} }
@ -1897,7 +1897,7 @@ FindPreviousInnerInitializer(HandleScript script, jsbytecode *initpc)
if (!script->hasAnalysis()) if (!script->hasAnalysis())
return nullptr; return nullptr;
if (!script->analysis()->maybeCode(initpc)) if (!script->analysis()->isReachable(initpc))
return nullptr; return nullptr;
/* /*

Просмотреть файл

@ -304,8 +304,8 @@ AssertStackDepth(JSScript *script, uint32_t offset, uint32_t stackDepth) {
* *
* call js_DumpScriptDepth(cx, script, pc) * call js_DumpScriptDepth(cx, script, pc)
*/ */
JS_ASSERT_IF(script->hasAnalysis() && script->analysis()->maybeCode(offset), if (script->hasAnalysis())
script->analysis()->getCode(offset).stackDepth == stackDepth); script->analysis()->assertMatchingStackDepthAtOffset(offset, stackDepth);
} }
namespace { namespace {