Use Unique<Cell> and Unique<PropertyCell> in LoadGlobalCell and StoreGlobalCell.

BUG=
R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/24072016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16865 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
titzer@chromium.org 2013-09-20 12:32:31 +00:00
parent 05babb3dca
commit 94a0a95b7a
7 changed files with 29 additions and 27 deletions

View File

@ -2954,7 +2954,7 @@ void LCodeGen::DoReturn(LReturn* instr) {
void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
Register result = ToRegister(instr->result());
__ mov(ip, Operand(Handle<Object>(instr->hydrogen()->cell())));
__ mov(ip, Operand(Handle<Object>(instr->hydrogen()->cell().handle())));
__ ldr(result, FieldMemOperand(ip, Cell::kValueOffset));
if (instr->hydrogen()->RequiresHoleCheck()) {
__ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
@ -2981,7 +2981,7 @@ void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
Register cell = scratch0();
// Load the cell.
__ mov(cell, Operand(instr->hydrogen()->cell()));
__ mov(cell, Operand(instr->hydrogen()->cell().handle()));
// If the cell we are storing to contains the hole it could have
// been deleted from the property dictionary. In that case, we need

View File

@ -3145,7 +3145,7 @@ void HTransitionElementsKind::PrintDataTo(StringStream* stream) {
void HLoadGlobalCell::PrintDataTo(StringStream* stream) {
stream->Add("[%p]", *cell());
stream->Add("[%p]", *cell().handle());
if (!details_.IsDontDelete()) stream->Add(" (deleteable)");
if (details_.IsReadOnly()) stream->Add(" (read-only)");
}
@ -3173,7 +3173,7 @@ void HInnerAllocatedObject::PrintDataTo(StringStream* stream) {
void HStoreGlobalCell::PrintDataTo(StringStream* stream) {
stream->Add("[%p] = ", *cell());
stream->Add("[%p] = ", *cell().handle());
value()->PrintNameTo(stream);
if (!details_.IsDontDelete()) stream->Add(" (deleteable)");
if (details_.IsReadOnly()) stream->Add(" (read-only)");

View File

@ -5122,23 +5122,23 @@ class HUnknownOSRValue V8_FINAL : public HTemplateInstruction<0> {
class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> {
public:
HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details)
: cell_(cell), details_(details), unique_id_() {
: cell_(Unique<Cell>::CreateUninitialized(cell)), details_(details) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnGlobalVars);
}
Handle<Cell> cell() const { return cell_; }
Unique<Cell> cell() const { return cell_; }
bool RequiresHoleCheck() const;
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
virtual intptr_t Hashcode() V8_OVERRIDE {
return unique_id_.Hashcode();
return cell_.Hashcode();
}
virtual void FinalizeUniqueValueId() V8_OVERRIDE {
unique_id_ = UniqueValueId(cell_);
cell_ = Unique<Cell>(cell_.handle());
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
@ -5149,16 +5149,14 @@ class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> {
protected:
virtual bool DataEquals(HValue* other) V8_OVERRIDE {
HLoadGlobalCell* b = HLoadGlobalCell::cast(other);
return unique_id_ == b->unique_id_;
return cell_ == HLoadGlobalCell::cast(other)->cell_;
}
private:
virtual bool IsDeletable() const V8_OVERRIDE { return !RequiresHoleCheck(); }
Handle<Cell> cell_;
Unique<Cell> cell_;
PropertyDetails details_;
UniqueValueId unique_id_;
};
@ -5429,7 +5427,7 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation {
DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*,
Handle<PropertyCell>, PropertyDetails);
Handle<PropertyCell> cell() const { return cell_; }
Unique<PropertyCell> cell() const { return cell_; }
bool RequiresHoleCheck() {
return !details_.IsDontDelete() || details_.IsReadOnly();
}
@ -5437,6 +5435,10 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation {
return StoringValueNeedsWriteBarrier(value());
}
virtual void FinalizeUniqueValueId() V8_OVERRIDE {
cell_ = Unique<PropertyCell>(cell_.handle());
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged();
}
@ -5449,12 +5451,12 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation {
Handle<PropertyCell> cell,
PropertyDetails details)
: HUnaryOperation(value),
cell_(cell),
cell_(Unique<PropertyCell>::CreateUninitialized(cell)),
details_(details) {
SetGVNFlag(kChangesGlobalVars);
}
Handle<PropertyCell> cell_;
Unique<PropertyCell> cell_;
PropertyDetails details_;
};

View File

@ -3151,7 +3151,7 @@ void LCodeGen::DoReturn(LReturn* instr) {
void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
Register result = ToRegister(instr->result());
__ mov(result, Operand::ForCell(instr->hydrogen()->cell()));
__ mov(result, Operand::ForCell(instr->hydrogen()->cell().handle()));
if (instr->hydrogen()->RequiresHoleCheck()) {
__ cmp(result, factory()->the_hole_value());
DeoptimizeIf(equal, instr->environment());
@ -3174,7 +3174,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
Register value = ToRegister(instr->value());
Handle<PropertyCell> cell_handle = instr->hydrogen()->cell();
Handle<PropertyCell> cell_handle = instr->hydrogen()->cell().handle();
// If the cell we are storing to contains the hole it could have
// been deleted from the property dictionary. In that case, we need

View File

@ -2805,7 +2805,7 @@ void LCodeGen::DoReturn(LReturn* instr) {
void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
Register result = ToRegister(instr->result());
__ li(at, Operand(Handle<Object>(instr->hydrogen()->cell())));
__ li(at, Operand(Handle<Object>(instr->hydrogen()->cell().handle())));
__ lw(result, FieldMemOperand(at, Cell::kValueOffset));
if (instr->hydrogen()->RequiresHoleCheck()) {
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
@ -2831,7 +2831,7 @@ void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
Register cell = scratch0();
// Load the cell.
__ li(cell, Operand(instr->hydrogen()->cell()));
__ li(cell, Operand(instr->hydrogen()->cell().handle()));
// If the cell we are storing to contains the hole it could have
// been deleted from the property dictionary. In that case, we need

View File

@ -90,34 +90,34 @@ class Unique V8_FINAL {
}
template <typename U>
bool operator==(const Unique<U>& other) const {
inline bool operator==(const Unique<U>& other) const {
ASSERT(IsInitialized() && other.IsInitialized());
return raw_address_ == other.raw_address_;
}
template <typename U>
bool operator!=(const Unique<U>& other) const {
inline bool operator!=(const Unique<U>& other) const {
ASSERT(IsInitialized() && other.IsInitialized());
return raw_address_ != other.raw_address_;
}
intptr_t Hashcode() const {
inline intptr_t Hashcode() const {
ASSERT(IsInitialized());
return reinterpret_cast<intptr_t>(raw_address_);
}
bool IsNull() const {
inline bool IsNull() const {
ASSERT(IsInitialized());
return raw_address_ == NULL;
}
// Extract the handle from this Unique in order to dereference it.
// WARNING: Only do this if you have access to the heap.
Handle<T> handle() const {
inline Handle<T> handle() const {
return handle_;
}
bool IsInitialized() const {
inline bool IsInitialized() const {
return raw_address_ != NULL || handle_.is_null();
}

View File

@ -2668,7 +2668,7 @@ void LCodeGen::DoReturn(LReturn* instr) {
void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
Register result = ToRegister(instr->result());
__ LoadGlobalCell(result, instr->hydrogen()->cell());
__ LoadGlobalCell(result, instr->hydrogen()->cell().handle());
if (instr->hydrogen()->RequiresHoleCheck()) {
__ CompareRoot(result, Heap::kTheHoleValueRootIndex);
DeoptimizeIf(equal, instr->environment());
@ -2690,7 +2690,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
Register value = ToRegister(instr->value());
Handle<Cell> cell_handle = instr->hydrogen()->cell();
Handle<Cell> cell_handle = instr->hydrogen()->cell().handle();
// If the cell we are storing to contains the hole it could have
// been deleted from the property dictionary. In that case, we need