From 480729ff79c3c20f65d4d38c61080eb70e7d3505 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 29 Jul 2013 17:07:28 +0000 Subject: [PATCH] Smi-support for HSar. BUG= R=mvstanton@chromium.org Review URL: https://chromiumcodereview.appspot.com/21049003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15938 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-arm.cc | 7 +++++-- src/arm/lithium-codegen-arm.cc | 3 +++ src/hydrogen-instructions.h | 4 +++- src/ia32/lithium-codegen-ia32.cc | 3 +++ src/ia32/lithium-ia32.cc | 7 +++++-- src/x64/lithium-x64.cc | 3 ++- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index b55679e..f728619 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -733,7 +733,9 @@ LInstruction* LChunkBuilder::DoShift(Token::Value op, constant_value = constant->Integer32Value() & 0x1f; // Left shifts can deoptimize if we shift by > 0 and the result cannot be // truncated to smi. - if (instr->representation().IsSmi() && constant_value > 0) { + if (instr->representation().IsSmi() && + op == Token::SHL && + constant_value > 0) { for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { does_deopt = true; @@ -752,7 +754,8 @@ LInstruction* LChunkBuilder::DoShift(Token::Value op, does_deopt = !instr->CheckFlag(HInstruction::kUint32); } else { for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { - if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { + if (!it.value()->CheckFlag(HValue::kTruncatingToInt32) && + !it.value()->CheckFlag(HValue::kTruncatingToSmi)) { does_deopt = true; break; } diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 929d04d..8cdc886 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -1725,6 +1725,9 @@ void LCodeGen::DoShiftI(LShiftI* instr) { case Token::SAR: if (shift_count != 0) { __ mov(result, Operand(left, ASR, shift_count)); + if (instr->hydrogen_value()->representation().IsSmi()) { + __ and_(result, result, Operand(~kSmiTagMask)); + } } else { __ Move(result, left); } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index e71b7cd..077d47b 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -4964,7 +4964,9 @@ class HShr: public HBitwiseBinaryOperation { virtual void UpdateRepresentation(Representation new_rep, HInferRepresentationPhase* h_infer, const char* reason) { - if (new_rep.IsSmi()) new_rep = Representation::Integer32(); + if (new_rep.IsSmi() && !right()->IsConstant()) { + new_rep = Representation::Integer32(); + } HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 3ddad06..5096ea8 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -1757,6 +1757,9 @@ void LCodeGen::DoShiftI(LShiftI* instr) { case Token::SAR: if (shift_count != 0) { __ sar(ToRegister(left), shift_count); + if (instr->hydrogen_value()->representation().IsSmi()) { + __ and_(ToRegister(left), ~kSmiTagMask); + } } break; case Token::SHR: diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 8c8103f..026c2a4 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -787,7 +787,9 @@ LInstruction* LChunkBuilder::DoShift(Token::Value op, constant_value = constant->Integer32Value() & 0x1f; // Left shifts can deoptimize if we shift by > 0 and the result cannot be // truncated to smi. - if (instr->representation().IsSmi() && constant_value > 0) { + if (instr->representation().IsSmi() && + op == Token::SHL && + constant_value > 0) { for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { does_deopt = true; @@ -806,7 +808,8 @@ LInstruction* LChunkBuilder::DoShift(Token::Value op, does_deopt = !instr->CheckFlag(HInstruction::kUint32); } else { for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { - if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { + if (!it.value()->CheckFlag(HValue::kTruncatingToInt32) && + !it.value()->CheckFlag(HValue::kTruncatingToSmi)) { does_deopt = true; break; } diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 4153417..79b575d 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -751,7 +751,8 @@ LInstruction* LChunkBuilder::DoShift(Token::Value op, does_deopt = !instr->CheckFlag(HInstruction::kUint32); } else { for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { - if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { + if (!it.value()->CheckFlag(HValue::kTruncatingToInt32) && + !it.value()->CheckFlag(HValue::kTruncatingToSmi)) { does_deopt = true; break; } -- 2.7.4