Commit e60acec3 authored by rossberg@chromium.org's avatar rossberg@chromium.org

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
parent bfa9fe95
...@@ -5015,7 +5015,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { ...@@ -5015,7 +5015,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
HControlInstruction* compare; HControlInstruction* compare;
if (stmt->switch_type() == SwitchStatement::SMI_SWITCH) { if (stmt->switch_type() == SwitchStatement::SMI_SWITCH) {
if (!clause->compare_type()->Is(Type::Integer31())) { if (!clause->compare_type()->Is(Type::Smi())) {
AddSoftDeoptimize(); AddSoftDeoptimize();
} }
...@@ -9453,8 +9453,8 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation( ...@@ -9453,8 +9453,8 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
break; break;
case Token::BIT_OR: { case Token::BIT_OR: {
HValue* operand, *shift_amount; HValue* operand, *shift_amount;
if (left_type->Is(Type::Integer32()) && if (left_type->Is(Type::Signed32()) &&
right_type->Is(Type::Integer32()) && right_type->Is(Type::Signed32()) &&
MatchRotateRight(left, right, &operand, &shift_amount)) { MatchRotateRight(left, right, &operand, &shift_amount)) {
instr = new(zone()) HRor(context, operand, shift_amount); instr = new(zone()) HRor(context, operand, shift_amount);
} else { } else {
...@@ -9654,7 +9654,7 @@ Representation HOptimizedGraphBuilder::ToRepresentation(TypeInfo info) { ...@@ -9654,7 +9654,7 @@ Representation HOptimizedGraphBuilder::ToRepresentation(TypeInfo info) {
Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) { Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) {
if (type->Is(Type::None())) return Representation::None(); 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(); if (type->Is(Type::Number())) return Representation::Double();
return Representation::Tagged(); return Representation::Tagged();
} }
...@@ -9879,8 +9879,8 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -9879,8 +9879,8 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
} else { } else {
// TODO(verwaest): Remove once ToRepresentation properly returns Smi when // TODO(verwaest): Remove once ToRepresentation properly returns Smi when
// the IC measures Smi. // the IC measures Smi.
if (left_type->Is(Type::Integer31())) left_rep = Representation::Smi(); if (left_type->Is(Type::Smi())) left_rep = Representation::Smi();
if (right_type->Is(Type::Integer31())) right_rep = Representation::Smi(); if (right_type->Is(Type::Smi())) right_rep = Representation::Smi();
HCompareIDAndBranch* result = HCompareIDAndBranch* result =
new(zone()) HCompareIDAndBranch(left, right, op); new(zone()) HCompareIDAndBranch(left, right, op);
result->set_observed_input_representation(left_rep, right_rep); result->set_observed_input_representation(left_rep, right_rep);
......
...@@ -2437,7 +2437,7 @@ Handle<Type> UnaryOpIC::TypeInfoToType(TypeInfo type_info, Isolate* isolate) { ...@@ -2437,7 +2437,7 @@ Handle<Type> UnaryOpIC::TypeInfoToType(TypeInfo type_info, Isolate* isolate) {
case UNINITIALIZED: case UNINITIALIZED:
return handle(Type::None(), isolate); return handle(Type::None(), isolate);
case SMI: case SMI:
return handle(Type::Integer31(), isolate); return handle(Type::Smi(), isolate);
case NUMBER: case NUMBER:
return handle(Type::Number(), isolate); return handle(Type::Number(), isolate);
case GENERIC: case GENERIC:
...@@ -2524,9 +2524,9 @@ Handle<Type> BinaryOpIC::TypeInfoToType(BinaryOpIC::TypeInfo binary_type, ...@@ -2524,9 +2524,9 @@ Handle<Type> BinaryOpIC::TypeInfoToType(BinaryOpIC::TypeInfo binary_type,
case UNINITIALIZED: case UNINITIALIZED:
return handle(Type::None(), isolate); return handle(Type::None(), isolate);
case SMI: case SMI:
return handle(Type::Integer31(), isolate); return handle(Type::Smi(), isolate);
case INT32: case INT32:
return handle(Type::Integer32(), isolate); return handle(Type::Signed32(), isolate);
case NUMBER: case NUMBER:
return handle(Type::Number(), isolate); return handle(Type::Number(), isolate);
case ODDBALL: case ODDBALL:
...@@ -2845,7 +2845,7 @@ Handle<Type> CompareIC::StateToType( ...@@ -2845,7 +2845,7 @@ Handle<Type> CompareIC::StateToType(
case CompareIC::UNINITIALIZED: case CompareIC::UNINITIALIZED:
return handle(Type::None(), isolate); return handle(Type::None(), isolate);
case CompareIC::SMI: case CompareIC::SMI:
return handle(Type::Integer31(), isolate); return handle(Type::Smi(), isolate);
case CompareIC::NUMBER: case CompareIC::NUMBER:
return handle(Type::Number(), isolate); return handle(Type::Number(), isolate);
case CompareIC::STRING: case CompareIC::STRING:
......
...@@ -125,7 +125,7 @@ int Type::LubBitset() { ...@@ -125,7 +125,7 @@ int Type::LubBitset() {
map = *this->as_class(); map = *this->as_class();
} else { } else {
Handle<v8::internal::Object> value = this->as_constant(); Handle<v8::internal::Object> value = this->as_constant();
if (value->IsSmi()) return kInteger31; if (value->IsSmi()) return kSmi;
map = HeapObject::cast(*value)->map(); map = HeapObject::cast(*value)->map();
if (map->instance_type() == ODDBALL_TYPE) { if (map->instance_type() == ODDBALL_TYPE) {
if (value->IsUndefined()) return kUndefined; if (value->IsUndefined()) return kUndefined;
...@@ -175,14 +175,17 @@ int Type::LubBitset() { ...@@ -175,14 +175,17 @@ int Type::LubBitset() {
case JS_ARRAY_BUFFER_TYPE: case JS_ARRAY_BUFFER_TYPE:
case JS_TYPED_ARRAY_TYPE: case JS_TYPED_ARRAY_TYPE:
case JS_DATA_VIEW_TYPE: case JS_DATA_VIEW_TYPE:
case JS_SET_TYPE:
case JS_MAP_TYPE:
case JS_WEAK_MAP_TYPE: case JS_WEAK_MAP_TYPE:
case JS_REGEXP_TYPE:
if (map->is_undetectable()) return kUndetectable; if (map->is_undetectable()) return kUndetectable;
return kOtherObject; return kOtherObject;
case JS_ARRAY_TYPE: case JS_ARRAY_TYPE:
return kArray; return kArray;
case JS_FUNCTION_TYPE: case JS_FUNCTION_TYPE:
return kFunction; return kFunction;
case JS_REGEXP_TYPE:
return kRegExp;
case JS_PROXY_TYPE: case JS_PROXY_TYPE:
case JS_FUNCTION_PROXY_TYPE: case JS_FUNCTION_PROXY_TYPE:
return kProxy; return kProxy;
......
...@@ -48,8 +48,8 @@ namespace internal { ...@@ -48,8 +48,8 @@ namespace internal {
// T <= Any // T <= Any
// //
// Oddball = Boolean \/ Null \/ Undefined // Oddball = Boolean \/ Null \/ Undefined
// Number = Integer32 \/ Double // Number = Signed32 \/ Unsigned32 \/ Double
// Integer31 < Integer32 // Smi <= Signed32
// Name = String \/ Symbol // Name = String \/ Symbol
// UniqueName = InternalizedString \/ Symbol // UniqueName = InternalizedString \/ Symbol
// InternalizedString < String // InternalizedString < String
...@@ -60,6 +60,7 @@ namespace internal { ...@@ -60,6 +60,7 @@ namespace internal {
// Receiver = Object \/ Proxy // Receiver = Object \/ Proxy
// Array < Object // Array < Object
// Function < Object // Function < Object
// RegExp < Object
// //
// Class(map) < T iff instance_type(map) < T // Class(map) < T iff instance_type(map) < T
// Constant(x) < T iff instance_type(map(x)) < T // Constant(x) < T iff instance_type(map(x)) < T
...@@ -83,6 +84,8 @@ namespace internal { ...@@ -83,6 +84,8 @@ namespace internal {
// lattice (e.g., splitting up number types further) without invalidating any // lattice (e.g., splitting up number types further) without invalidating any
// existing assumptions or tests. // 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 // Internally, all 'primitive' types, and their unions, are represented as
// bitsets via smis. Class is a heap pointer to the respective map. Only // 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. // Constant's, or unions containing Class'es or Constant's, require allocation.
...@@ -104,9 +107,11 @@ class Type : public Object { ...@@ -104,9 +107,11 @@ class Type : public Object {
static Type* Undefined() { return from_bitset(kUndefined); } static Type* Undefined() { return from_bitset(kUndefined); }
static Type* Number() { return from_bitset(kNumber); } static Type* Number() { return from_bitset(kNumber); }
static Type* Integer31() { return from_bitset(kInteger31); } static Type* Smi() { return from_bitset(kSmi); }
static Type* Integer32() { return from_bitset(kInteger32); } static Type* Signed32() { return from_bitset(kSigned32); }
static Type* Unsigned32() { return from_bitset(kUnsigned32); }
static Type* Double() { return from_bitset(kDouble); } static Type* Double() { return from_bitset(kDouble); }
static Type* NumberOrString() { return from_bitset(kNumberOrString); }
static Type* Name() { return from_bitset(kName); } static Type* Name() { return from_bitset(kName); }
static Type* UniqueName() { return from_bitset(kUniqueName); } static Type* UniqueName() { return from_bitset(kUniqueName); }
...@@ -119,6 +124,7 @@ class Type : public Object { ...@@ -119,6 +124,7 @@ class Type : public Object {
static Type* Undetectable() { return from_bitset(kUndetectable); } static Type* Undetectable() { return from_bitset(kUndetectable); }
static Type* Array() { return from_bitset(kArray); } static Type* Array() { return from_bitset(kArray); }
static Type* Function() { return from_bitset(kFunction); } static Type* Function() { return from_bitset(kFunction); }
static Type* RegExp() { return from_bitset(kRegExp); }
static Type* Proxy() { return from_bitset(kProxy); } static Type* Proxy() { return from_bitset(kProxy); }
static Type* Class(Handle<Map> map) { return from_handle(map); } static Type* Class(Handle<Map> map) { return from_handle(map); }
...@@ -188,25 +194,28 @@ class Type : public Object { ...@@ -188,25 +194,28 @@ class Type : public Object {
kNull = 1 << 0, kNull = 1 << 0,
kUndefined = 1 << 1, kUndefined = 1 << 1,
kBoolean = 1 << 2, kBoolean = 1 << 2,
kInteger31 = 1 << 3, kSmi = 1 << 3,
kOtherInteger = 1 << 4, kOtherSigned32 = 1 << 4,
kDouble = 1 << 5, kUnsigned32 = 1 << 5,
kSymbol = 1 << 6, kDouble = 1 << 6,
kInternalizedString = 1 << 7, kSymbol = 1 << 7,
kOtherString = 1 << 8, kInternalizedString = 1 << 8,
kUndetectable = 1 << 9, kOtherString = 1 << 9,
kArray = 1 << 10, kUndetectable = 1 << 10,
kFunction = 1 << 11, kArray = 1 << 11,
kOtherObject = 1 << 12, kFunction = 1 << 12,
kProxy = 1 << 13, kRegExp = 1 << 13,
kOtherObject = 1 << 14,
kProxy = 1 << 15,
kOddball = kBoolean | kNull | kUndefined, kOddball = kBoolean | kNull | kUndefined,
kInteger32 = kInteger31 | kOtherInteger, kSigned32 = kSmi | kOtherSigned32,
kNumber = kInteger32 | kDouble, kNumber = kSigned32 | kUnsigned32 | kDouble,
kString = kInternalizedString | kOtherString, kString = kInternalizedString | kOtherString,
kUniqueName = kSymbol | kInternalizedString, kUniqueName = kSymbol | kInternalizedString,
kName = kSymbol | kString, kName = kSymbol | kString,
kObject = kUndetectable | kArray | kFunction | kOtherObject, kNumberOrString = kNumber | kString,
kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject,
kReceiver = kObject | kProxy, kReceiver = kObject | kProxy,
kAllocated = kDouble | kName | kReceiver, kAllocated = kDouble | kName | kReceiver,
kAny = kOddball | kNumber | kAllocated, kAny = kOddball | kNumber | kAllocated,
......
...@@ -107,8 +107,8 @@ class HandlifiedTypes { ...@@ -107,8 +107,8 @@ class HandlifiedTypes {
Null(Type::Null(), isolate), Null(Type::Null(), isolate),
Undefined(Type::Undefined(), isolate), Undefined(Type::Undefined(), isolate),
Number(Type::Number(), isolate), Number(Type::Number(), isolate),
Integer31(Type::Integer31(), isolate), Integer31(Type::Smi(), isolate),
Integer32(Type::Integer32(), isolate), Integer32(Type::Signed32(), isolate),
Double(Type::Double(), isolate), Double(Type::Double(), isolate),
Name(Type::Name(), isolate), Name(Type::Name(), isolate),
UniqueName(Type::UniqueName(), isolate), UniqueName(Type::UniqueName(), isolate),
......
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