2014-04-01 11:07:09 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-06-05 15:43:53 +00:00
|
|
|
|
2014-11-13 09:02:07 +00:00
|
|
|
#include <iomanip>
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/types.h"
|
2014-04-01 11:07:09 +00:00
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
#include "src/ostreams.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/types-inl.h"
|
2013-06-05 15:43:53 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2014-08-07 15:30:16 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// NOTE: If code is marked as being a "shortcut", this means that removing
|
|
|
|
// the code won't affect the semantics of the surrounding function definition.
|
2014-08-07 15:30:16 +00:00
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Range-related helper functions.
|
2014-08-07 15:30:16 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// The result may be invalid (max < min).
|
|
|
|
template<class Config>
|
|
|
|
typename TypeImpl<Config>::Limits TypeImpl<Config>::Intersect(
|
|
|
|
Limits lhs, Limits rhs) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
Limits result(lhs);
|
|
|
|
if (lhs.min->Number() < rhs.min->Number()) result.min = rhs.min;
|
|
|
|
if (lhs.max->Number() > rhs.max->Number()) result.max = rhs.max;
|
|
|
|
return result;
|
2014-08-07 15:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
typename TypeImpl<Config>::Limits TypeImpl<Config>::Union(
|
|
|
|
Limits lhs, Limits rhs) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
Limits result(lhs);
|
|
|
|
if (lhs.min->Number() > rhs.min->Number()) result.min = rhs.min;
|
|
|
|
if (lhs.max->Number() < rhs.max->Number()) result.max = rhs.max;
|
|
|
|
return result;
|
2013-06-12 17:20:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-16 16:16:37 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
bool TypeImpl<Config>::Overlap(
|
|
|
|
typename TypeImpl<Config>::RangeType* lhs,
|
|
|
|
typename TypeImpl<Config>::RangeType* rhs) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
typename TypeImpl<Config>::Limits lim = Intersect(Limits(lhs), Limits(rhs));
|
|
|
|
return lim.min->Number() <= lim.max->Number();
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
bool TypeImpl<Config>::Contains(
|
|
|
|
typename TypeImpl<Config>::RangeType* lhs,
|
|
|
|
typename TypeImpl<Config>::RangeType* rhs) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
return lhs->Min()->Number() <= rhs->Min()->Number()
|
|
|
|
&& rhs->Max()->Number() <= lhs->Max()->Number();
|
2013-11-15 15:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
bool TypeImpl<Config>::Contains(
|
|
|
|
typename TypeImpl<Config>::RangeType* range, i::Object* val) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
return IsInteger(val)
|
|
|
|
&& range->Min()->Number() <= val->Number()
|
|
|
|
&& val->Number() <= range->Max()->Number();
|
2014-05-26 13:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Min and Max computation.
|
|
|
|
|
2014-05-26 13:10:52 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
double TypeImpl<Config>::Min() {
|
|
|
|
DCHECK(this->Is(Number()));
|
|
|
|
if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
|
|
|
|
if (this->IsUnion()) {
|
|
|
|
double min = +V8_INFINITY;
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
min = std::min(min, this->AsUnion()->Get(i)->Min());
|
|
|
|
}
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
if (this->IsRange()) return this->AsRange()->Min()->Number();
|
|
|
|
if (this->IsConstant()) return this->AsConstant()->Value()->Number();
|
|
|
|
UNREACHABLE();
|
|
|
|
return 0;
|
2014-08-05 13:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-07 15:30:16 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
double TypeImpl<Config>::Max() {
|
|
|
|
DCHECK(this->Is(Number()));
|
|
|
|
if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
|
|
|
|
if (this->IsUnion()) {
|
|
|
|
double max = -V8_INFINITY;
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
max = std::max(max, this->AsUnion()->Get(i)->Max());
|
|
|
|
}
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
if (this->IsRange()) return this->AsRange()->Max()->Number();
|
|
|
|
if (this->IsConstant()) return this->AsConstant()->Value()->Number();
|
|
|
|
UNREACHABLE();
|
|
|
|
return 0;
|
2014-08-07 15:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Glb and lub computation.
|
|
|
|
|
|
|
|
|
|
|
|
// The largest bitset subsumed by this type.
|
2014-08-05 13:19:32 +00:00
|
|
|
template<class Config>
|
2014-09-16 12:58:43 +00:00
|
|
|
typename TypeImpl<Config>::bitset
|
2014-09-24 07:33:51 +00:00
|
|
|
TypeImpl<Config>::BitsetType::Glb(TypeImpl* type) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
if (type->IsBitset()) {
|
|
|
|
return type->AsBitset();
|
|
|
|
} else if (type->IsUnion()) {
|
|
|
|
SLOW_DCHECK(type->AsUnion()->Wellformed());
|
|
|
|
return type->AsUnion()->Get(0)->BitsetGlb(); // Shortcut.
|
|
|
|
// (The remaining BitsetGlb's are None anyway).
|
|
|
|
} else {
|
|
|
|
return kNone;
|
2014-05-26 13:10:52 +00:00
|
|
|
}
|
2014-08-05 13:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// The smallest bitset subsuming this type.
|
2014-08-05 13:19:32 +00:00
|
|
|
template<class Config>
|
2014-09-16 12:58:43 +00:00
|
|
|
typename TypeImpl<Config>::bitset
|
2014-09-24 07:33:51 +00:00
|
|
|
TypeImpl<Config>::BitsetType::Lub(TypeImpl* type) {
|
2014-08-05 13:19:32 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
if (type->IsBitset()) return type->AsBitset();
|
|
|
|
if (type->IsUnion()) {
|
|
|
|
int bitset = kNone;
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
bitset |= type->AsUnion()->Get(i)->BitsetLub();
|
|
|
|
}
|
|
|
|
return bitset;
|
2014-05-26 13:10:52 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (type->IsClass()) {
|
|
|
|
// Little hack to avoid the need for a region for handlification here...
|
|
|
|
return Config::is_class(type) ? Lub(*Config::as_class(type)) :
|
|
|
|
type->AsClass()->Bound(NULL)->AsBitset();
|
|
|
|
}
|
|
|
|
if (type->IsConstant()) return type->AsConstant()->Bound()->AsBitset();
|
|
|
|
if (type->IsRange()) return type->AsRange()->BitsetLub();
|
|
|
|
if (type->IsContext()) return kInternal & kTaggedPtr;
|
|
|
|
if (type->IsArray()) return kArray;
|
|
|
|
if (type->IsFunction()) return kFunction;
|
|
|
|
UNREACHABLE();
|
|
|
|
return kNone;
|
2013-11-15 15:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-16 12:58:43 +00:00
|
|
|
typename TypeImpl<Config>::bitset
|
|
|
|
TypeImpl<Config>::BitsetType::Lub(i::Map* map) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2013-11-15 15:14:09 +00:00
|
|
|
switch (map->instance_type()) {
|
|
|
|
case STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case ONE_BYTE_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case CONS_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case CONS_ONE_BYTE_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case SLICED_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case SLICED_ONE_BYTE_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case EXTERNAL_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case EXTERNAL_ONE_BYTE_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
|
|
|
|
case SHORT_EXTERNAL_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
|
2014-09-24 07:33:51 +00:00
|
|
|
return kOtherString;
|
2013-11-15 15:14:09 +00:00
|
|
|
case INTERNALIZED_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case ONE_BYTE_INTERNALIZED_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case EXTERNAL_INTERNALIZED_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
|
|
|
|
case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE:
|
2014-09-10 12:38:12 +00:00
|
|
|
case SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
|
2014-09-24 07:33:51 +00:00
|
|
|
return kInternalizedString;
|
2013-11-15 15:14:09 +00:00
|
|
|
case SYMBOL_TYPE:
|
|
|
|
return kSymbol;
|
2014-04-07 09:41:13 +00:00
|
|
|
case ODDBALL_TYPE: {
|
|
|
|
Heap* heap = map->GetHeap();
|
|
|
|
if (map == heap->undefined_map()) return kUndefined;
|
|
|
|
if (map == heap->null_map()) return kNull;
|
|
|
|
if (map == heap->boolean_map()) return kBoolean;
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(map == heap->the_hole_map() ||
|
2014-07-10 12:37:08 +00:00
|
|
|
map == heap->uninitialized_map() ||
|
2014-04-10 11:51:03 +00:00
|
|
|
map == heap->no_interceptor_result_sentinel_map() ||
|
2014-04-07 09:41:13 +00:00
|
|
|
map == heap->termination_exception_map() ||
|
|
|
|
map == heap->arguments_marker_map());
|
|
|
|
return kInternal & kTaggedPtr;
|
|
|
|
}
|
2013-11-15 15:14:09 +00:00
|
|
|
case HEAP_NUMBER_TYPE:
|
2014-05-26 13:10:52 +00:00
|
|
|
return kNumber & kTaggedPtr;
|
2013-11-15 15:14:09 +00:00
|
|
|
case JS_VALUE_TYPE:
|
|
|
|
case JS_DATE_TYPE:
|
|
|
|
case JS_OBJECT_TYPE:
|
|
|
|
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
|
|
|
|
case JS_GENERATOR_OBJECT_TYPE:
|
|
|
|
case JS_MODULE_TYPE:
|
|
|
|
case JS_GLOBAL_OBJECT_TYPE:
|
|
|
|
case JS_BUILTINS_OBJECT_TYPE:
|
|
|
|
case JS_GLOBAL_PROXY_TYPE:
|
|
|
|
case JS_ARRAY_BUFFER_TYPE:
|
|
|
|
case JS_TYPED_ARRAY_TYPE:
|
|
|
|
case JS_DATA_VIEW_TYPE:
|
|
|
|
case JS_SET_TYPE:
|
|
|
|
case JS_MAP_TYPE:
|
2014-04-22 18:14:46 +00:00
|
|
|
case JS_SET_ITERATOR_TYPE:
|
|
|
|
case JS_MAP_ITERATOR_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case JS_WEAK_MAP_TYPE:
|
|
|
|
case JS_WEAK_SET_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;
|
|
|
|
case MAP_TYPE:
|
|
|
|
// When compiling stub templates, the meta map is used as a place holder
|
|
|
|
// for the actual map with which the template is later instantiated.
|
|
|
|
// We treat it as a kind of type variable whose upper bound is Any.
|
|
|
|
// TODO(rossberg): for caching of CompareNilIC stubs to work correctly,
|
|
|
|
// we must exclude Undetectable here. This makes no sense, really,
|
|
|
|
// because it means that the template isn't actually parametric.
|
|
|
|
// Also, it doesn't apply elsewhere. 8-(
|
|
|
|
// We ought to find a cleaner solution for compiling stubs parameterised
|
|
|
|
// over type or class variables, esp ones with bounds...
|
|
|
|
return kDetectable;
|
|
|
|
case DECLARED_ACCESSOR_INFO_TYPE:
|
|
|
|
case EXECUTABLE_ACCESSOR_INFO_TYPE:
|
2014-05-26 13:10:52 +00:00
|
|
|
case SHARED_FUNCTION_INFO_TYPE:
|
2013-11-15 15:14:09 +00:00
|
|
|
case ACCESSOR_PAIR_TYPE:
|
|
|
|
case FIXED_ARRAY_TYPE:
|
2014-10-15 11:38:04 +00:00
|
|
|
case BYTE_ARRAY_TYPE:
|
2014-04-24 07:16:10 +00:00
|
|
|
case FOREIGN_TYPE:
|
2014-07-30 13:54:45 +00:00
|
|
|
case CODE_TYPE:
|
2014-03-18 11:50:18 +00:00
|
|
|
return kInternal & kTaggedPtr;
|
2013-11-15 15:14:09 +00:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return kNone;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
template<class Config>
|
|
|
|
typename TypeImpl<Config>::bitset
|
|
|
|
TypeImpl<Config>::BitsetType::Lub(i::Object* value) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
if (value->IsNumber()) {
|
|
|
|
return Lub(value->Number()) & (value->IsSmi() ? kTaggedInt : kTaggedPtr);
|
|
|
|
}
|
|
|
|
return Lub(i::HeapObject::cast(value)->map());
|
|
|
|
}
|
|
|
|
|
2013-11-15 15:14:09 +00:00
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
typename TypeImpl<Config>::bitset
|
|
|
|
TypeImpl<Config>::BitsetType::Lub(double value) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
if (i::IsMinusZero(value)) return kMinusZero;
|
|
|
|
if (std::isnan(value)) return kNaN;
|
2014-09-30 10:34:54 +00:00
|
|
|
if (IsUint32Double(value) || IsInt32Double(value)) return Lub(value, value);
|
2014-09-24 07:33:51 +00:00
|
|
|
return kOtherNumber;
|
|
|
|
}
|
2014-04-16 16:16:37 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
|
|
|
|
// Minimum values of regular numeric bitsets when SmiValuesAre31Bits.
|
|
|
|
template<class Config>
|
|
|
|
const typename TypeImpl<Config>::BitsetType::BitsetMin
|
|
|
|
TypeImpl<Config>::BitsetType::BitsetMins31[] = {
|
|
|
|
{kOtherNumber, -V8_INFINITY},
|
|
|
|
{kOtherSigned32, kMinInt},
|
|
|
|
{kOtherSignedSmall, -0x40000000},
|
|
|
|
{kUnsignedSmall, 0},
|
|
|
|
{kOtherUnsigned31, 0x40000000},
|
|
|
|
{kOtherUnsigned32, 0x80000000},
|
|
|
|
{kOtherNumber, static_cast<double>(kMaxUInt32) + 1}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Minimum values of regular numeric bitsets when SmiValuesAre32Bits.
|
|
|
|
// OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h).
|
|
|
|
template<class Config>
|
|
|
|
const typename TypeImpl<Config>::BitsetType::BitsetMin
|
|
|
|
TypeImpl<Config>::BitsetType::BitsetMins32[] = {
|
|
|
|
{kOtherNumber, -V8_INFINITY},
|
|
|
|
{kOtherSignedSmall, kMinInt},
|
|
|
|
{kUnsignedSmall, 0},
|
|
|
|
{kOtherUnsigned32, 0x80000000},
|
|
|
|
{kOtherNumber, static_cast<double>(kMaxUInt32) + 1}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
typename TypeImpl<Config>::bitset
|
2014-09-30 10:34:54 +00:00
|
|
|
TypeImpl<Config>::BitsetType::Lub(double min, double max) {
|
2014-09-24 07:33:51 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
int lub = kNone;
|
|
|
|
const BitsetMin* mins = BitsetMins();
|
|
|
|
|
|
|
|
for (size_t i = 1; i < BitsetMinsSize(); ++i) {
|
|
|
|
if (min < mins[i].min) {
|
|
|
|
lub |= mins[i-1].bits;
|
|
|
|
if (max < mins[i].min) return lub;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lub |= mins[BitsetMinsSize()-1].bits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
double TypeImpl<Config>::BitsetType::Min(bitset bits) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
DCHECK(Is(bits, kNumber));
|
|
|
|
const BitsetMin* mins = BitsetMins();
|
|
|
|
bool mz = SEMANTIC(bits & kMinusZero);
|
|
|
|
for (size_t i = 0; i < BitsetMinsSize(); ++i) {
|
|
|
|
if (Is(SEMANTIC(mins[i].bits), bits)) {
|
|
|
|
return mz ? std::min(0.0, mins[i].min) : mins[i].min;
|
|
|
|
}
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (mz) return 0;
|
|
|
|
return base::OS::nan_value();
|
|
|
|
}
|
|
|
|
|
2013-06-05 15:43:53 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
template<class Config>
|
|
|
|
double TypeImpl<Config>::BitsetType::Max(bitset bits) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
DCHECK(Is(bits, kNumber));
|
|
|
|
const BitsetMin* mins = BitsetMins();
|
2014-10-15 08:21:46 +00:00
|
|
|
bool mz = SEMANTIC(bits & kMinusZero);
|
2014-09-24 07:33:51 +00:00
|
|
|
if (BitsetType::Is(mins[BitsetMinsSize()-1].bits, bits)) {
|
|
|
|
return +V8_INFINITY;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
for (size_t i = BitsetMinsSize()-1; i-- > 0; ) {
|
|
|
|
if (Is(SEMANTIC(mins[i].bits), bits)) {
|
|
|
|
return mz ?
|
|
|
|
std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1;
|
|
|
|
}
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (mz) return 0;
|
|
|
|
return base::OS::nan_value();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Predicates.
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
bool TypeImpl<Config>::SimplyEquals(TypeImpl* that) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
if (this->IsClass()) {
|
|
|
|
return that->IsClass()
|
|
|
|
&& *this->AsClass()->Map() == *that->AsClass()->Map();
|
|
|
|
}
|
|
|
|
if (this->IsConstant()) {
|
|
|
|
return that->IsConstant()
|
|
|
|
&& *this->AsConstant()->Value() == *that->AsConstant()->Value();
|
2014-08-07 15:30:16 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (this->IsContext()) {
|
|
|
|
return that->IsContext()
|
2014-05-26 13:10:52 +00:00
|
|
|
&& this->AsContext()->Outer()->Equals(that->AsContext()->Outer());
|
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (this->IsArray()) {
|
|
|
|
return that->IsArray()
|
2014-04-16 16:16:37 +00:00
|
|
|
&& this->AsArray()->Element()->Equals(that->AsArray()->Element());
|
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (this->IsFunction()) {
|
|
|
|
if (!that->IsFunction()) return false;
|
2014-04-16 16:16:37 +00:00
|
|
|
FunctionType* this_fun = this->AsFunction();
|
|
|
|
FunctionType* that_fun = that->AsFunction();
|
|
|
|
if (this_fun->Arity() != that_fun->Arity() ||
|
|
|
|
!this_fun->Result()->Equals(that_fun->Result()) ||
|
2014-09-24 07:33:51 +00:00
|
|
|
!this_fun->Receiver()->Equals(that_fun->Receiver())) {
|
2014-04-16 16:16:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this_fun->Arity(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
if (!this_fun->Parameter(i)->Equals(that_fun->Parameter(i))) return false;
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
|
|
|
return true;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check if [this] <= [that].
|
|
|
|
template<class Config>
|
|
|
|
bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
2013-06-05 15:43:53 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
if (that->IsBitset()) {
|
|
|
|
return BitsetType::Is(this->BitsetLub(), that->AsBitset());
|
|
|
|
}
|
|
|
|
if (this->IsBitset()) {
|
|
|
|
return BitsetType::Is(this->AsBitset(), that->BitsetGlb());
|
|
|
|
}
|
|
|
|
|
|
|
|
// (T1 \/ ... \/ Tn) <= T if (T1 <= T) /\ ... /\ (Tn <= T)
|
2014-01-10 12:19:01 +00:00
|
|
|
if (this->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
|
|
|
if (!this->AsUnion()->Get(i)->Is(that)) return false;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// T <= (T1 \/ ... \/ Tn) if (T <= T1) \/ ... \/ (T <= Tn)
|
|
|
|
if (that->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = that->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
if (this->Is(that->AsUnion()->Get(i))) return true;
|
|
|
|
if (i > 1 && this->IsRange()) return false; // Shortcut.
|
|
|
|
}
|
|
|
|
return false;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
|
|
|
|
if (that->IsRange()) {
|
|
|
|
return (this->IsRange() && Contains(that->AsRange(), this->AsRange()))
|
|
|
|
|| (this->IsConstant() &&
|
|
|
|
Contains(that->AsRange(), *this->AsConstant()->Value()));
|
|
|
|
}
|
|
|
|
if (this->IsRange()) return false;
|
2014-10-15 11:38:04 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
return this->SimplyEquals(that);
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-04-01 13:11:12 +00:00
|
|
|
bool TypeImpl<Config>::NowIs(TypeImpl* that) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
|
2014-04-14 15:35:36 +00:00
|
|
|
// TODO(rossberg): this is incorrect for
|
|
|
|
// Union(Constant(V), T)->NowIs(Class(M))
|
|
|
|
// but fuzzing does not cover that!
|
2014-04-10 08:04:50 +00:00
|
|
|
if (this->IsConstant()) {
|
2014-04-16 16:16:37 +00:00
|
|
|
i::Object* object = *this->AsConstant()->Value();
|
2014-04-10 08:04:50 +00:00
|
|
|
if (object->IsHeapObject()) {
|
|
|
|
i::Map* map = i::HeapObject::cast(object)->map();
|
|
|
|
for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) {
|
|
|
|
if (*it.Current() == map) return true;
|
|
|
|
}
|
2014-04-09 11:12:15 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-10 08:04:50 +00:00
|
|
|
return this->Is(that);
|
2013-11-22 13:16:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// Check if [this] contains only (currently) stable classes.
|
2014-04-17 08:22:22 +00:00
|
|
|
template<class Config>
|
|
|
|
bool TypeImpl<Config>::NowStable() {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) {
|
|
|
|
if (!it.Current()->is_stable()) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// Check if [this] and [that] overlap.
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
|
|
|
bool TypeImpl<Config>::Maybe(TypeImpl* that) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// (T1 \/ ... \/ Tn) overlaps T if (T1 overlaps T) \/ ... \/ (Tn overlaps T)
|
2014-01-10 12:19:01 +00:00
|
|
|
if (this->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
|
|
|
if (this->AsUnion()->Get(i)->Maybe(that)) return true;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// T overlaps (T1 \/ ... \/ Tn) if (T overlaps T1) \/ ... \/ (T overlaps Tn)
|
2014-01-10 12:19:01 +00:00
|
|
|
if (that->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = that->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
if (this->Maybe(that->AsUnion()->Get(i))) return true;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
if (!BitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()))
|
|
|
|
return false;
|
|
|
|
if (this->IsBitset() || that->IsBitset()) return true;
|
|
|
|
|
|
|
|
if (this->IsClass() != that->IsClass()) return true;
|
|
|
|
|
|
|
|
if (this->IsRange()) {
|
|
|
|
if (that->IsConstant()) {
|
|
|
|
return Contains(this->AsRange(), *that->AsConstant()->Value());
|
|
|
|
}
|
|
|
|
return that->IsRange() && Overlap(this->AsRange(), that->AsRange());
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (that->IsRange()) {
|
|
|
|
if (this->IsConstant()) {
|
|
|
|
return Contains(that->AsRange(), *this->AsConstant()->Value());
|
|
|
|
}
|
|
|
|
return this->IsRange() && Overlap(this->AsRange(), that->AsRange());
|
2013-06-20 09:10:10 +00:00
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
return this->SimplyEquals(that);
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// Return the range in [this], or [NULL].
|
2014-04-01 13:11:12 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
typename TypeImpl<Config>::RangeType* TypeImpl<Config>::GetRange() {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-24 07:33:51 +00:00
|
|
|
if (this->IsRange()) return this->AsRange();
|
|
|
|
if (this->IsUnion() && this->AsUnion()->Get(1)->IsRange()) {
|
|
|
|
return this->AsUnion()->Get(1)->AsRange();
|
2014-08-07 15:30:16 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
bool TypeImpl<Config>::Contains(i::Object* value) {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-04-09 11:12:15 +00:00
|
|
|
for (Iterator<i::Object> it = this->Constants(); !it.Done(); it.Advance()) {
|
|
|
|
if (*it.Current() == value) return true;
|
2014-04-01 13:11:12 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (IsInteger(value)) {
|
|
|
|
RangeType* range = this->GetRange();
|
|
|
|
if (range != NULL && Contains(range, value)) return true;
|
|
|
|
}
|
2014-04-16 16:16:37 +00:00
|
|
|
return BitsetType::New(BitsetType::Lub(value))->Is(this);
|
2014-04-01 13:11:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-05-27 13:52:31 +00:00
|
|
|
bool TypeImpl<Config>::UnionType::Wellformed() {
|
2014-09-24 07:33:51 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
// This checks the invariants of the union representation:
|
|
|
|
// 1. There are at least two elements.
|
|
|
|
// 2. At most one element is a bitset, and it must be the first one.
|
|
|
|
// 3. At most one element is a range, and it must be the second one
|
|
|
|
// (even when the first element is not a bitset).
|
|
|
|
// 4. No element is itself a union.
|
|
|
|
// 5. No element is a subtype of any other.
|
|
|
|
DCHECK(this->Length() >= 2); // (1)
|
2014-05-27 13:52:31 +00:00
|
|
|
for (int i = 0; i < this->Length(); ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
if (i != 0) DCHECK(!this->Get(i)->IsBitset()); // (2)
|
|
|
|
if (i != 1) DCHECK(!this->Get(i)->IsRange()); // (3)
|
|
|
|
DCHECK(!this->Get(i)->IsUnion()); // (4)
|
2014-05-27 13:52:31 +00:00
|
|
|
for (int j = 0; j < this->Length(); ++j) {
|
2014-09-24 07:33:51 +00:00
|
|
|
if (i != j) DCHECK(!this->Get(i)->Is(this->Get(j))); // (5)
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Union and intersection
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
|
|
|
|
static bool AddIsSafe(int x, int y) {
|
|
|
|
return x >= 0 ?
|
|
|
|
y <= std::numeric_limits<int>::max() - x :
|
|
|
|
y >= std::numeric_limits<int>::min() - x;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-27 13:52:31 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect(
|
|
|
|
TypeHandle type1, TypeHandle type2, Region* region) {
|
|
|
|
bitset bits = type1->BitsetGlb() & type2->BitsetGlb();
|
|
|
|
if (!BitsetType::IsInhabited(bits)) bits = BitsetType::kNone;
|
|
|
|
|
|
|
|
// Fast case: bit sets.
|
|
|
|
if (type1->IsBitset() && type2->IsBitset()) {
|
|
|
|
return BitsetType::New(bits, region);
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
|
|
|
|
// Fast case: top or bottom types.
|
|
|
|
if (type1->IsNone() || type2->IsAny()) return type1; // Shortcut.
|
|
|
|
if (type2->IsNone() || type1->IsAny()) return type2; // Shortcut.
|
|
|
|
|
|
|
|
// Semi-fast case.
|
|
|
|
if (type1->Is(type2)) return type1;
|
|
|
|
if (type2->Is(type1)) return type2;
|
|
|
|
|
|
|
|
// Slow case: create union.
|
|
|
|
int size1 = type1->IsUnion() ? type1->AsUnion()->Length() : 1;
|
|
|
|
int size2 = type2->IsUnion() ? type2->AsUnion()->Length() : 1;
|
|
|
|
if (!AddIsSafe(size1, size2)) return Any(region);
|
|
|
|
int size = size1 + size2;
|
|
|
|
if (!AddIsSafe(size, 2)) return Any(region);
|
|
|
|
size += 2;
|
|
|
|
UnionHandle result = UnionType::New(size, region);
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
// Deal with bitsets.
|
|
|
|
result->Set(size++, BitsetType::New(bits, region));
|
|
|
|
|
|
|
|
// Deal with ranges.
|
|
|
|
TypeHandle range = None(region);
|
|
|
|
RangeType* range1 = type1->GetRange();
|
|
|
|
RangeType* range2 = type2->GetRange();
|
|
|
|
if (range1 != NULL && range2 != NULL) {
|
|
|
|
Limits lim = Intersect(Limits(range1), Limits(range2));
|
|
|
|
if (lim.min->Number() <= lim.max->Number()) {
|
|
|
|
range = RangeType::New(lim, region);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result->Set(size++, range);
|
|
|
|
|
|
|
|
size = IntersectAux(type1, type2, result, size, region);
|
|
|
|
return NormalizeUnion(result, size);
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
int TypeImpl<Config>::UpdateRange(
|
|
|
|
RangeHandle range, UnionHandle result, int size, Region* region) {
|
|
|
|
TypeHandle old_range = result->Get(1);
|
|
|
|
DCHECK(old_range->IsRange() || old_range->IsNone());
|
|
|
|
if (range->Is(old_range)) return size;
|
|
|
|
if (!old_range->Is(range->unhandle())) {
|
|
|
|
range = RangeType::New(
|
|
|
|
Union(Limits(range->AsRange()), Limits(old_range->AsRange())), region);
|
|
|
|
}
|
|
|
|
result->Set(1, range);
|
|
|
|
|
|
|
|
// Remove any components that just got subsumed.
|
|
|
|
for (int i = 2; i < size; ) {
|
|
|
|
if (result->Get(i)->Is(range->unhandle())) {
|
|
|
|
result->Set(i, result->Get(--size));
|
|
|
|
} else {
|
|
|
|
++i;
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-05-27 13:52:31 +00:00
|
|
|
return size;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
int TypeImpl<Config>::IntersectAux(
|
|
|
|
TypeHandle lhs, TypeHandle rhs,
|
|
|
|
UnionHandle result, int size, Region* region) {
|
|
|
|
if (lhs->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = lhs->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
size = IntersectAux(lhs->AsUnion()->Get(i), rhs, result, size, region);
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
if (rhs->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = rhs->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
size = IntersectAux(lhs, rhs->AsUnion()->Get(i), result, size, region);
|
|
|
|
}
|
|
|
|
return size;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
if (!BitsetType::IsInhabited(lhs->BitsetLub() & rhs->BitsetLub())) {
|
|
|
|
return size;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
if (lhs->IsRange()) {
|
|
|
|
if (rhs->IsBitset() || rhs->IsClass()) {
|
|
|
|
return UpdateRange(
|
|
|
|
Config::template cast<RangeType>(lhs), result, size, region);
|
|
|
|
}
|
|
|
|
if (rhs->IsConstant() &&
|
|
|
|
Contains(lhs->AsRange(), *rhs->AsConstant()->Value())) {
|
|
|
|
return AddToUnion(rhs, result, size, region);
|
|
|
|
}
|
|
|
|
return size;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (rhs->IsRange()) {
|
|
|
|
if (lhs->IsBitset() || lhs->IsClass()) {
|
|
|
|
return UpdateRange(
|
|
|
|
Config::template cast<RangeType>(rhs), result, size, region);
|
|
|
|
}
|
|
|
|
if (lhs->IsConstant() &&
|
|
|
|
Contains(rhs->AsRange(), *lhs->AsConstant()->Value())) {
|
|
|
|
return AddToUnion(lhs, result, size, region);
|
|
|
|
}
|
|
|
|
return size;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
if (lhs->IsBitset() || rhs->IsBitset()) {
|
|
|
|
return AddToUnion(lhs->IsBitset() ? rhs : lhs, result, size, region);
|
Retry landing "Implement zone-allocated types"
Works around apparent scoping bug in VS, the only change to before being a method rename in the test suite:
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -153,7 +153,7 @@ struct ZoneRep {
return reinterpret_cast<ZoneList<ZoneType*>*>(AsTagged(t));
}
- static Zone* Region(Zone* zone, Isolate* isolate) { return zone; }
+ static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; }
};
@@ -168,7 +168,7 @@ struct HeapRep {
static Object* AsConstant(Handle<Type> t) { return Box::cast(*t)->value(); }
static FixedArray* AsUnion(Handle<Type> t) { return FixedArray::cast(*t); }
- static Isolate* Region(Zone* zone, Isolate* isolate) { return isolate; }
+ static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; }
};
@@ -183,7 +183,7 @@ struct Tests : Rep {
isolate(CcTest::i_isolate()),
scope(isolate),
zone(isolate),
- T(Rep::Region(&zone, isolate), isolate) {
+ T(Rep::ToRegion(&zone, isolate), isolate) {
}
static void CheckEqual(TypeHandle type1, TypeHandle type2) {
R=titzer@chromium.org
BUG=
Review URL: https://codereview.chromium.org/143693003
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18711 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-01-21 14:14:12 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (lhs->IsClass() != rhs->IsClass()) {
|
|
|
|
return AddToUnion(lhs->IsClass() ? rhs : lhs, result, size, region);
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (lhs->SimplyEquals(rhs->unhandle())) {
|
|
|
|
return AddToUnion(lhs, result, size, region);
|
|
|
|
}
|
|
|
|
return size;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-24 07:33:51 +00:00
|
|
|
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
|
2014-01-10 12:19:01 +00:00
|
|
|
TypeHandle type1, TypeHandle type2, Region* region) {
|
2014-09-24 07:33:51 +00:00
|
|
|
|
2013-06-20 09:10:10 +00:00
|
|
|
// Fast case: bit sets.
|
2014-01-10 12:19:01 +00:00
|
|
|
if (type1->IsBitset() && type2->IsBitset()) {
|
2014-09-24 07:33:51 +00:00
|
|
|
return BitsetType::New(type1->AsBitset() | type2->AsBitset(), region);
|
2013-06-20 09:10:10 +00:00
|
|
|
}
|
|
|
|
|
2013-06-21 11:10:06 +00:00
|
|
|
// Fast case: top or bottom types.
|
2014-09-24 07:33:51 +00:00
|
|
|
if (type1->IsAny() || type2->IsNone()) return type1;
|
|
|
|
if (type2->IsAny() || type1->IsNone()) return type2;
|
2013-06-21 11:10:06 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// Semi-fast case.
|
|
|
|
if (type1->Is(type2)) return type2;
|
|
|
|
if (type2->Is(type1)) return type1;
|
|
|
|
|
|
|
|
// Slow case: create union.
|
|
|
|
int size1 = type1->IsUnion() ? type1->AsUnion()->Length() : 1;
|
|
|
|
int size2 = type2->IsUnion() ? type2->AsUnion()->Length() : 1;
|
|
|
|
if (!AddIsSafe(size1, size2)) return Any(region);
|
|
|
|
int size = size1 + size2;
|
|
|
|
if (!AddIsSafe(size, 2)) return Any(region);
|
|
|
|
size += 2;
|
|
|
|
UnionHandle result = UnionType::New(size, region);
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
// Deal with bitsets.
|
|
|
|
TypeHandle bits = BitsetType::New(
|
|
|
|
type1->BitsetGlb() | type2->BitsetGlb(), region);
|
|
|
|
result->Set(size++, bits);
|
|
|
|
|
|
|
|
// Deal with ranges.
|
|
|
|
TypeHandle range = None(region);
|
|
|
|
RangeType* range1 = type1->GetRange();
|
|
|
|
RangeType* range2 = type2->GetRange();
|
|
|
|
if (range1 != NULL && range2 != NULL) {
|
|
|
|
range = RangeType::New(Union(Limits(range1), Limits(range2)), region);
|
|
|
|
} else if (range1 != NULL) {
|
|
|
|
range = handle(range1);
|
|
|
|
} else if (range2 != NULL) {
|
|
|
|
range = handle(range2);
|
2013-06-20 09:10:10 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
result->Set(size++, range);
|
|
|
|
|
|
|
|
size = AddToUnion(type1, result, size, region);
|
|
|
|
size = AddToUnion(type2, result, size, region);
|
|
|
|
return NormalizeUnion(result, size);
|
|
|
|
}
|
|
|
|
|
2013-06-20 09:10:10 +00:00
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
// Add [type] to [result] unless [type] is bitset, range, or already subsumed.
|
|
|
|
// Return new size of [result].
|
|
|
|
template<class Config>
|
|
|
|
int TypeImpl<Config>::AddToUnion(
|
|
|
|
TypeHandle type, UnionHandle result, int size, Region* region) {
|
|
|
|
if (type->IsBitset() || type->IsRange()) return size;
|
|
|
|
if (type->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) {
|
2014-09-24 07:33:51 +00:00
|
|
|
size = AddToUnion(type->AsUnion()->Get(i), result, size, region);
|
|
|
|
}
|
|
|
|
return size;
|
2013-06-20 09:10:10 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
if (type->Is(result->Get(i))) return size;
|
2013-06-20 09:10:10 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
result->Set(size++, type);
|
|
|
|
return size;
|
|
|
|
}
|
2013-06-20 09:10:10 +00:00
|
|
|
|
|
|
|
|
2014-09-24 07:33:51 +00:00
|
|
|
template<class Config>
|
|
|
|
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion(
|
|
|
|
UnionHandle unioned, int size) {
|
|
|
|
DCHECK(size >= 2);
|
|
|
|
// If range is subsumed by bitset, use its place for a different type.
|
|
|
|
if (unioned->Get(1)->Is(unioned->Get(0))) {
|
|
|
|
unioned->Set(1, unioned->Get(--size));
|
|
|
|
}
|
|
|
|
// If bitset is None, use its place for a different type.
|
|
|
|
if (size >= 2 && unioned->Get(0)->IsNone()) {
|
|
|
|
unioned->Set(0, unioned->Get(--size));
|
2013-06-20 09:10:10 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
if (size == 1) return unioned->Get(0);
|
|
|
|
unioned->Shrink(size);
|
|
|
|
SLOW_DCHECK(unioned->Wellformed());
|
|
|
|
return unioned;
|
2013-06-05 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 09:26:22 +00:00
|
|
|
|
2014-05-27 13:52:31 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Iteration.
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
int TypeImpl<Config>::NumClasses() {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
if (this->IsClass()) {
|
|
|
|
return 1;
|
|
|
|
} else if (this->IsUnion()) {
|
|
|
|
int result = 0;
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
|
|
|
if (this->AsUnion()->Get(i)->IsClass()) ++result;
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
int TypeImpl<Config>::NumConstants() {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
if (this->IsConstant()) {
|
|
|
|
return 1;
|
|
|
|
} else if (this->IsUnion()) {
|
|
|
|
int result = 0;
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
|
|
|
if (this->AsUnion()->Get(i)->IsConstant()) ++result;
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config> template<class T>
|
|
|
|
typename TypeImpl<Config>::TypeHandle
|
|
|
|
TypeImpl<Config>::Iterator<T>::get_type() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!Done());
|
2014-05-27 13:52:31 +00:00
|
|
|
return type_->IsUnion() ? type_->AsUnion()->Get(index_) : type_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// C++ cannot specialise nested templates, so we have to go through this
|
|
|
|
// contortion with an auxiliary template to simulate it.
|
|
|
|
template<class Config, class T>
|
|
|
|
struct TypeImplIteratorAux {
|
|
|
|
static bool matches(typename TypeImpl<Config>::TypeHandle type);
|
|
|
|
static i::Handle<T> current(typename TypeImpl<Config>::TypeHandle type);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
struct TypeImplIteratorAux<Config, i::Map> {
|
|
|
|
static bool matches(typename TypeImpl<Config>::TypeHandle type) {
|
|
|
|
return type->IsClass();
|
|
|
|
}
|
|
|
|
static i::Handle<i::Map> current(typename TypeImpl<Config>::TypeHandle type) {
|
|
|
|
return type->AsClass()->Map();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
struct TypeImplIteratorAux<Config, i::Object> {
|
|
|
|
static bool matches(typename TypeImpl<Config>::TypeHandle type) {
|
|
|
|
return type->IsConstant();
|
|
|
|
}
|
|
|
|
static i::Handle<i::Object> current(
|
|
|
|
typename TypeImpl<Config>::TypeHandle type) {
|
|
|
|
return type->AsConstant()->Value();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Config> template<class T>
|
|
|
|
bool TypeImpl<Config>::Iterator<T>::matches(TypeHandle type) {
|
|
|
|
return TypeImplIteratorAux<Config, T>::matches(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Config> template<class T>
|
|
|
|
i::Handle<T> TypeImpl<Config>::Iterator<T>::Current() {
|
|
|
|
return TypeImplIteratorAux<Config, T>::current(get_type());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Config> template<class T>
|
|
|
|
void TypeImpl<Config>::Iterator<T>::Advance() {
|
|
|
|
DisallowHeapAllocation no_allocation;
|
|
|
|
++index_;
|
|
|
|
if (type_->IsUnion()) {
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int n = type_->AsUnion()->Length(); index_ < n; ++index_) {
|
|
|
|
if (matches(type_->AsUnion()->Get(index_))) return;
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
|
|
|
} else if (index_ == 0 && matches(type_)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
index_ = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Conversion between low-level representations.
|
|
|
|
|
2014-01-24 11:47:47 +00:00
|
|
|
template<class Config>
|
|
|
|
template<class OtherType>
|
|
|
|
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
|
|
|
|
typename OtherType::TypeHandle type, Region* region) {
|
|
|
|
if (type->IsBitset()) {
|
2014-04-16 16:16:37 +00:00
|
|
|
return BitsetType::New(type->AsBitset(), region);
|
2014-01-24 11:47:47 +00:00
|
|
|
} else if (type->IsClass()) {
|
2014-09-24 07:33:51 +00:00
|
|
|
return ClassType::New(type->AsClass()->Map(), region);
|
2014-01-24 11:47:47 +00:00
|
|
|
} else if (type->IsConstant()) {
|
2014-09-24 07:33:51 +00:00
|
|
|
return ConstantType::New(type->AsConstant()->Value(), region);
|
2014-08-07 15:30:16 +00:00
|
|
|
} else if (type->IsRange()) {
|
|
|
|
return RangeType::New(
|
2014-09-24 07:33:51 +00:00
|
|
|
type->AsRange()->Min(), type->AsRange()->Max(), region);
|
2014-05-26 13:10:52 +00:00
|
|
|
} else if (type->IsContext()) {
|
|
|
|
TypeHandle outer = Convert<OtherType>(type->AsContext()->Outer(), region);
|
2014-09-24 07:33:51 +00:00
|
|
|
return ContextType::New(outer, region);
|
2014-04-16 16:16:37 +00:00
|
|
|
} else if (type->IsUnion()) {
|
|
|
|
int length = type->AsUnion()->Length();
|
|
|
|
UnionHandle unioned = UnionType::New(length, region);
|
2014-01-24 11:47:47 +00:00
|
|
|
for (int i = 0; i < length; ++i) {
|
2014-08-06 12:41:37 +00:00
|
|
|
TypeHandle t = Convert<OtherType>(type->AsUnion()->Get(i), region);
|
|
|
|
unioned->Set(i, t);
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
|
|
|
return unioned;
|
|
|
|
} else if (type->IsArray()) {
|
2014-08-06 12:41:37 +00:00
|
|
|
TypeHandle element = Convert<OtherType>(type->AsArray()->Element(), region);
|
2014-09-24 07:33:51 +00:00
|
|
|
return ArrayType::New(element, region);
|
2014-04-16 16:16:37 +00:00
|
|
|
} else if (type->IsFunction()) {
|
2014-08-06 12:41:37 +00:00
|
|
|
TypeHandle res = Convert<OtherType>(type->AsFunction()->Result(), region);
|
|
|
|
TypeHandle rcv = Convert<OtherType>(type->AsFunction()->Receiver(), region);
|
2014-04-16 16:16:37 +00:00
|
|
|
FunctionHandle function = FunctionType::New(
|
2014-09-24 07:33:51 +00:00
|
|
|
res, rcv, type->AsFunction()->Arity(), region);
|
2014-04-16 16:16:37 +00:00
|
|
|
for (int i = 0; i < function->Arity(); ++i) {
|
2014-08-06 12:41:37 +00:00
|
|
|
TypeHandle param = Convert<OtherType>(
|
|
|
|
type->AsFunction()->Parameter(i), region);
|
|
|
|
function->InitParameter(i, param);
|
2014-01-24 11:47:47 +00:00
|
|
|
}
|
2014-04-16 16:16:37 +00:00
|
|
|
return function;
|
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
|
|
|
return None(region);
|
2014-01-24 11:47:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-27 13:52:31 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Printing.
|
2013-07-05 09:26:22 +00:00
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template<class Config>
|
2014-09-16 12:58:43 +00:00
|
|
|
const char* TypeImpl<Config>::BitsetType::Name(bitset bits) {
|
|
|
|
switch (bits) {
|
2014-05-26 13:10:52 +00:00
|
|
|
case REPRESENTATION(kAny): return "Any";
|
|
|
|
#define RETURN_NAMED_REPRESENTATION_TYPE(type, value) \
|
|
|
|
case REPRESENTATION(k##type): return #type;
|
|
|
|
REPRESENTATION_BITSET_TYPE_LIST(RETURN_NAMED_REPRESENTATION_TYPE)
|
|
|
|
#undef RETURN_NAMED_REPRESENTATION_TYPE
|
2014-03-18 11:50:18 +00:00
|
|
|
|
2014-05-26 13:10:52 +00:00
|
|
|
#define RETURN_NAMED_SEMANTIC_TYPE(type, value) \
|
|
|
|
case SEMANTIC(k##type): return #type;
|
|
|
|
SEMANTIC_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
|
|
|
|
#undef RETURN_NAMED_SEMANTIC_TYPE
|
2014-03-18 11:50:18 +00:00
|
|
|
|
2013-11-22 12:38:49 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-03 07:18:30 +00:00
|
|
|
template <class Config>
|
2014-09-30 10:29:32 +00:00
|
|
|
void TypeImpl<Config>::BitsetType::Print(std::ostream& os, // NOLINT
|
2014-09-16 12:58:43 +00:00
|
|
|
bitset bits) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-09-16 12:58:43 +00:00
|
|
|
const char* name = Name(bits);
|
2014-03-18 11:50:18 +00:00
|
|
|
if (name != NULL) {
|
2014-07-03 07:18:30 +00:00
|
|
|
os << name;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-16 12:58:43 +00:00
|
|
|
static const bitset named_bitsets[] = {
|
2014-07-03 07:18:30 +00:00
|
|
|
#define BITSET_CONSTANT(type, value) REPRESENTATION(k##type),
|
2014-03-18 11:50:18 +00:00
|
|
|
REPRESENTATION_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
2014-07-03 07:18:30 +00:00
|
|
|
#undef BITSET_CONSTANT
|
2014-03-18 11:50:18 +00:00
|
|
|
|
2014-07-03 07:18:30 +00:00
|
|
|
#define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
|
2014-03-18 11:50:18 +00:00
|
|
|
SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
2014-07-03 07:18:30 +00:00
|
|
|
#undef BITSET_CONSTANT
|
|
|
|
};
|
|
|
|
|
|
|
|
bool is_first = true;
|
|
|
|
os << "(";
|
2014-09-16 12:58:43 +00:00
|
|
|
for (int i(arraysize(named_bitsets) - 1); bits != 0 && i >= 0; --i) {
|
|
|
|
bitset subset = named_bitsets[i];
|
|
|
|
if ((bits & subset) == subset) {
|
2014-07-03 07:18:30 +00:00
|
|
|
if (!is_first) os << " | ";
|
|
|
|
is_first = false;
|
|
|
|
os << Name(subset);
|
2014-09-16 12:58:43 +00:00
|
|
|
bits -= subset;
|
2014-03-18 11:50:18 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-16 12:58:43 +00:00
|
|
|
DCHECK(bits == 0);
|
2014-07-03 07:18:30 +00:00
|
|
|
os << ")";
|
2014-03-18 11:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-03 07:18:30 +00:00
|
|
|
template <class Config>
|
2014-09-30 10:29:32 +00:00
|
|
|
void TypeImpl<Config>::PrintTo(std::ostream& os, PrintDimension dim) {
|
2014-04-16 16:16:37 +00:00
|
|
|
DisallowHeapAllocation no_allocation;
|
2014-05-27 13:52:31 +00:00
|
|
|
if (dim != REPRESENTATION_DIM) {
|
|
|
|
if (this->IsBitset()) {
|
2014-07-03 07:18:30 +00:00
|
|
|
BitsetType::Print(os, SEMANTIC(this->AsBitset()));
|
2014-05-27 13:52:31 +00:00
|
|
|
} else if (this->IsClass()) {
|
2014-07-03 07:18:30 +00:00
|
|
|
os << "Class(" << static_cast<void*>(*this->AsClass()->Map()) << " < ";
|
2014-08-05 11:27:26 +00:00
|
|
|
BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
|
2014-07-03 07:18:30 +00:00
|
|
|
os << ")";
|
2014-05-27 13:52:31 +00:00
|
|
|
} else if (this->IsConstant()) {
|
2014-09-25 08:31:23 +00:00
|
|
|
os << "Constant(" << Brief(*this->AsConstant()->Value()) << ")";
|
2014-07-22 17:33:22 +00:00
|
|
|
} else if (this->IsRange()) {
|
2014-11-13 09:02:07 +00:00
|
|
|
std::ostream::fmtflags saved_flags = os.setf(std::ios::fixed);
|
|
|
|
std::streamsize saved_precision = os.precision(0);
|
2014-11-13 05:18:26 +00:00
|
|
|
os << "Range(" << this->AsRange()->Min()->Number() << ", "
|
|
|
|
<< this->AsRange()->Max()->Number() << ")";
|
2014-11-13 09:02:07 +00:00
|
|
|
os.flags(saved_flags);
|
|
|
|
os.precision(saved_precision);
|
2014-05-27 13:52:31 +00:00
|
|
|
} else if (this->IsContext()) {
|
2014-07-03 07:18:30 +00:00
|
|
|
os << "Context(";
|
|
|
|
this->AsContext()->Outer()->PrintTo(os, dim);
|
|
|
|
os << ")";
|
2014-05-27 13:52:31 +00:00
|
|
|
} else if (this->IsUnion()) {
|
2014-07-03 07:18:30 +00:00
|
|
|
os << "(";
|
2014-09-25 08:02:12 +00:00
|
|
|
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
|
|
|
TypeHandle type_i = this->AsUnion()->Get(i);
|
2014-07-03 07:18:30 +00:00
|
|
|
if (i > 0) os << " | ";
|
|
|
|
type_i->PrintTo(os, dim);
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
2014-07-03 07:18:30 +00:00
|
|
|
os << ")";
|
2014-05-27 13:52:31 +00:00
|
|
|
} else if (this->IsArray()) {
|
2014-07-03 07:18:30 +00:00
|
|
|
os << "Array(";
|
|
|
|
AsArray()->Element()->PrintTo(os, dim);
|
|
|
|
os << ")";
|
2014-05-27 13:52:31 +00:00
|
|
|
} else if (this->IsFunction()) {
|
|
|
|
if (!this->AsFunction()->Receiver()->IsAny()) {
|
2014-07-03 07:18:30 +00:00
|
|
|
this->AsFunction()->Receiver()->PrintTo(os, dim);
|
|
|
|
os << ".";
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
2014-07-03 07:18:30 +00:00
|
|
|
os << "(";
|
2014-05-27 13:52:31 +00:00
|
|
|
for (int i = 0; i < this->AsFunction()->Arity(); ++i) {
|
2014-07-03 07:18:30 +00:00
|
|
|
if (i > 0) os << ", ";
|
|
|
|
this->AsFunction()->Parameter(i)->PrintTo(os, dim);
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
2014-07-03 07:18:30 +00:00
|
|
|
os << ")->";
|
|
|
|
this->AsFunction()->Result()->PrintTo(os, dim);
|
2014-05-27 13:52:31 +00:00
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
2014-04-16 16:16:37 +00:00
|
|
|
}
|
2014-05-27 13:52:31 +00:00
|
|
|
}
|
2014-07-03 07:18:30 +00:00
|
|
|
if (dim == BOTH_DIMS) os << "/";
|
2014-05-27 13:52:31 +00:00
|
|
|
if (dim != SEMANTIC_DIM) {
|
2014-07-03 07:18:30 +00:00
|
|
|
BitsetType::Print(os, REPRESENTATION(this->BitsetLub()));
|
2013-07-10 11:20:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-06 09:26:49 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
template <class Config>
|
|
|
|
void TypeImpl<Config>::Print() {
|
|
|
|
OFStream os(stdout);
|
|
|
|
PrintTo(os);
|
2014-09-30 10:29:32 +00:00
|
|
|
os << std::endl;
|
2014-08-06 09:26:49 +00:00
|
|
|
}
|
2014-09-24 07:33:51 +00:00
|
|
|
template <class Config>
|
|
|
|
void TypeImpl<Config>::BitsetType::Print(bitset bits) {
|
|
|
|
OFStream os(stdout);
|
|
|
|
Print(os, bits);
|
2014-09-30 10:29:32 +00:00
|
|
|
os << std::endl;
|
2014-09-24 07:33:51 +00:00
|
|
|
}
|
2014-08-06 09:26:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-05-27 13:52:31 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Instantiations.
|
|
|
|
|
Retry landing "Implement zone-allocated types"
Works around apparent scoping bug in VS, the only change to before being a method rename in the test suite:
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -153,7 +153,7 @@ struct ZoneRep {
return reinterpret_cast<ZoneList<ZoneType*>*>(AsTagged(t));
}
- static Zone* Region(Zone* zone, Isolate* isolate) { return zone; }
+ static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; }
};
@@ -168,7 +168,7 @@ struct HeapRep {
static Object* AsConstant(Handle<Type> t) { return Box::cast(*t)->value(); }
static FixedArray* AsUnion(Handle<Type> t) { return FixedArray::cast(*t); }
- static Isolate* Region(Zone* zone, Isolate* isolate) { return isolate; }
+ static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; }
};
@@ -183,7 +183,7 @@ struct Tests : Rep {
isolate(CcTest::i_isolate()),
scope(isolate),
zone(isolate),
- T(Rep::Region(&zone, isolate), isolate) {
+ T(Rep::ToRegion(&zone, isolate), isolate) {
}
static void CheckEqual(TypeHandle type1, TypeHandle type2) {
R=titzer@chromium.org
BUG=
Review URL: https://codereview.chromium.org/143693003
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18711 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-01-21 14:14:12 +00:00
|
|
|
template class TypeImpl<ZoneTypeConfig>;
|
|
|
|
template class TypeImpl<ZoneTypeConfig>::Iterator<i::Map>;
|
|
|
|
template class TypeImpl<ZoneTypeConfig>::Iterator<i::Object>;
|
|
|
|
|
2014-01-10 12:19:01 +00:00
|
|
|
template class TypeImpl<HeapTypeConfig>;
|
|
|
|
template class TypeImpl<HeapTypeConfig>::Iterator<i::Map>;
|
|
|
|
template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
|
|
|
|
|
2014-01-24 11:47:47 +00:00
|
|
|
template TypeImpl<ZoneTypeConfig>::TypeHandle
|
|
|
|
TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
|
|
|
|
TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
|
|
|
|
template TypeImpl<HeapTypeConfig>::TypeHandle
|
|
|
|
TypeImpl<HeapTypeConfig>::Convert<Type>(
|
|
|
|
TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
|
|
|
|
|
2013-06-05 15:43:53 +00:00
|
|
|
} } // namespace v8::internal
|