[turbofan] put src/types.[h/cc] into src/compiler/types.[h/cc]

BUG=

Review-Url: https://codereview.chromium.org/2309823002
Cr-Commit-Position: refs/heads/master@{#39181}
This commit is contained in:
mvstanton 2016-09-05 08:58:05 -07:00 committed by Commit bot
parent e5ba156d88
commit c30cc0722e
23 changed files with 62 additions and 85 deletions

View File

@ -1147,6 +1147,8 @@ v8_source_set("v8_base") {
"src/compiler/typed-optimization.h",
"src/compiler/typer.cc",
"src/compiler/typer.h",
"src/compiler/types.cc",
"src/compiler/types.h",
"src/compiler/unwinding-info-writer.h",
"src/compiler/value-numbering-reducer.cc",
"src/compiler/value-numbering-reducer.h",
@ -1617,8 +1619,6 @@ v8_source_set("v8_base") {
"src/type-feedback-vector.h",
"src/type-info.cc",
"src/type-info.h",
"src/types.cc",
"src/types.h",
"src/unicode-cache-inl.h",
"src/unicode-cache.h",
"src/unicode-decoder.cc",

View File

@ -22,6 +22,7 @@ class Factory;
namespace compiler {
// Forward declarations.
class Type;
class TypeCache;
// Whether we are loading a property or storing to a property.

View File

@ -19,7 +19,7 @@ namespace compiler {
class CallDescriptor;
struct CommonOperatorGlobalCache;
class Operator;
class Type;
// Prediction hint for branches.
enum class BranchHint : uint8_t { kNone, kTrue, kFalse };

View File

@ -11,8 +11,8 @@
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/type-cache.h"
#include "src/compiler/types.h"
#include "src/objects-inl.h"
#include "src/types.h"
namespace v8 {
namespace internal {

View File

@ -14,7 +14,7 @@
#include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/type-cache.h"
#include "src/types.h"
#include "src/compiler/types.h"
namespace v8 {
namespace internal {

View File

@ -6,7 +6,7 @@
#define V8_COMPILER_NODE_PROPERTIES_H_
#include "src/compiler/node.h"
#include "src/types.h"
#include "src/compiler/types.h"
namespace v8 {
namespace internal {

View File

@ -7,7 +7,7 @@
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
#include "src/types.h"
#include "src/compiler/types.h"
#include "src/zone-containers.h"
namespace v8 {

View File

@ -6,9 +6,9 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/type-cache.h"
#include "src/compiler/types.h"
#include "src/factory.h"
#include "src/isolate.h"
#include "src/types.h"
#include "src/objects-inl.h"

View File

@ -14,13 +14,13 @@ namespace internal {
// Forward declarations.
class Isolate;
class RangeType;
class Type;
class Zone;
namespace compiler {
// Forward declarations.
class Operator;
class Type;
class TypeCache;
class OperationTyper {

View File

@ -7,7 +7,7 @@
#include "src/base/lazy-instance.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
#include "src/types.h"
#include "src/compiler/types.h"
namespace v8 {
namespace internal {

View File

@ -8,6 +8,7 @@
#include <iosfwd>
#include "src/compiler/operator.h"
#include "src/compiler/types.h"
#include "src/handles.h"
#include "src/machine-type.h"
#include "src/objects.h"
@ -16,10 +17,8 @@ namespace v8 {
namespace internal {
// Forward declarations.
class Type;
class Zone;
namespace compiler {
// Forward declarations.

View File

@ -5,8 +5,8 @@
#ifndef V8_COMPILER_TYPE_CACHE_H_
#define V8_COMPILER_TYPE_CACHE_H_
#include "src/compiler/types.h"
#include "src/date.h"
#include "src/types.h"
namespace v8 {
namespace internal {

View File

@ -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
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
#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

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TYPES_H_
#define V8_TYPES_H_
#ifndef V8_COMPILER_TYPES_H_
#define V8_COMPILER_TYPES_H_
#include "src/conversions.h"
#include "src/handles.h"
@ -12,6 +12,7 @@
namespace v8 {
namespace internal {
namespace compiler {
// SUMMARY
//
@ -242,7 +243,7 @@ namespace internal {
* occur as part of PlainNumber.
*/
#define PROPER_BITSET_TYPE_LIST(V) \
#define PROPER_BITSET_TYPE_LIST(V) \
REPRESENTATION_BITSET_TYPE_LIST(V) \
SEMANTIC_BITSET_TYPE_LIST(V)
@ -336,12 +337,7 @@ class TypeBase {
protected:
friend class Type;
enum Kind {
kConstant,
kTuple,
kUnion,
kRange
};
enum Kind { kConstant, kTuple, kUnion, kRange };
Kind kind() const { return kind_; }
explicit TypeBase(Kind kind) : kind_(kind) {}
@ -776,7 +772,8 @@ struct Bounds {
return that.lower->Is(this->lower) && this->upper->Is(that.upper);
}
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_TYPES_H_
#endif // V8_COMPILER_TYPES_H_

View File

@ -62,7 +62,6 @@ STATIC_ASSERT(SKIP_SYMBOLS ==
static_cast<PropertyFilter>(v8::PropertyFilter::SKIP_SYMBOLS));
class Smi;
class Type;
class TypeInfo;
// Type of properties.

View File

@ -725,6 +725,8 @@
'compiler/store-store-elimination.h',
'compiler/tail-call-optimization.cc',
'compiler/tail-call-optimization.h',
'compiler/types.cc',
'compiler/types.h',
'compiler/type-cache.cc',
'compiler/type-cache.h',
'compiler/type-hint-analyzer.cc',
@ -1215,8 +1217,6 @@
'type-feedback-vector.h',
'type-info.cc',
'type-info.h',
'types.cc',
'types.h',
'unicode-inl.h',
'unicode.cc',
'unicode.h',

View File

@ -18,7 +18,6 @@
#include "src/global-handles.h"
#include "src/ic/stub-cache.h"
#include "src/macro-assembler.h"
#include "src/types.h"
using namespace v8::internal;

View File

@ -28,7 +28,6 @@
#include "test/cctest/cctest.h"
#include "src/property-details.h"
#include "src/types.h"
using namespace v8::internal;

View File

@ -4,6 +4,7 @@
#include <vector>
#include "src/compiler/types.h"
#include "src/crankshaft/hydrogen-types.h"
#include "src/factory.h"
#include "src/heap/heap.h"
@ -11,7 +12,6 @@
// FIXME(mstarzinger, marja): This is weird, but required because of the missing
// (disallowed) include: src/factory.h -> src/objects-inl.h
#include "src/objects-inl.h"
#include "src/types.h"
// FIXME(mstarzinger, marja): This is weird, but required because of the missing
// (disallowed) include: src/type-feedback-vector.h ->
// src/type-feedback-vector-inl.h
@ -20,6 +20,7 @@
#include "test/cctest/types-fuzz.h"
using namespace v8::internal;
using namespace v8::internal::compiler;
namespace {

View File

@ -35,6 +35,7 @@
namespace v8 {
namespace internal {
namespace compiler {
class Types {
public:
@ -206,7 +207,7 @@ class Types {
v8::base::RandomNumberGenerator* rng_;
};
} // namespace compiler
} // namespace internal
} // namespace v8

View File

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/bit-vector.h"
#include "src/compiler/escape-analysis.h"
#include "src/bit-vector.h"
#include "src/compiler/escape-analysis-reducer.h"
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/types.h"
#include "src/compiler/types.h"
#include "src/zone-containers.h"
#include "test/unittests/compiler/graph-unittest.h"

View File

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/simplified-operator.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/simplified-operator-reducer.h"
#include "src/compiler/types.h"
#include "src/conversions-inl.h"
#include "src/types.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"

View File

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/types.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/operator.h"
#include "src/compiler/types.h"
#include "test/unittests/test-utils.h"
namespace v8 {