Commit cae6842a authored by rossberg@chromium.org's avatar rossberg@chromium.org

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
parent 6b7f9dba
...@@ -69,9 +69,7 @@ class Typer::Visitor : public NullNodeVisitor { ...@@ -69,9 +69,7 @@ class Typer::Visitor : public NullNodeVisitor {
Bounds TypeNode(Node* node) { Bounds TypeNode(Node* node) {
switch (node->opcode()) { switch (node->opcode()) {
#define DECLARE_CASE(x) \ #define DECLARE_CASE(x) case IrOpcode::k##x: return Type##x(node);
case IrOpcode::k##x: \
return Type##x(node);
VALUE_OP_LIST(DECLARE_CASE) VALUE_OP_LIST(DECLARE_CASE)
#undef DECLARE_CASE #undef DECLARE_CASE
...@@ -119,12 +117,11 @@ class Typer::RunVisitor : public Typer::Visitor { ...@@ -119,12 +117,11 @@ class Typer::RunVisitor : public Typer::Visitor {
phis(NodeSet::key_compare(), NodeSet::allocator_type(typer->zone())) {} phis(NodeSet::key_compare(), NodeSet::allocator_type(typer->zone())) {}
GenericGraphVisit::Control Pre(Node* node) { GenericGraphVisit::Control Pre(Node* node) {
return NodeProperties::IsControl(node) && return NodeProperties::IsControl(node)
node->opcode() != IrOpcode::kEnd && && node->opcode() != IrOpcode::kEnd
node->opcode() != IrOpcode::kMerge && && node->opcode() != IrOpcode::kMerge
node->opcode() != IrOpcode::kReturn && node->opcode() != IrOpcode::kReturn
? GenericGraphVisit::SKIP ? GenericGraphVisit::SKIP : GenericGraphVisit::CONTINUE;
: GenericGraphVisit::CONTINUE;
} }
GenericGraphVisit::Control Post(Node* node) { GenericGraphVisit::Control Post(Node* node) {
...@@ -153,8 +150,8 @@ class Typer::NarrowVisitor : public Typer::Visitor { ...@@ -153,8 +150,8 @@ class Typer::NarrowVisitor : public Typer::Visitor {
NodeProperties::SetBounds(node, Bounds::Both(bounds, previous, zone())); NodeProperties::SetBounds(node, Bounds::Both(bounds, previous, zone()));
DCHECK(bounds.Narrows(previous)); DCHECK(bounds.Narrows(previous));
// Stop when nothing changed (but allow reentry in case it does later). // Stop when nothing changed (but allow reentry in case it does later).
return previous.Narrows(bounds) ? GenericGraphVisit::DEFER return previous.Narrows(bounds)
: GenericGraphVisit::REENTER; ? GenericGraphVisit::DEFER : GenericGraphVisit::REENTER;
} }
GenericGraphVisit::Control Post(Node* node) { GenericGraphVisit::Control Post(Node* node) {
...@@ -175,8 +172,8 @@ class Typer::WidenVisitor : public Typer::Visitor { ...@@ -175,8 +172,8 @@ class Typer::WidenVisitor : public Typer::Visitor {
DCHECK(previous.upper->Is(bounds.upper)); DCHECK(previous.upper->Is(bounds.upper));
NodeProperties::SetBounds(node, bounds); // TODO(rossberg): Either? NodeProperties::SetBounds(node, bounds); // TODO(rossberg): Either?
// Stop when nothing changed (but allow reentry in case it does later). // Stop when nothing changed (but allow reentry in case it does later).
return bounds.Narrows(previous) ? GenericGraphVisit::DEFER return bounds.Narrows(previous)
: GenericGraphVisit::REENTER; ? GenericGraphVisit::DEFER : GenericGraphVisit::REENTER;
} }
GenericGraphVisit::Control Post(Node* node) { GenericGraphVisit::Control Post(Node* node) {
...@@ -344,23 +341,19 @@ Bounds Typer::Visitor::TypeJSAdd(Node* node) { ...@@ -344,23 +341,19 @@ Bounds Typer::Visitor::TypeJSAdd(Node* node) {
Bounds left = OperandType(node, 0); Bounds left = OperandType(node, 0);
Bounds right = OperandType(node, 1); Bounds right = OperandType(node, 1);
Type* lower = Type* lower =
left.lower->Is(Type::None()) || right.lower->Is(Type::None()) left.lower->Is(Type::None()) || right.lower->Is(Type::None()) ?
? Type::None(zone()) Type::None(zone()) :
: left.lower->Is(Type::Number()) && right.lower->Is(Type::Number()) left.lower->Is(Type::Number()) && right.lower->Is(Type::Number()) ?
? Type::SignedSmall(zone()) Type::SignedSmall(zone()) :
: left.lower->Is(Type::String()) || left.lower->Is(Type::String()) || right.lower->Is(Type::String()) ?
right.lower->Is(Type::String()) Type::String(zone()) : Type::None(zone());
? Type::String(zone())
: Type::None(zone());
Type* upper = Type* upper =
left.upper->Is(Type::None()) && right.upper->Is(Type::None()) left.upper->Is(Type::None()) && right.upper->Is(Type::None()) ?
? Type::None(zone()) Type::None(zone()) :
: left.upper->Is(Type::Number()) && right.upper->Is(Type::Number()) left.upper->Is(Type::Number()) && right.upper->Is(Type::Number()) ?
? Type::Number(zone()) Type::Number(zone()) :
: left.upper->Is(Type::String()) || left.upper->Is(Type::String()) || right.upper->Is(Type::String()) ?
right.upper->Is(Type::String()) Type::String(zone()) : Type::NumberOrString(zone());
? Type::String(zone())
: Type::NumberOrString(zone());
return Bounds(lower, upper); return Bounds(lower, upper);
} }
...@@ -437,12 +430,12 @@ Bounds Typer::Visitor::TypeJSLoadProperty(Node* node) { ...@@ -437,12 +430,12 @@ Bounds Typer::Visitor::TypeJSLoadProperty(Node* node) {
Bounds result = Bounds::Unbounded(zone()); Bounds result = Bounds::Unbounded(zone());
// TODO(rossberg): Use range types and sized array types to filter undefined. // TODO(rossberg): Use range types and sized array types to filter undefined.
if (object.lower->IsArray() && name.lower->Is(Type::Integral32())) { if (object.lower->IsArray() && name.lower->Is(Type::Integral32())) {
result.lower = Type::Union(object.lower->AsArray()->Element(), result.lower = Type::Union(
Type::Undefined(zone()), zone()); object.lower->AsArray()->Element(), Type::Undefined(zone()), zone());
} }
if (object.upper->IsArray() && name.upper->Is(Type::Integral32())) { if (object.upper->IsArray() && name.upper->Is(Type::Integral32())) {
result.upper = Type::Union(object.upper->AsArray()->Element(), result.upper = Type::Union(
Type::Undefined(zone()), zone()); object.upper->AsArray()->Element(), Type::Undefined(zone()), zone());
} }
return result; return result;
} }
...@@ -572,10 +565,10 @@ Bounds Typer::Visitor::TypeJSCallConstruct(Node* node) { ...@@ -572,10 +565,10 @@ Bounds Typer::Visitor::TypeJSCallConstruct(Node* node) {
Bounds Typer::Visitor::TypeJSCallFunction(Node* node) { Bounds Typer::Visitor::TypeJSCallFunction(Node* node) {
Bounds fun = OperandType(node, 0); Bounds fun = OperandType(node, 0);
Type* lower = fun.lower->IsFunction() ? fun.lower->AsFunction()->Result() Type* lower = fun.lower->IsFunction()
: Type::None(zone()); ? fun.lower->AsFunction()->Result() : Type::None(zone());
Type* upper = fun.upper->IsFunction() ? fun.upper->AsFunction()->Result() Type* upper = fun.upper->IsFunction()
: Type::Any(zone()); ? fun.upper->AsFunction()->Result() : Type::Any(zone());
return Bounds(lower, upper); return Bounds(lower, upper);
} }
...@@ -751,7 +744,7 @@ Bounds Typer::Visitor::TypeStoreElement(Node* node) { ...@@ -751,7 +744,7 @@ Bounds Typer::Visitor::TypeStoreElement(Node* node) {
// TODO(rossberg): implement // TODO(rossberg): implement
#define DEFINE_METHOD(x) \ #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) MACHINE_OP_LIST(DEFINE_METHOD)
#undef DEFINE_METHOD #undef DEFINE_METHOD
...@@ -831,12 +824,14 @@ class TyperDecorator : public GraphDecorator { ...@@ -831,12 +824,14 @@ class TyperDecorator : public GraphDecorator {
private: private:
Typer* typer_; Typer* typer_;
}; };
} }
void Typer::DecorateGraph(Graph* graph) { void Typer::DecorateGraph(Graph* graph) {
graph->AddDecorator(new (zone()) TyperDecorator(this)); graph->AddDecorator(new (zone()) TyperDecorator(this));
} }
} }
} }
} // namespace v8::internal::compiler } // namespace v8::internal::compiler
...@@ -123,21 +123,31 @@ int TypeImpl<Config>::BitsetType::Lub(double value) { ...@@ -123,21 +123,31 @@ int TypeImpl<Config>::BitsetType::Lub(double value) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
if (i::IsMinusZero(value)) return kMinusZero; if (i::IsMinusZero(value)) return kMinusZero;
if (std::isnan(value)) return kNaN; if (std::isnan(value)) return kNaN;
if (IsUint32Double(value)) { if (IsUint32Double(value)) return Lub(FastD2UI(value));
uint32_t u = FastD2UI(value); if (IsInt32Double(value)) return Lub(FastD2I(value));
if (u < 0x40000000u) return kUnsignedSmall; return kOtherNumber;
if (u < 0x80000000u) { }
return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall;
}
return kOtherUnsigned32; template<class Config>
int TypeImpl<Config>::BitsetType::Lub(int32_t value) {
if (value >= 0x40000000) {
return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall;
} }
if (IsInt32Double(value)) { if (value >= 0) return kUnsignedSmall;
int32_t i = FastD2I(value); if (value >= -0x40000000) return kOtherSignedSmall;
DCHECK(i < 0); return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall;
if (i >= -0x40000000) return kOtherSignedSmall; }
return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall;
template<class Config>
int TypeImpl<Config>::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;
} }
......
...@@ -7,12 +7,11 @@ ...@@ -7,12 +7,11 @@
#include "src/factory.h" #include "src/factory.h"
#include "src/handles.h" #include "src/handles.h"
#include "src/ostreams.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class OStream;
// SUMMARY // SUMMARY
// //
// A simple type system for compiler-internal use. It is based entirely on // A simple type system for compiler-internal use. It is based entirely on
...@@ -512,6 +511,8 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> { ...@@ -512,6 +511,8 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
static int Lub(TypeImpl* type); // least upper bound that's a bitset static int Lub(TypeImpl* type); // least upper bound that's a bitset
static int Lub(i::Object* value); static int Lub(i::Object* value);
static int Lub(double 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 Lub(i::Map* map);
static int InherentLub(TypeImpl* type); static int InherentLub(TypeImpl* type);
......
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