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

Yet more type system tests

R=bmeurer@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20649 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 956d4f3c
...@@ -306,8 +306,8 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { ...@@ -306,8 +306,8 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
template<class Config> template<class Config>
bool TypeImpl<Config>::NowIs(TypeImpl* that) { bool TypeImpl<Config>::NowIs(TypeImpl* that) {
if (this->IsConstant()) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
if (this->IsConstant()) {
i::Object* object = *this->AsConstant(); i::Object* object = *this->AsConstant();
if (object->IsHeapObject()) { if (object->IsHeapObject()) {
i::Map* map = i::HeapObject::cast(object)->map(); i::Map* map = i::HeapObject::cast(object)->map();
...@@ -373,8 +373,8 @@ bool TypeImpl<Config>::Contains(i::Object* value) { ...@@ -373,8 +373,8 @@ bool TypeImpl<Config>::Contains(i::Object* value) {
template<class Config> template<class Config>
bool TypeImpl<Config>::NowContains(i::Object* value) { bool TypeImpl<Config>::NowContains(i::Object* value) {
if (value->IsHeapObject()) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
if (value->IsHeapObject()) {
i::Map* map = i::HeapObject::cast(value)->map(); i::Map* map = i::HeapObject::cast(value)->map();
for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) { for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) {
if (*it.Current() == map) return true; if (*it.Current() == map) return true;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// SUMMARY
//
// A simple type system for compiler-internal use. It is based entirely on // A simple type system for compiler-internal use. It is based entirely on
// union types, and all subtyping hence amounts to set inclusion. Besides the // union types, and all subtyping hence amounts to set inclusion. Besides the
// obvious primitive types and some predefined unions, the type language also // obvious primitive types and some predefined unions, the type language also
...@@ -19,6 +21,8 @@ namespace internal { ...@@ -19,6 +21,8 @@ namespace internal {
// Types consist of two dimensions: semantic (value range) and representation. // Types consist of two dimensions: semantic (value range) and representation.
// Both are related through subtyping. // Both are related through subtyping.
// //
// SEMANTIC DIMENSION
//
// The following equations and inequations hold for the semantic axis: // The following equations and inequations hold for the semantic axis:
// //
// None <= T // None <= T
...@@ -44,6 +48,10 @@ namespace internal { ...@@ -44,6 +48,10 @@ namespace internal {
// change! (Its instance type cannot, however.) // change! (Its instance type cannot, however.)
// TODO(rossberg): the latter is not currently true for proxies, because of fix, // TODO(rossberg): the latter is not currently true for proxies, because of fix,
// but will hold once we implement direct proxies. // but will hold once we implement direct proxies.
// However, we also define a 'temporal' variant of the subtyping relation that
// considers the _current_ state only, i.e., Constant(x) <_now Class(map(x)).
//
// REPRESENTATIONAL DIMENSION
// //
// For the representation axis, the following holds: // For the representation axis, the following holds:
// //
...@@ -69,6 +77,8 @@ namespace internal { ...@@ -69,6 +77,8 @@ namespace internal {
// SignedSmall /\ TaggedInt (a 'smi') // SignedSmall /\ TaggedInt (a 'smi')
// Number /\ TaggedPtr (a heap number) // Number /\ TaggedPtr (a heap number)
// //
// PREDICATES
//
// There are two main functions for testing types: // There are two main functions for testing types:
// //
// T1->Is(T2) -- tests whether T1 is included in T2 (i.e., T1 <= T2) // T1->Is(T2) -- tests whether T1 is included in T2 (i.e., T1 <= T2)
...@@ -84,6 +94,22 @@ namespace internal { ...@@ -84,6 +94,22 @@ namespace internal {
// existing assumptions or tests. // existing assumptions or tests.
// Consequently, do not use pointer equality for type tests, always use Is! // Consequently, do not use pointer equality for type tests, always use Is!
// //
// The NowIs operator implements state-sensitive subtying, as described above.
// Any compilation decision based on such temporary properties requires runtime
// guarding!
//
// PROPERTIES
//
// Various formal properties hold for constructors, operators, and predicates
// over types. For example, constructors are injective, subtyping is a partial
// order, and union and intersection satisfy the usual algebraic properties.
//
// See test/cctest/test-types.cc for a comprehensive executable specification,
// especially with respect to the proeprties of the more exotic 'temporal'
// constructors and predicates (those prefixed 'Now').
//
// IMPLEMENTATION
//
// Internally, all 'primitive' types, and their unions, are represented as // Internally, all 'primitive' types, and their unions, are represented as
// bitsets. Class is a heap pointer to the respective map. Only Constant's, or // bitsets. Class is a heap pointer to the respective map. Only Constant's, or
// unions containing Class'es or Constant's, currently require allocation. // unions containing Class'es or Constant's, currently require allocation.
......
This diff is collapsed.
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