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

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

Issue 22640019: Fix for running with --throw_on_javascript_int_overflow: recognize pattern (a << b) & mask and test… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
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/code_descriptors.h" 10 #include "vm/code_descriptors.h"
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 ValueGraphVisitor for_value(owner(), temp_index()); 939 ValueGraphVisitor for_value(owner(), temp_index());
940 node->expr()->Visit(&for_value); 940 node->expr()->Visit(&for_value);
941 Append(for_value); 941 Append(for_value);
942 ReturnValue(BuildAssignableValue(node->expr()->token_pos(), 942 ReturnValue(BuildAssignableValue(node->expr()->token_pos(),
943 for_value.value(), 943 for_value.value(),
944 node->type(), 944 node->type(),
945 node->dst_name())); 945 node->dst_name()));
946 } 946 }
947 947
948 948
949
950 static const String& BinaryOpAndMaskName(BinaryOpNode* node) {
951 if (node->kind() == Token::kSHL) {
952 return PrivateCoreLibName(Symbols::_leftShiftWithMask32());
953 }
954 UNIMPLEMENTED();
955 return String::ZoneHandle();
956 }
957
958
949 // <Expression> :: BinaryOp { kind: Token::Kind 959 // <Expression> :: BinaryOp { kind: Token::Kind
950 // left: <Expression> 960 // left: <Expression>
951 // right: <Expression> } 961 // right: <Expression> }
952 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { 962 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
953 // Operators "&&" and "||" cannot be overloaded therefore do not call 963 // Operators "&&" and "||" cannot be overloaded therefore do not call
954 // operator. 964 // operator.
955 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 965 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
966 ASSERT(!node->has_mask32());
956 // See ValueGraphVisitor::VisitBinaryOpNode. 967 // See ValueGraphVisitor::VisitBinaryOpNode.
957 TestGraphVisitor for_left(owner(), 968 TestGraphVisitor for_left(owner(),
958 temp_index(), 969 temp_index(),
959 node->left()->token_pos()); 970 node->left()->token_pos());
960 node->left()->Visit(&for_left); 971 node->left()->Visit(&for_left);
961 EffectGraphVisitor for_right(owner(), temp_index()); 972 EffectGraphVisitor for_right(owner(), temp_index());
962 node->right()->Visit(&for_right); 973 node->right()->Visit(&for_right);
963 EffectGraphVisitor empty(owner(), temp_index()); 974 EffectGraphVisitor empty(owner(), temp_index());
964 if (node->kind() == Token::kAND) { 975 if (node->kind() == Token::kAND) {
965 Join(for_left, for_right, empty); 976 Join(for_left, for_right, empty);
966 } else { 977 } else {
967 Join(for_left, empty, for_right); 978 Join(for_left, empty, for_right);
968 } 979 }
969 return; 980 return;
970 } 981 }
971 ValueGraphVisitor for_left_value(owner(), temp_index()); 982 ValueGraphVisitor for_left_value(owner(), temp_index());
972 node->left()->Visit(&for_left_value); 983 node->left()->Visit(&for_left_value);
973 Append(for_left_value); 984 Append(for_left_value);
974 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 985 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
975 986
976 ValueGraphVisitor for_right_value(owner(), temp_index()); 987 ValueGraphVisitor for_right_value(owner(), temp_index());
977 node->right()->Visit(&for_right_value); 988 node->right()->Visit(&for_right_value);
978 Append(for_right_value); 989 Append(for_right_value);
979 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); 990 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
980 991
992 PushArgumentInstr* push_mask = NULL;
993 if (node->has_mask32()) {
994 Value* mask_value = Bind(new ConstantInstr(
995 Integer::ZoneHandle(Integer::New(node->mask32(), Heap::kOld))));
996 push_mask = PushArgument(mask_value);
997 }
998
999 InstanceCallInstr* call = NULL;
981 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1000 ZoneGrowableArray<PushArgumentInstr*>* arguments =
982 new ZoneGrowableArray<PushArgumentInstr*>(2); 1001 new ZoneGrowableArray<PushArgumentInstr*>(node->has_mask32() ? 3 : 2);
983 arguments->Add(push_left); 1002 arguments->Add(push_left);
984 arguments->Add(push_right); 1003 arguments->Add(push_right);
985 const String& name = String::ZoneHandle(Symbols::New(node->Name())); 1004 if (node->has_mask32()) {
986 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), 1005 // Call to special method 'BinaryOpAndMaskName(node)'.
987 name, 1006 arguments->Add(push_mask);
988 node->kind(), 1007 call = new InstanceCallInstr(node->token_pos(),
989 arguments, 1008 BinaryOpAndMaskName(node),
990 Object::null_array(), 1009 Token::kILLEGAL,
991 2, 1010 arguments,
992 owner()->ic_data_array()); 1011 Object::null_array(),
1012 2, // Collect data for both arguments.
1013 owner()->ic_data_array());
1014
1015 } else {
1016 // Regular code.
1017 const String& name = String::ZoneHandle(Symbols::New(node->Name()));
1018 call = new InstanceCallInstr(node->token_pos(),
1019 name,
1020 node->kind(),
1021 arguments,
1022 Object::null_array(),
1023 2, // Collect data for both arguments.
1024 owner()->ic_data_array());
1025 }
993 ReturnDefinition(call); 1026 ReturnDefinition(call);
994 } 1027 }
995 1028
996 1029
997 // Special handling for AND/OR. 1030 // Special handling for AND/OR.
998 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { 1031 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
999 // Operators "&&" and "||" cannot be overloaded therefore do not call 1032 // Operators "&&" and "||" cannot be overloaded therefore do not call
1000 // operator. 1033 // operator.
1001 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 1034 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
1035 ASSERT(!node->has_mask32());
1002 // Implement short-circuit logic: do not evaluate right if evaluation 1036 // Implement short-circuit logic: do not evaluate right if evaluation
1003 // of left is sufficient. 1037 // of left is sufficient.
1004 // AND: left ? right === true : false; 1038 // AND: left ? right === true : false;
1005 // OR: left ? true : right === true; 1039 // OR: left ? true : right === true;
1006 1040
1007 TestGraphVisitor for_test(owner(), 1041 TestGraphVisitor for_test(owner(),
1008 temp_index(), 1042 temp_index(),
1009 node->left()->token_pos()); 1043 node->left()->token_pos());
1010 node->left()->Visit(&for_test); 1044 node->left()->Visit(&for_test);
1011 1045
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
3626 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3660 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3627 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3661 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3628 OS::SNPrint(chars, len, kFormat, function_name, reason); 3662 OS::SNPrint(chars, len, kFormat, function_name, reason);
3629 const Error& error = Error::Handle( 3663 const Error& error = Error::Handle(
3630 LanguageError::New(String::Handle(String::New(chars)))); 3664 LanguageError::New(String::Handle(String::New(chars))));
3631 Isolate::Current()->long_jump_base()->Jump(1, error); 3665 Isolate::Current()->long_jump_base()->Jump(1, error);
3632 } 3666 }
3633 3667
3634 3668
3635 } // namespace dart 3669 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698