From: jkummerow@chromium.org Date: Fri, 20 Dec 2013 13:33:20 +0000 (+0000) Subject: Delete unused TypeInfo class X-Git-Tag: upstream/4.7.83~11315 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=315b0c6a30b6943b4409f6a4e5683f06d4db6002;p=platform%2Fupstream%2Fv8.git Delete unused TypeInfo class R=rossberg@chromium.org Review URL: https://codereview.chromium.org/105313008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18389 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/api.cc b/src/api.cc index 9c22cebe9..1f5b16557 100644 --- a/src/api.cc +++ b/src/api.cc @@ -2487,13 +2487,7 @@ bool Value::IsInt32() const { i::Handle obj = Utils::OpenHandle(this); if (obj->IsSmi()) return true; if (obj->IsNumber()) { - double value = obj->Number(); - static const i::DoubleRepresentation minus_zero(-0.0); - i::DoubleRepresentation rep(value); - if (rep.bits == minus_zero.bits) { - return false; - } - return i::FastI2D(i::FastD2I(value)) == value; + return i::IsInt32Double(obj->Number()); } return false; } @@ -2504,12 +2498,10 @@ bool Value::IsUint32() const { if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; if (obj->IsNumber()) { double value = obj->Number(); - static const i::DoubleRepresentation minus_zero(-0.0); - i::DoubleRepresentation rep(value); - if (rep.bits == minus_zero.bits) { - return false; - } - return i::FastUI2D(i::FastD2UI(value)) == value; + return !i::IsMinusZero(value) && + value >= 0 && + value <= i::kMaxUInt32 && + value == i::FastUI2D(i::FastD2UI(value)); } return false; } diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 5f6076b41..1e36b3578 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -815,11 +815,11 @@ void MacroAssembler::Vmov(const DwVfpRegister dst, const Register scratch) { static const DoubleRepresentation minus_zero(-0.0); static const DoubleRepresentation zero(0.0); - DoubleRepresentation value(imm); + DoubleRepresentation value_rep(imm); // Handle special values first. - if (value.bits == zero.bits) { + if (value_rep == zero) { vmov(dst, kDoubleRegZero); - } else if (value.bits == minus_zero.bits) { + } else if (value_rep == minus_zero) { vneg(dst, kDoubleRegZero); } else { vmov(dst, imm, scratch); diff --git a/src/ast.h b/src/ast.h index cf3ef92cc..f8de9be0e 100644 --- a/src/ast.h +++ b/src/ast.h @@ -39,7 +39,6 @@ #include "small-pointer-list.h" #include "smart-pointers.h" #include "token.h" -#include "type-info.h" // TODO(rossberg): this should eventually be removed #include "types.h" #include "utils.h" #include "variables.h" diff --git a/src/codegen.h b/src/codegen.h index b271d21f6..d160f1348 100644 --- a/src/codegen.h +++ b/src/codegen.h @@ -30,7 +30,6 @@ #include "code-stubs.h" #include "runtime.h" -#include "type-info.h" // Include the declaration of the architecture defined class CodeGenerator. // The contract to the shared code is that the the CodeGenerator is a subclass diff --git a/src/conversions.h b/src/conversions.h index 7aa2d3fb3..f850f581f 100644 --- a/src/conversions.h +++ b/src/conversions.h @@ -72,7 +72,7 @@ inline int FastD2IChecked(double x) { // The result is unspecified if x is infinite or NaN, or if the rounded // integer value is outside the range of type int. inline int FastD2I(double x) { - return static_cast(x); + return static_cast(x); } inline unsigned int FastD2UI(double x); diff --git a/src/heap.cc b/src/heap.cc index c42c445af..7477450f8 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -49,6 +49,7 @@ #include "snapshot.h" #include "store-buffer.h" #include "utils/random-number-generator.h" +#include "v8conversions.h" #include "v8threads.h" #include "v8utils.h" #include "vm-state-inl.h" @@ -3689,6 +3690,7 @@ Heap::RootListIndex Heap::RootIndexForExternalArrayType( } } + Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( ElementsKind elementsKind) { switch (elementsKind) { @@ -3723,16 +3725,11 @@ ExternalArray* Heap::EmptyExternalArrayForMap(Map* map) { } - - MaybeObject* Heap::NumberFromDouble(double value, PretenureFlag pretenure) { // We need to distinguish the minus zero value and this cannot be // done after conversion to int. Doing this by comparing bit // patterns is faster than using fpclassify() et al. - static const DoubleRepresentation minus_zero(-0.0); - - DoubleRepresentation rep(value); - if (rep.bits == minus_zero.bits) { + if (IsMinusZero(value)) { return AllocateHeapNumber(-0.0, pretenure); } diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 46893e881..6e1739716 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -1377,7 +1377,7 @@ HInstruction* HForceRepresentation::New(Zone* zone, HValue* context, HConstant* c = HConstant::cast(value); if (c->HasNumberValue()) { double double_res = c->DoubleValue(); - if (TypeInfo::IsInt32Double(double_res)) { + if (IsInt32Double(double_res)) { return HConstant::New(zone, context, static_cast(double_res), required_representation); @@ -3794,7 +3794,7 @@ HInstruction* HInstr::New( \ HConstant* c_right = HConstant::cast(right); \ if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \ - if (TypeInfo::IsInt32Double(double_res)) { \ + if (IsInt32Double(double_res)) { \ return H_CONSTANT_INT(double_res); \ } \ return H_CONSTANT_DOUBLE(double_res); \ @@ -3990,7 +3990,7 @@ HInstruction* HDiv::New( if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { if (c_right->DoubleValue() != 0) { double double_res = c_left->DoubleValue() / c_right->DoubleValue(); - if (TypeInfo::IsInt32Double(double_res)) { + if (IsInt32Double(double_res)) { return H_CONSTANT_INT(double_res); } return H_CONSTANT_DOUBLE(double_res); diff --git a/src/ic.cc b/src/ic.cc index 25f875a83..dd7df9874 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -35,6 +35,7 @@ #include "ic-inl.h" #include "runtime.h" #include "stub-cache.h" +#include "v8conversions.h" namespace v8 { namespace internal { @@ -2674,7 +2675,7 @@ BinaryOpIC::State::Kind BinaryOpIC::State::UpdateKind(Handle object, new_kind = SMI; } else if (object->IsHeapNumber()) { double value = Handle::cast(object)->value(); - new_kind = TypeInfo::IsInt32Double(value) ? INT32 : NUMBER; + new_kind = IsInt32Double(value) ? INT32 : NUMBER; } else if (object->IsString() && op() == Token::ADD) { new_kind = STRING; } diff --git a/src/ic.h b/src/ic.h index fa7ed6dbc..d1d2b6139 100644 --- a/src/ic.h +++ b/src/ic.h @@ -29,12 +29,14 @@ #define V8_IC_H_ #include "macro-assembler.h" -#include "type-info.h" namespace v8 { namespace internal { +const int kMaxKeyedPolymorphism = 4; + + // IC_UTIL_LIST defines all utility functions called from generated // inline caching code. The argument for the macro, ICU, is the function name. #define IC_UTIL_LIST(ICU) \ @@ -296,6 +298,12 @@ class IC_Utility { }; +enum StringStubFeedback { + DEFAULT_STRING_STUB = 0, + STRING_INDEX_OUT_OF_BOUNDS = 1 +}; + + class CallICBase: public IC { public: // ExtraICState bits diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc index bc981cbaa..4e3ab3291 100644 --- a/src/mips/macro-assembler-mips.cc +++ b/src/mips/macro-assembler-mips.cc @@ -1228,12 +1228,12 @@ void MacroAssembler::BranchF(Label* target, void MacroAssembler::Move(FPURegister dst, double imm) { static const DoubleRepresentation minus_zero(-0.0); static const DoubleRepresentation zero(0.0); - DoubleRepresentation value(imm); + DoubleRepresentation value_rep(imm); // Handle special values first. bool force_load = dst.is(kDoubleRegZero); - if (value.bits == zero.bits && !force_load) { + if (value_rep == zero && !force_load) { mov_d(dst, kDoubleRegZero); - } else if (value.bits == minus_zero.bits && !force_load) { + } else if (value_rep == minus_zero && !force_load) { neg_d(dst, kDoubleRegZero); } else { uint32_t lo, hi; diff --git a/src/property-details.h b/src/property-details.h index 617e9b2af..753eeeec5 100644 --- a/src/property-details.h +++ b/src/property-details.h @@ -113,8 +113,6 @@ class Representation { static Representation FromKind(Kind kind) { return Representation(kind); } - // TODO(rossberg): this should die eventually. - static Representation FromType(TypeInfo info); static Representation FromType(Handle type); bool Equals(const Representation& other) const { diff --git a/src/stub-cache.cc b/src/stub-cache.cc index 6e68314be..dc2c3406a 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -35,6 +35,7 @@ #include "gdb-jit.h" #include "ic-inl.h" #include "stub-cache.h" +#include "type-info.h" #include "vm-state-inl.h" namespace v8 { diff --git a/src/type-info.cc b/src/type-info.cc index 73d8c756a..3cdcf8e43 100644 --- a/src/type-info.cc +++ b/src/type-info.cc @@ -42,20 +42,6 @@ namespace v8 { namespace internal { -TypeInfo TypeInfo::FromValue(Handle value) { - if (value->IsSmi()) { - return TypeInfo::Smi(); - } else if (value->IsHeapNumber()) { - return TypeInfo::IsInt32Double(HeapNumber::cast(*value)->value()) - ? TypeInfo::Integer32() - : TypeInfo::Double(); - } else if (value->IsString()) { - return TypeInfo::String(); - } - return TypeInfo::Unknown(); -} - - TypeFeedbackOracle::TypeFeedbackOracle(Handle code, Handle native_context, Isolate* isolate, @@ -586,14 +572,4 @@ void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { } -Representation Representation::FromType(TypeInfo info) { - if (info.IsUninitialized()) return Representation::None(); - if (info.IsSmi()) return Representation::Smi(); - if (info.IsInteger32()) return Representation::Integer32(); - if (info.IsDouble()) return Representation::Double(); - if (info.IsNumber()) return Representation::Double(); - return Representation::Tagged(); -} - - } } // namespace v8::internal diff --git a/src/type-info.h b/src/type-info.h index 8bad5c057..635be1a80 100644 --- a/src/type-info.h +++ b/src/type-info.h @@ -36,189 +36,7 @@ namespace v8 { namespace internal { -const int kMaxKeyedPolymorphism = 4; - -// Unknown -// | \____________ -// | | -// Primitive Non-primitive -// | \_______ | -// | | | -// Number String | -// / \ | | -// Double Integer32 | / -// | | / / -// | Smi / / -// | | / __/ -// Uninitialized. - -class TypeInfo { - public: - TypeInfo() : type_(kUninitialized) { } - - static TypeInfo Unknown() { return TypeInfo(kUnknown); } - // We know it's a primitive type. - static TypeInfo Primitive() { return TypeInfo(kPrimitive); } - // We know it's a number of some sort. - static TypeInfo Number() { return TypeInfo(kNumber); } - // We know it's a signed 32 bit integer. - static TypeInfo Integer32() { return TypeInfo(kInteger32); } - // We know it's a Smi. - static TypeInfo Smi() { return TypeInfo(kSmi); } - // We know it's a heap number. - static TypeInfo Double() { return TypeInfo(kDouble); } - // We know it's a string. - static TypeInfo String() { return TypeInfo(kString); } - // We know it's an internalized string. - static TypeInfo InternalizedString() { return TypeInfo(kInternalizedString); } - // We know it's a non-primitive (object) type. - static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } - // We haven't started collecting info yet. - static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } - - int ToInt() { - return type_; - } - - static TypeInfo FromInt(int bit_representation) { - Type t = static_cast(bit_representation); - ASSERT(t == kUnknown || - t == kPrimitive || - t == kNumber || - t == kInteger32 || - t == kSmi || - t == kDouble || - t == kString || - t == kNonPrimitive); - return TypeInfo(t); - } - - // Return the weakest (least precise) common type. - static TypeInfo Combine(TypeInfo a, TypeInfo b) { - return TypeInfo(static_cast(a.type_ & b.type_)); - } - - - // Integer32 is an integer that can be represented as a signed - // 32-bit integer. It has to be - // in the range [-2^31, 2^31 - 1]. We also have to check for negative 0 - // as it is not an Integer32. - static inline bool IsInt32Double(double value) { - const DoubleRepresentation minus_zero(-0.0); - DoubleRepresentation rep(value); - if (rep.bits == minus_zero.bits) return false; - if (value >= kMinInt && value <= kMaxInt && - value == static_cast(value)) { - return true; - } - return false; - } - - static TypeInfo FromValue(Handle value); - - bool Equals(const TypeInfo& other) { - return type_ == other.type_; - } - - inline bool IsUnknown() { - ASSERT(type_ != kUninitialized); - return type_ == kUnknown; - } - - inline bool IsPrimitive() { - ASSERT(type_ != kUninitialized); - return ((type_ & kPrimitive) == kPrimitive); - } - - inline bool IsNumber() { - ASSERT(type_ != kUninitialized); - return ((type_ & kNumber) == kNumber); - } - - inline bool IsSmi() { - ASSERT(type_ != kUninitialized); - return ((type_ & kSmi) == kSmi); - } - - inline bool IsInternalizedString() { - ASSERT(type_ != kUninitialized); - return ((type_ & kInternalizedString) == kInternalizedString); - } - - inline bool IsNonInternalizedString() { - ASSERT(type_ != kUninitialized); - return ((type_ & kInternalizedString) == kString); - } - - inline bool IsInteger32() { - ASSERT(type_ != kUninitialized); - return ((type_ & kInteger32) == kInteger32); - } - - inline bool IsDouble() { - ASSERT(type_ != kUninitialized); - return ((type_ & kDouble) == kDouble); - } - - inline bool IsString() { - ASSERT(type_ != kUninitialized); - return ((type_ & kString) == kString); - } - - inline bool IsNonPrimitive() { - ASSERT(type_ != kUninitialized); - return ((type_ & kNonPrimitive) == kNonPrimitive); - } - - inline bool IsUninitialized() { - return type_ == kUninitialized; - } - - const char* ToString() { - switch (type_) { - case kUnknown: return "Unknown"; - case kPrimitive: return "Primitive"; - case kNumber: return "Number"; - case kInteger32: return "Integer32"; - case kSmi: return "Smi"; - case kInternalizedString: return "InternalizedString"; - case kDouble: return "Double"; - case kString: return "String"; - case kNonPrimitive: return "Object"; - case kUninitialized: return "Uninitialized"; - } - UNREACHABLE(); - return "Unreachable code"; - } - - private: - enum Type { - kUnknown = 0, // 0000000 - kPrimitive = 0x10, // 0010000 - kNumber = 0x11, // 0010001 - kInteger32 = 0x13, // 0010011 - kSmi = 0x17, // 0010111 - kDouble = 0x19, // 0011001 - kString = 0x30, // 0110000 - kInternalizedString = 0x32, // 0110010 - kNonPrimitive = 0x40, // 1000000 - kUninitialized = 0x7f // 1111111 - }; - - explicit inline TypeInfo(Type t) : type_(t) { } - - Type type_; -}; - - -enum StringStubFeedback { - DEFAULT_STRING_STUB = 0, - STRING_INDEX_OUT_OF_BOUNDS = 1 -}; - - // Forward declarations. -class CompilationInfo; class ICStub; class SmallMapList; diff --git a/src/v8conversions.h b/src/v8conversions.h index 68107de97..f2568c066 100644 --- a/src/v8conversions.h +++ b/src/v8conversions.h @@ -33,6 +33,24 @@ namespace v8 { namespace internal { + +static inline bool IsMinusZero(double value) { + static const DoubleRepresentation minus_zero(-0.0); + return DoubleRepresentation(value) == minus_zero; +} + + +// Integer32 is an integer that can be represented as a signed 32-bit +// integer. It has to be in the range [-2^31, 2^31 - 1]. +// We also have to check for negative 0 as it is not an Integer32. +static inline bool IsInt32Double(double value) { + return !IsMinusZero(value) && + value >= kMinInt && + value <= kMaxInt && + value == FastI2D(FastD2I(value)); +} + + // Convert from Number object to C integer. inline int32_t NumberToInt32(Object* number) { if (number->IsSmi()) return Smi::cast(number)->value(); diff --git a/src/v8globals.h b/src/v8globals.h index 4910cb735..a9980e5b3 100644 --- a/src/v8globals.h +++ b/src/v8globals.h @@ -322,6 +322,9 @@ union DoubleRepresentation { double value; int64_t bits; DoubleRepresentation(double x) { value = x; } + bool operator==(const DoubleRepresentation& other) const { + return bits == other.bits; + } }; diff --git a/src/x64/code-stubs-x64.h b/src/x64/code-stubs-x64.h index 3c5666e50..6586a275d 100644 --- a/src/x64/code-stubs-x64.h +++ b/src/x64/code-stubs-x64.h @@ -29,7 +29,6 @@ #define V8_X64_CODE_STUBS_X64_H_ #include "ic-inl.h" -#include "type-info.h" namespace v8 { namespace internal {