Commit 17e9e2f4 authored by mvstanton's avatar mvstanton Committed by Commit bot

Forking the type system between Crankshaft & Turbofan.

Our Type class has a semantic and representational dimension.
Much code in src/ast, Crankshaft and Turbofan is based on it.
Going forward in Turbofan we'd like to remove representational information
entirely. To that end, new type AstType has been created to preserve
existing behavior for the benefit of Crankshaft and the AST.

BUG=

Review-Url: https://codereview.chromium.org/2302283002
Cr-Commit-Position: refs/heads/master@{#39135}
parent 6ef6d902
...@@ -857,6 +857,8 @@ v8_source_set("v8_base") { ...@@ -857,6 +857,8 @@ v8_source_set("v8_base") {
"src/ast/ast-numbering.h", "src/ast/ast-numbering.h",
"src/ast/ast-traversal-visitor.h", "src/ast/ast-traversal-visitor.h",
"src/ast/ast-type-bounds.h", "src/ast/ast-type-bounds.h",
"src/ast/ast-types.cc",
"src/ast/ast-types.h",
"src/ast/ast-value-factory.cc", "src/ast/ast-value-factory.cc",
"src/ast/ast-value-factory.h", "src/ast/ast-value-factory.h",
"src/ast/ast.cc", "src/ast/ast.cc",
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/asmjs/asm-types.h" #include "src/asmjs/asm-types.h"
#include "src/ast/ast-type-bounds.h" #include "src/ast/ast-type-bounds.h"
#include "src/ast/ast-types.h"
#include "src/ast/ast.h" #include "src/ast/ast.h"
#include "src/effects.h" #include "src/effects.h"
#include "src/type-info.h" #include "src/type-info.h"
#include "src/types.h"
#include "src/zone-containers.h" #include "src/zone-containers.h"
#include "src/zone.h" #include "src/zone.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef V8_AST_AST_TYPE_BOUNDS_H_ #ifndef V8_AST_AST_TYPE_BOUNDS_H_
#define V8_AST_AST_TYPE_BOUNDS_H_ #define V8_AST_AST_TYPE_BOUNDS_H_
#include "src/types.h" #include "src/ast/ast-types.h"
#include "src/zone-containers.h" #include "src/zone-containers.h"
namespace v8 { namespace v8 {
...@@ -20,18 +20,18 @@ class AstTypeBounds { ...@@ -20,18 +20,18 @@ class AstTypeBounds {
explicit AstTypeBounds(Zone* zone) : bounds_map_(zone) {} explicit AstTypeBounds(Zone* zone) : bounds_map_(zone) {}
~AstTypeBounds() {} ~AstTypeBounds() {}
Bounds get(Expression* expression) const { AstBounds get(Expression* expression) const {
ZoneMap<Expression*, Bounds>::const_iterator i = ZoneMap<Expression*, AstBounds>::const_iterator i =
bounds_map_.find(expression); bounds_map_.find(expression);
return (i != bounds_map_.end()) ? i->second : Bounds::Unbounded(); return (i != bounds_map_.end()) ? i->second : AstBounds::Unbounded();
} }
void set(Expression* expression, Bounds bounds) { void set(Expression* expression, AstBounds bounds) {
bounds_map_[expression] = bounds; bounds_map_[expression] = bounds;
} }
private: private:
ZoneMap<Expression*, Bounds> bounds_map_; ZoneMap<Expression*, AstBounds> bounds_map_;
}; };
} // namespace internal } // namespace internal
......
This diff is collapsed.
This diff is collapsed.
...@@ -950,7 +950,7 @@ CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements, ...@@ -950,7 +950,7 @@ CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements,
: Expression(pos, kCaseClause), : Expression(pos, kCaseClause),
label_(label), label_(label),
statements_(statements), statements_(statements),
compare_type_(Type::None()) {} compare_type_(AstType::None()) {}
void CaseClause::AssignFeedbackVectorSlots(Isolate* isolate, void CaseClause::AssignFeedbackVectorSlots(Isolate* isolate,
FeedbackVectorSpec* spec, FeedbackVectorSpec* spec,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_AST_AST_H_ #ifndef V8_AST_AST_H_
#define V8_AST_AST_H_ #define V8_AST_AST_H_
#include "src/ast/ast-types.h"
#include "src/ast/ast-value-factory.h" #include "src/ast/ast-value-factory.h"
#include "src/ast/modules.h" #include "src/ast/modules.h"
#include "src/ast/variables.h" #include "src/ast/variables.h"
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
#include "src/parsing/token.h" #include "src/parsing/token.h"
#include "src/runtime/runtime.h" #include "src/runtime/runtime.h"
#include "src/small-pointer-list.h" #include "src/small-pointer-list.h"
#include "src/types.h"
#include "src/utils.h" #include "src/utils.h"
namespace v8 { namespace v8 {
...@@ -939,8 +939,8 @@ class CaseClause final : public Expression { ...@@ -939,8 +939,8 @@ class CaseClause final : public Expression {
BailoutId EntryId() const { return BailoutId(local_id(0)); } BailoutId EntryId() const { return BailoutId(local_id(0)); }
TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); }
Type* compare_type() { return compare_type_; } AstType* compare_type() { return compare_type_; }
void set_compare_type(Type* type) { compare_type_ = type; } void set_compare_type(AstType* type) { compare_type_ = type; }
// CaseClause will have both a slot in the feedback vector and the // CaseClause will have both a slot in the feedback vector and the
// TypeFeedbackId to record the type information. TypeFeedbackId is used by // TypeFeedbackId to record the type information. TypeFeedbackId is used by
...@@ -962,7 +962,7 @@ class CaseClause final : public Expression { ...@@ -962,7 +962,7 @@ class CaseClause final : public Expression {
Expression* label_; Expression* label_;
Label body_target_; Label body_target_;
ZoneList<Statement*>* statements_; ZoneList<Statement*>* statements_;
Type* compare_type_; AstType* compare_type_;
FeedbackVectorSlot type_feedback_slot_; FeedbackVectorSlot type_feedback_slot_;
}; };
...@@ -2135,14 +2135,14 @@ class CountOperation final : public Expression { ...@@ -2135,14 +2135,14 @@ class CountOperation final : public Expression {
KeyedAccessStoreMode GetStoreMode() const { KeyedAccessStoreMode GetStoreMode() const {
return StoreModeField::decode(bit_field_); return StoreModeField::decode(bit_field_);
} }
Type* type() const { return type_; } AstType* type() const { return type_; }
void set_key_type(IcCheckType type) { void set_key_type(IcCheckType type) {
bit_field_ = KeyTypeField::update(bit_field_, type); bit_field_ = KeyTypeField::update(bit_field_, type);
} }
void set_store_mode(KeyedAccessStoreMode mode) { void set_store_mode(KeyedAccessStoreMode mode) {
bit_field_ = StoreModeField::update(bit_field_, mode); bit_field_ = StoreModeField::update(bit_field_, mode);
} }
void set_type(Type* type) { type_ = type; } void set_type(AstType* type) { type_ = type; }
static int num_ids() { return parent_num_ids() + 4; } static int num_ids() { return parent_num_ids() + 4; }
BailoutId AssignmentId() const { return BailoutId(local_id(0)); } BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
...@@ -2187,7 +2187,7 @@ class CountOperation final : public Expression { ...@@ -2187,7 +2187,7 @@ class CountOperation final : public Expression {
uint16_t bit_field_; uint16_t bit_field_;
FeedbackVectorSlot slot_; FeedbackVectorSlot slot_;
FeedbackVectorSlot binary_operation_slot_; FeedbackVectorSlot binary_operation_slot_;
Type* type_; AstType* type_;
Expression* expression_; Expression* expression_;
SmallMapList receiver_types_; SmallMapList receiver_types_;
}; };
...@@ -2207,8 +2207,8 @@ class CompareOperation final : public Expression { ...@@ -2207,8 +2207,8 @@ class CompareOperation final : public Expression {
TypeFeedbackId CompareOperationFeedbackId() const { TypeFeedbackId CompareOperationFeedbackId() const {
return TypeFeedbackId(local_id(0)); return TypeFeedbackId(local_id(0));
} }
Type* combined_type() const { return combined_type_; } AstType* combined_type() const { return combined_type_; }
void set_combined_type(Type* type) { combined_type_ = type; } void set_combined_type(AstType* type) { combined_type_ = type; }
// CompareOperation will have both a slot in the feedback vector and the // CompareOperation will have both a slot in the feedback vector and the
// TypeFeedbackId to record the type information. TypeFeedbackId is used // TypeFeedbackId to record the type information. TypeFeedbackId is used
...@@ -2234,7 +2234,7 @@ class CompareOperation final : public Expression { ...@@ -2234,7 +2234,7 @@ class CompareOperation final : public Expression {
op_(op), op_(op),
left_(left), left_(left),
right_(right), right_(right),
combined_type_(Type::None()) { combined_type_(AstType::None()) {
DCHECK(Token::IsCompareOp(op)); DCHECK(Token::IsCompareOp(op));
} }
...@@ -2245,7 +2245,7 @@ class CompareOperation final : public Expression { ...@@ -2245,7 +2245,7 @@ class CompareOperation final : public Expression {
Expression* left_; Expression* left_;
Expression* right_; Expression* right_;
Type* combined_type_; AstType* combined_type_;
FeedbackVectorSlot type_feedback_slot_; FeedbackVectorSlot type_feedback_slot_;
}; };
......
...@@ -335,7 +335,7 @@ template <> ...@@ -335,7 +335,7 @@ template <>
HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() { HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() {
info()->MarkAsSavesCallerDoubles(); info()->MarkAsSavesCallerDoubles();
HValue* number = GetParameter(Descriptor::kArgument); HValue* number = GetParameter(Descriptor::kArgument);
return BuildNumberToString(number, Type::Number()); return BuildNumberToString(number, AstType::Number());
} }
...@@ -1263,26 +1263,26 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() { ...@@ -1263,26 +1263,26 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
HValue* left = GetParameter(Descriptor::kLeft); HValue* left = GetParameter(Descriptor::kLeft);
HValue* right = GetParameter(Descriptor::kRight); HValue* right = GetParameter(Descriptor::kRight);
Type* left_type = state.GetLeftType(); AstType* left_type = state.GetLeftType();
Type* right_type = state.GetRightType(); AstType* right_type = state.GetRightType();
Type* result_type = state.GetResultType(); AstType* result_type = state.GetResultType();
DCHECK(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && DCHECK(!left_type->Is(AstType::None()) && !right_type->Is(AstType::None()) &&
(state.HasSideEffects() || !result_type->Is(Type::None()))); (state.HasSideEffects() || !result_type->Is(AstType::None())));
HValue* result = NULL; HValue* result = NULL;
HAllocationMode allocation_mode(NOT_TENURED); HAllocationMode allocation_mode(NOT_TENURED);
if (state.op() == Token::ADD && if (state.op() == Token::ADD && (left_type->Maybe(AstType::String()) ||
(left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && right_type->Maybe(AstType::String())) &&
!left_type->Is(Type::String()) && !right_type->Is(Type::String())) { !left_type->Is(AstType::String()) && !right_type->Is(AstType::String())) {
// For the generic add stub a fast case for string addition is performance // For the generic add stub a fast case for string addition is performance
// critical. // critical.
if (left_type->Maybe(Type::String())) { if (left_type->Maybe(AstType::String())) {
IfBuilder if_leftisstring(this); IfBuilder if_leftisstring(this);
if_leftisstring.If<HIsStringAndBranch>(left); if_leftisstring.If<HIsStringAndBranch>(left);
if_leftisstring.Then(); if_leftisstring.Then();
{ {
Push(BuildBinaryOperation(state.op(), left, right, Type::String(), Push(BuildBinaryOperation(state.op(), left, right, AstType::String(),
right_type, result_type, right_type, result_type,
state.fixed_right_arg(), allocation_mode)); state.fixed_right_arg(), allocation_mode));
} }
...@@ -1300,7 +1300,7 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() { ...@@ -1300,7 +1300,7 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
if_rightisstring.Then(); if_rightisstring.Then();
{ {
Push(BuildBinaryOperation(state.op(), left, right, left_type, Push(BuildBinaryOperation(state.op(), left, right, left_type,
Type::String(), result_type, AstType::String(), result_type,
state.fixed_right_arg(), allocation_mode)); state.fixed_right_arg(), allocation_mode));
} }
if_rightisstring.Else(); if_rightisstring.Else();
...@@ -1341,9 +1341,9 @@ HValue* CodeStubGraphBuilder<BinaryOpWithAllocationSiteStub>::BuildCodeStub() { ...@@ -1341,9 +1341,9 @@ HValue* CodeStubGraphBuilder<BinaryOpWithAllocationSiteStub>::BuildCodeStub() {
HValue* left = GetParameter(Descriptor::kLeft); HValue* left = GetParameter(Descriptor::kLeft);
HValue* right = GetParameter(Descriptor::kRight); HValue* right = GetParameter(Descriptor::kRight);
Type* left_type = state.GetLeftType(); AstType* left_type = state.GetLeftType();
Type* right_type = state.GetRightType(); AstType* right_type = state.GetRightType();
Type* result_type = state.GetResultType(); AstType* result_type = state.GetResultType();
HAllocationMode allocation_mode(allocation_site); HAllocationMode allocation_mode(allocation_site);
return BuildBinaryOperation(state.op(), left, right, left_type, right_type, return BuildBinaryOperation(state.op(), left, right, left_type, right_type,
...@@ -1364,7 +1364,7 @@ HValue* CodeStubGraphBuilderBase::BuildToString(HValue* input, bool convert) { ...@@ -1364,7 +1364,7 @@ HValue* CodeStubGraphBuilderBase::BuildToString(HValue* input, bool convert) {
if_inputissmi.Then(); if_inputissmi.Then();
{ {
// Convert the input smi to a string. // Convert the input smi to a string.
Push(BuildNumberToString(input, Type::SignedSmall())); Push(BuildNumberToString(input, AstType::SignedSmall()));
} }
if_inputissmi.Else(); if_inputissmi.Else();
{ {
......
...@@ -5837,20 +5837,20 @@ ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, ...@@ -5837,20 +5837,20 @@ ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate,
InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate)
: PlatformCodeStub(isolate) {} : PlatformCodeStub(isolate) {}
Representation RepresentationFromType(Type* type) { Representation RepresentationFromType(AstType* type) {
if (type->Is(Type::UntaggedIntegral())) { if (type->Is(AstType::UntaggedIntegral())) {
return Representation::Integer32(); return Representation::Integer32();
} }
if (type->Is(Type::TaggedSigned())) { if (type->Is(AstType::TaggedSigned())) {
return Representation::Smi(); return Representation::Smi();
} }
if (type->Is(Type::UntaggedPointer())) { if (type->Is(AstType::UntaggedPointer())) {
return Representation::External(); return Representation::External();
} }
DCHECK(!type->Is(Type::Untagged())); DCHECK(!type->Is(AstType::Untagged()));
return Representation::Tagged(); return Representation::Tagged();
} }
......
...@@ -12,17 +12,17 @@ namespace v8 { ...@@ -12,17 +12,17 @@ namespace v8 {
namespace internal { namespace internal {
// static // static
HType HType::FromType(Type* type) { HType HType::FromType(AstType* type) {
if (Type::Any()->Is(type)) return HType::Any(); if (AstType::Any()->Is(type)) return HType::Any();
if (!type->IsInhabited()) return HType::None(); if (!type->IsInhabited()) return HType::None();
if (type->Is(Type::SignedSmall())) return HType::Smi(); if (type->Is(AstType::SignedSmall())) return HType::Smi();
if (type->Is(Type::Number())) return HType::TaggedNumber(); if (type->Is(AstType::Number())) return HType::TaggedNumber();
if (type->Is(Type::Null())) return HType::Null(); if (type->Is(AstType::Null())) return HType::Null();
if (type->Is(Type::String())) return HType::String(); if (type->Is(AstType::String())) return HType::String();
if (type->Is(Type::Boolean())) return HType::Boolean(); if (type->Is(AstType::Boolean())) return HType::Boolean();
if (type->Is(Type::Undefined())) return HType::Undefined(); if (type->Is(AstType::Undefined())) return HType::Undefined();
if (type->Is(Type::Object())) return HType::JSObject(); if (type->Is(AstType::Object())) return HType::JSObject();
if (type->Is(Type::DetectableReceiver())) return HType::JSReceiver(); if (type->Is(AstType::DetectableReceiver())) return HType::JSReceiver();
return HType::Tagged(); return HType::Tagged();
} }
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <climits> #include <climits>
#include <iosfwd> #include <iosfwd>
#include "src/ast/ast-types.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/types.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -64,7 +64,7 @@ class HType final { ...@@ -64,7 +64,7 @@ class HType final {
HTYPE_LIST(DECLARE_IS_TYPE) HTYPE_LIST(DECLARE_IS_TYPE)
#undef DECLARE_IS_TYPE #undef DECLARE_IS_TYPE
static HType FromType(Type* type) WARN_UNUSED_RESULT; static HType FromType(AstType* type) WARN_UNUSED_RESULT;
static HType FromFieldType(Handle<FieldType> type, static HType FromFieldType(Handle<FieldType> type,
Zone* temp_zone) WARN_UNUSED_RESULT; Zone* temp_zone) WARN_UNUSED_RESULT;
static HType FromValue(Handle<Object> value) WARN_UNUSED_RESULT; static HType FromValue(Handle<Object> value) WARN_UNUSED_RESULT;
......
This diff is collapsed.
...@@ -1396,7 +1396,7 @@ class HGraphBuilder { ...@@ -1396,7 +1396,7 @@ class HGraphBuilder {
ElementsKind to_kind, ElementsKind to_kind,
bool is_jsarray); bool is_jsarray);
HValue* BuildNumberToString(HValue* object, Type* type); HValue* BuildNumberToString(HValue* object, AstType* type);
HValue* BuildToNumber(HValue* input); HValue* BuildToNumber(HValue* input);
HValue* BuildToObject(HValue* receiver); HValue* BuildToObject(HValue* receiver);
...@@ -1500,8 +1500,8 @@ class HGraphBuilder { ...@@ -1500,8 +1500,8 @@ class HGraphBuilder {
HValue** shift_amount); HValue** shift_amount);
HValue* BuildBinaryOperation(Token::Value op, HValue* left, HValue* right, HValue* BuildBinaryOperation(Token::Value op, HValue* left, HValue* right,
Type* left_type, Type* right_type, AstType* left_type, AstType* right_type,
Type* result_type, Maybe<int> fixed_right_arg, AstType* result_type, Maybe<int> fixed_right_arg,
HAllocationMode allocation_mode, HAllocationMode allocation_mode,
BailoutId opt_id = BailoutId::None()); BailoutId opt_id = BailoutId::None());
...@@ -1514,8 +1514,8 @@ class HGraphBuilder { ...@@ -1514,8 +1514,8 @@ class HGraphBuilder {
HValue* AddLoadJSBuiltin(int context_index); HValue* AddLoadJSBuiltin(int context_index);
HValue* EnforceNumberType(HValue* number, Type* expected); HValue* EnforceNumberType(HValue* number, AstType* expected);
HValue* TruncateToNumber(HValue* value, Type** expected); HValue* TruncateToNumber(HValue* value, AstType** expected);
void FinishExitWithHardDeoptimization(DeoptimizeReason reason); void FinishExitWithHardDeoptimization(DeoptimizeReason reason);
...@@ -2707,8 +2707,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder, ...@@ -2707,8 +2707,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder,
}; };
HControlInstruction* BuildCompareInstruction( HControlInstruction* BuildCompareInstruction(
Token::Value op, HValue* left, HValue* right, Type* left_type, Token::Value op, HValue* left, HValue* right, AstType* left_type,
Type* right_type, Type* combined_type, SourcePosition left_position, AstType* right_type, AstType* combined_type, SourcePosition left_position,
SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result, SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
BailoutId bailout_id); BailoutId bailout_id);
......
...@@ -33,7 +33,7 @@ AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure, ...@@ -33,7 +33,7 @@ AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure,
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
static void PrintObserved(Variable* var, Object* value, Type* type) { static void PrintObserved(Variable* var, Object* value, AstType* type) {
OFStream os(stdout); OFStream os(stdout);
os << " observed " << (var->IsParameter() ? "param" : "local") << " "; os << " observed " << (var->IsParameter() ? "param" : "local") << " ";
var->name()->Print(os); var->name()->Print(os);
...@@ -45,8 +45,8 @@ AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure, ...@@ -45,8 +45,8 @@ AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure,
Effect AstTyper::ObservedOnStack(Object* value) { Effect AstTyper::ObservedOnStack(Object* value) {
Type* lower = Type::NowOf(value, zone()); AstType* lower = AstType::NowOf(value, zone());
return Effect(Bounds(lower, Type::Any())); return Effect(AstBounds(lower, AstType::Any()));
} }
...@@ -206,9 +206,9 @@ void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) { ...@@ -206,9 +206,9 @@ void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) {
if (!clause->is_default()) { if (!clause->is_default()) {
Expression* label = clause->label(); Expression* label = clause->label();
// Collect type feedback. // Collect type feedback.
Type* tag_type; AstType* tag_type;
Type* label_type; AstType* label_type;
Type* combined_type; AstType* combined_type;
oracle()->CompareType(clause->CompareId(), oracle()->CompareType(clause->CompareId(),
&tag_type, &label_type, &combined_type); &tag_type, &label_type, &combined_type);
NarrowLowerType(stmt->tag(), tag_type); NarrowLowerType(stmt->tag(), tag_type);
...@@ -367,7 +367,7 @@ void AstTyper::VisitConditional(Conditional* expr) { ...@@ -367,7 +367,7 @@ void AstTyper::VisitConditional(Conditional* expr) {
store_.Seq(then_effects); store_.Seq(then_effects);
NarrowType(expr, NarrowType(expr,
Bounds::Either(bounds_->get(expr->then_expression()), AstBounds::Either(bounds_->get(expr->then_expression()),
bounds_->get(expr->else_expression()), zone())); bounds_->get(expr->else_expression()), zone()));
} }
...@@ -381,14 +381,14 @@ void AstTyper::VisitVariableProxy(VariableProxy* expr) { ...@@ -381,14 +381,14 @@ void AstTyper::VisitVariableProxy(VariableProxy* expr) {
void AstTyper::VisitLiteral(Literal* expr) { void AstTyper::VisitLiteral(Literal* expr) {
Type* type = Type::Constant(expr->value(), zone()); AstType* type = AstType::Constant(expr->value(), zone());
NarrowType(expr, Bounds(type)); NarrowType(expr, AstBounds(type));
} }
void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) { void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) {
// TODO(rossberg): Reintroduce RegExp type. // TODO(rossberg): Reintroduce RegExp type.
NarrowType(expr, Bounds(Type::Object())); NarrowType(expr, AstBounds(AstType::Object()));
} }
...@@ -416,7 +416,7 @@ void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -416,7 +416,7 @@ void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) {
RECURSE(Visit(prop->value())); RECURSE(Visit(prop->value()));
} }
NarrowType(expr, Bounds(Type::Object())); NarrowType(expr, AstBounds(AstType::Object()));
} }
...@@ -427,7 +427,7 @@ void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -427,7 +427,7 @@ void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) {
RECURSE(Visit(value)); RECURSE(Visit(value));
} }
NarrowType(expr, Bounds(Type::Object())); NarrowType(expr, AstBounds(AstType::Object()));
} }
...@@ -480,7 +480,7 @@ void AstTyper::VisitThrow(Throw* expr) { ...@@ -480,7 +480,7 @@ void AstTyper::VisitThrow(Throw* expr) {
RECURSE(Visit(expr->exception())); RECURSE(Visit(expr->exception()));
// TODO(rossberg): is it worth having a non-termination effect? // TODO(rossberg): is it worth having a non-termination effect?
NarrowType(expr, Bounds(Type::None())); NarrowType(expr, AstBounds(AstType::None()));
} }
...@@ -563,7 +563,7 @@ void AstTyper::VisitCallNew(CallNew* expr) { ...@@ -563,7 +563,7 @@ void AstTyper::VisitCallNew(CallNew* expr) {
RECURSE(Visit(arg)); RECURSE(Visit(arg));
} }
NarrowType(expr, Bounds(Type::None(), Type::Receiver())); NarrowType(expr, AstBounds(AstType::None(), AstType::Receiver()));
} }
...@@ -590,13 +590,13 @@ void AstTyper::VisitUnaryOperation(UnaryOperation* expr) { ...@@ -590,13 +590,13 @@ void AstTyper::VisitUnaryOperation(UnaryOperation* expr) {
switch (expr->op()) { switch (expr->op()) {
case Token::NOT: case Token::NOT:
case Token::DELETE: case Token::DELETE:
NarrowType(expr, Bounds(Type::Boolean())); NarrowType(expr, AstBounds(AstType::Boolean()));
break; break;
case Token::VOID: case Token::VOID:
NarrowType(expr, Bounds(Type::Undefined())); NarrowType(expr, AstBounds(AstType::Undefined()));
break; break;
case Token::TYPEOF: case Token::TYPEOF:
NarrowType(expr, Bounds(Type::InternalizedString())); NarrowType(expr, AstBounds(AstType::InternalizedString()));
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -618,7 +618,7 @@ void AstTyper::VisitCountOperation(CountOperation* expr) { ...@@ -618,7 +618,7 @@ void AstTyper::VisitCountOperation(CountOperation* expr) {
RECURSE(Visit(expr->expression())); RECURSE(Visit(expr->expression()));
NarrowType(expr, Bounds(Type::SignedSmall(), Type::Number())); NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number()));
VariableProxy* proxy = expr->expression()->AsVariableProxy(); VariableProxy* proxy = expr->expression()->AsVariableProxy();
if (proxy != NULL && proxy->var()->IsStackAllocated()) { if (proxy != NULL && proxy->var()->IsStackAllocated()) {
...@@ -629,9 +629,9 @@ void AstTyper::VisitCountOperation(CountOperation* expr) { ...@@ -629,9 +629,9 @@ void AstTyper::VisitCountOperation(CountOperation* expr) {
void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
// Collect type feedback. // Collect type feedback.
Type* type; AstType* type;
Type* left_type; AstType* left_type;
Type* right_type; AstType* right_type;
Maybe<int> fixed_right_arg = Nothing<int>(); Maybe<int> fixed_right_arg = Nothing<int>();
Handle<AllocationSite> allocation_site; Handle<AllocationSite> allocation_site;
oracle()->BinaryType(expr->BinaryOperationFeedbackId(), oracle()->BinaryType(expr->BinaryOperationFeedbackId(),
...@@ -663,7 +663,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -663,7 +663,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
left_effects.Alt(right_effects); left_effects.Alt(right_effects);
store_.Seq(left_effects); store_.Seq(left_effects);
NarrowType(expr, Bounds::Either(bounds_->get(expr->left()), NarrowType(expr, AstBounds::Either(bounds_->get(expr->left()),
bounds_->get(expr->right()), zone())); bounds_->get(expr->right()), zone()));
break; break;
} }
...@@ -671,11 +671,13 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -671,11 +671,13 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
case Token::BIT_AND: { case Token::BIT_AND: {
RECURSE(Visit(expr->left())); RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right())); RECURSE(Visit(expr->right()));
Type* upper = Type::Union(bounds_->get(expr->left()).upper, AstType* upper =
AstType::Union(bounds_->get(expr->left()).upper,
bounds_->get(expr->right()).upper, zone()); bounds_->get(expr->right()).upper, zone());
if (!upper->Is(Type::Signed32())) upper = Type::Signed32(); if (!upper->Is(AstType::Signed32())) upper = AstType::Signed32();
Type* lower = Type::Intersect(Type::SignedSmall(), upper, zone()); AstType* lower =
NarrowType(expr, Bounds(lower, upper)); AstType::Intersect(AstType::SignedSmall(), upper, zone());
NarrowType(expr, AstBounds(lower, upper));
break; break;
} }
case Token::BIT_XOR: case Token::BIT_XOR:
...@@ -683,7 +685,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -683,7 +685,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
case Token::SAR: case Token::SAR:
RECURSE(Visit(expr->left())); RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right())); RECURSE(Visit(expr->right()));
NarrowType(expr, Bounds(Type::SignedSmall(), Type::Signed32())); NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Signed32()));
break; break;
case Token::SHR: case Token::SHR:
RECURSE(Visit(expr->left())); RECURSE(Visit(expr->left()));
...@@ -691,28 +693,29 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -691,28 +693,29 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
// TODO(rossberg): The upper bound would be Unsigned32, but since there // TODO(rossberg): The upper bound would be Unsigned32, but since there
// is no 'positive Smi' type for the lower bound, we use the smallest // is no 'positive Smi' type for the lower bound, we use the smallest
// union of Smi and Unsigned32 as upper bound instead. // union of Smi and Unsigned32 as upper bound instead.
NarrowType(expr, Bounds(Type::SignedSmall(), Type::Number())); NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number()));
break; break;
case Token::ADD: { case Token::ADD: {
RECURSE(Visit(expr->left())); RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right())); RECURSE(Visit(expr->right()));
Bounds l = bounds_->get(expr->left()); AstBounds l = bounds_->get(expr->left());
Bounds r = bounds_->get(expr->right()); AstBounds r = bounds_->get(expr->right());
Type* lower = AstType* lower =
!l.lower->IsInhabited() || !r.lower->IsInhabited() !l.lower->IsInhabited() || !r.lower->IsInhabited()
? Type::None() ? AstType::None()
: l.lower->Is(Type::String()) || r.lower->Is(Type::String()) : l.lower->Is(AstType::String()) || r.lower->Is(AstType::String())
? Type::String() ? AstType::String()
: l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) : l.lower->Is(AstType::Number()) &&
? Type::SignedSmall() r.lower->Is(AstType::Number())
: Type::None(); ? AstType::SignedSmall()
Type* upper = : AstType::None();
l.upper->Is(Type::String()) || r.upper->Is(Type::String()) AstType* upper =
? Type::String() l.upper->Is(AstType::String()) || r.upper->Is(AstType::String())
: l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? AstType::String()
? Type::Number() : l.upper->Is(AstType::Number()) && r.upper->Is(AstType::Number())
: Type::NumberOrString(); ? AstType::Number()
NarrowType(expr, Bounds(lower, upper)); : AstType::NumberOrString();
NarrowType(expr, AstBounds(lower, upper));
break; break;
} }
case Token::SUB: case Token::SUB:
...@@ -721,7 +724,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -721,7 +724,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
case Token::MOD: case Token::MOD:
RECURSE(Visit(expr->left())); RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right())); RECURSE(Visit(expr->right()));
NarrowType(expr, Bounds(Type::SignedSmall(), Type::Number())); NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number()));
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -731,9 +734,9 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { ...@@ -731,9 +734,9 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
void AstTyper::VisitCompareOperation(CompareOperation* expr) { void AstTyper::VisitCompareOperation(CompareOperation* expr) {
// Collect type feedback. // Collect type feedback.
Type* left_type; AstType* left_type;
Type* right_type; AstType* right_type;
Type* combined_type; AstType* combined_type;
oracle()->CompareType(expr->CompareOperationFeedbackId(), oracle()->CompareType(expr->CompareOperationFeedbackId(),
&left_type, &right_type, &combined_type); &left_type, &right_type, &combined_type);
NarrowLowerType(expr->left(), left_type); NarrowLowerType(expr->left(), left_type);
...@@ -743,7 +746,7 @@ void AstTyper::VisitCompareOperation(CompareOperation* expr) { ...@@ -743,7 +746,7 @@ void AstTyper::VisitCompareOperation(CompareOperation* expr) {
RECURSE(Visit(expr->left())); RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right())); RECURSE(Visit(expr->right()));
NarrowType(expr, Bounds(Type::Boolean())); NarrowType(expr, AstBounds(AstType::Boolean()));
} }
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/ast/ast-type-bounds.h" #include "src/ast/ast-type-bounds.h"
#include "src/ast/ast-types.h"
#include "src/ast/scopes.h" #include "src/ast/scopes.h"
#include "src/ast/variables.h" #include "src/ast/variables.h"
#include "src/effects.h" #include "src/effects.h"
#include "src/type-info.h" #include "src/type-info.h"
#include "src/types.h"
#include "src/zone.h" #include "src/zone.h"
namespace v8 { namespace v8 {
...@@ -49,11 +49,11 @@ class AstTyper final : public AstVisitor<AstTyper> { ...@@ -49,11 +49,11 @@ class AstTyper final : public AstVisitor<AstTyper> {
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
TypeFeedbackOracle* oracle() { return &oracle_; } TypeFeedbackOracle* oracle() { return &oracle_; }
void NarrowType(Expression* e, Bounds b) { void NarrowType(Expression* e, AstBounds b) {
bounds_->set(e, Bounds::Both(bounds_->get(e), b, zone())); bounds_->set(e, AstBounds::Both(bounds_->get(e), b, zone()));
} }
void NarrowLowerType(Expression* e, Type* t) { void NarrowLowerType(Expression* e, AstType* t) {
bounds_->set(e, Bounds::NarrowLower(bounds_->get(e), t, zone())); bounds_->set(e, AstBounds::NarrowLower(bounds_->get(e), t, zone()));
} }
Effects EnterEffects() { Effects EnterEffects() {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef V8_EFFECTS_H_ #ifndef V8_EFFECTS_H_
#define V8_EFFECTS_H_ #define V8_EFFECTS_H_
#include "src/types.h" #include "src/ast/ast-types.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -28,30 +28,30 @@ struct Effect { ...@@ -28,30 +28,30 @@ struct Effect {
enum Modality { POSSIBLE, DEFINITE }; enum Modality { POSSIBLE, DEFINITE };
Modality modality; Modality modality;
Bounds bounds; AstBounds bounds;
Effect() : modality(DEFINITE) {} Effect() : modality(DEFINITE) {}
explicit Effect(Bounds b, Modality m = DEFINITE) : modality(m), bounds(b) {} explicit Effect(AstBounds b, Modality m = DEFINITE)
: modality(m), bounds(b) {}
// The unknown effect. // The unknown effect.
static Effect Unknown(Zone* zone) { static Effect Unknown(Zone* zone) {
return Effect(Bounds::Unbounded(), POSSIBLE); return Effect(AstBounds::Unbounded(), POSSIBLE);
} }
static Effect Forget(Zone* zone) { static Effect Forget(Zone* zone) {
return Effect(Bounds::Unbounded(), DEFINITE); return Effect(AstBounds::Unbounded(), DEFINITE);
} }
// Sequential composition, as in 'e1; e2'. // Sequential composition, as in 'e1; e2'.
static Effect Seq(Effect e1, Effect e2, Zone* zone) { static Effect Seq(Effect e1, Effect e2, Zone* zone) {
if (e2.modality == DEFINITE) return e2; if (e2.modality == DEFINITE) return e2;
return Effect(Bounds::Either(e1.bounds, e2.bounds, zone), e1.modality); return Effect(AstBounds::Either(e1.bounds, e2.bounds, zone), e1.modality);
} }
// Alternative composition, as in 'cond ? e1 : e2'. // Alternative composition, as in 'cond ? e1 : e2'.
static Effect Alt(Effect e1, Effect e2, Zone* zone) { static Effect Alt(Effect e1, Effect e2, Zone* zone) {
return Effect( return Effect(AstBounds::Either(e1.bounds, e2.bounds, zone),
Bounds::Either(e1.bounds, e2.bounds, zone),
e1.modality == POSSIBLE ? POSSIBLE : e2.modality); e1.modality == POSSIBLE ? POSSIBLE : e2.modality);
} }
}; };
...@@ -84,10 +84,10 @@ class EffectsMixin: public Base { ...@@ -84,10 +84,10 @@ class EffectsMixin: public Base {
? locator.value() : Effect::Unknown(Base::zone()); ? locator.value() : Effect::Unknown(Base::zone());
} }
Bounds LookupBounds(Var var) { AstBounds LookupBounds(Var var) {
Effect effect = Lookup(var); Effect effect = Lookup(var);
return effect.modality == Effect::DEFINITE return effect.modality == Effect::DEFINITE ? effect.bounds
? effect.bounds : Bounds::Unbounded(); : AstBounds::Unbounded();
} }
// Sequential composition. // Sequential composition.
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "src/field-type.h" #include "src/field-type.h"
#include "src/ast/ast-types.h"
#include "src/handles-inl.h" #include "src/handles-inl.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/types.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -71,11 +71,11 @@ bool FieldType::NowIs(FieldType* other) { ...@@ -71,11 +71,11 @@ bool FieldType::NowIs(FieldType* other) {
bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); } bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); }
Type* FieldType::Convert(Zone* zone) { AstType* FieldType::Convert(Zone* zone) {
if (IsAny()) return Type::NonInternal(); if (IsAny()) return AstType::NonInternal();
if (IsNone()) return Type::None(); if (IsNone()) return AstType::None();
DCHECK(IsClass()); DCHECK(IsClass());
return Type::Class(AsClass(), zone); return AstType::Class(AsClass(), zone);
} }
void FieldType::PrintTo(std::ostream& os) { void FieldType::PrintTo(std::ostream& os) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_FIELD_TYPE_H_ #ifndef V8_FIELD_TYPE_H_
#define V8_FIELD_TYPE_H_ #define V8_FIELD_TYPE_H_
#include "src/ast/ast-types.h"
#include "src/handles.h" #include "src/handles.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/ostreams.h" #include "src/ostreams.h"
...@@ -38,7 +39,7 @@ class FieldType : public Object { ...@@ -38,7 +39,7 @@ class FieldType : public Object {
bool NowStable(); bool NowStable();
bool NowIs(FieldType* other); bool NowIs(FieldType* other);
bool NowIs(Handle<FieldType> other); bool NowIs(Handle<FieldType> other);
Type* Convert(Zone* zone); AstType* Convert(Zone* zone);
void PrintTo(std::ostream& os); void PrintTo(std::ostream& os);
}; };
......
...@@ -189,15 +189,14 @@ void BinaryOpICState::GenerateAheadOfTime( ...@@ -189,15 +189,14 @@ void BinaryOpICState::GenerateAheadOfTime(
#undef GENERATE #undef GENERATE
} }
AstType* BinaryOpICState::GetResultType() const {
Type* BinaryOpICState::GetResultType() const {
Kind result_kind = result_kind_; Kind result_kind = result_kind_;
if (HasSideEffects()) { if (HasSideEffects()) {
result_kind = NONE; result_kind = NONE;
} else if (result_kind == GENERIC && op_ == Token::ADD) { } else if (result_kind == GENERIC && op_ == Token::ADD) {
return Type::NumberOrString(); return AstType::NumberOrString();
} else if (result_kind == NUMBER && op_ == Token::SHR) { } else if (result_kind == NUMBER && op_ == Token::SHR) {
return Type::Unsigned32(); return AstType::Unsigned32();
} }
DCHECK_NE(GENERIC, result_kind); DCHECK_NE(GENERIC, result_kind);
return KindToType(result_kind); return KindToType(result_kind);
...@@ -318,20 +317,20 @@ const char* BinaryOpICState::KindToString(Kind kind) { ...@@ -318,20 +317,20 @@ const char* BinaryOpICState::KindToString(Kind kind) {
// static // static
Type* BinaryOpICState::KindToType(Kind kind) { AstType* BinaryOpICState::KindToType(Kind kind) {
switch (kind) { switch (kind) {
case NONE: case NONE:
return Type::None(); return AstType::None();
case SMI: case SMI:
return Type::SignedSmall(); return AstType::SignedSmall();
case INT32: case INT32:
return Type::Signed32(); return AstType::Signed32();
case NUMBER: case NUMBER:
return Type::Number(); return AstType::Number();
case STRING: case STRING:
return Type::String(); return AstType::String();
case GENERIC: case GENERIC:
return Type::Any(); return AstType::Any();
} }
UNREACHABLE(); UNREACHABLE();
return NULL; return NULL;
...@@ -365,29 +364,28 @@ const char* CompareICState::GetStateName(State state) { ...@@ -365,29 +364,28 @@ const char* CompareICState::GetStateName(State state) {
return NULL; return NULL;
} }
AstType* CompareICState::StateToType(Zone* zone, State state, Handle<Map> map) {
Type* CompareICState::StateToType(Zone* zone, State state, Handle<Map> map) {
switch (state) { switch (state) {
case UNINITIALIZED: case UNINITIALIZED:
return Type::None(); return AstType::None();
case BOOLEAN: case BOOLEAN:
return Type::Boolean(); return AstType::Boolean();
case SMI: case SMI:
return Type::SignedSmall(); return AstType::SignedSmall();
case NUMBER: case NUMBER:
return Type::Number(); return AstType::Number();
case STRING: case STRING:
return Type::String(); return AstType::String();
case INTERNALIZED_STRING: case INTERNALIZED_STRING:
return Type::InternalizedString(); return AstType::InternalizedString();
case UNIQUE_NAME: case UNIQUE_NAME:
return Type::UniqueName(); return AstType::UniqueName();
case RECEIVER: case RECEIVER:
return Type::Receiver(); return AstType::Receiver();
case KNOWN_RECEIVER: case KNOWN_RECEIVER:
return map.is_null() ? Type::Receiver() : Type::Class(map, zone); return map.is_null() ? AstType::Receiver() : AstType::Class(map, zone);
case GENERIC: case GENERIC:
return Type::Any(); return AstType::Any();
} }
UNREACHABLE(); UNREACHABLE();
return NULL; return NULL;
......
...@@ -120,9 +120,9 @@ class BinaryOpICState final BASE_EMBEDDED { ...@@ -120,9 +120,9 @@ class BinaryOpICState final BASE_EMBEDDED {
Token::Value op() const { return op_; } Token::Value op() const { return op_; }
Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
Type* GetLeftType() const { return KindToType(left_kind_); } AstType* GetLeftType() const { return KindToType(left_kind_); }
Type* GetRightType() const { return KindToType(right_kind_); } AstType* GetRightType() const { return KindToType(right_kind_); }
Type* GetResultType() const; AstType* GetResultType() const;
void Update(Handle<Object> left, Handle<Object> right, Handle<Object> result); void Update(Handle<Object> left, Handle<Object> right, Handle<Object> result);
...@@ -140,7 +140,7 @@ class BinaryOpICState final BASE_EMBEDDED { ...@@ -140,7 +140,7 @@ class BinaryOpICState final BASE_EMBEDDED {
Kind UpdateKind(Handle<Object> object, Kind kind) const; Kind UpdateKind(Handle<Object> object, Kind kind) const;
static const char* KindToString(Kind kind); static const char* KindToString(Kind kind);
static Type* KindToType(Kind kind); static AstType* KindToType(Kind kind);
static bool KindMaybeSmi(Kind kind) { static bool KindMaybeSmi(Kind kind) {
return (kind >= SMI && kind <= NUMBER) || kind == GENERIC; return (kind >= SMI && kind <= NUMBER) || kind == GENERIC;
} }
...@@ -202,7 +202,7 @@ class CompareICState { ...@@ -202,7 +202,7 @@ class CompareICState {
GENERIC GENERIC
}; };
static Type* StateToType(Zone* zone, State state, static AstType* StateToType(Zone* zone, State state,
Handle<Map> map = Handle<Map>()); Handle<Map> map = Handle<Map>());
static State NewInputState(State old_state, Handle<Object> value); static State NewInputState(State old_state, Handle<Object> value);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef V8_PARSING_PARAMETER_EXPRESSION_REWRITER_H_ #ifndef V8_PARSING_PARAMETER_EXPRESSION_REWRITER_H_
#define V8_PARSING_PARAMETER_EXPRESSION_REWRITER_H_ #define V8_PARSING_PARAMETER_EXPRESSION_REWRITER_H_
#include "src/types.h" #include "src/ast/ast-types.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -191,15 +191,13 @@ Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite( ...@@ -191,15 +191,13 @@ Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite(
return Handle<AllocationSite>::null(); return Handle<AllocationSite>::null();
} }
void TypeFeedbackOracle::CompareType(TypeFeedbackId id, AstType** left_type,
void TypeFeedbackOracle::CompareType(TypeFeedbackId id, AstType** right_type,
Type** left_type, AstType** combined_type) {
Type** right_type,
Type** combined_type) {
Handle<Object> info = GetInfo(id); Handle<Object> info = GetInfo(id);
if (!info->IsCode()) { if (!info->IsCode()) {
// For some comparisons we don't have ICs, e.g. LiteralCompareTypeof. // For some comparisons we don't have ICs, e.g. LiteralCompareTypeof.
*left_type = *right_type = *combined_type = Type::None(); *left_type = *right_type = *combined_type = AstType::None();
return; return;
} }
Handle<Code> code = Handle<Code>::cast(info); Handle<Code> code = Handle<Code>::cast(info);
...@@ -216,11 +214,8 @@ void TypeFeedbackOracle::CompareType(TypeFeedbackId id, ...@@ -216,11 +214,8 @@ void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
} }
} }
void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, AstType** left,
void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, AstType** right, AstType** result,
Type** left,
Type** right,
Type** result,
Maybe<int>* fixed_right_arg, Maybe<int>* fixed_right_arg,
Handle<AllocationSite>* allocation_site, Handle<AllocationSite>* allocation_site,
Token::Value op) { Token::Value op) {
...@@ -230,7 +225,7 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, ...@@ -230,7 +225,7 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
// operations covered by the BinaryOpIC we should always have them. // operations covered by the BinaryOpIC we should always have them.
DCHECK(op < BinaryOpICState::FIRST_TOKEN || DCHECK(op < BinaryOpICState::FIRST_TOKEN ||
op > BinaryOpICState::LAST_TOKEN); op > BinaryOpICState::LAST_TOKEN);
*left = *right = *result = Type::None(); *left = *right = *result = AstType::None();
*fixed_right_arg = Nothing<int>(); *fixed_right_arg = Nothing<int>();
*allocation_site = Handle<AllocationSite>::null(); *allocation_site = Handle<AllocationSite>::null();
return; return;
...@@ -253,10 +248,9 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, ...@@ -253,10 +248,9 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
} }
} }
AstType* TypeFeedbackOracle::CountType(TypeFeedbackId id) {
Type* TypeFeedbackOracle::CountType(TypeFeedbackId id) {
Handle<Object> object = GetInfo(id); Handle<Object> object = GetInfo(id);
if (!object->IsCode()) return Type::None(); if (!object->IsCode()) return AstType::None();
Handle<Code> code = Handle<Code>::cast(object); Handle<Code> code = Handle<Code>::cast(object);
DCHECK_EQ(Code::BINARY_OP_IC, code->kind()); DCHECK_EQ(Code::BINARY_OP_IC, code->kind());
BinaryOpICState state(isolate(), code->extra_ic_state()); BinaryOpICState state(isolate(), code->extra_ic_state());
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
#define V8_TYPE_INFO_H_ #define V8_TYPE_INFO_H_
#include "src/allocation.h" #include "src/allocation.h"
#include "src/ast/ast-types.h"
#include "src/contexts.h" #include "src/contexts.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/parsing/token.h" #include "src/parsing/token.h"
#include "src/types.h"
#include "src/zone.h" #include "src/zone.h"
namespace v8 { namespace v8 {
...@@ -77,20 +77,15 @@ class TypeFeedbackOracle: public ZoneObject { ...@@ -77,20 +77,15 @@ class TypeFeedbackOracle: public ZoneObject {
uint16_t ToBooleanTypes(TypeFeedbackId id); uint16_t ToBooleanTypes(TypeFeedbackId id);
// Get type information for arithmetic operations and compares. // Get type information for arithmetic operations and compares.
void BinaryType(TypeFeedbackId id, void BinaryType(TypeFeedbackId id, AstType** left, AstType** right,
Type** left, AstType** result, Maybe<int>* fixed_right_arg,
Type** right,
Type** result,
Maybe<int>* fixed_right_arg,
Handle<AllocationSite>* allocation_site, Handle<AllocationSite>* allocation_site,
Token::Value operation); Token::Value operation);
void CompareType(TypeFeedbackId id, void CompareType(TypeFeedbackId id, AstType** left, AstType** right,
Type** left, AstType** combined);
Type** right,
Type** combined);
Type* CountType(TypeFeedbackId id); AstType* CountType(TypeFeedbackId id);
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
......
...@@ -980,7 +980,6 @@ struct Bounds { ...@@ -980,7 +980,6 @@ struct Bounds {
return that.lower->Is(this->lower) && this->upper->Is(that.upper); return that.lower->Is(this->lower) && this->upper->Is(that.upper);
} }
}; };
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -451,6 +451,8 @@ ...@@ -451,6 +451,8 @@
'ast/ast-numbering.h', 'ast/ast-numbering.h',
'ast/ast-traversal-visitor.h', 'ast/ast-traversal-visitor.h',
'ast/ast-type-bounds.h', 'ast/ast-type-bounds.h',
'ast/ast-types.cc',
'ast/ast-types.h',
'ast/ast-value-factory.cc', 'ast/ast-value-factory.cc',
'ast/ast-value-factory.h', 'ast/ast-value-factory.h',
'ast/ast.cc', 'ast/ast.cc',
......
This diff is collapsed.
...@@ -174,6 +174,7 @@ ...@@ -174,6 +174,7 @@
'test-trace-event.cc', 'test-trace-event.cc',
'test-transitions.cc', 'test-transitions.cc',
'test-typedarrays.cc', 'test-typedarrays.cc',
'test-ast-types.cc',
'test-types.cc', 'test-types.cc',
'test-unbound-queue.cc', 'test-unbound-queue.cc',
'test-unboxed-doubles.cc', 'test-unboxed-doubles.cc',
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
# This tests only the type system, no point in running several variants. # This tests only the type system, no point in running several variants.
'test-hydrogen-types/*': [PASS, NO_VARIANTS], 'test-hydrogen-types/*': [PASS, NO_VARIANTS],
'test-types/*': [PASS, NO_VARIANTS], 'test-types/*': [PASS, NO_VARIANTS],
'test-ast-types/*': [PASS, NO_VARIANTS],
# This tests API threading, no point in running several variants. # This tests API threading, no point in running several variants.
'test-api/Threading*': [PASS, NO_VARIANTS], 'test-api/Threading*': [PASS, NO_VARIANTS],
......
This diff is collapsed.
...@@ -2419,8 +2419,8 @@ TEST(FieldTypeConvertSimple) { ...@@ -2419,8 +2419,8 @@ TEST(FieldTypeConvertSimple) {
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
CHECK_EQ(FieldType::Any()->Convert(&zone), Type::NonInternal()); CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal());
CHECK_EQ(FieldType::None()->Convert(&zone), Type::None()); CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None());
} }
// TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported.
......
...@@ -1866,18 +1866,6 @@ struct Tests { ...@@ -1866,18 +1866,6 @@ struct Tests {
} }
} }
} }
void HTypeFromType() {
for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
Type* type1 = *it1;
Type* type2 = *it2;
HType htype1 = HType::FromType(type1);
HType htype2 = HType::FromType(type2);
CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2));
}
}
}
}; };
TEST(IsSomeType_zone) { Tests().IsSomeType(); } TEST(IsSomeType_zone) { Tests().IsSomeType(); }
...@@ -1931,5 +1919,3 @@ TEST(Intersect_zone) { Tests().Intersect(); } ...@@ -1931,5 +1919,3 @@ TEST(Intersect_zone) { Tests().Intersect(); }
TEST(Distributivity_zone) { Tests().Distributivity(); } TEST(Distributivity_zone) { Tests().Distributivity(); }
TEST(GetRange_zone) { Tests().GetRange(); } TEST(GetRange_zone) { Tests().GetRange(); }
TEST(HTypeFromType_zone) { Tests().HTypeFromType(); }
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