Introduce Unsigned32 and RegExp types

Also, renamed Integer31 back to Smi, and Integer32 to Signed32.

R=jkummerow@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15332 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rossberg@chromium.org 2013-06-26 09:51:57 +00:00
parent bfa9fe95dc
commit e60acec321
5 changed files with 44 additions and 32 deletions

View File

@ -5015,7 +5015,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
HControlInstruction* compare;
if (stmt->switch_type() == SwitchStatement::SMI_SWITCH) {
if (!clause->compare_type()->Is(Type::Integer31())) {
if (!clause->compare_type()->Is(Type::Smi())) {
AddSoftDeoptimize();
}
@ -9453,8 +9453,8 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
break;
case Token::BIT_OR: {
HValue* operand, *shift_amount;
if (left_type->Is(Type::Integer32()) &&
right_type->Is(Type::Integer32()) &&
if (left_type->Is(Type::Signed32()) &&
right_type->Is(Type::Signed32()) &&
MatchRotateRight(left, right, &operand, &shift_amount)) {
instr = new(zone()) HRor(context, operand, shift_amount);
} else {
@ -9654,7 +9654,7 @@ Representation HOptimizedGraphBuilder::ToRepresentation(TypeInfo info) {
Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) {
if (type->Is(Type::None())) return Representation::None();
if (type->Is(Type::Integer32())) return Representation::Integer32();
if (type->Is(Type::Signed32())) return Representation::Integer32();
if (type->Is(Type::Number())) return Representation::Double();
return Representation::Tagged();
}
@ -9879,8 +9879,8 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
} else {
// TODO(verwaest): Remove once ToRepresentation properly returns Smi when
// the IC measures Smi.
if (left_type->Is(Type::Integer31())) left_rep = Representation::Smi();
if (right_type->Is(Type::Integer31())) right_rep = Representation::Smi();
if (left_type->Is(Type::Smi())) left_rep = Representation::Smi();
if (right_type->Is(Type::Smi())) right_rep = Representation::Smi();
HCompareIDAndBranch* result =
new(zone()) HCompareIDAndBranch(left, right, op);
result->set_observed_input_representation(left_rep, right_rep);

View File

@ -2437,7 +2437,7 @@ Handle<Type> UnaryOpIC::TypeInfoToType(TypeInfo type_info, Isolate* isolate) {
case UNINITIALIZED:
return handle(Type::None(), isolate);
case SMI:
return handle(Type::Integer31(), isolate);
return handle(Type::Smi(), isolate);
case NUMBER:
return handle(Type::Number(), isolate);
case GENERIC:
@ -2524,9 +2524,9 @@ Handle<Type> BinaryOpIC::TypeInfoToType(BinaryOpIC::TypeInfo binary_type,
case UNINITIALIZED:
return handle(Type::None(), isolate);
case SMI:
return handle(Type::Integer31(), isolate);
return handle(Type::Smi(), isolate);
case INT32:
return handle(Type::Integer32(), isolate);
return handle(Type::Signed32(), isolate);
case NUMBER:
return handle(Type::Number(), isolate);
case ODDBALL:
@ -2845,7 +2845,7 @@ Handle<Type> CompareIC::StateToType(
case CompareIC::UNINITIALIZED:
return handle(Type::None(), isolate);
case CompareIC::SMI:
return handle(Type::Integer31(), isolate);
return handle(Type::Smi(), isolate);
case CompareIC::NUMBER:
return handle(Type::Number(), isolate);
case CompareIC::STRING:

View File

@ -125,7 +125,7 @@ int Type::LubBitset() {
map = *this->as_class();
} else {
Handle<v8::internal::Object> value = this->as_constant();
if (value->IsSmi()) return kInteger31;
if (value->IsSmi()) return kSmi;
map = HeapObject::cast(*value)->map();
if (map->instance_type() == ODDBALL_TYPE) {
if (value->IsUndefined()) return kUndefined;
@ -175,14 +175,17 @@ int Type::LubBitset() {
case JS_ARRAY_BUFFER_TYPE:
case JS_TYPED_ARRAY_TYPE:
case JS_DATA_VIEW_TYPE:
case JS_SET_TYPE:
case JS_MAP_TYPE:
case JS_WEAK_MAP_TYPE:
case JS_REGEXP_TYPE:
if (map->is_undetectable()) return kUndetectable;
return kOtherObject;
case JS_ARRAY_TYPE:
return kArray;
case JS_FUNCTION_TYPE:
return kFunction;
case JS_REGEXP_TYPE:
return kRegExp;
case JS_PROXY_TYPE:
case JS_FUNCTION_PROXY_TYPE:
return kProxy;

View File

@ -48,8 +48,8 @@ namespace internal {
// T <= Any
//
// Oddball = Boolean \/ Null \/ Undefined
// Number = Integer32 \/ Double
// Integer31 < Integer32
// Number = Signed32 \/ Unsigned32 \/ Double
// Smi <= Signed32
// Name = String \/ Symbol
// UniqueName = InternalizedString \/ Symbol
// InternalizedString < String
@ -60,6 +60,7 @@ namespace internal {
// Receiver = Object \/ Proxy
// Array < Object
// Function < Object
// RegExp < Object
//
// Class(map) < T iff instance_type(map) < T
// Constant(x) < T iff instance_type(map(x)) < T
@ -83,6 +84,8 @@ namespace internal {
// lattice (e.g., splitting up number types further) without invalidating any
// existing assumptions or tests.
//
// Consequently, do not use pointer equality for type tests, always use Is!
//
// Internally, all 'primitive' types, and their unions, are represented as
// bitsets via smis. Class is a heap pointer to the respective map. Only
// Constant's, or unions containing Class'es or Constant's, require allocation.
@ -104,9 +107,11 @@ class Type : public Object {
static Type* Undefined() { return from_bitset(kUndefined); }
static Type* Number() { return from_bitset(kNumber); }
static Type* Integer31() { return from_bitset(kInteger31); }
static Type* Integer32() { return from_bitset(kInteger32); }
static Type* Smi() { return from_bitset(kSmi); }
static Type* Signed32() { return from_bitset(kSigned32); }
static Type* Unsigned32() { return from_bitset(kUnsigned32); }
static Type* Double() { return from_bitset(kDouble); }
static Type* NumberOrString() { return from_bitset(kNumberOrString); }
static Type* Name() { return from_bitset(kName); }
static Type* UniqueName() { return from_bitset(kUniqueName); }
@ -119,6 +124,7 @@ class Type : public Object {
static Type* Undetectable() { return from_bitset(kUndetectable); }
static Type* Array() { return from_bitset(kArray); }
static Type* Function() { return from_bitset(kFunction); }
static Type* RegExp() { return from_bitset(kRegExp); }
static Type* Proxy() { return from_bitset(kProxy); }
static Type* Class(Handle<Map> map) { return from_handle(map); }
@ -188,25 +194,28 @@ class Type : public Object {
kNull = 1 << 0,
kUndefined = 1 << 1,
kBoolean = 1 << 2,
kInteger31 = 1 << 3,
kOtherInteger = 1 << 4,
kDouble = 1 << 5,
kSymbol = 1 << 6,
kInternalizedString = 1 << 7,
kOtherString = 1 << 8,
kUndetectable = 1 << 9,
kArray = 1 << 10,
kFunction = 1 << 11,
kOtherObject = 1 << 12,
kProxy = 1 << 13,
kSmi = 1 << 3,
kOtherSigned32 = 1 << 4,
kUnsigned32 = 1 << 5,
kDouble = 1 << 6,
kSymbol = 1 << 7,
kInternalizedString = 1 << 8,
kOtherString = 1 << 9,
kUndetectable = 1 << 10,
kArray = 1 << 11,
kFunction = 1 << 12,
kRegExp = 1 << 13,
kOtherObject = 1 << 14,
kProxy = 1 << 15,
kOddball = kBoolean | kNull | kUndefined,
kInteger32 = kInteger31 | kOtherInteger,
kNumber = kInteger32 | kDouble,
kSigned32 = kSmi | kOtherSigned32,
kNumber = kSigned32 | kUnsigned32 | kDouble,
kString = kInternalizedString | kOtherString,
kUniqueName = kSymbol | kInternalizedString,
kName = kSymbol | kString,
kObject = kUndetectable | kArray | kFunction | kOtherObject,
kNumberOrString = kNumber | kString,
kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject,
kReceiver = kObject | kProxy,
kAllocated = kDouble | kName | kReceiver,
kAny = kOddball | kNumber | kAllocated,

View File

@ -107,8 +107,8 @@ class HandlifiedTypes {
Null(Type::Null(), isolate),
Undefined(Type::Undefined(), isolate),
Number(Type::Number(), isolate),
Integer31(Type::Integer31(), isolate),
Integer32(Type::Integer32(), isolate),
Integer31(Type::Smi(), isolate),
Integer32(Type::Signed32(), isolate),
Double(Type::Double(), isolate),
Name(Type::Name(), isolate),
UniqueName(Type::UniqueName(), isolate),