Reviewers: rossberg,
Description:
Give more precise types to some Math functions.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/602693002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+24, -12 lines):
M src/compiler/js-typed-lowering.cc
M src/compiler/typer.h
M src/compiler/typer.cc
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc
b/src/compiler/js-typed-lowering.cc
index
be125342eaed0cc683322c7ccf19ecb3bc4bd79f..23fe36c3ba2f17c4300d2f8b1b7659a1d4270e61
100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -163,7 +163,7 @@ class JSBinopReduction {
return n;
}
- // Try to narrowing a double or number operation to an Int32 operation.
+ // Try narrowing a double or number operation to an Int32 operation.
bool TryNarrowingToI32(Type* type, Node* node) {
switch (node->opcode()) {
case IrOpcode::kFloat64Add:
@@ -573,7 +573,7 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node*
node) {
Type* base_type = NodeProperties::GetBounds(base).upper;
// TODO(mstarzinger): This lowering is not correct if:
// a) The typed array turns external (i.e. MaterializeArrayBuffer)
- // b) The typed array or it's buffer is neutered.
+ // b) The typed array or its buffer is neutered.
if (key_type->Is(Type::Integral32()) && base_type->IsConstant() &&
base_type->AsConstant()->Value()->IsJSTypedArray()) {
// JSStoreProperty(typed-array, int32, value)
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index
bfecdef61e9b5f80413d3a0c653cd0d9e5c9ba81..b6349c9e010f02a3fe9b8e33e50b5589cf7e6a0f
100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -15,16 +15,26 @@ namespace internal {
namespace compiler {
Typer::Typer(Zone* zone) : zone_(zone) {
- Type* number = Type::Number(zone);
- Type* signed32 = Type::Signed32(zone);
- Type* unsigned32 = Type::Unsigned32(zone);
- Type* integral32 = Type::Integral32(zone);
- Type* object = Type::Object(zone);
- Type* undefined = Type::Undefined(zone);
+ Factory* f = zone->isolate()->factory();
+
+ Type* number = Type::Number();
+ Type* signed32 = Type::Signed32();
+ Type* unsigned32 = Type::Unsigned32();
+ Type* integral32 = Type::Integral32();
+ Type* object = Type::Object();
+ Type* undefined = Type::Undefined();
+ Type* weakint = Type::Union(
+ Type::Range(f->NewNumber(-V8_INFINITY), f->NewNumber(+V8_INFINITY),
zone),
+ Type::Union(Type::NaN(), Type::MinusZero(), zone), zone);
+
number_fun0_ = Type::Function(number, zone);
number_fun1_ = Type::Function(number, number, zone);
number_fun2_ = Type::Function(number, number, number, zone);
+ weakint_fun1_ = Type::Function(weakint, number, zone);
imul_fun_ = Type::Function(signed32, integral32, integral32, zone);
+ random_fun_ = Type::Function(Type::Union(
+ Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
+
#define NATIVE_TYPE(sem, rep) \
Type::Intersect(Type::sem(zone), Type::rep(zone), zone)
@@ -834,13 +844,13 @@ Type* Typer::Visitor::TypeConstant(Handle<Object>
value) {
} else if (*value == native->math_atan2_fun()) {
return typer_->number_fun2_;
} else if (*value == native->math_ceil_fun()) {
- return typer_->number_fun1_;
+ return typer_->weakint_fun1_;
} else if (*value == native->math_cos_fun()) {
return typer_->number_fun1_;
} else if (*value == native->math_exp_fun()) {
return typer_->number_fun1_;
} else if (*value == native->math_floor_fun()) {
- return typer_->number_fun1_;
+ return typer_->weakint_fun1_;
} else if (*value == native->math_imul_fun()) {
return typer_->imul_fun_;
} else if (*value == native->math_log_fun()) {
@@ -848,9 +858,9 @@ Type* Typer::Visitor::TypeConstant(Handle<Object>
value) {
} else if (*value == native->math_pow_fun()) {
return typer_->number_fun2_;
} else if (*value == native->math_random_fun()) {
- return typer_->number_fun0_;
+ return typer_->random_fun_;
} else if (*value == native->math_round_fun()) {
- return typer_->number_fun1_;
+ return typer_->weakint_fun1_;
} else if (*value == native->math_sin_fun()) {
return typer_->number_fun1_;
} else if (*value == native->math_sqrt_fun()) {
Index: src/compiler/typer.h
diff --git a/src/compiler/typer.h b/src/compiler/typer.h
index
2957e4b4a8e0dd0035ce4d532f476e4d5825df5a..2adbab5ff7002505e39484277cdc8be98cb7a62e
100644
--- a/src/compiler/typer.h
+++ b/src/compiler/typer.h
@@ -39,7 +39,9 @@ class Typer {
Type* number_fun0_;
Type* number_fun1_;
Type* number_fun2_;
+ Type* weakint_fun1_;
Type* imul_fun_;
+ Type* random_fun_;
Type* array_buffer_fun_;
Type* int8_array_fun_;
Type* int16_array_fun_;
--
--
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.