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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 24360002: VM: Fix bug in constant propagation with integer division and modulo. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 6401 matching lines...) Expand 10 before | Expand all | Expand 10 after
6412 const Object& left = left_val.definition()->constant_value(); 6412 const Object& left = left_val.definition()->constant_value();
6413 const Object& right = right_val.definition()->constant_value(); 6413 const Object& right = right_val.definition()->constant_value();
6414 if (IsNonConstant(left) || IsNonConstant(right)) { 6414 if (IsNonConstant(left) || IsNonConstant(right)) {
6415 // TODO(srdjan): Add arithemtic simplifications, e.g, add with 0. 6415 // TODO(srdjan): Add arithemtic simplifications, e.g, add with 0.
6416 SetValue(instr, non_constant_); 6416 SetValue(instr, non_constant_);
6417 } else if (IsConstant(left) && IsConstant(right)) { 6417 } else if (IsConstant(left) && IsConstant(right)) {
6418 if (left.IsInteger() && right.IsInteger()) { 6418 if (left.IsInteger() && right.IsInteger()) {
6419 const Integer& left_int = Integer::Cast(left); 6419 const Integer& left_int = Integer::Cast(left);
6420 const Integer& right_int = Integer::Cast(right); 6420 const Integer& right_int = Integer::Cast(right);
6421 switch (op_kind) { 6421 switch (op_kind) {
6422 case Token::kTRUNCDIV:
6423 case Token::kMOD:
6424 // Check right value for zero.
6425 if (right_int.AsInt64Value() == 0) {
6426 SetValue(instr, non_constant_);
6427 break;
6428 }
6429 // Fall through.
6422 case Token::kADD: 6430 case Token::kADD:
6423 case Token::kSUB: 6431 case Token::kSUB:
6424 case Token::kMUL: 6432 case Token::kMUL: {
6425 case Token::kTRUNCDIV:
6426 case Token::kMOD: {
6427 Instance& result = Integer::ZoneHandle( 6433 Instance& result = Integer::ZoneHandle(
6428 left_int.ArithmeticOp(op_kind, right_int)); 6434 left_int.ArithmeticOp(op_kind, right_int));
6429 result = result.CheckAndCanonicalize(NULL); 6435 result = result.CheckAndCanonicalize(NULL);
6430 ASSERT(!result.IsNull()); 6436 ASSERT(!result.IsNull());
6431 SetValue(instr, result); 6437 SetValue(instr, result);
6432 break; 6438 break;
6433 } 6439 }
6434 case Token::kSHL: 6440 case Token::kSHL:
6435 case Token::kSHR: 6441 case Token::kSHR:
6436 if (left.IsSmi() && right.IsSmi()) { 6442 if (left.IsSmi() && right.IsSmi()) {
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
7647 } 7653 }
7648 7654
7649 // Insert materializations at environment uses. 7655 // Insert materializations at environment uses.
7650 for (intptr_t i = 0; i < exits.length(); i++) { 7656 for (intptr_t i = 0; i < exits.length(); i++) {
7651 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7657 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7652 } 7658 }
7653 } 7659 }
7654 7660
7655 7661
7656 } // namespace dart 7662 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698