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()) if (!emitSPSPush())
return false; 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; return true;
} }
@ -3003,17 +2999,6 @@ static const VMFunction PopBlockScopeInfo = FunctionInfo<PopBlockScopeFn>(jit::P
bool bool
BaselineCompiler::emit_JSOP_POPBLOCKSCOPE() 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. // Call a stub to pop the block from the block chain.
prepareVMCall(); prepareVMCall();
@ -3029,12 +3014,8 @@ static const VMFunction DebugLeaveBlockInfo = FunctionInfo<DebugLeaveBlockFn>(ji
bool bool
BaselineCompiler::emit_JSOP_DEBUGLEAVEBLOCK() BaselineCompiler::emit_JSOP_DEBUGLEAVEBLOCK()
{ {
if (!compileDebugInstrumentation_) { if (!compileDebugInstrumentation_)
// See the comment in emit_JSOP_POPBLOCKSCOPE.
if (*GetNextPc(pc) == JSOP_POPBLOCKSCOPE)
masm.nop();
return true; return true;
}
prepareVMCall(); prepareVMCall();
masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg()); masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());

View File

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

View File

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

View File

@ -78,7 +78,8 @@ JitcodeGlobalEntry::BaselineEntry::callStackAtAddr(JSRuntime *rt, void *ptr,
MOZ_ASSERT(containsPointer(ptr)); MOZ_ASSERT(containsPointer(ptr));
MOZ_ASSERT(script_->hasBaselineScript()); 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))) if (!results.append(BytecodeLocation(script_, pc)))
return false; return false;