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

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

Issue 269273002: Remove optimization in unoptimized code that leave the graph in bad state (type test). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 const AbstractType& type = node->right()->AsTypeNode()->type(); 1413 const AbstractType& type = node->right()->AsTypeNode()->type();
1414 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); 1414 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
1415 const bool negate_result = (node->kind() == Token::kISNOT); 1415 const bool negate_result = (node->kind() == Token::kISNOT);
1416 // All objects are instances of type T if Object type is a subtype of type T. 1416 // All objects are instances of type T if Object type is a subtype of type T.
1417 const Type& object_type = Type::Handle(Type::ObjectType()); 1417 const Type& object_type = Type::Handle(Type::ObjectType());
1418 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { 1418 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) {
1419 // Must evaluate left side. 1419 // Must evaluate left side.
1420 EffectGraphVisitor for_left_value(owner()); 1420 EffectGraphVisitor for_left_value(owner());
1421 node->left()->Visit(&for_left_value); 1421 node->left()->Visit(&for_left_value);
1422 Append(for_left_value); 1422 Append(for_left_value);
1423 ReturnDefinition(new ConstantInstr(Bool::Get(!negate_result))); 1423 ReturnDefinition(new ConstantInstr(Bool::Get(!negate_result)));
regis 2014/05/06 23:36:57 Will this other optimization cause the same issue?
srdjan 2014/05/06 23:51:56 Do not think so as we are not adding a ConstantIns
1424 return; 1424 return;
1425 } 1425 }
1426 1426
1427 // Eliminate the test if it can be performed successfully at compile time.
1428 if ((node->left() != NULL) &&
1429 node->left()->IsLiteralNode() &&
1430 type.IsInstantiated()) {
1431 const Instance& literal_value = node->left()->AsLiteralNode()->literal();
1432 ConstantInstr* result = NULL;
1433
1434 Error& malformed_error = Error::Handle();
1435 if (literal_value.IsInstanceOf(type,
1436 TypeArguments::Handle(),
1437 &malformed_error)) {
1438 result = new ConstantInstr(Bool::Get(!negate_result));
1439 } else {
1440 result = new ConstantInstr(Bool::Get(negate_result));
1441 }
1442 ASSERT(malformed_error.IsNull());
1443
1444 ReturnDefinition(result);
1445 return;
1446 }
1447
1448 ValueGraphVisitor for_left_value(owner()); 1427 ValueGraphVisitor for_left_value(owner());
1449 node->left()->Visit(&for_left_value); 1428 node->left()->Visit(&for_left_value);
1450 Append(for_left_value); 1429 Append(for_left_value);
1451 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1430 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1452 PushArgumentInstr* push_instantiator = NULL; 1431 PushArgumentInstr* push_instantiator = NULL;
1453 PushArgumentInstr* push_type_args = NULL; 1432 PushArgumentInstr* push_type_args = NULL;
1454 if (type.IsInstantiated()) { 1433 if (type.IsInstantiated()) {
1455 push_instantiator = PushArgument(BuildNullValue()); 1434 push_instantiator = PushArgument(BuildNullValue());
1456 push_type_args = PushArgument(BuildNullValue()); 1435 push_type_args = PushArgument(BuildNullValue());
1457 } else { 1436 } else {
(...skipping 2466 matching lines...) Expand 10 before | Expand all | Expand 10 after
3924 function.token_pos(), 3903 function.token_pos(),
3925 LanguageError::kError, 3904 LanguageError::kError,
3926 Heap::kNew, 3905 Heap::kNew,
3927 "FlowGraphBuilder Bailout: %s %s", 3906 "FlowGraphBuilder Bailout: %s %s",
3928 String::Handle(function.name()).ToCString(), 3907 String::Handle(function.name()).ToCString(),
3929 reason)); 3908 reason));
3930 Isolate::Current()->long_jump_base()->Jump(1, error); 3909 Isolate::Current()->long_jump_base()->Jump(1, error);
3931 } 3910 }
3932 3911
3933 } // namespace dart 3912 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698