Revert change r12912 (http://code.google.com/p/v8/source/detail?r=12912) due to x64 perf issue

R=verwaest@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12943 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 827f8919
......@@ -1881,7 +1881,6 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
(instr->representation().IsDouble() &&
((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
LOperand* external_pointer = UseRegister(instr->elements());
result = new(zone()) LLoadKeyed(external_pointer, key);
}
......@@ -1906,22 +1905,32 @@ LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
LOperand* elements = UseRegisterAtStart(instr->elements());
LOperand* key;
LOperand* val;
if (instr->NeedsWriteBarrier()) {
key = UseTempRegister(instr->key());
val = UseTempRegister(instr->value());
} else {
key = UseRegisterOrConstantAtStart(instr->key());
val = UseRegisterAtStart(instr->value());
}
ElementsKind elements_kind = instr->elements_kind();
bool needs_write_barrier = instr->NeedsWriteBarrier();
LOperand* key = needs_write_barrier
? UseTempRegister(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
bool val_is_temp_register =
elements_kind == EXTERNAL_PIXEL_ELEMENTS ||
elements_kind == EXTERNAL_FLOAT_ELEMENTS;
LOperand* val = val_is_temp_register || needs_write_barrier
? UseTempRegister(instr->value())
: UseRegister(instr->value());
#ifdef DEBUG
LStoreKeyed* result = NULL;
if (!instr->is_external()) {
ASSERT(instr->elements()->representation().IsTagged());
LOperand* object = NULL;
if (instr->value()->representation().IsDouble()) {
object = UseRegisterAtStart(instr->elements());
} else {
ASSERT(instr->value()->representation().IsTagged());
object = UseTempRegister(instr->elements());
}
result = new(zone()) LStoreKeyed(object, key, val);
} else {
ElementsKind elements_kind = instr->elements_kind();
ASSERT(
(instr->value()->representation().IsInteger32() &&
(elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
......@@ -1930,10 +1939,11 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
ASSERT(instr->elements()->representation().IsExternal());
LOperand* external_pointer = UseRegister(instr->elements());
result = new(zone()) LStoreKeyed(external_pointer, key, val);
}
#endif
LStoreKeyed* result = new(zone()) LStoreKeyed(elements, key, val);
ASSERT(result != NULL);
return result;
}
......
......@@ -2775,12 +2775,15 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
if (ExternalArrayOpRequiresTemp<HLoadKeyed>(instr->hydrogen())) {
__ SmiUntag(ToRegister(instr->key()));
LOperand* key = instr->key();
if (!key->IsConstantOperand() &&
ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(),
elements_kind)) {
__ SmiUntag(ToRegister(key));
}
Operand operand(BuildFastArrayOperand(
instr->elements(),
instr->key(),
key,
instr->hydrogen()->key()->representation(),
elements_kind,
0,
......@@ -3850,12 +3853,15 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
if (ExternalArrayOpRequiresTemp<HStoreKeyed>(instr->hydrogen())) {
__ SmiUntag(ToRegister(instr->key()));
LOperand* key = instr->key();
if (!key->IsConstantOperand() &&
ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(),
elements_kind)) {
__ SmiUntag(ToRegister(key));
}
Operand operand(BuildFastArrayOperand(
instr->elements(),
instr->key(),
key,
instr->hydrogen()->key()->representation(),
elements_kind,
0,
......
......@@ -1933,14 +1933,17 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
ASSERT(instr->key()->representation().IsInteger32() ||
instr->key()->representation().IsTagged());
ElementsKind elements_kind = instr->elements_kind();
LOperand* elements = UseRegisterAtStart(instr->elements());
LOperand* key = instr->is_external() &&
ExternalArrayOpRequiresTemp<HLoadKeyed>(instr)
bool clobbers_key = ExternalArrayOpRequiresTemp(
instr->key()->representation(), elements_kind);
LOperand* key = clobbers_key
? UseTempRegister(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
LLoadKeyed* result = NULL;
#ifdef DEBUG
if (instr->is_external()) {
if (!instr->is_external()) {
LOperand* obj = UseRegisterAtStart(instr->elements());
result = new(zone()) LLoadKeyed(obj, key);
} else {
ASSERT(
(instr->representation().IsInteger32() &&
(elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
......@@ -1948,10 +1951,10 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
(instr->representation().IsDouble() &&
((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
LOperand* external_pointer = UseRegister(instr->elements());
result = new(zone()) LLoadKeyed(external_pointer, key);
}
#endif
LLoadKeyed* result = new(zone()) LLoadKeyed(elements, key);
DefineAsRegister(result);
bool can_deoptimize = instr->RequiresHoleCheck() ||
(elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS);
......@@ -1973,27 +1976,34 @@ LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
LOperand* elements;
LOperand* val;
LOperand* key;
LStoreKeyed* result = NULL;
if (!instr->is_external()) {
ASSERT(instr->elements()->representation().IsTagged());
ASSERT(instr->key()->representation().IsInteger32() ||
instr->key()->representation().IsTagged());
if (instr->NeedsWriteBarrier() &&
!IsFastDoubleElementsKind(elements_kind)) {
val = UseTempRegister(instr->value());
key = UseTempRegister(instr->key());
elements = UseRegister(instr->elements());
if (instr->value()->representation().IsDouble()) {
LOperand* object = UseRegisterAtStart(instr->elements());
LOperand* val = UseTempRegister(instr->value());
LOperand* key = UseRegisterOrConstantAtStart(instr->key());
result = new(zone()) LStoreKeyed(object, key, val);
} else {
val = UseRegisterAtStart(instr->value());
key = UseRegisterOrConstantAtStart(instr->key());
elements = UseRegisterAtStart(instr->elements());
ASSERT(instr->value()->representation().IsTagged());
bool needs_write_barrier = instr->NeedsWriteBarrier();
LOperand* obj = UseRegister(instr->elements());
LOperand* val = needs_write_barrier
? UseTempRegister(instr->value())
: UseRegisterAtStart(instr->value());
LOperand* key = needs_write_barrier
? UseTempRegister(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
result = new(zone()) LStoreKeyed(obj, key, val);
}
} else {
ElementsKind elements_kind = instr->elements_kind();
ASSERT(
(instr->value()->representation().IsInteger32() &&
(elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
......@@ -2003,25 +2013,26 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
ASSERT(instr->elements()->representation().IsExternal());
if (ExternalArrayOpRequiresTemp<HStoreKeyed>(instr)) {
key = UseTempRegister(instr->key());
elements = UseRegister(instr->elements());
} else {
key = UseRegisterOrConstantAtStart(instr->key());
elements = UseRegisterAtStart(instr->elements());
}
LOperand* external_pointer = UseRegister(instr->elements());
// Determine if we need a byte register in this case for the value.
bool val_is_fixed_register =
elements_kind == EXTERNAL_BYTE_ELEMENTS ||
elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
elements_kind == EXTERNAL_PIXEL_ELEMENTS;
val = val_is_fixed_register
LOperand* val = val_is_fixed_register
? UseFixed(instr->value(), eax)
: UseRegister(instr->value());
bool clobbers_key = ExternalArrayOpRequiresTemp(
instr->key()->representation(), elements_kind);
LOperand* key = clobbers_key
? UseTempRegister(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
result = new(zone()) LStoreKeyed(external_pointer,
key,
val);
}
LStoreKeyed* result = new(zone()) LStoreKeyed(elements, key, val);
ASSERT(result != NULL);
return result;
}
......
......@@ -1408,16 +1408,13 @@ class LLoadKeyed: public LTemplateInstruction<1, 2, 0> {
};
template <class T>
inline static bool ExternalArrayOpRequiresTemp(T* value) {
CHECK(value->IsLoadKeyed() || value->IsStoreKeyed());
Representation key_representation = value->key()->representation();
ElementsKind elements_kind = value->elements_kind();
inline static bool ExternalArrayOpRequiresTemp(
Representation key_representation,
ElementsKind elements_kind) {
// Operations that require the key to be divided by two to be converted into
// an index cannot fold the scale operation into a load and need an extra
// temp register to do the work.
return !value->IsConstant() && key_representation.IsTagged() &&
return key_representation.IsTagged() &&
(elements_kind == EXTERNAL_BYTE_ELEMENTS ||
elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
elements_kind == EXTERNAL_PIXEL_ELEMENTS);
......
......@@ -2624,30 +2624,24 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
}
template <class T>
inline void LCodeGen::PrepareKeyForKeyedOp(T* hydrogen_instr, LOperand* key) {
if (ArrayOpClobbersKey<T>(hydrogen_instr)) {
void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
LOperand* key = instr->key();
if (!key->IsConstantOperand()) {
Register key_reg = ToRegister(key);
// Even though the HLoad/StoreKeyed (in this case) instructions force
// the input representation for the key to be an integer, the input
// gets replaced during bound check elimination with the index argument
// to the bounds check, which can be tagged, so that case must be
// handled here, too.
Register key_reg = ToRegister(key);
if (hydrogen_instr->key()->representation().IsTagged()) {
if (instr->hydrogen()->key()->representation().IsTagged()) {
__ SmiToInteger64(key_reg, key_reg);
} else if (hydrogen_instr->IsDehoisted()) {
} else if (instr->hydrogen()->IsDehoisted()) {
// Sign extend key because it could be a 32 bit negative value
// and the dehoisted address computation happens in 64 bits
__ movsxlq(key_reg, key_reg);
}
}
}
void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
LOperand* key = instr->key();
PrepareKeyForKeyedOp(instr->hydrogen(), key);
Operand operand(BuildFastArrayOperand(
instr->elements(),
key,
......@@ -2707,7 +2701,21 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
XMMRegister result(ToDoubleRegister(instr->result()));
LOperand* key = instr->key();
PrepareKeyForKeyedOp<HLoadKeyed>(instr->hydrogen(), key);
if (!key->IsConstantOperand()) {
Register key_reg = ToRegister(key);
// Even though the HLoad/StoreKeyed instructions force the input
// representation for the key to be an integer, the input gets replaced
// during bound check elimination with the index argument to the bounds
// check, which can be tagged, so that case must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) {
__ SmiToInteger64(key_reg, key_reg);
} else if (instr->hydrogen()->IsDehoisted()) {
// Sign extend key because it could be a 32 bit negative value
// and the dehoisted address computation happens in 64 bits
__ movsxlq(key_reg, key_reg);
}
}
if (instr->hydrogen()->RequiresHoleCheck()) {
int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag +
sizeof(kHoleNanLower32);
......@@ -2734,7 +2742,21 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) {
Register result = ToRegister(instr->result());
LOperand* key = instr->key();
PrepareKeyForKeyedOp<HLoadKeyed>(instr->hydrogen(), key);
if (!key->IsConstantOperand()) {
Register key_reg = ToRegister(key);
// Even though the HLoad/StoreKeyedFastElement instructions force
// the input representation for the key to be an integer, the input
// gets replaced during bound check elimination with the index
// argument to the bounds check, which can be tagged, so that
// case must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) {
__ SmiToInteger64(key_reg, key_reg);
} else if (instr->hydrogen()->IsDehoisted()) {
// Sign extend key because it could be a 32 bit negative value
// and the dehoisted address computation happens in 64 bits
__ movsxlq(key_reg, key_reg);
}
}
// Load the result.
__ movq(result,
......@@ -3729,7 +3751,21 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
LOperand* key = instr->key();
PrepareKeyForKeyedOp<HStoreKeyed>(instr->hydrogen(), key);
if (!key->IsConstantOperand()) {
Register key_reg = ToRegister(key);
// Even though the HLoad/StoreKeyedFastElement instructions force
// the input representation for the key to be an integer, the input
// gets replaced during bound check elimination with the index
// argument to the bounds check, which can be tagged, so that case
// must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) {
__ SmiToInteger64(key_reg, key_reg);
} else if (instr->hydrogen()->IsDehoisted()) {
// Sign extend key because it could be a 32 bit negative value
// and the dehoisted address computation happens in 64 bits
__ movsxlq(key_reg, key_reg);
}
}
Operand operand(BuildFastArrayOperand(
instr->elements(),
key,
......@@ -3779,7 +3815,22 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
XMMRegister value = ToDoubleRegister(instr->value());
LOperand* key = instr->key();
PrepareKeyForKeyedOp<HStoreKeyed>(instr->hydrogen(), key);
if (!key->IsConstantOperand()) {
Register key_reg = ToRegister(key);
// Even though the HLoad/StoreKeyedFastElement instructions force
// the input representation for the key to be an integer, the
// input gets replaced during bound check elimination with the index
// argument to the bounds check, which can be tagged, so that case
// must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) {
__ SmiToInteger64(key_reg, key_reg);
} else if (instr->hydrogen()->IsDehoisted()) {
// Sign extend key because it could be a 32 bit negative value
// and the dehoisted address computation happens in 64 bits
__ movsxlq(key_reg, key_reg);
}
}
if (instr->NeedsCanonicalization()) {
Label have_value;
......@@ -3808,7 +3859,21 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) {
Register value = ToRegister(instr->value());
Register elements = ToRegister(instr->elements());
LOperand* key = instr->key();
PrepareKeyForKeyedOp<HStoreKeyed>(instr->hydrogen(), key);
if (!key->IsConstantOperand()) {
Register key_reg = ToRegister(key);
// Even though the HLoad/StoreKeyedFastElement instructions force
// the input representation for the key to be an integer, the
// input gets replaced during bound check elimination with the index
// argument to the bounds check, which can be tagged, so that case
// must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) {
__ SmiToInteger64(key_reg, key_reg);
} else if (instr->hydrogen()->IsDehoisted()) {
// Sign extend key because it could be a 32 bit negative value
// and the dehoisted address computation happens in 64 bits
__ movsxlq(key_reg, key_reg);
}
}
Operand operand =
BuildFastArrayOperand(instr->elements(),
......
......@@ -341,8 +341,6 @@ class LCodeGen BASE_EMBEDDED {
void DoStoreKeyedExternalArray(LStoreKeyed* instr);
void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
void DoStoreKeyedFixedArray(LStoreKeyed* instr);
template <class T>
void PrepareKeyForKeyedOp(T* hydrogen_instr, LOperand* key);
Zone* zone_;
LPlatformChunk* const chunk_;
......
......@@ -1844,15 +1844,16 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
ASSERT(instr->key()->representation().IsInteger32() ||
instr->key()->representation().IsTagged());
ElementsKind elements_kind = instr->elements_kind();
bool clobbers_key = ArrayOpClobbersKey<HLoadKeyed>(instr);
bool clobbers_key = instr->key()->representation().IsTagged();
LOperand* key = clobbers_key
? UseTempRegister(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
LOperand* elements = UseRegisterAtStart(instr->elements());
LLoadKeyed* result = new(zone()) LLoadKeyed(elements, key);
LLoadKeyed* result = NULL;
#ifdef DEBUG
if (instr->is_external()) {
if (!instr->is_external()) {
LOperand* obj = UseRegisterAtStart(instr->elements());
result = new(zone()) LLoadKeyed(obj, key);
} else {
ASSERT(
(instr->representation().IsInteger32() &&
(elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
......@@ -1860,8 +1861,9 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
(instr->representation().IsDouble() &&
((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
LOperand* external_pointer = UseRegister(instr->elements());
result = new(zone()) LLoadKeyed(external_pointer, key);
}
#endif
DefineAsRegister(result);
bool can_deoptimize = instr->RequiresHoleCheck() ||
......@@ -1882,21 +1884,33 @@ LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
ElementsKind elements_kind = instr->elements_kind();
bool needs_write_barrier = instr->NeedsWriteBarrier();
bool clobbers_key = ArrayOpClobbersKey<HStoreKeyed>(instr);
bool clobbers_key = instr->key()->representation().IsTagged();
LOperand* key = (clobbers_key || needs_write_barrier)
? UseTempRegister(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
LOperand* val = needs_write_barrier
bool val_is_temp_register =
elements_kind == EXTERNAL_PIXEL_ELEMENTS ||
elements_kind == EXTERNAL_FLOAT_ELEMENTS;
LOperand* val = (needs_write_barrier || val_is_temp_register)
? UseTempRegister(instr->value())
: UseRegisterAtStart(instr->value());
LOperand* elements = UseRegisterAtStart(instr->elements());
LStoreKeyed* result = NULL;
#ifdef DEBUG
if (!instr->is_external()) {
ASSERT(instr->elements()->representation().IsTagged());
LOperand* object = NULL;
if (instr->value()->representation().IsDouble()) {
object = UseRegisterAtStart(instr->elements());
} else {
ASSERT(instr->value()->representation().IsTagged());
object = UseTempRegister(instr->elements());
}
result = new(zone()) LStoreKeyed(object, key, val);
} else {
ElementsKind elements_kind = instr->elements_kind();
ASSERT(
(instr->value()->representation().IsInteger32() &&
(elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
......@@ -1905,10 +1919,11 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
ASSERT(instr->elements()->representation().IsExternal());
LOperand* external_pointer = UseRegister(instr->elements());
result = new(zone()) LStoreKeyed(external_pointer, key, val);
}
#endif
LStoreKeyed* result = new(zone()) LStoreKeyed(elements, key, val);
ASSERT(result != NULL);
return result;
}
......
......@@ -1371,14 +1371,6 @@ class LLoadKeyed: public LTemplateInstruction<1, 2, 0> {
};
template <class T>
inline static bool ArrayOpClobbersKey(T *value) {
CHECK(value->IsLoadKeyed() || value->IsStoreKeyed());
return !value->IsConstant() && (value->key()->representation().IsTagged()
|| value->IsDehoisted());
}
class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
public:
LLoadKeyedGeneric(LOperand* obj, LOperand* key) {
......
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