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

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

Issue 11694003: In unoptimized code use call for instanceof instead of inlined checks. This allows us to collect ty… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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/flow_graph_optimizer.h » ('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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/code_descriptors.h" 8 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 for_true.Do(BuildStoreExprTemp(constant_true)); 737 for_true.Do(BuildStoreExprTemp(constant_true));
738 Join(for_test, for_true, for_right); 738 Join(for_test, for_true, for_right);
739 } 739 }
740 ReturnDefinition(BuildLoadExprTemp()); 740 ReturnDefinition(BuildLoadExprTemp());
741 return; 741 return;
742 } 742 }
743 EffectGraphVisitor::VisitBinaryOpNode(node); 743 EffectGraphVisitor::VisitBinaryOpNode(node);
744 } 744 }
745 745
746 746
747 void EffectGraphVisitor::BuildTypecheckPushArguments(
748 intptr_t token_pos,
749 PushArgumentInstr** push_instantiator_result,
750 PushArgumentInstr** push_instantiator_type_arguments_result) {
751 const Class& instantiator_class = Class::Handle(
752 owner()->parsed_function().function().Owner());
753 // Since called only when type tested against is not instantiated.
754 ASSERT(instantiator_class.NumTypeParameters() > 0);
755 Value* instantiator_type_arguments = NULL;
756 Value* instantiator = BuildInstantiator();
757 if (instantiator == NULL) {
758 // No instantiator when inside factory.
759 *push_instantiator_result = PushArgument(BuildNullValue());
760 instantiator_type_arguments =
761 BuildInstantiatorTypeArguments(token_pos, NULL);
762 } else {
763 instantiator = Bind(BuildStoreExprTemp(instantiator));
764 *push_instantiator_result = PushArgument(instantiator);
765 Value* loaded = Bind(BuildLoadExprTemp());
766 instantiator_type_arguments =
767 BuildInstantiatorTypeArguments(token_pos, loaded);
768 }
769 *push_instantiator_type_arguments_result =
770 PushArgument(instantiator_type_arguments);
771 }
772
773
774
747 void EffectGraphVisitor::BuildTypecheckArguments( 775 void EffectGraphVisitor::BuildTypecheckArguments(
748 intptr_t token_pos, 776 intptr_t token_pos,
749 Value** instantiator_result, 777 Value** instantiator_result,
750 Value** instantiator_type_arguments_result) { 778 Value** instantiator_type_arguments_result) {
751 Value* instantiator = NULL; 779 Value* instantiator = NULL;
752 Value* instantiator_type_arguments = NULL; 780 Value* instantiator_type_arguments = NULL;
753 const Class& instantiator_class = Class::Handle( 781 const Class& instantiator_class = Class::Handle(
754 owner()->parsed_function().function().Owner()); 782 owner()->parsed_function().function().Owner());
755 // Since called only when type tested against is not instantiated. 783 // Since called only when type tested against is not instantiated.
756 ASSERT(instantiator_class.NumTypeParameters() > 0); 784 ASSERT(instantiator_class.NumTypeParameters() > 0);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 result = new ConstantInstr(negate_result ? bool_true : bool_false); 905 result = new ConstantInstr(negate_result ? bool_true : bool_false);
878 } 906 }
879 } 907 }
880 ReturnDefinition(result); 908 ReturnDefinition(result);
881 return; 909 return;
882 } 910 }
883 911
884 ValueGraphVisitor for_left_value(owner(), temp_index(), loop_depth()); 912 ValueGraphVisitor for_left_value(owner(), temp_index(), loop_depth());
885 node->left()->Visit(&for_left_value); 913 node->left()->Visit(&for_left_value);
886 Append(for_left_value); 914 Append(for_left_value);
887 Value* instantiator = NULL; 915 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
888 Value* instantiator_type_arguments = NULL; 916 PushArgumentInstr* push_instantiator = NULL;
917 PushArgumentInstr* push_type_args = NULL;
889 if (type.IsInstantiated()) { 918 if (type.IsInstantiated()) {
890 instantiator = BuildNullValue(); 919 push_instantiator = PushArgument(BuildNullValue());
891 instantiator_type_arguments = BuildNullValue(); 920 push_type_args = PushArgument(BuildNullValue());
892 } else { 921 } else {
893 BuildTypecheckArguments(node->token_pos(), 922 BuildTypecheckPushArguments(node->token_pos(),
894 &instantiator, 923 &push_instantiator,
895 &instantiator_type_arguments); 924 &push_type_args);
896 } 925 }
897 InstanceOfInstr* instance_of = 926 const String& name = String::ZoneHandle(Symbols::New("_instanceOf"));
898 new InstanceOfInstr(node->token_pos(), 927 ZoneGrowableArray<PushArgumentInstr*>* arguments =
899 for_left_value.value(), 928 new ZoneGrowableArray<PushArgumentInstr*>(5);
900 instantiator, 929 arguments->Add(push_left);
901 instantiator_type_arguments, 930 arguments->Add(push_instantiator);
902 node->right()->AsTypeNode()->type(), 931 arguments->Add(push_type_args);
903 (node->kind() == Token::kISNOT)); 932 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
904 ReturnDefinition(instance_of); 933 Value* type_arg = Bind(
934 new ConstantInstr(node->right()->AsTypeNode()->type()));
935 arguments->Add(PushArgument(type_arg));
936 const Bool& negate = Bool::ZoneHandle(node->kind() == Token::kISNOT ?
937 Bool::True() : Bool::False());
938 Value* negate_arg = Bind(new ConstantInstr(negate));
939 arguments->Add(PushArgument(negate_arg));
940 const intptr_t kNumArgsChecked = 1;
941 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(),
942 name,
943 node->kind(),
944 arguments,
945 Array::ZoneHandle(),
946 kNumArgsChecked);
947 ReturnDefinition(call);
905 } 948 }
906 949
907 950
908 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) { 951 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) {
909 ASSERT(Token::IsTypeCastOperator(node->kind())); 952 ASSERT(Token::IsTypeCastOperator(node->kind()));
910 const AbstractType& type = node->right()->AsTypeNode()->type(); 953 const AbstractType& type = node->right()->AsTypeNode()->type();
911 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed. 954 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed.
912 ValueGraphVisitor for_value(owner(), temp_index(), loop_depth()); 955 ValueGraphVisitor for_value(owner(), temp_index(), loop_depth());
913 node->left()->Visit(&for_value); 956 node->left()->Visit(&for_value);
914 Append(for_value); 957 Append(for_value);
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3074 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3032 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3075 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3033 OS::SNPrint(chars, len, kFormat, function_name, reason); 3076 OS::SNPrint(chars, len, kFormat, function_name, reason);
3034 const Error& error = Error::Handle( 3077 const Error& error = Error::Handle(
3035 LanguageError::New(String::Handle(String::New(chars)))); 3078 LanguageError::New(String::Handle(String::New(chars))));
3036 Isolate::Current()->long_jump_base()->Jump(1, error); 3079 Isolate::Current()->long_jump_base()->Jump(1, error);
3037 } 3080 }
3038 3081
3039 3082
3040 } // namespace dart 3083 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698