Commit b2ca7e0b authored by haitao.feng@intel.com's avatar haitao.feng@intel.com

Introduce SmiValuesAre31Bits and SmiValuesAre32Bits global predicate functions

R=danno@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16365 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6be4e945
...@@ -5383,6 +5383,8 @@ template <> struct SmiTagging<8> { ...@@ -5383,6 +5383,8 @@ template <> struct SmiTagging<8> {
typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
V8_INLINE(static bool SmiValuesAre31Bits()) { return kSmiValueSize == 31; }
V8_INLINE(static bool SmiValuesAre32Bits()) { return kSmiValueSize == 32; }
/** /**
* This class exports constants and functionality from within v8 that * This class exports constants and functionality from within v8 that
......
...@@ -2496,7 +2496,7 @@ static void PrepareConstant(Handle<Object> object) { ...@@ -2496,7 +2496,7 @@ static void PrepareConstant(Handle<Object> object) {
void HConstant::Initialize(Representation r) { void HConstant::Initialize(Representation r) {
if (r.IsNone()) { if (r.IsNone()) {
if (has_smi_value_ && kSmiValueSize == 31) { if (has_smi_value_ && SmiValuesAre31Bits()) {
r = Representation::Smi(); r = Representation::Smi();
} else if (has_int32_value_) { } else if (has_int32_value_) {
r = Representation::Integer32(); r = Representation::Integer32();
......
...@@ -3335,7 +3335,7 @@ class HConstant V8_FINAL : public HTemplateInstruction<0> { ...@@ -3335,7 +3335,7 @@ class HConstant V8_FINAL : public HTemplateInstruction<0> {
} }
virtual Representation KnownOptimalRepresentation() V8_OVERRIDE { virtual Representation KnownOptimalRepresentation() V8_OVERRIDE {
if (HasSmiValue() && kSmiValueSize == 31) return Representation::Smi(); if (HasSmiValue() && SmiValuesAre31Bits()) return Representation::Smi();
if (HasInteger32Value()) return Representation::Integer32(); if (HasInteger32Value()) return Representation::Integer32();
if (HasNumberValue()) return Representation::Double(); if (HasNumberValue()) return Representation::Double();
if (HasExternalReferenceValue()) return Representation::External(); if (HasExternalReferenceValue()) return Representation::External();
...@@ -5841,7 +5841,7 @@ class ArrayInstructionInterface { ...@@ -5841,7 +5841,7 @@ class ArrayInstructionInterface {
virtual ~ArrayInstructionInterface() { }; virtual ~ArrayInstructionInterface() { };
static Representation KeyedAccessIndexRequirement(Representation r) { static Representation KeyedAccessIndexRequirement(Representation r) {
return r.IsInteger32() || kSmiValueSize != 31 return r.IsInteger32() || SmiValuesAre32Bits()
? Representation::Integer32() : Representation::Smi(); ? Representation::Integer32() : Representation::Smi();
} }
}; };
......
...@@ -2581,7 +2581,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value, ...@@ -2581,7 +2581,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value,
v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(value); v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(value);
if (type.IsSmi()) return BinaryOpIC::SMI; if (type.IsSmi()) return BinaryOpIC::SMI;
if (type.IsInteger32()) { if (type.IsInteger32()) {
if (kSmiValueSize == 32) return BinaryOpIC::SMI; if (SmiValuesAre32Bits()) return BinaryOpIC::SMI;
return BinaryOpIC::INT32; return BinaryOpIC::INT32;
} }
if (type.IsNumber()) return BinaryOpIC::NUMBER; if (type.IsNumber()) return BinaryOpIC::NUMBER;
...@@ -2593,7 +2593,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value, ...@@ -2593,7 +2593,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value,
op == Token::SAR || op == Token::SAR ||
op == Token::SHL || op == Token::SHL ||
op == Token::SHR) { op == Token::SHR) {
if (kSmiValueSize == 32) return BinaryOpIC::SMI; if (SmiValuesAre32Bits()) return BinaryOpIC::SMI;
return BinaryOpIC::INT32; return BinaryOpIC::INT32;
} }
return BinaryOpIC::ODDBALL; return BinaryOpIC::ODDBALL;
...@@ -2671,7 +2671,7 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) { ...@@ -2671,7 +2671,7 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
if (op == Token::DIV || if (op == Token::DIV ||
op == Token::MUL || op == Token::MUL ||
op == Token::SHR || op == Token::SHR ||
kSmiValueSize == 32) { SmiValuesAre32Bits()) {
// Arithmetic on two Smi inputs has yielded a heap number. // Arithmetic on two Smi inputs has yielded a heap number.
// That is the only way to get here from the Smi stub. // That is the only way to get here from the Smi stub.
// With 32-bit Smis, all overflows give heap numbers, but with // With 32-bit Smis, all overflows give heap numbers, but with
......
...@@ -966,7 +966,7 @@ bool MacroAssembler::IsUnsafeInt(const int x) { ...@@ -966,7 +966,7 @@ bool MacroAssembler::IsUnsafeInt(const int x) {
void MacroAssembler::SafeMove(Register dst, Smi* src) { void MacroAssembler::SafeMove(Register dst, Smi* src) {
ASSERT(!dst.is(kScratchRegister)); ASSERT(!dst.is(kScratchRegister));
ASSERT(kSmiValueSize == 32); // JIT cookie can be converted to Smi. ASSERT(SmiValuesAre32Bits()); // JIT cookie can be converted to Smi.
if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { if (IsUnsafeInt(src->value()) && jit_cookie() != 0) {
Move(dst, Smi::FromInt(src->value() ^ jit_cookie())); Move(dst, Smi::FromInt(src->value() ^ jit_cookie()));
Move(kScratchRegister, Smi::FromInt(jit_cookie())); Move(kScratchRegister, Smi::FromInt(jit_cookie()));
...@@ -978,7 +978,7 @@ void MacroAssembler::SafeMove(Register dst, Smi* src) { ...@@ -978,7 +978,7 @@ void MacroAssembler::SafeMove(Register dst, Smi* src) {
void MacroAssembler::SafePush(Smi* src) { void MacroAssembler::SafePush(Smi* src) {
ASSERT(kSmiValueSize == 32); // JIT cookie can be converted to Smi. ASSERT(SmiValuesAre32Bits()); // JIT cookie can be converted to Smi.
if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { if (IsUnsafeInt(src->value()) && jit_cookie() != 0) {
Push(Smi::FromInt(src->value() ^ jit_cookie())); Push(Smi::FromInt(src->value() ^ jit_cookie()));
Move(kScratchRegister, Smi::FromInt(jit_cookie())); Move(kScratchRegister, Smi::FromInt(jit_cookie()));
......
...@@ -1358,7 +1358,7 @@ THREADED_TEST(BigSmiInteger) { ...@@ -1358,7 +1358,7 @@ THREADED_TEST(BigSmiInteger) {
int32_t value = i::Smi::kMaxValue; int32_t value = i::Smi::kMaxValue;
// We cannot add one to a Smi::kMaxValue without wrapping. // We cannot add one to a Smi::kMaxValue without wrapping.
if (i::kSmiValueSize < 32) { if (i::SmiValuesAre31Bits()) {
CHECK(i::Smi::IsValid(value)); CHECK(i::Smi::IsValid(value));
CHECK(!i::Smi::IsValid(value + 1)); CHECK(!i::Smi::IsValid(value + 1));
...@@ -1377,7 +1377,7 @@ THREADED_TEST(BigInteger) { ...@@ -1377,7 +1377,7 @@ THREADED_TEST(BigInteger) {
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
// We cannot add one to a Smi::kMaxValue without wrapping. // We cannot add one to a Smi::kMaxValue without wrapping.
if (i::kSmiValueSize < 32) { if (i::SmiValuesAre31Bits()) {
// The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1.
// The code will not be run in that case, due to the "if" guard. // The code will not be run in that case, due to the "if" guard.
int32_t value = int32_t value =
......
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