Bug 1082875 - Make BytecodeSite a TempObject to save on duplicates. (r=djvj)

This commit is contained in:
Shu-yu Guo 2014-10-30 17:23:04 -07:00
parent 8ce6b1be38
commit 13de6f7313
13 changed files with 62 additions and 62 deletions

View File

@ -4099,7 +4099,7 @@ CodeGenerator::generateBody()
if (iter->mirRaw()) {
// Only add instructions that have a tracked inline script tree.
if (iter->mirRaw()->trackedSite().hasTree()) {
if (iter->mirRaw()->trackedTree()) {
if (!addNativeToBytecodeEntry(iter->mirRaw()->trackedSite()))
return false;
}
@ -7335,7 +7335,8 @@ CodeGenerator::generate()
// top-level script.
InlineScriptTree *tree = gen->info().inlineScriptTree();
jsbytecode *startPC = tree->script()->code();
if (!addNativeToBytecodeEntry(BytecodeSite(tree, startPC)))
BytecodeSite *startSite = new(gen->alloc()) BytecodeSite(tree, startPC);
if (!addNativeToBytecodeEntry(startSite))
return false;
if (!snapshots_.init())
@ -7394,21 +7395,21 @@ CodeGenerator::generate()
return false;
// Reset native => bytecode map table with top-level script and startPc.
if (!addNativeToBytecodeEntry(BytecodeSite(tree, startPC)))
if (!addNativeToBytecodeEntry(startSite))
return false;
if (!generateBody())
return false;
// Reset native => bytecode map table with top-level script and startPc.
if (!addNativeToBytecodeEntry(BytecodeSite(tree, startPC)))
if (!addNativeToBytecodeEntry(startSite))
return false;
if (!generateEpilogue())
return false;
// Reset native => bytecode map table with top-level script and startPc.
if (!addNativeToBytecodeEntry(BytecodeSite(tree, startPC)))
if (!addNativeToBytecodeEntry(startSite))
return false;
if (!generateInvalidateEpilogue())
@ -7424,7 +7425,7 @@ CodeGenerator::generate()
return false;
// Add terminal entry.
if (!addNativeToBytecodeEntry(BytecodeSite(tree, startPC)))
if (!addNativeToBytecodeEntry(startSite))
return false;
// Dump Native to bytecode entries to spew.

View File

@ -9,14 +9,13 @@
#include "jsfun.h"
#include "jit/IonAllocPolicy.h"
#include "jit/Registers.h"
#include "vm/ScopeObject.h"
namespace js {
namespace jit {
class TempAllocator;
inline unsigned
StartArgSlot(JSScript *script)
{
@ -74,7 +73,7 @@ class InlineScriptTree {
jsbytecode *callerPc, JSScript *script);
InlineScriptTree *addCallee(TempAllocator *allocator, jsbytecode *callerPc,
JSScript *calleeScript);
JSScript *calleeScript);
InlineScriptTree *caller() const {
return caller_;
@ -123,7 +122,8 @@ class InlineScriptTree {
}
};
class BytecodeSite {
class BytecodeSite : public TempObject
{
// InlineScriptTree identifying innermost active function at site.
InlineScriptTree *tree_;
@ -142,10 +142,6 @@ class BytecodeSite {
MOZ_ASSERT(pc_ != nullptr);
}
bool hasTree() const {
return tree_ != nullptr;
}
InlineScriptTree *tree() const {
return tree_;
}

View File

@ -12,7 +12,6 @@
#include "jscntxt.h"
#include "jscompartment.h"
#include "jit/CompileInfo.h"
#include "jit/CompileWrappers.h"
#include "jit/JitOptions.h"

View File

@ -900,9 +900,9 @@ class IonBuilder
MBasicBlock *current;
uint32_t loopDepth_;
BytecodeSite bytecodeSite(jsbytecode *pc) {
BytecodeSite *bytecodeSite(jsbytecode *pc) {
MOZ_ASSERT(info().inlineScriptTree()->script()->containsPC(pc));
return BytecodeSite(info().inlineScriptTree(), pc);
return new(alloc()) BytecodeSite(info().inlineScriptTree(), pc);
}
MDefinition *lexicalCheck_;

View File

@ -198,7 +198,7 @@ LoopUnroller::go(LoopIterationBound *bound)
// The old preheader will go before the unrolled loop, and the old loop
// will need a new empty preheader.
CompileInfo &info = oldPreheader->info();
if (header->trackedSite().pc()) {
if (header->trackedPc()) {
unrolledHeader =
MBasicBlock::New(graph, nullptr, info,
oldPreheader, header->trackedSite(), MBasicBlock::LOOP_HEADER);

View File

@ -355,7 +355,7 @@ class MDefinition : public MNode
// Track bailouts by storing the current pc in MIR instruction. Also used
// for profiling and keeping track of what the last known pc was.
BytecodeSite trackedSite_;
const BytecodeSite *trackedSite_;
private:
enum Flag {
@ -391,7 +391,7 @@ class MDefinition : public MNode
resultType_(MIRType_None),
resultTypeSet_(nullptr),
dependency_(nullptr),
trackedSite_()
trackedSite_(nullptr)
{ }
// Copying a definition leaves the list of uses and the block empty.
@ -426,17 +426,18 @@ class MDefinition : public MNode
// be worthwhile.
virtual bool possiblyCalls() const { return false; }
void setTrackedSite(const BytecodeSite &site) {
void setTrackedSite(const BytecodeSite *site) {
MOZ_ASSERT(site);
trackedSite_ = site;
}
const BytecodeSite &trackedSite() const {
const BytecodeSite *trackedSite() const {
return trackedSite_;
}
jsbytecode *trackedPc() const {
return trackedSite_.pc();
return trackedSite_ ? trackedSite_->pc() : nullptr;
}
InlineScriptTree *trackedTree() const {
return trackedSite_.tree();
return trackedSite_ ? trackedSite_->tree() : nullptr;
}
JSScript *profilerLeaveScript() const {

View File

@ -234,9 +234,9 @@ MIRGraph::forkJoinContext()
MBasicBlock *
MBasicBlock::New(MIRGraph &graph, BytecodeAnalysis *analysis, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site, Kind kind)
MBasicBlock *pred, const BytecodeSite *site, Kind kind)
{
MOZ_ASSERT(site.pc() != nullptr);
MOZ_ASSERT(site->pc() != nullptr);
MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, site, kind);
if (!block->init())
@ -250,7 +250,7 @@ MBasicBlock::New(MIRGraph &graph, BytecodeAnalysis *analysis, CompileInfo &info,
MBasicBlock *
MBasicBlock::NewPopN(MIRGraph &graph, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site, Kind kind, uint32_t popped)
MBasicBlock *pred, const BytecodeSite *site, Kind kind, uint32_t popped)
{
MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, site, kind);
if (!block->init())
@ -264,7 +264,7 @@ MBasicBlock::NewPopN(MIRGraph &graph, CompileInfo &info,
MBasicBlock *
MBasicBlock::NewWithResumePoint(MIRGraph &graph, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site,
MBasicBlock *pred, const BytecodeSite *site,
MResumePoint *resumePoint)
{
MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, site, NORMAL);
@ -286,10 +286,10 @@ MBasicBlock::NewWithResumePoint(MIRGraph &graph, CompileInfo &info,
MBasicBlock *
MBasicBlock::NewPendingLoopHeader(MIRGraph &graph, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site,
MBasicBlock *pred, const BytecodeSite *site,
unsigned stackPhiCount)
{
MOZ_ASSERT(site.pc() != nullptr);
MOZ_ASSERT(site->pc() != nullptr);
MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, site, PENDING_LOOP_HEADER);
if (!block->init())
@ -306,14 +306,16 @@ MBasicBlock::NewSplitEdge(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred)
{
return pred->pc()
? MBasicBlock::New(graph, nullptr, info, pred,
BytecodeSite(pred->trackedTree(), pred->pc()), SPLIT_EDGE)
new(graph.alloc()) BytecodeSite(pred->trackedTree(), pred->pc()),
SPLIT_EDGE)
: MBasicBlock::NewAsmJS(graph, info, pred, SPLIT_EDGE);
}
MBasicBlock *
MBasicBlock::NewAsmJS(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred, Kind kind)
{
MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, BytecodeSite(), kind);
BytecodeSite *site = new(graph.alloc()) BytecodeSite();
MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, site, kind);
if (!block->init())
return nullptr;
@ -352,14 +354,14 @@ MBasicBlock::NewAsmJS(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred, Kin
return block;
}
MBasicBlock::MBasicBlock(MIRGraph &graph, CompileInfo &info, const BytecodeSite &site, Kind kind)
MBasicBlock::MBasicBlock(MIRGraph &graph, CompileInfo &info, const BytecodeSite *site, Kind kind)
: unreachable_(false),
graph_(graph),
info_(info),
predecessors_(graph.alloc()),
stackPosition_(info_.firstStackSlot()),
numDominated_(0),
pc_(site.pc()),
pc_(site->pc()),
lir_(nullptr),
entryResumePoint_(nullptr),
outerResumePoint_(nullptr),

View File

@ -46,7 +46,7 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
};
private:
MBasicBlock(MIRGraph &graph, CompileInfo &info, const BytecodeSite &site, Kind kind);
MBasicBlock(MIRGraph &graph, CompileInfo &info, const BytecodeSite *site, Kind kind);
bool init();
void copySlots(MBasicBlock *from);
bool inherit(TempAllocator &alloc, BytecodeAnalysis *analysis, MBasicBlock *pred,
@ -107,14 +107,14 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
// Creates a new basic block for a MIR generator. If |pred| is not nullptr,
// its slots and stack depth are initialized from |pred|.
static MBasicBlock *New(MIRGraph &graph, BytecodeAnalysis *analysis, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site, Kind kind);
MBasicBlock *pred, const BytecodeSite *site, Kind kind);
static MBasicBlock *NewPopN(MIRGraph &graph, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site, Kind kind, uint32_t popn);
MBasicBlock *pred, const BytecodeSite *site, Kind kind, uint32_t popn);
static MBasicBlock *NewWithResumePoint(MIRGraph &graph, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site,
MBasicBlock *pred, const BytecodeSite *site,
MResumePoint *resumePoint);
static MBasicBlock *NewPendingLoopHeader(MIRGraph &graph, CompileInfo &info,
MBasicBlock *pred, const BytecodeSite &site,
MBasicBlock *pred, const BytecodeSite *site,
unsigned loopStateSlots);
static MBasicBlock *NewSplitEdge(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred);
static MBasicBlock *NewAsmJS(MIRGraph &graph, CompileInfo &info,
@ -596,18 +596,18 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
// Track bailouts by storing the current pc in MIR instruction added at this
// cycle. This is also used for tracking calls when profiling.
void updateTrackedSite(const BytecodeSite &site) {
MOZ_ASSERT(site.tree() == trackedSite_.tree());
void updateTrackedSite(const BytecodeSite *site) {
MOZ_ASSERT(site->tree() == trackedSite_->tree());
trackedSite_ = site;
}
const BytecodeSite &trackedSite() const {
const BytecodeSite *trackedSite() const {
return trackedSite_;
}
jsbytecode *trackedPc() const {
return trackedSite_.pc();
return trackedSite_ ? trackedSite_->pc() : nullptr;
}
InlineScriptTree *trackedTree() const {
return trackedSite_.tree();
return trackedSite_ ? trackedSite_->tree() : nullptr;
}
private:
@ -649,7 +649,7 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
Vector<MBasicBlock *, 1, IonAllocPolicy> immediatelyDominated_;
MBasicBlock *immediateDominator_;
BytecodeSite trackedSite_;
const BytecodeSite *trackedSite_;
#if defined (JS_ION_PERF)
unsigned lineno_;

View File

@ -185,7 +185,7 @@ CodeGeneratorARM::bailoutIf(Assembler::Condition condition, LSnapshot *snapshot)
// All bailout code is associated with the bytecodeSite of the block we are
// bailing out from.
if (!addOutOfLineCode(ool, BytecodeSite(tree, tree->script()->code())))
if (!addOutOfLineCode(ool, new(alloc()) BytecodeSite(tree, tree->script()->code())))
return false;
masm.ma_b(ool->entry(), condition);
@ -215,7 +215,7 @@ CodeGeneratorARM::bailoutFrom(Label *label, LSnapshot *snapshot)
// All bailout code is associated with the bytecodeSite of the block we are
// bailing out from.
if (!addOutOfLineCode(ool, BytecodeSite(tree, tree->script()->code())))
if (!addOutOfLineCode(ool, new(alloc()) BytecodeSite(tree, tree->script()->code())))
return false;
masm.retarget(label, ool->entry());

View File

@ -199,7 +199,7 @@ CodeGeneratorMIPS::bailoutFrom(Label *label, LSnapshot *snapshot)
// We don't use table bailouts because retargeting is easier this way.
InlineScriptTree *tree = snapshot->mir()->block()->trackedTree();
OutOfLineBailout *ool = new(alloc()) OutOfLineBailout(snapshot, masm.framePushed());
if (!addOutOfLineCode(ool, BytecodeSite(tree, tree->script()->code()))) {
if (!addOutOfLineCode(ool, new(alloc()) BytecodeSite(tree, tree->script()->code()))) {
return false;
}

View File

@ -145,7 +145,7 @@ CodeGeneratorShared::addOutOfLineCode(OutOfLineCode *code, const MInstruction *m
}
bool
CodeGeneratorShared::addOutOfLineCode(OutOfLineCode *code, const BytecodeSite &site)
CodeGeneratorShared::addOutOfLineCode(OutOfLineCode *code, const BytecodeSite *site)
{
code->setFramePushed(masm.framePushed());
code->setBytecodeSite(site);
@ -154,17 +154,18 @@ CodeGeneratorShared::addOutOfLineCode(OutOfLineCode *code, const BytecodeSite &s
}
bool
CodeGeneratorShared::addNativeToBytecodeEntry(const BytecodeSite &site)
CodeGeneratorShared::addNativeToBytecodeEntry(const BytecodeSite *site)
{
// Skip the table entirely if profiling is not enabled.
if (!isNativeToBytecodeMapEnabled())
return true;
MOZ_ASSERT(site.tree());
MOZ_ASSERT(site.pc());
MOZ_ASSERT(site);
MOZ_ASSERT(site->tree());
MOZ_ASSERT(site->pc());
InlineScriptTree *tree = site.tree();
jsbytecode *pc = site.pc();
InlineScriptTree *tree = site->tree();
jsbytecode *pc = site->pc();
uint32_t nativeOffset = masm.currentOffset();
MOZ_ASSERT_IF(nativeToBytecodeList_.empty(), nativeOffset == 0);

View File

@ -251,7 +251,7 @@ class CodeGeneratorShared : public LElementVisitor
void verifyOsiPointRegs(LSafepoint *safepoint);
#endif
bool addNativeToBytecodeEntry(const BytecodeSite &site);
bool addNativeToBytecodeEntry(const BytecodeSite *site);
void dumpNativeToBytecodeEntries();
void dumpNativeToBytecodeEntry(uint32_t idx);
@ -478,7 +478,7 @@ class CodeGeneratorShared : public LElementVisitor
protected:
bool addOutOfLineCode(OutOfLineCode *code, const MInstruction *mir);
bool addOutOfLineCode(OutOfLineCode *code, const BytecodeSite &site);
bool addOutOfLineCode(OutOfLineCode *code, const BytecodeSite *site);
bool hasOutOfLineCode() { return !outOfLineCode_.empty(); }
bool generateOutOfLineCode();
@ -536,7 +536,7 @@ class OutOfLineCode : public TempObject
Label entry_;
Label rejoin_;
uint32_t framePushed_;
BytecodeSite site_;
const BytecodeSite *site_;
public:
OutOfLineCode()
@ -561,17 +561,17 @@ class OutOfLineCode : public TempObject
uint32_t framePushed() const {
return framePushed_;
}
void setBytecodeSite(const BytecodeSite &site) {
void setBytecodeSite(const BytecodeSite *site) {
site_ = site;
}
const BytecodeSite &bytecodeSite() const {
const BytecodeSite *bytecodeSite() const {
return site_;
}
jsbytecode *pc() const {
return site_.pc();
return site_->pc();
}
JSScript *script() const {
return site_.script();
return site_->script();
}
};

View File

@ -441,7 +441,7 @@ CodeGeneratorX86Shared::bailout(const T &binder, LSnapshot *snapshot)
// bailing out from.
InlineScriptTree *tree = snapshot->mir()->block()->trackedTree();
OutOfLineBailout *ool = new(alloc()) OutOfLineBailout(snapshot);
if (!addOutOfLineCode(ool, BytecodeSite(tree, tree->script()->code())))
if (!addOutOfLineCode(ool, new(alloc()) BytecodeSite(tree, tree->script()->code())))
return false;
binder(masm, ool->entry());