From cae6842a748696ca34f7db7d695a819f24970337 Mon Sep 17 00:00:00 2001 From: "rossberg@chromium.org" Date: Tue, 5 Aug 2014 13:19:32 +0000 Subject: [PATCH] Undo some unintended changes from the Turbofan merge R=mstarzinger@chromium.org BUG= Review URL: https://codereview.chromium.org/435423002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22873 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler/typer.cc | 71 ++++++++++++++++++++++++--------------------------- src/types.cc | 36 ++++++++++++++++---------- src/types.h | 5 ++-- 3 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc index 3869cac..54af9db 100644 --- a/src/compiler/typer.cc +++ b/src/compiler/typer.cc @@ -69,9 +69,7 @@ class Typer::Visitor : public NullNodeVisitor { Bounds TypeNode(Node* node) { switch (node->opcode()) { -#define DECLARE_CASE(x) \ - case IrOpcode::k##x: \ - return Type##x(node); +#define DECLARE_CASE(x) case IrOpcode::k##x: return Type##x(node); VALUE_OP_LIST(DECLARE_CASE) #undef DECLARE_CASE @@ -119,12 +117,11 @@ class Typer::RunVisitor : public Typer::Visitor { phis(NodeSet::key_compare(), NodeSet::allocator_type(typer->zone())) {} GenericGraphVisit::Control Pre(Node* node) { - return NodeProperties::IsControl(node) && - node->opcode() != IrOpcode::kEnd && - node->opcode() != IrOpcode::kMerge && - node->opcode() != IrOpcode::kReturn - ? GenericGraphVisit::SKIP - : GenericGraphVisit::CONTINUE; + return NodeProperties::IsControl(node) + && node->opcode() != IrOpcode::kEnd + && node->opcode() != IrOpcode::kMerge + && node->opcode() != IrOpcode::kReturn + ? GenericGraphVisit::SKIP : GenericGraphVisit::CONTINUE; } GenericGraphVisit::Control Post(Node* node) { @@ -153,8 +150,8 @@ class Typer::NarrowVisitor : public Typer::Visitor { NodeProperties::SetBounds(node, Bounds::Both(bounds, previous, zone())); DCHECK(bounds.Narrows(previous)); // Stop when nothing changed (but allow reentry in case it does later). - return previous.Narrows(bounds) ? GenericGraphVisit::DEFER - : GenericGraphVisit::REENTER; + return previous.Narrows(bounds) + ? GenericGraphVisit::DEFER : GenericGraphVisit::REENTER; } GenericGraphVisit::Control Post(Node* node) { @@ -175,8 +172,8 @@ class Typer::WidenVisitor : public Typer::Visitor { DCHECK(previous.upper->Is(bounds.upper)); NodeProperties::SetBounds(node, bounds); // TODO(rossberg): Either? // Stop when nothing changed (but allow reentry in case it does later). - return bounds.Narrows(previous) ? GenericGraphVisit::DEFER - : GenericGraphVisit::REENTER; + return bounds.Narrows(previous) + ? GenericGraphVisit::DEFER : GenericGraphVisit::REENTER; } GenericGraphVisit::Control Post(Node* node) { @@ -344,23 +341,19 @@ Bounds Typer::Visitor::TypeJSAdd(Node* node) { Bounds left = OperandType(node, 0); Bounds right = OperandType(node, 1); Type* lower = - left.lower->Is(Type::None()) || right.lower->Is(Type::None()) - ? Type::None(zone()) - : left.lower->Is(Type::Number()) && right.lower->Is(Type::Number()) - ? Type::SignedSmall(zone()) - : left.lower->Is(Type::String()) || - right.lower->Is(Type::String()) - ? Type::String(zone()) - : Type::None(zone()); + left.lower->Is(Type::None()) || right.lower->Is(Type::None()) ? + Type::None(zone()) : + left.lower->Is(Type::Number()) && right.lower->Is(Type::Number()) ? + Type::SignedSmall(zone()) : + left.lower->Is(Type::String()) || right.lower->Is(Type::String()) ? + Type::String(zone()) : Type::None(zone()); Type* upper = - left.upper->Is(Type::None()) && right.upper->Is(Type::None()) - ? Type::None(zone()) - : left.upper->Is(Type::Number()) && right.upper->Is(Type::Number()) - ? Type::Number(zone()) - : left.upper->Is(Type::String()) || - right.upper->Is(Type::String()) - ? Type::String(zone()) - : Type::NumberOrString(zone()); + left.upper->Is(Type::None()) && right.upper->Is(Type::None()) ? + Type::None(zone()) : + left.upper->Is(Type::Number()) && right.upper->Is(Type::Number()) ? + Type::Number(zone()) : + left.upper->Is(Type::String()) || right.upper->Is(Type::String()) ? + Type::String(zone()) : Type::NumberOrString(zone()); return Bounds(lower, upper); } @@ -437,12 +430,12 @@ Bounds Typer::Visitor::TypeJSLoadProperty(Node* node) { Bounds result = Bounds::Unbounded(zone()); // TODO(rossberg): Use range types and sized array types to filter undefined. if (object.lower->IsArray() && name.lower->Is(Type::Integral32())) { - result.lower = Type::Union(object.lower->AsArray()->Element(), - Type::Undefined(zone()), zone()); + result.lower = Type::Union( + object.lower->AsArray()->Element(), Type::Undefined(zone()), zone()); } if (object.upper->IsArray() && name.upper->Is(Type::Integral32())) { - result.upper = Type::Union(object.upper->AsArray()->Element(), - Type::Undefined(zone()), zone()); + result.upper = Type::Union( + object.upper->AsArray()->Element(), Type::Undefined(zone()), zone()); } return result; } @@ -572,10 +565,10 @@ Bounds Typer::Visitor::TypeJSCallConstruct(Node* node) { Bounds Typer::Visitor::TypeJSCallFunction(Node* node) { Bounds fun = OperandType(node, 0); - Type* lower = fun.lower->IsFunction() ? fun.lower->AsFunction()->Result() - : Type::None(zone()); - Type* upper = fun.upper->IsFunction() ? fun.upper->AsFunction()->Result() - : Type::Any(zone()); + Type* lower = fun.lower->IsFunction() + ? fun.lower->AsFunction()->Result() : Type::None(zone()); + Type* upper = fun.upper->IsFunction() + ? fun.upper->AsFunction()->Result() : Type::Any(zone()); return Bounds(lower, upper); } @@ -751,7 +744,7 @@ Bounds Typer::Visitor::TypeStoreElement(Node* node) { // TODO(rossberg): implement #define DEFINE_METHOD(x) \ - Bounds Typer::Visitor::Type##x(Node* node) { return Bounds(Type::None()); } + Bounds Typer::Visitor::Type##x(Node* node) { return Bounds(Type::None()); } MACHINE_OP_LIST(DEFINE_METHOD) #undef DEFINE_METHOD @@ -831,12 +824,14 @@ class TyperDecorator : public GraphDecorator { private: Typer* typer_; }; + } void Typer::DecorateGraph(Graph* graph) { graph->AddDecorator(new (zone()) TyperDecorator(this)); } + } } } // namespace v8::internal::compiler diff --git a/src/types.cc b/src/types.cc index 6205c4a..c4e32f7 100644 --- a/src/types.cc +++ b/src/types.cc @@ -123,21 +123,31 @@ int TypeImpl::BitsetType::Lub(double value) { DisallowHeapAllocation no_allocation; if (i::IsMinusZero(value)) return kMinusZero; if (std::isnan(value)) return kNaN; - if (IsUint32Double(value)) { - uint32_t u = FastD2UI(value); - if (u < 0x40000000u) return kUnsignedSmall; - if (u < 0x80000000u) { - return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall; - } - return kOtherUnsigned32; + if (IsUint32Double(value)) return Lub(FastD2UI(value)); + if (IsInt32Double(value)) return Lub(FastD2I(value)); + return kOtherNumber; +} + + +template +int TypeImpl::BitsetType::Lub(int32_t value) { + if (value >= 0x40000000) { + return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall; } - if (IsInt32Double(value)) { - int32_t i = FastD2I(value); - DCHECK(i < 0); - if (i >= -0x40000000) return kOtherSignedSmall; - return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall; + if (value >= 0) return kUnsignedSmall; + if (value >= -0x40000000) return kOtherSignedSmall; + return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall; +} + + +template +int TypeImpl::BitsetType::Lub(uint32_t value) { + DisallowHeapAllocation no_allocation; + if (value >= 0x80000000u) return kOtherUnsigned32; + if (value >= 0x40000000u) { + return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall; } - return kOtherNumber; + return kUnsignedSmall; } diff --git a/src/types.h b/src/types.h index 98b9e01..f141712 100644 --- a/src/types.h +++ b/src/types.h @@ -7,12 +7,11 @@ #include "src/factory.h" #include "src/handles.h" +#include "src/ostreams.h" namespace v8 { namespace internal { -class OStream; - // SUMMARY // // A simple type system for compiler-internal use. It is based entirely on @@ -512,6 +511,8 @@ class TypeImpl::BitsetType : public TypeImpl { static int Lub(TypeImpl* type); // least upper bound that's a bitset static int Lub(i::Object* value); static int Lub(double value); + static int Lub(int32_t value); + static int Lub(uint32_t value); static int Lub(i::Map* map); static int InherentLub(TypeImpl* type); -- 2.7.4