Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1664)

Unified Diff: runtime/vm/parser.cc

Issue 8355041: Some performance improvements to make raytracer faster (e.g, support intensified operation in mix... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 578)
+++ runtime/vm/parser.cc (working copy)
@@ -4923,7 +4923,7 @@
str_concat->AddExpr(right_operand);
left_operand = str_concat;
} else {
- left_operand = new BinaryOpNode(
+ left_operand = OptimizeBinaryOpNode(
op_pos, op_kind, left_operand, right_operand);
}
}
@@ -5036,6 +5036,31 @@
}
+// TODO(srdjan): Implement other optimizations.
+AstNode* Parser::OptimizeBinaryOpNode(intptr_t op_pos,
+ Token::Kind binary_op,
+ AstNode* lhs,
+ AstNode* rhs) {
+ LiteralNode* lhs_literal = lhs->AsLiteralNode();
+ LiteralNode* rhs_literal = rhs->AsLiteralNode();
+ if ((lhs_literal != NULL) && (rhs_literal != NULL)) {
+ if (lhs_literal->literal().IsDouble() &&
+ rhs_literal->literal().IsDouble()) {
+ Double& dbl_obj = Double::ZoneHandle();
+ dbl_obj ^= lhs_literal->literal().raw();
+ double left_double = dbl_obj.value();
+ dbl_obj ^= rhs_literal->literal().raw();
+ double right_double = dbl_obj.value();
+ if (binary_op == Token::kDIV) {
+ dbl_obj = Double::New(left_double / right_double);
siva 2011/10/21 00:41:52 what if right_double is 0.0? Also do you have to d
srdjan 2011/10/21 06:52:59 The division in C++ behaves the same as in Dart (s
+ return new LiteralNode(op_pos, dbl_obj);
+ }
+ }
+ }
+ return new BinaryOpNode(op_pos, binary_op, lhs, rhs);
+}
+
+
AstNode* Parser::ExpandAssignableOp(intptr_t op_pos,
Token::Kind assignment_op,
AstNode* lhs,
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698