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

Unified Diff: src/compiler/types.cc

Issue 2309823002: [turbofan] put src/types.[h/cc] into src/compiler/types.[h/cc] (Closed)
Patch Set: Updates/comments. Created 4 years, 3 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/compiler/types.h ('k') | src/property-details.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/types.cc
diff --git a/src/types.cc b/src/compiler/types.cc
similarity index 96%
rename from src/types.cc
rename to src/compiler/types.cc
index d2b5e2b8e13cc2b75ecacf28d1bfbe76b0f470c9..1b0b88dee2b982e1ea683197d5c9dc9eb7ae88eb 100644
--- a/src/types.cc
+++ b/src/compiler/types.cc
@@ -4,14 +4,14 @@
#include <iomanip>
-#include "src/types.h"
+#include "src/compiler/types.h"
#include "src/handles-inl.h"
#include "src/ostreams.h"
namespace v8 {
namespace internal {
-
+namespace compiler {
// 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.
@@ -58,18 +58,16 @@ bool Type::Contains(RangeType* lhs, RangeType* rhs) {
bool Type::Contains(RangeType* lhs, ConstantType* rhs) {
DisallowHeapAllocation no_allocation;
- return IsInteger(*rhs->Value()) &&
- lhs->Min() <= rhs->Value()->Number() &&
+ return IsInteger(*rhs->Value()) && lhs->Min() <= rhs->Value()->Number() &&
rhs->Value()->Number() <= lhs->Max();
}
bool Type::Contains(RangeType* range, i::Object* val) {
DisallowHeapAllocation no_allocation;
- return IsInteger(val) &&
- range->Min() <= val->Number() && val->Number() <= range->Max();
+ return IsInteger(val) && range->Min() <= val->Number() &&
+ val->Number() <= range->Max();
}
-
// -----------------------------------------------------------------------------
// Min and Max computation.
@@ -105,11 +103,9 @@ double Type::Max() {
return 0;
}
-
// -----------------------------------------------------------------------------
// Glb and lub computation.
-
// The largest bitset subsumed by this type.
Type::bitset BitsetType::Glb(Type* type) {
DisallowHeapAllocation no_allocation;
@@ -129,7 +125,6 @@ Type::bitset BitsetType::Glb(Type* type) {
}
}
-
// The smallest bitset subsuming this type, possibly not a proper one.
Type::bitset BitsetType::Lub(Type* type) {
DisallowHeapAllocation no_allocation;
@@ -286,7 +281,7 @@ Type::bitset BitsetType::Lub(i::Object* value) {
DisallowHeapAllocation no_allocation;
if (value->IsNumber()) {
return Lub(value->Number()) &
- (value->IsSmi() ? kTaggedSigned : kTaggedPointer);
+ (value->IsSmi() ? kTaggedSigned : kTaggedPointer);
}
return Lub(i::HeapObject::cast(value)->map());
}
@@ -299,7 +294,6 @@ Type::bitset BitsetType::Lub(double value) {
return kOtherNumber;
}
-
// Minimum values of plain numeric bitsets.
const BitsetType::Boundary BitsetType::BoundariesArray[] = {
{kOtherNumber, kPlainNumber, -V8_INFINITY},
@@ -337,7 +331,7 @@ Type::bitset BitsetType::Lub(double min, double max) {
for (size_t i = 1; i < BoundariesSize(); ++i) {
if (min < mins[i].min) {
- lub |= mins[i-1].internal;
+ lub |= mins[i - 1].internal;
if (max < mins[i].min) return lub;
}
}
@@ -391,23 +385,21 @@ double BitsetType::Max(bitset bits) {
}
for (size_t i = BoundariesSize() - 1; i-- > 0;) {
if (Is(SEMANTIC(mins[i].internal), bits)) {
- return mz ?
- std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1;
+ return mz ? std::max(0.0, mins[i + 1].min - 1) : mins[i + 1].min - 1;
}
}
if (mz) return 0;
return std::numeric_limits<double>::quiet_NaN();
}
-
// -----------------------------------------------------------------------------
// Predicates.
bool Type::SimplyEquals(Type* that) {
DisallowHeapAllocation no_allocation;
if (this->IsConstant()) {
- return that->IsConstant()
- && *this->AsConstant()->Value() == *that->AsConstant()->Value();
+ return that->IsConstant() &&
+ *this->AsConstant()->Value() == *that->AsConstant()->Value();
}
if (this->IsTuple()) {
if (!that->IsTuple()) return false;
@@ -429,7 +421,6 @@ Type::bitset Type::Representation() {
return REPRESENTATION(this->BitsetLub());
}
-
// Check if [this] <= [that].
bool Type::SlowIs(Type* that) {
DisallowHeapAllocation no_allocation;
@@ -452,7 +443,6 @@ bool Type::SlowIs(Type* that) {
return SemanticIs(that);
}
-
// Check if SEMANTIC([this]) <= SEMANTIC([that]). The result of the method
// should be independent of the representation axis of the types.
bool Type::SemanticIs(Type* that) {
@@ -494,7 +484,6 @@ bool Type::SemanticIs(Type* that) {
return this->SimplyEquals(that);
}
-
// Check if [this] and [that] overlap.
bool Type::Maybe(Type* that) {
DisallowHeapAllocation no_allocation;
@@ -557,7 +546,6 @@ bool Type::SemanticMaybe(Type* that) {
return this->SimplyEquals(that);
}
-
// Return the range in [this], or [NULL].
Type* Type::GetRange() {
DisallowHeapAllocation no_allocation;
@@ -590,7 +578,7 @@ bool UnionType::Wellformed() {
// 5. No element (except the bitset) is a subtype of any other.
// 6. If there is a range, then the bitset type does not contain
// plain number bits.
- DCHECK(this->Length() >= 2); // (1)
+ DCHECK(this->Length() >= 2); // (1)
DCHECK(this->Get(0)->IsBitset()); // (2a)
for (int i = 0; i < this->Length(); ++i) {
@@ -608,15 +596,12 @@ bool UnionType::Wellformed() {
return true;
}
-
// -----------------------------------------------------------------------------
// Union and intersection
-
static bool AddIsSafe(int x, int y) {
- return x >= 0 ?
- y <= std::numeric_limits<int>::max() - x :
- y >= std::numeric_limits<int>::min() - x;
+ return x >= 0 ? y <= std::numeric_limits<int>::max() - x
+ : y >= std::numeric_limits<int>::min() - x;
}
Type* Type::Intersect(Type* type1, Type* type2, Zone* zone) {
@@ -694,7 +679,7 @@ int Type::UpdateRange(Type* range, UnionType* result, int size, Zone* zone) {
}
// Remove any components that just got subsumed.
- for (int i = 2; i < size; ) {
+ for (int i = 2; i < size;) {
if (result->Get(i)->SemanticIs(range)) {
result->Set(i, result->Get(--size));
} else {
@@ -777,7 +762,6 @@ int Type::IntersectAux(Type* lhs, Type* rhs, UnionType* result, int size,
return size;
}
-
// Make sure that we produce a well-formed range and bitset:
// If the range is non-empty, the number bits in the bitset should be
// clear. Moreover, if we have a canonical range (such as Signed32),
@@ -883,7 +867,6 @@ Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
return NormalizeUnion(result_type, size, zone);
}
-
// Add [type] to [result] unless [type] is bitset, range, or already subsumed.
// Return new size of [result].
int Type::AddToUnion(Type* type, UnionType* result, int size, Zone* zone) {
@@ -927,7 +910,6 @@ Type* Type::NormalizeUnion(Type* union_type, int size, Zone* zone) {
return union_type;
}
-
// -----------------------------------------------------------------------------
// Component extraction
@@ -936,13 +918,11 @@ Type* Type::Representation(Type* t, Zone* zone) {
return BitsetType::New(t->Representation());
}
-
// static
Type* Type::Semantic(Type* t, Zone* zone) {
return Intersect(t, BitsetType::New(BitsetType::kSemantic), zone);
}
-
// -----------------------------------------------------------------------------
// Iteration.
@@ -967,7 +947,6 @@ Type* Type::Iterator<T>::get_type() {
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 T>
@@ -1008,23 +987,25 @@ void Type::Iterator<T>::Advance() {
index_ = -1;
}
-
// -----------------------------------------------------------------------------
// Printing.
const char* BitsetType::Name(bitset bits) {
switch (bits) {
- 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
-
- #define RETURN_NAMED_SEMANTIC_TYPE(type, value) \
- case SEMANTIC(k##type): return #type;
- SEMANTIC_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
- INTERNAL_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
- #undef RETURN_NAMED_SEMANTIC_TYPE
+ 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
+
+#define RETURN_NAMED_SEMANTIC_TYPE(type, value) \
+ case SEMANTIC(k##type): \
+ return #type;
+ SEMANTIC_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
+ INTERNAL_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
+#undef RETURN_NAMED_SEMANTIC_TYPE
default:
return NULL;
@@ -1108,7 +1089,6 @@ void Type::PrintTo(std::ostream& os, PrintDimension dim) {
}
}
-
#ifdef DEBUG
void Type::Print() {
OFStream os(stdout);
@@ -1135,5 +1115,6 @@ BitsetType::bitset BitsetType::UnsignedSmall() {
template class Type::Iterator<i::Object>;
+} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/compiler/types.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698