Index: src/compiler/code-generator.cc |
diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc |
index 97cc76289ffaf3c31f1e6e23c684fb6f1bc28e3d..c6e6ed4797f49e6906543ec9434a69ba8d5d44ef 100644 |
--- a/src/compiler/code-generator.cc |
+++ b/src/compiler/code-generator.cc |
@@ -861,14 +861,33 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation, |
Handle<Object> constant_object; |
switch (constant.type()) { |
case Constant::kInt32: |
- DCHECK(type == MachineType::Int32() || type == MachineType::Uint32() || |
- type.representation() == MachineRepresentation::kBit || |
- type.representation() == MachineRepresentation::kNone); |
- DCHECK(type.representation() != MachineRepresentation::kNone || |
- constant.ToInt32() == FrameStateDescriptor::kImpossibleValue); |
- |
+ if (type.representation() == MachineRepresentation::kTagged) { |
+ // When pointers are 4 bytes, we can use int32 constants to represent |
+ // Smis. |
+ DCHECK_EQ(4, kPointerSize); |
+ constant_object = |
+ handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate()); |
+ DCHECK(constant_object->IsSmi()); |
+ } else { |
+ DCHECK(type == MachineType::Int32() || |
+ type == MachineType::Uint32() || |
+ type.representation() == MachineRepresentation::kBit || |
+ type.representation() == MachineRepresentation::kNone); |
+ DCHECK(type.representation() != MachineRepresentation::kNone || |
+ constant.ToInt32() == FrameStateDescriptor::kImpossibleValue); |
+ |
+ constant_object = |
+ isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
+ } |
+ break; |
+ case Constant::kInt64: |
+ // When pointers are 8 bytes, we can use int64 constants to represent |
+ // Smis. |
+ DCHECK_EQ(type.representation(), MachineRepresentation::kTagged); |
+ DCHECK_EQ(8, kPointerSize); |
constant_object = |
- isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
+ handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate()); |
+ DCHECK(constant_object->IsSmi()); |
break; |
case Constant::kFloat32: |
DCHECK(type.representation() == MachineRepresentation::kFloat32 || |