| Index: src/x64/lithium-x64.cc
|
| diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
|
| index 60b0a2c14a92ae3498806d1e677b412da5598072..d190ef98c3411f62c524db4fd9eb3ed5297b5b3b 100644
|
| --- a/src/x64/lithium-x64.cc
|
| +++ b/src/x64/lithium-x64.cc
|
| @@ -717,17 +717,28 @@ LInstruction* LChunkBuilder::DoShift(Token::Value op,
|
| HValue* right_value = instr->right();
|
| LOperand* right = NULL;
|
| int constant_value = 0;
|
| + bool does_deopt = false;
|
| if (right_value->IsConstant()) {
|
| HConstant* constant = HConstant::cast(right_value);
|
| right = chunk_->DefineConstantOperand(constant);
|
| constant_value = constant->Integer32Value() & 0x1f;
|
| + // Left shifts can deoptimize if we shift by > 0 and the result cannot be
|
| + // truncated to smi.
|
| + if (kSmiValueSize == 31 && instr->representation().IsSmi() &&
|
| + constant_value > 0) {
|
| + for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) {
|
| + if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) {
|
| + does_deopt = true;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| } else {
|
| right = UseFixed(right_value, rcx);
|
| }
|
|
|
| // Shift operations can only deoptimize if we do a logical shift by 0 and
|
| // the result cannot be truncated to int32.
|
| - bool does_deopt = false;
|
| if (op == Token::SHR && constant_value == 0) {
|
| if (FLAG_opt_safe_uint32_operations) {
|
| does_deopt = !instr->CheckFlag(HInstruction::kUint32);
|
| @@ -1855,7 +1866,8 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
|
| } else if (val->HasRange() && val->range()->IsInSmiRange()) {
|
| return DefineSameAsFirst(new(zone()) LSmiTag(value));
|
| } else {
|
| - LNumberTagI* result = new(zone()) LNumberTagI(value);
|
| + LOperand* temp = (kSmiValueSize == 31) ? FixedTemp(xmm1) : NULL;
|
| + LNumberTagI* result = new(zone()) LNumberTagI(value, temp);
|
| return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
|
| }
|
| } else if (to.IsSmi()) {
|
| @@ -2088,9 +2100,15 @@ LInstruction* LChunkBuilder::DoLoadExternalArrayPointer(
|
|
|
|
|
| LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
|
| - ASSERT(instr->key()->representation().IsInteger32());
|
| + ASSERT((kSmiValueSize == 32 &&
|
| + instr->key()->representation().IsInteger32()) ||
|
| + (kSmiValueSize == 31 &&
|
| + instr->key()->representation().IsSmiOrInteger32()));
|
| ElementsKind elements_kind = instr->elements_kind();
|
| - LOperand* key = UseRegisterOrConstantAtStart(instr->key());
|
| + bool clobbers_key = instr->key()->representation().IsSmi();
|
| + LOperand* key = clobbers_key
|
| + ? UseTempRegister(instr->key())
|
| + : UseRegisterOrConstantAtStart(instr->key());
|
| LLoadKeyed* result = NULL;
|
|
|
| if (!instr->is_external()) {
|
| @@ -2128,6 +2146,7 @@ LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
|
|
|
| LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
|
| ElementsKind elements_kind = instr->elements_kind();
|
| + bool clobbers_key = instr->key()->representation().IsSmi();
|
|
|
| if (!instr->is_external()) {
|
| ASSERT(instr->elements()->representation().IsTagged());
|
| @@ -2139,7 +2158,8 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
|
| if (instr->value()->representation().IsDouble()) {
|
| object = UseRegisterAtStart(instr->elements());
|
| val = UseTempRegister(instr->value());
|
| - key = UseRegisterOrConstantAtStart(instr->key());
|
| + key = clobbers_key ? UseTempRegister(instr->key())
|
| + : UseRegisterOrConstantAtStart(instr->key());
|
| } else {
|
| ASSERT(instr->value()->representation().IsSmiOrTagged());
|
| object = UseTempRegister(instr->elements());
|
| @@ -2148,7 +2168,8 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
|
| key = UseTempRegister(instr->key());
|
| } else {
|
| val = UseRegisterOrConstantAtStart(instr->value());
|
| - key = UseRegisterOrConstantAtStart(instr->key());
|
| + key = clobbers_key ? UseTempRegister(instr->key())
|
| + : UseRegisterOrConstantAtStart(instr->key());
|
| }
|
| }
|
|
|
| @@ -2168,7 +2189,8 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
|
| elements_kind == EXTERNAL_FLOAT_ELEMENTS;
|
| LOperand* val = val_is_temp_register ? UseTempRegister(instr->value())
|
| : UseRegister(instr->value());
|
| - LOperand* key = UseRegisterOrConstantAtStart(instr->key());
|
| + LOperand* key = clobbers_key ? UseTempRegister(instr->key())
|
| + : UseRegisterOrConstantAtStart(instr->key());
|
| LOperand* external_pointer = UseRegister(instr->elements());
|
| return new(zone()) LStoreKeyed(external_pointer, key, val);
|
| }
|
|
|