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