Commit 75cdb913 authored by jarin's avatar jarin Committed by Commit bot

Move FieldType to separate h/cc files.

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

Cr-Commit-Position: refs/heads/master@{#34026}
parent 70910752
......@@ -1020,6 +1020,8 @@ source_set("v8_base") {
"src/fast-dtoa.h",
"src/field-index.h",
"src/field-index-inl.h",
"src/field-type.cc",
"src/field-type.h",
"src/fixed-dtoa.cc",
"src/fixed-dtoa.h",
"src/flag-definitions.h",
......
......@@ -8,9 +8,7 @@
#include "src/allocation.h"
#include "src/ast/ast.h"
#include "src/ast/scopes.h"
#include "src/effects.h"
#include "src/type-info.h"
#include "src/types.h"
#include "src/zone.h"
namespace v8 {
......
......@@ -8,9 +8,7 @@
#include "src/allocation.h"
#include "src/ast/ast.h"
#include "src/ast/scopes.h"
#include "src/effects.h"
#include "src/type-info.h"
#include "src/types.h"
#include "src/zone.h"
namespace v8 {
......
// Copyright 2016 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.
#include "src/field-type.h"
#include "src/handles-inl.h"
#include "src/ostreams.h"
#include "src/types.h"
namespace v8 {
namespace internal {
// static
FieldType* FieldType::None() {
return reinterpret_cast<FieldType*>(Smi::FromInt(0));
}
// static
FieldType* FieldType::Any() {
return reinterpret_cast<FieldType*>(Smi::FromInt(1));
}
// static
Handle<FieldType> FieldType::None(Isolate* isolate) {
return handle(None(), isolate);
}
// static
Handle<FieldType> FieldType::Any(Isolate* isolate) {
return handle(Any(), isolate);
}
// static
FieldType* FieldType::Class(i::Map* map) { return FieldType::cast(map); }
// static
Handle<FieldType> FieldType::Class(i::Handle<i::Map> map, Isolate* isolate) {
return handle(Class(*map), isolate);
}
// static
FieldType* FieldType::cast(Object* object) {
DCHECK(object == None() || object == Any() || object->IsMap());
return reinterpret_cast<FieldType*>(object);
}
bool FieldType::NowContains(Object* value) {
if (this == Any()) return true;
if (this == None()) return false;
if (!value->IsHeapObject()) return false;
return HeapObject::cast(value)->map() == Map::cast(this);
}
bool FieldType::NowContains(Handle<Object> value) {
return NowContains(*value);
}
bool FieldType::IsClass() { return this->IsMap(); }
Handle<i::Map> FieldType::AsClass() {
DCHECK(IsClass());
i::Map* map = Map::cast(this);
return handle(map, map->GetIsolate());
}
bool FieldType::NowStable() {
return !this->IsClass() || this->AsClass()->is_stable();
}
bool FieldType::NowIs(FieldType* other) {
if (other->IsAny()) return true;
if (IsNone()) return true;
if (other->IsNone()) return false;
if (IsAny()) return false;
DCHECK(IsClass());
DCHECK(other->IsClass());
return this == other;
}
bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); }
Type* FieldType::Convert(Zone* zone) {
if (IsAny()) return Type::Any();
if (IsNone()) return Type::None();
DCHECK(IsClass());
return Type::Class(AsClass(), zone);
}
void FieldType::PrintTo(std::ostream& os) {
if (IsAny()) {
os << "Any";
} else if (IsNone()) {
os << "None";
} else {
DCHECK(IsClass());
os << "Class(" << static_cast<void*>(*AsClass()) << ")";
}
}
} // namespace internal
} // namespace v8
// Copyright 2016 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.
#ifndef V8_FIELD_TYPE_H_
#define V8_FIELD_TYPE_H_
#include "src/handles.h"
#include "src/objects.h"
#include "src/ostreams.h"
namespace v8 {
namespace internal {
class FieldType : public Object {
public:
static FieldType* None();
static FieldType* Any();
static Handle<FieldType> None(Isolate* isolate);
static Handle<FieldType> Any(Isolate* isolate);
static FieldType* Class(i::Map* map);
static Handle<FieldType> Class(i::Handle<i::Map> map, Isolate* isolate);
static FieldType* cast(Object* object);
bool NowContains(Object* value);
bool NowContains(Handle<Object> value);
bool IsClass();
Handle<i::Map> AsClass();
bool IsNone() { return this == None(); }
bool IsAny() { return this == Any(); }
bool NowStable();
bool NowIs(FieldType* other);
bool NowIs(Handle<FieldType> other);
Type* Convert(Zone* zone);
void PrintTo(std::ostream& os);
};
} // namespace internal
} // namespace v8
#endif // V8_FIELD_TYPE_H_
......@@ -13,7 +13,6 @@
#include "src/parsing/scanner.h"
#include "src/parsing/token.h"
#include "src/transitions.h"
#include "src/types.h"
namespace v8 {
namespace internal {
......
......@@ -11,7 +11,6 @@
#include "src/profiler/allocation-tracker.h"
#include "src/profiler/heap-profiler.h"
#include "src/profiler/heap-snapshot-generator-inl.h"
#include "src/types.h"
namespace v8 {
namespace internal {
......
......@@ -9,8 +9,8 @@
#include "src/factory.h"
#include "src/field-index.h"
#include "src/field-type.h"
#include "src/isolate.h"
#include "src/types.h"
namespace v8 {
namespace internal {
......
......@@ -1258,93 +1258,6 @@ void BitsetType::Print(bitset bits) {
}
#endif
// static
FieldType* FieldType::None() {
return reinterpret_cast<FieldType*>(Smi::FromInt(0));
}
// static
FieldType* FieldType::Any() {
return reinterpret_cast<FieldType*>(Smi::FromInt(1));
}
// static
Handle<FieldType> FieldType::None(Isolate* isolate) {
return handle(None(), isolate);
}
// static
Handle<FieldType> FieldType::Any(Isolate* isolate) {
return handle(Any(), isolate);
}
// static
FieldType* FieldType::Class(i::Map* map) { return FieldType::cast(map); }
// static
Handle<FieldType> FieldType::Class(i::Handle<i::Map> map, Isolate* isolate) {
return handle(Class(*map), isolate);
}
// static
FieldType* FieldType::cast(Object* object) {
DCHECK(object == None() || object == Any() || object->IsMap());
return reinterpret_cast<FieldType*>(object);
}
bool FieldType::NowContains(Object* value) {
if (this == Any()) return true;
if (this == None()) return false;
if (!value->IsHeapObject()) return false;
return HeapObject::cast(value)->map() == Map::cast(this);
}
bool FieldType::NowContains(Handle<Object> value) {
return NowContains(*value);
}
bool FieldType::IsClass() { return this->IsMap(); }
Handle<i::Map> FieldType::AsClass() {
DCHECK(IsClass());
i::Map* map = Map::cast(this);
return handle(map, map->GetIsolate());
}
bool FieldType::NowStable() {
return !this->IsClass() || this->AsClass()->is_stable();
}
bool FieldType::NowIs(FieldType* other) {
if (other->IsAny()) return true;
if (IsNone()) return true;
if (other->IsNone()) return false;
if (IsAny()) return false;
DCHECK(IsClass());
DCHECK(other->IsClass());
return this == other;
}
bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); }
Type* FieldType::Convert(Zone* zone) {
if (IsAny()) return Type::Any();
if (IsNone()) return Type::None();
DCHECK(IsClass());
return Type::Class(AsClass(), zone);
}
void FieldType::PrintTo(std::ostream& os) {
if (IsAny()) {
os << "Any";
} else if (IsNone()) {
os << "None";
} else {
DCHECK(IsClass());
os << "Class(" << static_cast<void*>(*AsClass()) << ")";
}
}
BitsetType::bitset BitsetType::SignedSmall() {
return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32;
}
......
......@@ -964,30 +964,6 @@ struct Bounds {
}
};
class FieldType : public Object {
public:
static FieldType* None();
static FieldType* Any();
static Handle<FieldType> None(Isolate* isolate);
static Handle<FieldType> Any(Isolate* isolate);
static FieldType* Class(i::Map* map);
static Handle<FieldType> Class(i::Handle<i::Map> map, Isolate* isolate);
static FieldType* cast(Object* object);
bool NowContains(Object* value);
bool NowContains(Handle<Object> value);
bool IsClass();
Handle<i::Map> AsClass();
bool IsNone() { return this == None(); }
bool IsAny() { return this == Any(); }
bool NowStable();
bool NowIs(FieldType* other);
bool NowIs(Handle<FieldType> other);
Type* Convert(Zone* zone);
void PrintTo(std::ostream& os);
};
} // namespace internal
} // namespace v8
......
......@@ -843,6 +843,8 @@
'../../src/fast-dtoa.h',
'../../src/field-index.h',
'../../src/field-index-inl.h',
'../../src/field-type.cc',
'../../src/field-type.h',
'../../src/fixed-dtoa.cc',
'../../src/fixed-dtoa.h',
'../../src/flag-definitions.h',
......
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