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

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
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/flow_graph_optimizer.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/code_descriptors.h" 10 #include "vm/code_descriptors.h"
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 ValueGraphVisitor for_right_value(owner(), temp_index()); 976 ValueGraphVisitor for_right_value(owner(), temp_index());
977 node->right()->Visit(&for_right_value); 977 node->right()->Visit(&for_right_value);
978 Append(for_right_value); 978 Append(for_right_value);
979 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); 979 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
980 980
981 ZoneGrowableArray<PushArgumentInstr*>* arguments = 981 ZoneGrowableArray<PushArgumentInstr*>* arguments =
982 new ZoneGrowableArray<PushArgumentInstr*>(2); 982 new ZoneGrowableArray<PushArgumentInstr*>(2);
983 arguments->Add(push_left); 983 arguments->Add(push_left);
984 arguments->Add(push_right); 984 arguments->Add(push_right);
985 const String& name = String::ZoneHandle(Symbols::New(node->Name())); 985 const String& name = String::ZoneHandle(Symbols::New(node->Name()));
986 const intptr_t kNumArgsChecked = 2;
986 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), 987 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(),
987 name, 988 name,
988 node->kind(), 989 node->kind(),
989 arguments, 990 arguments,
990 Object::null_array(), 991 Object::null_array(),
991 2, 992 kNumArgsChecked,
992 owner()->ic_data_array()); 993 owner()->ic_data_array());
993 ReturnDefinition(call); 994 ReturnDefinition(call);
994 } 995 }
995 996
996 997
997 // Special handling for AND/OR. 998 // Special handling for AND/OR.
998 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { 999 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
999 // Operators "&&" and "||" cannot be overloaded therefore do not call 1000 // Operators "&&" and "||" cannot be overloaded therefore do not call
1000 // operator. 1001 // operator.
1001 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 1002 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 for_true.Do(BuildStoreExprTemp(constant_true)); 1038 for_true.Do(BuildStoreExprTemp(constant_true));
1038 Join(for_test, for_true, for_right); 1039 Join(for_test, for_true, for_right);
1039 } 1040 }
1040 ReturnDefinition(BuildLoadExprTemp()); 1041 ReturnDefinition(BuildLoadExprTemp());
1041 return; 1042 return;
1042 } 1043 }
1043 EffectGraphVisitor::VisitBinaryOpNode(node); 1044 EffectGraphVisitor::VisitBinaryOpNode(node);
1044 } 1045 }
1045 1046
1046 1047
1048 static const String& BinaryOpAndMaskName(BinaryOpNode* node) {
1049 if (node->kind() == Token::kSHL) {
1050 return PrivateCoreLibName(Symbols::_leftShiftWithMask32());
1051 }
1052 UNIMPLEMENTED();
1053 return String::ZoneHandle();
1054 }
1055
1056
1057 // <Expression> :: BinaryOp { kind: Token::Kind
1058 // left: <Expression>
1059 // right: <Expression>
1060 // mask32: constant }
1061 void EffectGraphVisitor::VisitBinaryOpWithMask32Node(
1062 BinaryOpWithMask32Node* node) {
1063 ASSERT((node->kind() != Token::kAND) && (node->kind() != Token::kOR));
1064 ValueGraphVisitor for_left_value(owner(), temp_index());
1065 node->left()->Visit(&for_left_value);
1066 Append(for_left_value);
1067 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1068
1069 ValueGraphVisitor for_right_value(owner(), temp_index());
1070 node->right()->Visit(&for_right_value);
1071 Append(for_right_value);
1072 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
1073
1074 Value* mask_value = Bind(new ConstantInstr(
1075 Integer::ZoneHandle(Integer::New(node->mask32(), Heap::kOld))));
1076 PushArgumentInstr* push_mask = PushArgument(mask_value);
1077
1078 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1079 new ZoneGrowableArray<PushArgumentInstr*>(3);
1080 arguments->Add(push_left);
1081 arguments->Add(push_right);
1082 // Call to special method 'BinaryOpAndMaskName(node)'.
1083 arguments->Add(push_mask);
1084 const intptr_t kNumArgsChecked = 2;
1085 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(),
1086 BinaryOpAndMaskName(node),
1087 Token::kILLEGAL,
1088 arguments,
1089 Object::null_array(),
1090 kNumArgsChecked,
1091 owner()->ic_data_array());
1092 ReturnDefinition(call);
1093 }
1094
1095
1047 void EffectGraphVisitor::BuildTypecheckPushArguments( 1096 void EffectGraphVisitor::BuildTypecheckPushArguments(
1048 intptr_t token_pos, 1097 intptr_t token_pos,
1049 PushArgumentInstr** push_instantiator_result, 1098 PushArgumentInstr** push_instantiator_result,
1050 PushArgumentInstr** push_instantiator_type_arguments_result) { 1099 PushArgumentInstr** push_instantiator_type_arguments_result) {
1051 const Class& instantiator_class = Class::Handle( 1100 const Class& instantiator_class = Class::Handle(
1052 owner()->parsed_function()->function().Owner()); 1101 owner()->parsed_function()->function().Owner());
1053 // Since called only when type tested against is not instantiated. 1102 // Since called only when type tested against is not instantiated.
1054 ASSERT(instantiator_class.NumTypeParameters() > 0); 1103 ASSERT(instantiator_class.NumTypeParameters() > 0);
1055 Value* instantiator_type_arguments = NULL; 1104 Value* instantiator_type_arguments = NULL;
1056 Value* instantiator = BuildInstantiator(); 1105 Value* instantiator = BuildInstantiator();
(...skipping 2569 matching lines...) Expand 10 before | Expand all | Expand 10 after
3626 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3675 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3627 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3676 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3628 OS::SNPrint(chars, len, kFormat, function_name, reason); 3677 OS::SNPrint(chars, len, kFormat, function_name, reason);
3629 const Error& error = Error::Handle( 3678 const Error& error = Error::Handle(
3630 LanguageError::New(String::Handle(String::New(chars)))); 3679 LanguageError::New(String::Handle(String::New(chars))));
3631 Isolate::Current()->long_jump_base()->Jump(1, error); 3680 Isolate::Current()->long_jump_base()->Jump(1, error);
3632 } 3681 }
3633 3682
3634 3683
3635 } // namespace dart 3684 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698