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

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

Issue 246293008: Do not ignore side effects of a type test or type cast as expression, such (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/intermediate_language.cc » ('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) 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 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 const String& dst_name) { 1374 const String& dst_name) {
1375 if (CanSkipTypeCheck(token_pos, value, dst_type, dst_name)) { 1375 if (CanSkipTypeCheck(token_pos, value, dst_type, dst_name)) {
1376 return value; 1376 return value;
1377 } 1377 }
1378 return Bind(BuildAssertAssignable(token_pos, value, dst_type, dst_name)); 1378 return Bind(BuildAssertAssignable(token_pos, value, dst_type, dst_name));
1379 } 1379 }
1380 1380
1381 1381
1382 void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) { 1382 void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) {
1383 ASSERT(Token::IsTypeTestOperator(node->kind())); 1383 ASSERT(Token::IsTypeTestOperator(node->kind()));
1384 EffectGraphVisitor for_left_value(owner());
1385 node->left()->Visit(&for_left_value);
1386 Append(for_left_value);
1387 }
1388
1389
1390 void ValueGraphVisitor::BuildTypeTest(ComparisonNode* node) {
1391 ASSERT(Token::IsTypeTestOperator(node->kind()));
1392 const AbstractType& type = node->right()->AsTypeNode()->type(); 1384 const AbstractType& type = node->right()->AsTypeNode()->type();
1393 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); 1385 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
1394 const bool negate_result = (node->kind() == Token::kISNOT); 1386 const bool negate_result = (node->kind() == Token::kISNOT);
1395 // All objects are instances of type T if Object type is a subtype of type T. 1387 // All objects are instances of type T if Object type is a subtype of type T.
1396 const Type& object_type = Type::Handle(Type::ObjectType()); 1388 const Type& object_type = Type::Handle(Type::ObjectType());
1397 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { 1389 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) {
1398 // Must evaluate left side. 1390 // Must evaluate left side.
1399 EffectGraphVisitor for_left_value(owner()); 1391 EffectGraphVisitor for_left_value(owner());
1400 node->left()->Visit(&for_left_value); 1392 node->left()->Visit(&for_left_value);
1401 Append(for_left_value); 1393 Append(for_left_value);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 arguments, 1450 arguments,
1459 Object::null_array(), // No argument names. 1451 Object::null_array(), // No argument names.
1460 kNumArgsChecked, 1452 kNumArgsChecked,
1461 owner()->ic_data_array()); 1453 owner()->ic_data_array());
1462 ReturnDefinition(call); 1454 ReturnDefinition(call);
1463 } 1455 }
1464 1456
1465 1457
1466 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { 1458 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) {
1467 ASSERT(Token::IsTypeCastOperator(node->kind())); 1459 ASSERT(Token::IsTypeCastOperator(node->kind()));
1468 const AbstractType& type = node->right()->AsTypeNode()->type();
1469 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
1470 ValueGraphVisitor for_value(owner());
1471 node->left()->Visit(&for_value);
1472 Append(for_value);
1473 const String& dst_name = String::ZoneHandle(
1474 Symbols::New(Exceptions::kCastErrorDstName));
1475 if (CanSkipTypeCheck(node->token_pos(), for_value.value(), type, dst_name)) {
1476 // Drop the value and 0 additional temporaries.
1477 Do(new DropTempsInstr(0, for_value.value()));
1478 } else {
1479 Do(BuildAssertAssignable(node->token_pos(),
1480 for_value.value(),
1481 type,
1482 dst_name));
1483 }
1484 }
1485
1486
1487 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) {
1488 ASSERT(Token::IsTypeCastOperator(node->kind()));
1489 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); 1460 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
1490 const AbstractType& type = node->right()->AsTypeNode()->type(); 1461 const AbstractType& type = node->right()->AsTypeNode()->type();
1491 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); 1462 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded());
1492 ValueGraphVisitor for_value(owner()); 1463 ValueGraphVisitor for_value(owner());
1493 node->left()->Visit(&for_value); 1464 node->left()->Visit(&for_value);
1494 Append(for_value); 1465 Append(for_value);
1495 const String& dst_name = String::ZoneHandle( 1466 const String& dst_name = String::ZoneHandle(
1496 Symbols::New(Exceptions::kCastErrorDstName)); 1467 Symbols::New(Exceptions::kCastErrorDstName));
1497 if (CanSkipTypeCheck(node->token_pos(), 1468 if (CanSkipTypeCheck(node->token_pos(),
1498 for_value.value(), 1469 for_value.value(),
(...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 LanguageError::kError, 3855 LanguageError::kError,
3885 Heap::kNew, 3856 Heap::kNew,
3886 "FlowGraphBuilder Bailout: %s %s", 3857 "FlowGraphBuilder Bailout: %s %s",
3887 String::Handle(function.name()).ToCString(), 3858 String::Handle(function.name()).ToCString(),
3888 reason)); 3859 reason));
3889 Isolate::Current()->long_jump_base()->Jump(1, error); 3860 Isolate::Current()->long_jump_base()->Jump(1, error);
3890 } 3861 }
3891 3862
3892 3863
3893 } // namespace dart 3864 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698