Reviewers: jarin,
Description:
[WIP] Faster smi tagging.
THIS IS NOT CORRECT, JUST A STARTER IDEA...
[email protected]
Please review this at https://codereview.chromium.org/711923003/
Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+15, -0 lines):
M src/compiler/change-lowering.cc
M src/compiler/typer.cc
Index: src/compiler/change-lowering.cc
diff --git a/src/compiler/change-lowering.cc
b/src/compiler/change-lowering.cc
index
16fbfa3fbedcf84d3ff256a399465e8c91274e2c..a4e081a58d6481d39aa0f082353bd856eb5cdbdd
100644
--- a/src/compiler/change-lowering.cc
+++ b/src/compiler/change-lowering.cc
@@ -163,6 +163,9 @@ Reduction ChangeLowering::ChangeInt32ToTagged(Node*
value, Node* control) {
machine()->Word64Shl(),
graph()->NewNode(machine()->ChangeInt32ToInt64(), value),
SmiShiftBitsConstant()));
+ } else if
(NodeProperties::GetBounds(value).upper->Is(Type::SignedSmall())) {
+ return Replace(
+ graph()->NewNode(machine()->WordShl(), value,
SmiShiftBitsConstant()));
}
Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), value,
value);
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index
0fa2b95ebd3460350def99acdd14b2341d7b1b00..745a43536afeeb6997adb43d468fa559c92cef82
100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -739,6 +739,11 @@ Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs,
Type* rhs, Typer* t) {
double rmin = rhs->Min();
double lmax = lhs->Max();
double rmax = rhs->Max();
+ if (std::min(lmax, rmax) < kMaxInt) {
+ Handle<Object> min = f->NewNumber(0);
+ Handle<Object> max = f->NewNumber(std::min(lmax, rmax));
+ return Type::Range(min, max, t->zone());
+ }
// And-ing any two values results in a value no larger than their
maximum.
// Even no larger than their minimum if both values are non-negative.
Handle<Object> max = f->NewNumber(
@@ -780,6 +785,7 @@ Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type*
rhs, Typer* t) {
Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) {
lhs = NumberToInt32(ToNumber(lhs, t), t);
+ rhs = NumberToInt32(ToNumber(rhs, t), t);
Factory* f = t->isolate()->factory();
if (lhs->Min() >= 0) {
// Right-shifting a non-negative value cannot make it negative, nor
larger.
@@ -793,6 +799,12 @@ Type* Typer::Visitor::JSShiftRightTyper(Type* lhs,
Type* rhs, Typer* t) {
Handle<Object> max = f->NewNumber(-1);
return Type::Range(min, max, t->zone());
}
+ if (rhs->Min() > 0) {
+ // Right-shifting by a positve value yields a small integer value.
+ Handle<Object> min = f->NewNumber(kMinInt >>
static_cast<int>(rhs->Min()));
+ Handle<Object> max = f->NewNumber(kMaxInt >>
static_cast<int>(rhs->Min()));
+ return Type::Range(min, max, t->zone());
+ }
return Type::Signed32();
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.