Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: src/types-inl.h

Issue 882063002: [turbofan] Use unboxed doubles in range types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make tests less fragile. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/types.cc ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types-inl.h
diff --git a/src/types-inl.h b/src/types-inl.h
index c22dfd4fcc3bf365cdf68ac2ab1601f56a4ffa86..762a11df303d85f6c8289d8526564233140def4d 100644
--- a/src/types-inl.h
+++ b/src/types-inl.h
@@ -96,7 +96,18 @@ bool ZoneTypeConfig::is_bitset(Type* type) {
// static
bool ZoneTypeConfig::is_struct(Type* type, int tag) {
- return !is_bitset(type) && struct_tag(as_struct(type)) == tag;
+ DCHECK(tag != kRangeStructTag);
+ if (is_bitset(type)) return false;
+ int type_tag = struct_tag(as_struct(type));
+ return type_tag == tag;
+}
+
+
+// static
+bool ZoneTypeConfig::is_range(Type* type) {
+ if (is_bitset(type)) return false;
+ int type_tag = struct_tag(as_struct(type));
+ return type_tag == kRangeStructTag;
}
@@ -121,6 +132,13 @@ ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) {
// static
+ZoneTypeConfig::Range* ZoneTypeConfig::as_range(Type* type) {
+ DCHECK(!is_bitset(type));
+ return reinterpret_cast<Range*>(type);
+}
+
+
+// static
i::Handle<i::Map> ZoneTypeConfig::as_class(Type* type) {
UNREACHABLE();
return i::Handle<i::Map>();
@@ -147,6 +165,12 @@ ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structure) {
// static
+ZoneTypeConfig::Type* ZoneTypeConfig::from_range(Range* range) {
+ return reinterpret_cast<Type*>(range);
+}
+
+
+// static
ZoneTypeConfig::Type* ZoneTypeConfig::from_class(
i::Handle<i::Map> map, Zone* zone) {
return from_bitset(0);
@@ -156,6 +180,7 @@ ZoneTypeConfig::Type* ZoneTypeConfig::from_class(
// static
ZoneTypeConfig::Struct* ZoneTypeConfig::struct_create(
int tag, int length, Zone* zone) {
+ DCHECK(tag != kRangeStructTag);
Struct* structure = reinterpret_cast<Struct*>(
zone->New(sizeof(void*) * (length + 2))); // NOLINT
structure[0] = reinterpret_cast<void*>(tag);
@@ -214,6 +239,45 @@ void ZoneTypeConfig::struct_set_value(
}
+// static
+ZoneTypeConfig::Range* ZoneTypeConfig::range_create(Zone* zone) {
+ Range* range = reinterpret_cast<Range*>(zone->New(sizeof(Range))); // NOLINT
+ range->tag = reinterpret_cast<void*>(kRangeStructTag);
+ range->bitset = 0;
+ range->limits[0] = 1;
+ range->limits[1] = 0;
+ return range;
+}
+
+
+// static
+int ZoneTypeConfig::range_get_bitset(ZoneTypeConfig::Range* range) {
+ return range->bitset;
+}
+
+
+// static
+void ZoneTypeConfig::range_set_bitset(ZoneTypeConfig::Range* range, int value) {
+ range->bitset = value;
+}
+
+
+// static
+double ZoneTypeConfig::range_get_double(ZoneTypeConfig::Range* range,
+ int index) {
+ DCHECK(index >= 0 && index < 2);
+ return range->limits[index];
+}
+
+
+// static
+void ZoneTypeConfig::range_set_double(ZoneTypeConfig::Range* range, int index,
+ double value, Zone*) {
+ DCHECK(index >= 0 && index < 2);
+ range->limits[index] = value;
+}
+
+
// -----------------------------------------------------------------------------
// HeapTypeConfig
@@ -252,11 +316,18 @@ bool HeapTypeConfig::is_class(Type* type) {
// static
bool HeapTypeConfig::is_struct(Type* type, int tag) {
+ DCHECK(tag != kRangeStructTag);
return type->IsFixedArray() && struct_tag(as_struct(type)) == tag;
}
// static
+bool HeapTypeConfig::is_range(Type* type) {
+ return type->IsFixedArray() && struct_tag(as_struct(type)) == kRangeStructTag;
+}
+
+
+// static
HeapTypeConfig::Type::bitset HeapTypeConfig::as_bitset(Type* type) {
// TODO(rossberg): Breaks the Smi abstraction. Fix once there is a better way.
return static_cast<Type::bitset>(reinterpret_cast<uintptr_t>(type));
@@ -276,6 +347,12 @@ i::Handle<HeapTypeConfig::Struct> HeapTypeConfig::as_struct(Type* type) {
// static
+i::Handle<HeapTypeConfig::Range> HeapTypeConfig::as_range(Type* type) {
+ return i::handle(Range::cast(type));
+}
+
+
+// static
HeapTypeConfig::Type* HeapTypeConfig::from_bitset(Type::bitset bitset) {
// TODO(rossberg): Breaks the Smi abstraction. Fix once there is a better way.
return reinterpret_cast<Type*>(static_cast<uintptr_t>(bitset));
@@ -304,6 +381,13 @@ i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_struct(
// static
+i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_range(
+ i::Handle<Range> range) {
+ return i::Handle<Type>::cast(i::Handle<Object>::cast(range));
+}
+
+
+// static
i::Handle<HeapTypeConfig::Struct> HeapTypeConfig::struct_create(
int tag, int length, Isolate* isolate) {
i::Handle<Struct> structure = isolate->factory()->NewFixedArray(length + 1);
@@ -361,6 +445,46 @@ void HeapTypeConfig::struct_set_value(
structure->set(i + 1, *x);
}
+
+// static
+i::Handle<HeapTypeConfig::Range> HeapTypeConfig::range_create(
+ Isolate* isolate) {
+ i::Handle<Range> range = isolate->factory()->NewFixedArray(4);
+ range->set(0, i::Smi::FromInt(kRangeStructTag));
+ return range;
+}
+
+
+// static
+int HeapTypeConfig::range_get_bitset(i::Handle<HeapTypeConfig::Range> range) {
+ Type* v = static_cast<Type*>(range->get(1));
+ return as_bitset(v);
+}
+
+
+// static
+void HeapTypeConfig::range_set_bitset(i::Handle<HeapTypeConfig::Range> range,
+ int value) {
+ range->set(1, from_bitset(value));
+}
+
+
+// static
+double HeapTypeConfig::range_get_double(i::Handle<HeapTypeConfig::Range> range,
+ int index) {
+ DCHECK(index >= 0 && index < 2);
+ return range->get(index + 2)->Number();
+}
+
+
+// static
+void HeapTypeConfig::range_set_double(i::Handle<HeapTypeConfig::Range> range,
+ int index, double value,
+ Isolate* isolate) {
+ DCHECK(index >= 0 && index < 2);
+ i::Handle<Object> number = isolate->factory()->NewNumber(value);
+ range->set(index + 2, *number);
+}
} } // namespace v8::internal
#endif // V8_TYPES_INL_H_
« no previous file with comments | « src/types.cc ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698