Clean up MObjectState
parent
5f9f343762
commit
99e451fe76
|
@ -4817,15 +4817,14 @@ MCreateThisWithTemplate::canRecoverOnBailout() const
|
||||||
|
|
||||||
MObjectState::MObjectState(MObjectState* state)
|
MObjectState::MObjectState(MObjectState* state)
|
||||||
: numSlots_(state->numSlots_),
|
: numSlots_(state->numSlots_),
|
||||||
numFixedSlots_(state->numFixedSlots_),
|
numFixedSlots_(state->numFixedSlots_)
|
||||||
operandIndex_(state->operandIndex_)
|
|
||||||
{
|
{
|
||||||
// This instruction is only used as a summary for bailout paths.
|
// This instruction is only used as a summary for bailout paths.
|
||||||
setResultType(MIRType::Object);
|
setResultType(MIRType::Object);
|
||||||
setRecoveredOnBailout();
|
setRecoveredOnBailout();
|
||||||
}
|
}
|
||||||
|
|
||||||
MObjectState::MObjectState(JSObject *templateObject, OperandIndexMap* operandIndex)
|
MObjectState::MObjectState(JSObject* templateObject)
|
||||||
{
|
{
|
||||||
// This instruction is only used as a summary for bailout paths.
|
// This instruction is only used as a summary for bailout paths.
|
||||||
setResultType(MIRType::Object);
|
setResultType(MIRType::Object);
|
||||||
|
@ -4836,8 +4835,6 @@ MObjectState::MObjectState(JSObject *templateObject, OperandIndexMap* operandInd
|
||||||
NativeObject* nativeObject = &templateObject->as<NativeObject>();
|
NativeObject* nativeObject = &templateObject->as<NativeObject>();
|
||||||
numSlots_ = nativeObject->slotSpan();
|
numSlots_ = nativeObject->slotSpan();
|
||||||
numFixedSlots_ = nativeObject->numFixedSlots();
|
numFixedSlots_ = nativeObject->numFixedSlots();
|
||||||
|
|
||||||
operandIndex_ = operandIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
|
@ -4897,7 +4894,7 @@ MObjectState::New(TempAllocator& alloc, MDefinition* obj)
|
||||||
JSObject* templateObject = templateObjectOf(obj);
|
JSObject* templateObject = templateObjectOf(obj);
|
||||||
MOZ_ASSERT(templateObject, "Unexpected object creation.");
|
MOZ_ASSERT(templateObject, "Unexpected object creation.");
|
||||||
|
|
||||||
MObjectState* res = new(alloc) MObjectState(templateObject, nullptr);
|
MObjectState* res = new(alloc) MObjectState(templateObject);
|
||||||
if (!res || !res->init(alloc, obj))
|
if (!res || !res->init(alloc, obj))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -375,7 +375,7 @@ class AliasSet {
|
||||||
Element = 1 << 1, // A Value member of obj->elements or
|
Element = 1 << 1, // A Value member of obj->elements or
|
||||||
// a typed object.
|
// a typed object.
|
||||||
UnboxedElement = 1 << 2, // An unboxed scalar or reference member of
|
UnboxedElement = 1 << 2, // An unboxed scalar or reference member of
|
||||||
// typed object or unboxed object.
|
// typed object.
|
||||||
DynamicSlot = 1 << 3, // A Value member of obj->slots.
|
DynamicSlot = 1 << 3, // A Value member of obj->slots.
|
||||||
FixedSlot = 1 << 4, // A Value member of obj->fixedSlots().
|
FixedSlot = 1 << 4, // A Value member of obj->fixedSlots().
|
||||||
DOMProperty = 1 << 5, // A DOM property
|
DOMProperty = 1 << 5, // A DOM property
|
||||||
|
@ -3758,14 +3758,9 @@ class MObjectState
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
uint32_t numSlots_;
|
uint32_t numSlots_;
|
||||||
uint32_t numFixedSlots_; // valid if isUnboxed() == false.
|
uint32_t numFixedSlots_;
|
||||||
OperandIndexMap* operandIndex_; // valid if isUnboxed() == true.
|
|
||||||
|
|
||||||
bool isUnboxed() const {
|
MObjectState(JSObject *templateObject);
|
||||||
return operandIndex_ != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
MObjectState(JSObject *templateObject, OperandIndexMap* operandIndex);
|
|
||||||
explicit MObjectState(MObjectState* state);
|
explicit MObjectState(MObjectState* state);
|
||||||
|
|
||||||
MOZ_MUST_USE bool init(TempAllocator& alloc, MDefinition* obj);
|
MOZ_MUST_USE bool init(TempAllocator& alloc, MDefinition* obj);
|
||||||
|
@ -3825,18 +3820,6 @@ class MObjectState
|
||||||
setSlot(slot + numFixedSlots(), def);
|
setSlot(slot + numFixedSlots(), def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interface reserved for unboxed objects.
|
|
||||||
bool hasOffset(uint32_t offset) const {
|
|
||||||
MOZ_ASSERT(isUnboxed());
|
|
||||||
return offset < operandIndex_->map.length() && operandIndex_->map[offset] != 0;
|
|
||||||
}
|
|
||||||
MDefinition* getOffset(uint32_t offset) const {
|
|
||||||
return getOperand(operandIndex_->map[offset]);
|
|
||||||
}
|
|
||||||
void setOffset(uint32_t offset, MDefinition* def) {
|
|
||||||
replaceOperand(operandIndex_->map[offset], def);
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
|
MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
|
||||||
bool canRecoverOnBailout() const override {
|
bool canRecoverOnBailout() const override {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -285,10 +285,6 @@ class ObjectMemoryView : public MDefinitionVisitorDefaultNoop
|
||||||
void visitGuardShape(MGuardShape* ins);
|
void visitGuardShape(MGuardShape* ins);
|
||||||
void visitFunctionEnvironment(MFunctionEnvironment* ins);
|
void visitFunctionEnvironment(MFunctionEnvironment* ins);
|
||||||
void visitLambda(MLambda* ins);
|
void visitLambda(MLambda* ins);
|
||||||
|
|
||||||
private:
|
|
||||||
void storeOffset(MInstruction* ins, size_t offset, MDefinition* value);
|
|
||||||
void loadOffset(MInstruction* ins, size_t offset);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* ObjectMemoryView::phaseName = "Scalar Replacement of Object";
|
const char* ObjectMemoryView::phaseName = "Scalar Replacement of Object";
|
||||||
|
@ -630,35 +626,6 @@ ObjectMemoryView::visitLambda(MLambda* ins)
|
||||||
ins->setIncompleteObject();
|
ins->setIncompleteObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ObjectMemoryView::storeOffset(MInstruction* ins, size_t offset, MDefinition* value)
|
|
||||||
{
|
|
||||||
// Clone the state and update the slot value.
|
|
||||||
MOZ_ASSERT(state_->hasOffset(offset));
|
|
||||||
state_ = BlockState::Copy(alloc_, state_);
|
|
||||||
if (!state_) {
|
|
||||||
oom_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
state_->setOffset(offset, value);
|
|
||||||
ins->block()->insertBefore(ins, state_);
|
|
||||||
|
|
||||||
// Remove original instruction.
|
|
||||||
ins->block()->discard(ins);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ObjectMemoryView::loadOffset(MInstruction* ins, size_t offset)
|
|
||||||
{
|
|
||||||
// Replace load by the slot value.
|
|
||||||
MOZ_ASSERT(state_->hasOffset(offset));
|
|
||||||
ins->replaceAllUsesWith(state_->getOffset(offset));
|
|
||||||
|
|
||||||
// Remove original instruction.
|
|
||||||
ins->block()->discard(ins);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
IndexOf(MDefinition* ins, int32_t* res)
|
IndexOf(MDefinition* ins, int32_t* res)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue