Reviewers: Sven Panne,
Description:
Fixed Typefeedback for Number Truncation
Additionally split BuildBinaryOperation into two parts for future usage
by a stub.
BUG=
Please review this at https://codereview.chromium.org/21505002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen.h
M src/hydrogen.cc
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
34ecfa34b58b342399052df6ef589f33fe17eb6c..a905673802ef25a21cbdf6c75bda12fbb2a90b54
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -7631,7 +7631,7 @@ static bool ShiftAmountsAllowReplaceByRotate(HValue*
sa,
// directions that can be replaced by one rotate right instruction or not.
// Returns the operand and the shift amount for the rotate instruction in
the
// former case.
-bool HOptimizedGraphBuilder::MatchRotateRight(HValue* left,
+bool HGraphBuilder::MatchRotateRight(HValue* left,
HValue* right,
HValue** operand,
HValue** shift_amount) {
@@ -7697,6 +7697,7 @@ HValue* HGraphBuilder::TruncateToNumber(HValue*
value, Handle<Type>* expected) {
if_nan.Then();
if_nan.ElseDeopt();
if_nan.End();
+ *expected = handle(Type::Double(), isolate());
return Add<HConstant>(OS::nan_value());
}
@@ -7713,12 +7714,28 @@ HInstruction*
HOptimizedGraphBuilder::BuildBinaryOperation(
Handle<Type> right_type = expr->right()->bounds().lower;
Handle<Type> result_type = expr->bounds().lower;
Maybe<int> fixed_right_arg = expr->fixed_right_arg();
+
+ return HGraphBuilder::BuildBinaryOperation(expr->op(), left, right,
+ left_type, right_type, result_type, fixed_right_arg, context);
+}
+
+
+HInstruction* HGraphBuilder::BuildBinaryOperation(
+ Token::Value op,
+ HValue* left,
+ HValue* right,
+ Handle<Type> left_type,
+ Handle<Type> right_type,
+ Handle<Type> result_type,
+ Maybe<int> fixed_right_arg,
+ HValue* context) {
Representation left_rep = Representation::FromType(left_type);
Representation right_rep = Representation::FromType(right_type);
Representation result_rep = Representation::FromType(result_type);
- if (expr->op() != Token::ADD ||
- (left->type().IsNonString() && right->type().IsNonString())) {
+ if (op != Token::ADD ||
+ (!left_type->Maybe(Type::String()) &&
+ !right_type->Maybe(Type::String()))) {
// For addition we can only truncate the arguments to number if we can
// prove that we will not end up in string concatenation mode.
left = TruncateToNumber(left, &left_type);
@@ -7735,7 +7752,7 @@ HInstruction*
HOptimizedGraphBuilder::BuildBinaryOperation(
right_type = handle(Type::Any(), isolate());
}
HInstruction* instr = NULL;
- switch (expr->op()) {
+ switch (op) {
case Token::ADD:
if (left_type->Is(Type::String()) && right_type->Is(Type::String()))
{
BuildCheckHeapObject(left);
@@ -7761,7 +7778,7 @@ HInstruction*
HOptimizedGraphBuilder::BuildBinaryOperation(
break;
case Token::BIT_XOR:
case Token::BIT_AND:
- instr = NewUncasted<HBitwise>(expr->op(), left, right);
+ instr = NewUncasted<HBitwise>(op, left, right);
break;
case Token::BIT_OR: {
HValue* operand, *shift_amount;
@@ -7770,7 +7787,7 @@ HInstruction*
HOptimizedGraphBuilder::BuildBinaryOperation(
MatchRotateRight(left, right, &operand, &shift_amount)) {
instr = new(zone()) HRor(context, operand, shift_amount);
} else {
- instr = NewUncasted<HBitwise>(expr->op(), left, right);
+ instr = NewUncasted<HBitwise>(op, left, right);
}
break;
}
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
2668d194f2dddcea6915e316b1760a8f046bec28..939a6661c0f96d599da0f024113fb7af2f4d97da
100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1260,6 +1260,21 @@ class HGraphBuilder {
HObjectAccess access,
HValue* typecheck = NULL);
HInstruction* BuildLoadStringLength(HValue* object, HValue* typecheck =
NULL);
+
+ bool MatchRotateRight(HValue* left,
+ HValue* right,
+ HValue** operand,
+ HValue** shift_amount);
+
+ HInstruction* BuildBinaryOperation(Token::Value op,
+ HValue* left,
+ HValue* right,
+ Handle<Type> left_type,
+ Handle<Type> right_type,
+ Handle<Type> result_type,
+ Maybe<int> fixed_right_arg,
+ HValue* context);
+
HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>);
HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck =
NULL);
HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
@@ -2148,11 +2163,6 @@ class HOptimizedGraphBuilder: public HGraphBuilder,
public AstVisitor {
HValue* receiver,
Handle<Map> receiver_map);
- bool MatchRotateRight(HValue* left,
- HValue* right,
- HValue** operand,
- HValue** shift_amount);
-
// The translation state of the currently-being-translated function.
FunctionState* function_state_;
--
--
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/groups/opt_out.