Remove duplicate members from some LIR instruction by using the HIR accessors.

Remove unused LOperands from keyed-loads. We do not have multiple representations
for load instructions anymore.

Correct number of output operands as for a couple of instructions form 1 to 0
because they do not produce a result (e.g. PushArgument)

Review URL: http://codereview.chromium.org/6158004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6258 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 14cb39e5
......@@ -1690,23 +1690,12 @@ LInstruction* LChunkBuilder::DoLoadElements(HLoadElements* instr) {
LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
HLoadKeyedFastElement* instr) {
Representation r = instr->representation();
LOperand* obj = UseRegisterAtStart(instr->object());
ASSERT(instr->representation().IsTagged());
ASSERT(instr->key()->representation().IsInteger32());
LOperand* obj = UseRegisterAtStart(instr->object());
LOperand* key = UseRegisterAtStart(instr->key());
LOperand* load_result = NULL;
// Double needs an extra temp, because the result is converted from heap
// number to a double register.
if (r.IsDouble()) load_result = TempRegister();
LInstruction* result = new LLoadKeyedFastElement(obj,
key,
load_result);
if (r.IsDouble()) {
result = DefineAsRegister(result);
} else {
result = DefineSameAsFirst(result);
}
return AssignEnvironment(result);
LInstruction* result = new LLoadKeyedFastElement(obj, key);
return AssignEnvironment(DefineSameAsFirst(result));
}
......@@ -1763,13 +1752,7 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
? UseTempRegister(instr->value())
: UseRegister(instr->value());
return new LStoreNamedField(obj,
instr->name(),
val,
instr->is_in_object(),
instr->offset(),
needs_write_barrier,
instr->transition());
return new LStoreNamedField(obj, val);
}
......@@ -1777,7 +1760,7 @@ LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
LOperand* obj = UseFixed(instr->object(), r1);
LOperand* val = UseFixed(instr->value(), r0);
LInstruction* result = new LStoreNamedGeneric(obj, instr->name(), val);
LInstruction* result = new LStoreNamedGeneric(obj, val);
return MarkAsCall(result, instr);
}
......
......@@ -1242,21 +1242,14 @@ class LLoadElements: public LUnaryOperation {
class LLoadKeyedFastElement: public LBinaryOperation {
public:
LLoadKeyedFastElement(LOperand* elements,
LOperand* key,
LOperand* load_result)
: LBinaryOperation(elements, key),
load_result_(load_result) { }
LLoadKeyedFastElement(LOperand* elements, LOperand* key)
: LBinaryOperation(elements, key) { }
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
LOperand* elements() const { return left(); }
LOperand* key() const { return right(); }
LOperand* load_result() const { return load_result_; }
private:
LOperand* load_result_;
};
......@@ -1492,63 +1485,46 @@ class LSmiUntag: public LUnaryOperation {
class LStoreNamed: public LInstruction {
public:
LStoreNamed(LOperand* obj, Handle<Object> name, LOperand* val)
: object_(obj), name_(name), value_(val) { }
LStoreNamed(LOperand* obj, LOperand* val)
: object_(obj), value_(val) { }
DECLARE_INSTRUCTION(StoreNamed)
DECLARE_HYDROGEN_ACCESSOR(StoreNamed)
virtual void PrintDataTo(StringStream* stream) const;
LOperand* object() const { return object_; }
Handle<Object> name() const { return name_; }
Handle<Object> name() const { return hydrogen()->name(); }
LOperand* value() const { return value_; }
private:
LOperand* object_;
Handle<Object> name_;
LOperand* value_;
};
class LStoreNamedField: public LStoreNamed {
public:
LStoreNamedField(LOperand* obj,
Handle<Object> name,
LOperand* val,
bool in_object,
int offset,
bool needs_write_barrier,
Handle<Map> transition)
: LStoreNamed(obj, name, val),
is_in_object_(in_object),
offset_(offset),
needs_write_barrier_(needs_write_barrier),
transition_(transition) { }
LStoreNamedField(LOperand* obj, LOperand* val)
: LStoreNamed(obj, val) { }
DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
bool is_in_object() { return is_in_object_; }
int offset() { return offset_; }
bool needs_write_barrier() { return needs_write_barrier_; }
Handle<Map> transition() const { return transition_; }
void set_transition(Handle<Map> map) { transition_ = map; }
private:
bool is_in_object_;
int offset_;
bool needs_write_barrier_;
Handle<Map> transition_;
bool is_in_object() { return hydrogen()->is_in_object(); }
int offset() { return hydrogen()->offset(); }
bool needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
Handle<Map> transition() { return hydrogen()->transition(); }
};
class LStoreNamedGeneric: public LStoreNamed {
public:
LStoreNamedGeneric(LOperand* obj,
Handle<Object> name,
LOperand* val)
: LStoreNamed(obj, name, val) { }
LStoreNamedGeneric(LOperand* obj, LOperand* val)
: LStoreNamed(obj, val) { }
DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
};
......
......@@ -1636,36 +1636,19 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
Register elements = ToRegister(instr->elements());
Register key = EmitLoadRegister(instr->key(), scratch0());
Register result;
Register result = ToRegister(instr->result());
Register scratch = scratch0();
if (instr->load_result() != NULL) {
result = ToRegister(instr->load_result());
} else {
result = ToRegister(instr->result());
ASSERT(result.is(elements));
}
ASSERT(result.is(elements));
// Load the result.
__ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2));
__ ldr(result, FieldMemOperand(scratch, FixedArray::kHeaderSize));
Representation r = instr->hydrogen()->representation();
if (r.IsInteger32()) {
// Untag and check for smi.
__ SmiUntag(result);
DeoptimizeIf(cs, instr->environment());
} else if (r.IsDouble()) {
EmitNumberUntagD(result,
ToDoubleRegister(instr->result()),
instr->environment());
} else {
// Check for the hole value.
ASSERT(r.IsTagged());
__ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
__ cmp(result, scratch);
DeoptimizeIf(eq, instr->environment());
}
// Check for the hole value.
ASSERT(r.IsTagged());
__ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
__ cmp(result, scratch);
DeoptimizeIf(eq, instr->environment());
}
......
......@@ -2009,32 +2009,15 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
Register elements = ToRegister(instr->elements());
Register key = ToRegister(instr->key());
Register result;
if (instr->load_result() != NULL) {
result = ToRegister(instr->load_result());
} else {
result = ToRegister(instr->result());
ASSERT(result.is(elements));
}
Register result = ToRegister(instr->result());
ASSERT(result.is(elements));
// Load the result.
__ mov(result, FieldOperand(elements, key, times_4, FixedArray::kHeaderSize));
Representation r = instr->hydrogen()->representation();
if (r.IsInteger32()) {
// Untag and check for smi.
__ SmiUntag(result);
DeoptimizeIf(carry, instr->environment());
} else if (r.IsDouble()) {
EmitNumberUntagD(result,
ToDoubleRegister(instr->result()),
instr->environment());
} else {
// Check for the hole value.
ASSERT(r.IsTagged());
__ cmp(result, Factory::the_hole_value());
DeoptimizeIf(equal, instr->environment());
}
// Check for the hole value.
__ cmp(result, Factory::the_hole_value());
DeoptimizeIf(equal, instr->environment());
}
......
......@@ -1674,8 +1674,9 @@ LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) {
LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
return DefineAsRegister(
new LLoadNamedField(UseRegisterAtStart(instr->object())));
ASSERT(instr->representation().IsTagged());
LOperand* obj = UseRegisterAtStart(instr->object());
return DefineAsRegister(new LLoadNamedField(obj));
}
......@@ -1702,21 +1703,12 @@ LInstruction* LChunkBuilder::DoLoadElements(HLoadElements* instr) {
LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
HLoadKeyedFastElement* instr) {
Representation r = instr->representation();
LOperand* obj = UseRegisterAtStart(instr->object());
ASSERT(instr->representation().IsTagged());
ASSERT(instr->key()->representation().IsInteger32());
LOperand* obj = UseRegisterAtStart(instr->object());
LOperand* key = UseRegisterAtStart(instr->key());
LOperand* load_result = NULL;
// Double needs an extra temp, because the result is converted from heap
// number to a double register.
if (r.IsDouble()) load_result = TempRegister();
LLoadKeyedFastElement* load = new LLoadKeyedFastElement(obj,
key,
load_result);
LInstruction* result = r.IsDouble()
? DefineAsRegister(load)
: DefineSameAsFirst(load);
return AssignEnvironment(result);
LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key);
return AssignEnvironment(DefineSameAsFirst(result));
}
......@@ -1777,14 +1769,7 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
LOperand* temp = (!instr->is_in_object() || needs_write_barrier)
? TempRegister() : NULL;
return new LStoreNamedField(obj,
instr->name(),
val,
instr->is_in_object(),
instr->offset(),
temp,
needs_write_barrier,
instr->transition());
return new LStoreNamedField(obj, val, temp);
}
......@@ -1792,7 +1777,7 @@ LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
LOperand* obj = UseFixed(instr->object(), edx);
LOperand* val = UseFixed(instr->value(), eax);
LStoreNamedGeneric* result = new LStoreNamedGeneric(obj, instr->name(), val);
LStoreNamedGeneric* result = new LStoreNamedGeneric(obj, val);
return MarkAsCall(result, instr);
}
......
......@@ -1103,10 +1103,10 @@ class LConstantT: public LConstant {
};
class LBranch: public LUnaryOperation<1> {
class LBranch: public LUnaryOperation<0> {
public:
LBranch(LOperand* input, int true_block_id, int false_block_id)
: LUnaryOperation<1>(input),
: LUnaryOperation<0>(input),
true_block_id_(true_block_id),
false_block_id_(false_block_id) { }
......@@ -1125,9 +1125,9 @@ class LBranch: public LUnaryOperation<1> {
};
class LCmpMapAndBranch: public LUnaryOperation<1> {
class LCmpMapAndBranch: public LUnaryOperation<0> {
public:
explicit LCmpMapAndBranch(LOperand* value) : LUnaryOperation<1>(value) { }
explicit LCmpMapAndBranch(LOperand* value) : LUnaryOperation<0>(value) { }
DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
DECLARE_HYDROGEN_ACCESSOR(CompareMapAndBranch)
......@@ -1243,9 +1243,9 @@ class LArithmeticT: public LBinaryOperation {
};
class LReturn: public LUnaryOperation<1> {
class LReturn: public LUnaryOperation<0> {
public:
explicit LReturn(LOperand* use) : LUnaryOperation<1>(use) { }
explicit LReturn(LOperand* use) : LUnaryOperation<0>(use) { }
DECLARE_CONCRETE_INSTRUCTION(Return, "return")
};
......@@ -1298,21 +1298,14 @@ class LLoadElements: public LUnaryOperation<1> {
class LLoadKeyedFastElement: public LBinaryOperation {
public:
LLoadKeyedFastElement(LOperand* elements,
LOperand* key,
LOperand* load_result)
: LBinaryOperation(elements, key),
load_result_(load_result) { }
LLoadKeyedFastElement(LOperand* elements, LOperand* key)
: LBinaryOperation(elements, key) { }
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
LOperand* elements() const { return left(); }
LOperand* key() const { return right(); }
LOperand* load_result() const { return load_result_; }
private:
LOperand* load_result_;
};
......@@ -1335,18 +1328,18 @@ class LLoadGlobal: public LTemplateInstruction<1> {
};
class LStoreGlobal: public LUnaryOperation<1> {
class LStoreGlobal: public LUnaryOperation<0> {
public:
explicit LStoreGlobal(LOperand* value) : LUnaryOperation<1>(value) {}
explicit LStoreGlobal(LOperand* value) : LUnaryOperation<0>(value) {}
DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store-global")
DECLARE_HYDROGEN_ACCESSOR(StoreGlobal)
};
class LPushArgument: public LUnaryOperation<1> {
class LPushArgument: public LUnaryOperation<0> {
public:
explicit LPushArgument(LOperand* argument) : LUnaryOperation<1>(argument) {}
explicit LPushArgument(LOperand* argument) : LUnaryOperation<0>(argument) {}
DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
};
......@@ -1546,67 +1539,49 @@ class LSmiUntag: public LUnaryOperation<1> {
class LStoreNamed: public LTemplateInstruction<0> {
public:
LStoreNamed(LOperand* obj, Handle<Object> name, LOperand* val)
: object_(obj), name_(name), value_(val) { }
LStoreNamed(LOperand* obj, LOperand* val) : object_(obj), value_(val) { }
DECLARE_INSTRUCTION(StoreNamed)
DECLARE_HYDROGEN_ACCESSOR(StoreNamed)
virtual void PrintDataTo(StringStream* stream);
LOperand* object() const { return object_; }
Handle<Object> name() const { return name_; }
Handle<Object> name() const { return hydrogen()->name(); }
LOperand* value() const { return value_; }
private:
LOperand* object_;
Handle<Object> name_;
LOperand* value_;
};
class LStoreNamedField: public LStoreNamed {
public:
LStoreNamedField(LOperand* obj,
Handle<Object> name,
LOperand* val,
bool in_object,
int offset,
LOperand* temp,
bool needs_write_barrier,
Handle<Map> transition)
: LStoreNamed(obj, name, val),
is_in_object_(in_object),
offset_(offset),
temp_(temp),
needs_write_barrier_(needs_write_barrier),
transition_(transition) { }
LStoreNamedField(LOperand* obj, LOperand* val, LOperand* temp)
: LStoreNamed(obj, val), temp_(temp) { }
DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
bool is_in_object() { return is_in_object_; }
int offset() { return offset_; }
bool is_in_object() { return hydrogen()->is_in_object(); }
int offset() { return hydrogen()->offset(); }
LOperand* temp() { return temp_; }
bool needs_write_barrier() { return needs_write_barrier_; }
Handle<Map> transition() const { return transition_; }
void set_transition(Handle<Map> map) { transition_ = map; }
bool needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
Handle<Map> transition() const { return hydrogen()->transition(); }
private:
bool is_in_object_;
int offset_;
LOperand* temp_;
bool needs_write_barrier_;
Handle<Map> transition_;
};
class LStoreNamedGeneric: public LStoreNamed {
public:
LStoreNamedGeneric(LOperand* obj,
Handle<Object> name,
LOperand* val)
: LStoreNamed(obj, name, val) { }
LStoreNamedGeneric(LOperand* obj, LOperand* val)
: LStoreNamed(obj, val) { }
DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment