Bug 1118826 part 2 - Remove more pc-mapping related code and workarounds we no longer need. r=shu

This commit is contained in:
Jan de Mooij 2015-01-14 20:13:02 +01:00
parent 1972a7676a
commit b69db6d9d3
4 changed files with 16 additions and 77 deletions

View File

@ -415,10 +415,6 @@ BaselineCompiler::emitPrologue()
if (!emitSPSPush())
return false;
// Pad a nop so that the last non-op ICEntry we pushed does not get
// confused with the start address of the first op for PC mapping.
masm.nop();
return true;
}
@ -3003,17 +2999,6 @@ static const VMFunction PopBlockScopeInfo = FunctionInfo<PopBlockScopeFn>(jit::P
bool
BaselineCompiler::emit_JSOP_POPBLOCKSCOPE()
{
#ifdef DEBUG
// The static block scope ends right before this op. Assert we generated
// JIT code for the previous op, so that pcForNativeOffset does not
// incorrectly return this pc instead of the previous one and confuse
// ScopeIter::settle. TODO: remove this when bug 1118826 lands.
PCMappingEntry &prevEntry = pcMappingEntries_[pcMappingEntries_.length() - 2];
PCMappingEntry &curEntry = pcMappingEntries_[pcMappingEntries_.length() - 1];
MOZ_ASSERT(curEntry.pcOffset == script->pcToOffset(pc));
MOZ_ASSERT(curEntry.nativeOffset > prevEntry.nativeOffset);
#endif
// Call a stub to pop the block from the block chain.
prepareVMCall();
@ -3029,12 +3014,8 @@ static const VMFunction DebugLeaveBlockInfo = FunctionInfo<DebugLeaveBlockFn>(ji
bool
BaselineCompiler::emit_JSOP_DEBUGLEAVEBLOCK()
{
if (!compileDebugInstrumentation_) {
// See the comment in emit_JSOP_POPBLOCKSCOPE.
if (*GetNextPc(pc) == JSOP_POPBLOCKSCOPE)
masm.nop();
if (!compileDebugInstrumentation_)
return true;
}
prepareVMCall();
masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());

View File

@ -747,30 +747,13 @@ BaselineScript::nativeCodeForPC(JSScript *script, jsbytecode *pc, PCMappingSlotI
}
jsbytecode *
BaselineScript::pcForReturnOffset(JSScript *script, uint32_t nativeOffset)
{
return pcForNativeOffset(script, nativeOffset, true);
}
jsbytecode *
BaselineScript::pcForReturnAddress(JSScript *script, uint8_t *nativeAddress)
BaselineScript::approximatePcForNativeAddress(JSScript *script, uint8_t *nativeAddress)
{
MOZ_ASSERT(script->baselineScript() == this);
MOZ_ASSERT(nativeAddress >= method_->raw());
MOZ_ASSERT(nativeAddress < method_->raw() + method_->instructionsSize());
return pcForReturnOffset(script, uint32_t(nativeAddress - method_->raw()));
}
jsbytecode *
BaselineScript::pcForNativeOffset(JSScript *script, uint32_t nativeOffset)
{
return pcForNativeOffset(script, nativeOffset, false);
}
jsbytecode *
BaselineScript::pcForNativeOffset(JSScript *script, uint32_t nativeOffset, bool isReturn)
{
MOZ_ASSERT(script->baselineScript() == this);
uint32_t nativeOffset = nativeAddress - method_->raw();
MOZ_ASSERT(nativeOffset < method_->instructionsSize());
// Look for the first PCMappingIndexEntry with native offset > the native offset we are
@ -786,21 +769,18 @@ BaselineScript::pcForNativeOffset(JSScript *script, uint32_t nativeOffset, bool
i--;
PCMappingIndexEntry &entry = pcMappingIndexEntry(i);
MOZ_ASSERT_IF(isReturn, nativeOffset >= entry.nativeOffset);
CompactBufferReader reader(pcMappingReader(i));
jsbytecode *curPC = script->offsetToPC(entry.pcOffset);
uint32_t curNativeOffset = entry.nativeOffset;
MOZ_ASSERT(script->containsPC(curPC));
MOZ_ASSERT_IF(isReturn, nativeOffset >= curNativeOffset);
// In the raw native-lookup case, the native code address can occur
// before the start of ops. Associate those with bytecode offset 0.
if (!isReturn && (curNativeOffset > nativeOffset))
// The native code address can occur before the start of ops.
// Associate those with bytecode offset 0.
if (curNativeOffset > nativeOffset)
return script->code();
mozilla::DebugOnly<uint32_t> lastNativeOffset = curNativeOffset;
jsbytecode *lastPC = curPC;
while (true) {
// If the high bit is set, the native offset relative to the
@ -812,38 +792,20 @@ BaselineScript::pcForNativeOffset(JSScript *script, uint32_t nativeOffset, bool
// Return the last PC that matched nativeOffset. Some bytecode
// generate no native code (e.g., constant-pushing bytecode like
// JSOP_INT8), and so their entries share the same nativeOffset as the
// next op that does generate code. Trying to find an entry for a
// return address is impossible for bytecodes that generate no code
// since calling this method requires VM reentry, so assert an exact
// match.
if (curNativeOffset > nativeOffset) {
MOZ_ASSERT_IF(isReturn, lastNativeOffset == nativeOffset);
// next op that does generate code.
if (curNativeOffset > nativeOffset)
return lastPC;
}
// If this is a raw native lookup (not jsop return addresses), then
// the native address may lie in-between the last delta-entry in
// The native address may lie in-between the last delta-entry in
// a pcMappingIndexEntry, and the next pcMappingIndexEntry.
if (!reader.more()) {
MOZ_ASSERT_IF(isReturn, curNativeOffset == nativeOffset);
if (!reader.more())
return curPC;
}
lastNativeOffset = curNativeOffset;
lastPC = curPC;
curPC += GetBytecodeLength(curPC);
}
}
jsbytecode *
BaselineScript::pcForNativeAddress(JSScript *script, uint8_t *nativeAddress)
{
MOZ_ASSERT(script->baselineScript() == this);
MOZ_ASSERT(nativeAddress >= method_->raw());
MOZ_ASSERT(nativeAddress < method_->raw() + method_->instructionsSize());
return pcForNativeOffset(script, uint32_t(nativeAddress - method_->raw()));
}
void
BaselineScript::toggleDebugTraps(JSScript *script, jsbytecode *pc)
{

View File

@ -371,20 +371,15 @@ struct BaselineScript
uint8_t *nativeCodeForPC(JSScript *script, jsbytecode *pc,
PCMappingSlotInfo *slotInfo = nullptr);
jsbytecode *pcForReturnOffset(JSScript *script, uint32_t nativeOffset);
jsbytecode *pcForReturnAddress(JSScript *script, uint8_t *nativeAddress);
jsbytecode *pcForNativeAddress(JSScript *script, uint8_t *nativeAddress);
jsbytecode *pcForNativeOffset(JSScript *script, uint32_t nativeOffset);
// Return the bytecode offset for a given native code address. Be careful
// when using this method: we don't emit code for some bytecode ops, so
// the result may not be accurate.
jsbytecode *approximatePcForNativeAddress(JSScript *script, uint8_t *nativeAddress);
bool addDependentAsmJSModule(JSContext *cx, DependentAsmJSModuleExit exit);
void unlinkDependentAsmJSModules(FreeOp *fop);
void removeDependentAsmJSModule(DependentAsmJSModuleExit exit);
private:
jsbytecode *pcForNativeOffset(JSScript *script, uint32_t nativeOffset, bool isReturn);
public:
// Toggle debug traps (used for breakpoints and step mode) in the script.
// If |pc| is nullptr, toggle traps for all ops in the script. Else, only
// toggle traps at |pc|.

View File

@ -78,7 +78,8 @@ JitcodeGlobalEntry::BaselineEntry::callStackAtAddr(JSRuntime *rt, void *ptr,
MOZ_ASSERT(containsPointer(ptr));
MOZ_ASSERT(script_->hasBaselineScript());
jsbytecode *pc = script_->baselineScript()->pcForNativeAddress(script_, (uint8_t*) ptr);
uint8_t *addr = reinterpret_cast<uint8_t*>(ptr);
jsbytecode *pc = script_->baselineScript()->approximatePcForNativeAddress(script_, addr);
if (!results.append(BytecodeLocation(script_, pc)))
return false;