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
parent be32761a
......@@ -2487,13 +2487,7 @@ bool Value::IsInt32() const {
i::Handle<i::Object> 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;
}
......
......@@ -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);
......
......@@ -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"
......
......@@ -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
......
......@@ -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<int>(x);
return static_cast<int32_t>(x);
}
inline unsigned int FastD2UI(double x);
......
......@@ -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);
}
......
......@@ -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<int32_t>(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);
......
......@@ -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> object,
new_kind = SMI;
} else if (object->IsHeapNumber()) {
double value = Handle<HeapNumber>::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;
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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> type);
bool Equals(const Representation& other) const {
......
......@@ -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 {
......
......@@ -42,20 +42,6 @@ namespace v8 {
namespace internal {
TypeInfo TypeInfo::FromValue(Handle<Object> 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> code,
Handle<Context> 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
......@@ -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<Type>(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<Type>(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<int32_t>(value)) {
return true;
}
return false;
}
static TypeInfo FromValue(Handle<Object> 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;
......
......@@ -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();
......
......@@ -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;
}
};
......
......@@ -29,7 +29,6 @@
#define V8_X64_CODE_STUBS_X64_H_
#include "ic-inl.h"
#include "type-info.h"
namespace v8 {
namespace internal {
......
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