mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 909989 - Part 1: Implement DataPtr to refer to objects in runtimeData_. (r=nbp)
This commit is contained in:
parent
cd9990d950
commit
21a02a2728
@ -95,7 +95,7 @@ class OutOfLineUpdateCache :
|
||||
bool
|
||||
CodeGeneratorShared::addCache(LInstruction *lir, size_t cacheIndex)
|
||||
{
|
||||
IonCache *cache = reinterpret_cast<IonCache *>(&runtimeData_[cacheIndex]);
|
||||
DataPtr<IonCache> cache(this, cacheIndex);
|
||||
MInstruction *mir = lir->mirRaw()->toInstruction();
|
||||
if (mir->resumePoint())
|
||||
cache->setScriptedLocation(mir->block()->info().script(),
|
||||
@ -119,7 +119,7 @@ CodeGeneratorShared::addCache(LInstruction *lir, size_t cacheIndex)
|
||||
bool
|
||||
CodeGenerator::visitOutOfLineCache(OutOfLineUpdateCache *ool)
|
||||
{
|
||||
IonCache *cache = reinterpret_cast<IonCache *>(&runtimeData_[ool->getCacheIndex()]);
|
||||
DataPtr<IonCache> cache(this, ool->getCacheIndex());
|
||||
|
||||
// Register the location of the OOL path in the IC.
|
||||
cache->setFallbackLabel(masm.labelForPatch());
|
||||
|
@ -205,6 +205,33 @@ class CodeGeneratorShared : public LInstructionVisitor
|
||||
void verifyOsiPointRegs(LSafepoint *safepoint);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
// When appending to runtimeData_, the vector might realloc, leaving pointers
|
||||
// int the origianl vector stale and unusable. DataPtr acts like a pointer,
|
||||
// but allows safety in the face of potentially realloc'ing vector appends.
|
||||
friend class DataPtr;
|
||||
template <typename T>
|
||||
class DataPtr
|
||||
{
|
||||
CodeGeneratorShared *cg_;
|
||||
size_t index_;
|
||||
|
||||
T *lookup() {
|
||||
return reinterpret_cast<T *>(&cg_->runtimeData_[index_]);
|
||||
}
|
||||
public:
|
||||
DataPtr(CodeGeneratorShared *cg, size_t index)
|
||||
: cg_(cg), index_(index) { }
|
||||
|
||||
T * operator ->() {
|
||||
return lookup();
|
||||
}
|
||||
T * operator *() {
|
||||
return lookup();
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
size_t allocateData(size_t size) {
|
||||
|
Loading…
Reference in New Issue
Block a user