Revision: 20531
Author: bmeu...@chromium.org
Date: Mon Apr 7 09:41:13 2014 UTC
Log: Use distinct maps for oddballs with special handling in the type
system.
R=rossb...@chromium.org
Review URL: https://codereview.chromium.org/227473002
http://code.google.com/p/v8/source/detail?r=20531
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/code-stubs.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/ic.cc
/branches/bleeding_edge/src/objects-debug.cc
/branches/bleeding_edge/src/types.cc
/branches/bleeding_edge/src/types.h
/branches/bleeding_edge/test/cctest/test-types.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Thu Apr 3 07:51:27 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Mon Apr 7 09:41:13 2014 UTC
@@ -5599,7 +5599,7 @@
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
- static const int kEmptyStringRootIndex = 152;
+ static const int kEmptyStringRootIndex = 159;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
=======================================
--- /branches/bleeding_edge/src/code-stubs.h Fri Apr 4 16:18:59 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.h Mon Apr 7 09:41:13 2014 UTC
@@ -1201,7 +1201,7 @@
Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
Handle<AllocationSite>
allocation_site) {
Code::FindAndReplacePattern pattern;
- pattern.Add(isolate->factory()->oddball_map(), allocation_site);
+ pattern.Add(isolate->factory()->undefined_map(), allocation_site);
return CodeStub::GetCodeCopy(isolate, pattern);
}
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Apr 1 11:30:31 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Mon Apr 7 09:41:13 2014 UTC
@@ -2757,22 +2757,21 @@
set_meta_map(new_meta_map);
new_meta_map->set_map(new_meta_map);
- { MaybeObject* maybe_obj =
- AllocatePartialMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
- if (!maybe_obj->ToObject(&obj)) return false;
- }
- set_fixed_array_map(Map::cast(obj));
+ { // Partial map allocation
+#define ALLOCATE_PARTIAL_MAP(instance_type, size,
field_name) \
+ { Map*
map; \
+ if (!AllocatePartialMap((instance_type), (size))->To(&map)) return
false;\
+
set_##field_name##_map(map); \
+ }
- { MaybeObject* maybe_obj = AllocatePartialMap(ODDBALL_TYPE,
Oddball::kSize);
- if (!maybe_obj->ToObject(&obj)) return false;
- }
- set_oddball_map(Map::cast(obj));
+ ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel,
fixed_array);
+ ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined);
+ ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null);
+ ALLOCATE_PARTIAL_MAP(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel,
+ constant_pool_array);
- { MaybeObject* maybe_obj =
- AllocatePartialMap(CONSTANT_POOL_ARRAY_TYPE,
kVariableSizeSentinel);
- if (!maybe_obj->ToObject(&obj)) return false;
+#undef ALLOCATE_PARTIAL_MAP
}
- set_constant_pool_array_map(Map::cast(obj));
// Allocate the empty array.
{ MaybeObject* maybe_obj = AllocateEmptyFixedArray();
@@ -2780,13 +2779,13 @@
}
set_empty_fixed_array(FixedArray::cast(obj));
- { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE);
+ { MaybeObject* maybe_obj = Allocate(null_map(), OLD_POINTER_SPACE);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_null_value(Oddball::cast(obj));
Oddball::cast(obj)->set_kind(Oddball::kNull);
- { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE);
+ { MaybeObject* maybe_obj = Allocate(undefined_map(), OLD_POINTER_SPACE);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_undefined_value(Oddball::cast(obj));
@@ -2817,10 +2816,15 @@
fixed_array_map()->init_back_pointer(undefined_value());
fixed_array_map()->set_instance_descriptors(empty_descriptor_array());
- oddball_map()->set_code_cache(empty_fixed_array());
-
oddball_map()->set_dependent_code(DependentCode::cast(empty_fixed_array()));
- oddball_map()->init_back_pointer(undefined_value());
- oddball_map()->set_instance_descriptors(empty_descriptor_array());
+ undefined_map()->set_code_cache(empty_fixed_array());
+
undefined_map()->set_dependent_code(DependentCode::cast(empty_fixed_array()));
+ undefined_map()->init_back_pointer(undefined_value());
+ undefined_map()->set_instance_descriptors(empty_descriptor_array());
+
+ null_map()->set_code_cache(empty_fixed_array());
+ null_map()->set_dependent_code(DependentCode::cast(empty_fixed_array()));
+ null_map()->init_back_pointer(undefined_value());
+ null_map()->set_instance_descriptors(empty_descriptor_array());
constant_pool_array_map()->set_code_cache(empty_fixed_array());
constant_pool_array_map()->set_dependent_code(
@@ -2835,8 +2839,11 @@
fixed_array_map()->set_prototype(null_value());
fixed_array_map()->set_constructor(null_value());
- oddball_map()->set_prototype(null_value());
- oddball_map()->set_constructor(null_value());
+ undefined_map()->set_prototype(null_value());
+ undefined_map()->set_constructor(null_value());
+
+ null_map()->set_prototype(null_value());
+ null_map()->set_constructor(null_value());
constant_pool_array_map()->set_prototype(null_value());
constant_pool_array_map()->set_constructor(null_value());
@@ -2859,6 +2866,13 @@
ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol)
ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign)
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole);
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean);
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized);
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker);
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize,
no_interceptor_result_sentinel);
+ ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
+
for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) {
const StringTypeTable& entry = string_type_table[i];
{ MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size);
@@ -3042,11 +3056,12 @@
}
-MaybeObject* Heap::CreateOddball(const char* to_string,
+MaybeObject* Heap::CreateOddball(Map* map,
+ const char* to_string,
Object* to_number,
byte kind) {
Object* result;
- { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE);
+ { MaybeObject* maybe_result = Allocate(map, OLD_POINTER_SPACE);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
return Oddball::cast(result)->Initialize(this, to_string, to_number,
kind);
@@ -3171,54 +3186,61 @@
if (!maybe_obj->ToObject(&obj)) return false;
}
- { MaybeObject* maybe_obj = CreateOddball("true",
+ { MaybeObject* maybe_obj = CreateOddball(boolean_map(),
+ "true",
Smi::FromInt(1),
Oddball::kTrue);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_true_value(Oddball::cast(obj));
- { MaybeObject* maybe_obj = CreateOddball("false",
+ { MaybeObject* maybe_obj = CreateOddball(boolean_map(),
+ "false",
Smi::FromInt(0),
Oddball::kFalse);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_false_value(Oddball::cast(obj));
- { MaybeObject* maybe_obj = CreateOddball("hole",
+ { MaybeObject* maybe_obj = CreateOddball(the_hole_map(),
+ "hole",
Smi::FromInt(-1),
Oddball::kTheHole);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_the_hole_value(Oddball::cast(obj));
- { MaybeObject* maybe_obj = CreateOddball("uninitialized",
+ { MaybeObject* maybe_obj = CreateOddball(uninitialized_map(),
+ "uninitialized",
Smi::FromInt(-1),
Oddball::kUninitialized);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_uninitialized_value(Oddball::cast(obj));
- { MaybeObject* maybe_obj = CreateOddball("arguments_marker",
+ { MaybeObject* maybe_obj = CreateOddball(arguments_marker_map(),
+ "arguments_marker",
Smi::FromInt(-4),
Oddball::kArgumentMarker);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_arguments_marker(Oddball::cast(obj));
- { MaybeObject* maybe_obj =
CreateOddball("no_interceptor_result_sentinel",
+ { MaybeObject* maybe_obj =
CreateOddball(no_interceptor_result_sentinel_map(),
+ "no_interceptor_result_sentinel",
Smi::FromInt(-2),
Oddball::kOther);
if (!maybe_obj->ToObject(&obj)) return false;
}
- set_no_interceptor_result_sentinel(obj);
+ set_no_interceptor_result_sentinel(Oddball::cast(obj));
- { MaybeObject* maybe_obj = CreateOddball("termination_exception",
+ { MaybeObject* maybe_obj = CreateOddball(termination_exception_map(),
+ "termination_exception",
Smi::FromInt(-3),
Oddball::kOther);
if (!maybe_obj->ToObject(&obj)) return false;
}
- set_termination_exception(obj);
+ set_termination_exception(Oddball::cast(obj));
for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) {
{ MaybeObject* maybe_obj =
=======================================
--- /branches/bleeding_edge/src/heap.h Wed Apr 2 11:03:05 2014 UTC
+++ /branches/bleeding_edge/src/heap.h Mon Apr 7 09:41:13 2014 UTC
@@ -72,7 +72,7 @@
V(Map, fixed_cow_array_map,
FixedCOWArrayMap) \
V(Map, fixed_double_array_map,
FixedDoubleArrayMap) \
V(Map, constant_pool_array_map,
ConstantPoolArrayMap) \
- V(Object, no_interceptor_result_sentinel,
NoInterceptorResultSentinel) \
+ V(Oddball, no_interceptor_result_sentinel,
NoInterceptorResultSentinel) \
V(Map, hash_table_map,
HashTableMap) \
V(FixedArray, empty_fixed_array,
EmptyFixedArray) \
V(ByteArray, empty_byte_array,
EmptyByteArray) \
@@ -89,7 +89,7 @@
V(FixedArray, single_character_string_cache,
SingleCharacterStringCache) \
V(FixedArray, string_split_cache,
StringSplitCache) \
V(FixedArray, regexp_multiple_cache,
RegExpMultipleCache) \
- V(Object, termination_exception,
TerminationException) \
+ V(Oddball, termination_exception,
TerminationException) \
V(Smi, hash_seed,
HashSeed) \
V(Map, symbol_map,
SymbolMap) \
V(Map, string_map,
StringMap) \
@@ -179,7 +179,14 @@
V(Map, block_context_map,
BlockContextMap) \
V(Map, module_context_map,
ModuleContextMap) \
V(Map, global_context_map,
GlobalContextMap) \
- V(Map, oddball_map,
OddballMap) \
+ V(Map, undefined_map,
UndefinedMap) \
+ V(Map, the_hole_map,
TheHoleMap) \
+ V(Map, null_map,
NullMap) \
+ V(Map, boolean_map,
BooleanMap) \
+ V(Map, uninitialized_map,
UninitializedMap) \
+ V(Map, arguments_marker_map,
ArgumentsMarkerMap) \
+ V(Map, no_interceptor_result_sentinel_map,
NoInterceptorResultSentinelMap) \
+ V(Map, termination_exception_map,
TerminationExceptionMap) \
V(Map, message_object_map,
JSMessageObjectMap) \
V(Map, foreign_map,
ForeignMap) \
V(HeapNumber, nan_value,
NanValue) \
@@ -266,7 +273,11 @@
V(block_context_map) \
V(module_context_map) \
V(global_context_map) \
- V(oddball_map) \
+ V(undefined_map) \
+ V(the_hole_map) \
+ V(null_map) \
+ V(boolean_map) \
+ V(uninitialized_map) \
V(message_object_map) \
V(foreign_map) \
V(neander_map)
@@ -2213,7 +2224,8 @@
void CreateFixedStubs();
- MUST_USE_RESULT MaybeObject* CreateOddball(const char* to_string,
+ MUST_USE_RESULT MaybeObject* CreateOddball(Map* map,
+ const char* to_string,
Object* to_number,
byte kind);
=======================================
--- /branches/bleeding_edge/src/ic.cc Mon Apr 7 07:52:24 2014 UTC
+++ /branches/bleeding_edge/src/ic.cc Mon Apr 7 09:41:13 2014 UTC
@@ -692,7 +692,7 @@
Handle<Map> IC::TypeToMap(HeapType* type, Isolate* isolate) {
if (type->Is(HeapType::Number()))
return isolate->factory()->heap_number_map();
- if (type->Is(HeapType::Boolean())) return
isolate->factory()->oddball_map();
+ if (type->Is(HeapType::Boolean())) return
isolate->factory()->boolean_map();
if (type->IsConstant()) {
return handle(Handle<JSGlobalObject>::cast(type->AsConstant())->map());
}
=======================================
--- /branches/bleeding_edge/src/objects-debug.cc Tue Apr 1 08:57:48 2014
UTC
+++ /branches/bleeding_edge/src/objects-debug.cc Mon Apr 7 09:41:13 2014
UTC
@@ -596,10 +596,11 @@
void Oddball::OddballVerify() {
CHECK(IsOddball());
+ Heap* heap = GetHeap();
VerifyHeapPointer(to_string());
Object* number = to_number();
if (number->IsHeapObject()) {
- CHECK(number == HeapObject::cast(number)->GetHeap()->nan_value());
+ CHECK(number == heap->nan_value());
} else {
CHECK(number->IsSmi());
int value = Smi::cast(number)->value();
@@ -608,6 +609,26 @@
CHECK_LE(value, 1);
CHECK(value >= kLeastHiddenOddballNumber);
}
+ if (map() == heap->undefined_map()) {
+ CHECK(this == heap->undefined_value());
+ } else if (map() == heap->the_hole_map()) {
+ CHECK(this == heap->the_hole_value());
+ } else if (map() == heap->null_map()) {
+ CHECK(this == heap->null_value());
+ } else if (map() == heap->boolean_map()) {
+ CHECK(this == heap->true_value() ||
+ this == heap->false_value());
+ } else if (map() == heap->uninitialized_map()) {
+ CHECK(this == heap->uninitialized_value());
+ } else if (map() == heap->no_interceptor_result_sentinel_map()) {
+ CHECK(this == heap->no_interceptor_result_sentinel());
+ } else if (map() == heap->arguments_marker_map()) {
+ CHECK(this == heap->arguments_marker());
+ } else if (map() == heap->termination_exception_map()) {
+ CHECK(this == heap->termination_exception());
+ } else {
+ UNREACHABLE();
+ }
}
=======================================
--- /branches/bleeding_edge/src/types.cc Fri Apr 4 09:00:30 2014 UTC
+++ /branches/bleeding_edge/src/types.cc Mon Apr 7 09:41:13 2014 UTC
@@ -140,14 +140,6 @@
value->ToInt32(&i) ? (Smi::IsValid(i) ? kSignedSmall :
kOtherSigned32) :
value->ToUint32(&u) ? kUnsigned32 : kFloat);
}
- if (map->instance_type() == ODDBALL_TYPE) {
- if (value->IsUndefined()) return kUndefined;
- if (value->IsNull()) return kNull;
- if (value->IsBoolean()) return kBoolean;
- if (value->IsTheHole()) return kAny; // TODO(rossberg): kNone?
- if (value->IsUninitialized()) return kNone;
- UNREACHABLE();
- }
return LubBitset(map);
}
@@ -178,8 +170,18 @@
return kString;
case SYMBOL_TYPE:
return kSymbol;
- case ODDBALL_TYPE:
- return kOddball;
+ case ODDBALL_TYPE: {
+ Heap* heap = map->GetHeap();
+ if (map == heap->undefined_map()) return kUndefined;
+ if (map == heap->the_hole_map()) return kAny; // TODO(rossberg):
kNone?
+ if (map == heap->null_map()) return kNull;
+ if (map == heap->boolean_map()) return kBoolean;
+ if (map == heap->uninitialized_map()) return kNone;
+ ASSERT(map == heap->no_interceptor_result_sentinel_map() ||
+ map == heap->termination_exception_map() ||
+ map == heap->arguments_marker_map());
+ return kInternal & kTaggedPtr;
+ }
case HEAP_NUMBER_TYPE:
return kFloat & kTaggedPtr;
case JS_VALUE_TYPE:
@@ -251,8 +253,7 @@
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf(
i::Object* value, Region* region) {
if (value->IsSmi() ||
- i::HeapObject::cast(value)->map()->instance_type() ==
HEAP_NUMBER_TYPE ||
- i::HeapObject::cast(value)->map()->instance_type() == ODDBALL_TYPE) {
+ i::HeapObject::cast(value)->map()->instance_type() ==
HEAP_NUMBER_TYPE) {
return Of(value, region);
}
return Class(i::handle(i::HeapObject::cast(value)->map()), region);
=======================================
--- /branches/bleeding_edge/src/types.h Fri Apr 4 07:21:59 2014 UTC
+++ /branches/bleeding_edge/src/types.h Mon Apr 7 09:41:13 2014 UTC
@@ -24,7 +24,6 @@
// None <= T
// T <= Any
//
-// Oddball = Boolean \/ Null \/ Undefined
// Number = Signed32 \/ Unsigned32 \/ Double
// Smi <= Signed32
// Name = String \/ Symbol
@@ -142,7 +141,6 @@
V(Proxy, 1 << 15 | REPRESENTATION(kTaggedPtr)) \
V(Internal, 1 << 16 | REPRESENTATION(kTagged | kUntagged)) \
\
- V(Oddball, kBoolean | kNull | kUndefined) \
V(Signed32, kSignedSmall | kOtherSigned32) \
V(Number, kSigned32 | kUnsigned32 | kFloat) \
V(String, kInternalizedString | kOtherString) \
@@ -154,7 +152,8 @@
V(Detectable, kDetectableReceiver | kNumber | kName) \
V(Object, kDetectableObject | kUndetectable) \
V(Receiver, kObject | kProxy) \
- V(NonNumber, kOddball | kName | kReceiver | kInternal) \
+ V(NonNumber, kBoolean | kName | kNull | kReceiver | \
+ kUndefined | kInternal) \
V(Any, kNumber | kNonNumber)
#define BITSET_TYPE_LIST(V) \
=======================================
--- /branches/bleeding_edge/test/cctest/test-types.cc Tue Mar 18 11:50:18
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-types.cc Mon Apr 7 09:41:13
2014 UTC
@@ -38,7 +38,6 @@
Semantic(Type::Semantic(region)),
None(Type::None(region)),
Any(Type::Any(region)),
- Oddball(Type::Oddball(region)),
Boolean(Type::Boolean(region)),
Null(Type::Null(region)),
Undefined(Type::Undefined(region)),
@@ -78,7 +77,6 @@
TypeHandle Semantic;
TypeHandle None;
TypeHandle Any;
- TypeHandle Oddball;
TypeHandle Boolean;
TypeHandle Null;
TypeHandle Undefined;
@@ -351,10 +349,6 @@
CheckSub(T.None, T.Number);
CheckSub(T.None, T.Any);
- CheckSub(T.Oddball, T.Any);
- CheckSub(T.Boolean, T.Oddball);
- CheckSub(T.Null, T.Oddball);
- CheckSub(T.Undefined, T.Oddball);
CheckUnordered(T.Boolean, T.Null);
CheckUnordered(T.Undefined, T.Null);
CheckUnordered(T.Boolean, T.Undefined);
@@ -420,10 +414,6 @@
CheckOverlap(T.Any, T.Any, T.Semantic);
CheckOverlap(T.Object, T.Object, T.Semantic);
- CheckOverlap(T.Oddball, T.Any, T.Semantic);
- CheckOverlap(T.Boolean, T.Oddball, T.Semantic);
- CheckOverlap(T.Null, T.Oddball, T.Semantic);
- CheckOverlap(T.Undefined, T.Oddball, T.Semantic);
CheckDisjoint(T.Boolean, T.Null, T.Semantic);
CheckDisjoint(T.Undefined, T.Null, T.Semantic);
CheckDisjoint(T.Boolean, T.Undefined, T.Semantic);
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.