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

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

Issue 11968022: Lookup functions by name that contains the private key, except for dart_api which allows ignoring t… (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
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 13 matching lines...) Expand all
24 "Eliminate type checks when allowed by static type analysis."); 24 "Eliminate type checks when allowed by static type analysis.");
25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); 25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree.");
26 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); 26 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph.");
27 DEFINE_FLAG(bool, print_flow_graph_optimized, false, 27 DEFINE_FLAG(bool, print_flow_graph_optimized, false,
28 "Print the IR flow graph when optimizing."); 28 "Print the IR flow graph when optimizing.");
29 DEFINE_FLAG(bool, trace_type_check_elimination, false, 29 DEFINE_FLAG(bool, trace_type_check_elimination, false,
30 "Trace type check elimination at compile time."); 30 "Trace type check elimination at compile time.");
31 DECLARE_FLAG(bool, enable_type_checks); 31 DECLARE_FLAG(bool, enable_type_checks);
32 32
33 33
34 static const String& PrivateCoreLibName(const String& str) {
35 const Library& core_lib = Library::Handle(Library::CoreLibrary());
36 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str));
37 return private_name;
38 }
39
40
34 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function, 41 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function,
35 InliningContext* inlining_context) 42 InliningContext* inlining_context)
36 : parsed_function_(parsed_function), 43 : parsed_function_(parsed_function),
37 num_copied_params_(parsed_function.num_copied_params()), 44 num_copied_params_(parsed_function.num_copied_params()),
38 // All parameters are copied if any parameter is. 45 // All parameters are copied if any parameter is.
39 num_non_copied_params_((num_copied_params_ == 0) 46 num_non_copied_params_((num_copied_params_ == 0)
40 ? parsed_function.function().num_fixed_parameters() 47 ? parsed_function.function().num_fixed_parameters()
41 : 0), 48 : 0),
42 num_stack_locals_(parsed_function.num_stack_locals()), 49 num_stack_locals_(parsed_function.num_stack_locals()),
43 inlining_context_(inlining_context), 50 inlining_context_(inlining_context),
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 PushArgumentInstr* push_instantiator = NULL; 950 PushArgumentInstr* push_instantiator = NULL;
944 PushArgumentInstr* push_type_args = NULL; 951 PushArgumentInstr* push_type_args = NULL;
945 if (type.IsInstantiated()) { 952 if (type.IsInstantiated()) {
946 push_instantiator = PushArgument(BuildNullValue()); 953 push_instantiator = PushArgument(BuildNullValue());
947 push_type_args = PushArgument(BuildNullValue()); 954 push_type_args = PushArgument(BuildNullValue());
948 } else { 955 } else {
949 BuildTypecheckPushArguments(node->token_pos(), 956 BuildTypecheckPushArguments(node->token_pos(),
950 &push_instantiator, 957 &push_instantiator,
951 &push_type_args); 958 &push_type_args);
952 } 959 }
953 const String& name = String::ZoneHandle(Symbols::New("_instanceOf"));
954 ZoneGrowableArray<PushArgumentInstr*>* arguments = 960 ZoneGrowableArray<PushArgumentInstr*>* arguments =
955 new ZoneGrowableArray<PushArgumentInstr*>(5); 961 new ZoneGrowableArray<PushArgumentInstr*>(5);
956 arguments->Add(push_left); 962 arguments->Add(push_left);
957 arguments->Add(push_instantiator); 963 arguments->Add(push_instantiator);
958 arguments->Add(push_type_args); 964 arguments->Add(push_type_args);
959 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); 965 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
960 Value* type_arg = Bind( 966 Value* type_arg = Bind(
961 new ConstantInstr(node->right()->AsTypeNode()->type())); 967 new ConstantInstr(node->right()->AsTypeNode()->type()));
962 arguments->Add(PushArgument(type_arg)); 968 arguments->Add(PushArgument(type_arg));
963 const Bool& negate = (node->kind() == Token::kISNOT) ? Bool::True() : 969 const Bool& negate = (node->kind() == Token::kISNOT) ? Bool::True() :
964 Bool::False(); 970 Bool::False();
965 Value* negate_arg = Bind(new ConstantInstr(negate)); 971 Value* negate_arg = Bind(new ConstantInstr(negate));
966 arguments->Add(PushArgument(negate_arg)); 972 arguments->Add(PushArgument(negate_arg));
967 const intptr_t kNumArgsChecked = 1; 973 const intptr_t kNumArgsChecked = 1;
968 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), 974 InstanceCallInstr* call = new InstanceCallInstr(
969 name, 975 node->token_pos(),
970 node->kind(), 976 PrivateCoreLibName(Symbols::_instanceOf()),
971 arguments, 977 node->kind(),
972 Array::ZoneHandle(), 978 arguments,
973 kNumArgsChecked); 979 Array::ZoneHandle(),
980 kNumArgsChecked);
974 ReturnDefinition(call); 981 ReturnDefinition(call);
975 } 982 }
976 983
977 984
978 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) { 985 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) {
979 ASSERT(Token::IsTypeCastOperator(node->kind())); 986 ASSERT(Token::IsTypeCastOperator(node->kind()));
980 const AbstractType& type = node->right()->AsTypeNode()->type(); 987 const AbstractType& type = node->right()->AsTypeNode()->type();
981 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed. 988 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed.
982 ValueGraphVisitor for_value(owner(), temp_index(), loop_depth()); 989 ValueGraphVisitor for_value(owner(), temp_index(), loop_depth());
983 node->left()->Visit(&for_value); 990 node->left()->Visit(&for_value);
(...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 AstNode* receiver, 2878 AstNode* receiver,
2872 const String& method_name, 2879 const String& method_name,
2873 ArgumentListNode* method_arguments) { 2880 ArgumentListNode* method_arguments) {
2874 // Build the graph to allocate an InvocationMirror object by calling 2881 // Build the graph to allocate an InvocationMirror object by calling
2875 // the static allocation method. 2882 // the static allocation method.
2876 const Library& corelib = Library::Handle(Library::CoreLibrary()); 2883 const Library& corelib = Library::Handle(Library::CoreLibrary());
2877 const Class& mirror_class = Class::Handle( 2884 const Class& mirror_class = Class::Handle(
2878 corelib.LookupClassAllowPrivate(Symbols::InvocationMirror())); 2885 corelib.LookupClassAllowPrivate(Symbols::InvocationMirror()));
2879 ASSERT(!mirror_class.IsNull()); 2886 ASSERT(!mirror_class.IsNull());
2880 const Function& allocation_function = Function::ZoneHandle( 2887 const Function& allocation_function = Function::ZoneHandle(
2881 Resolver::ResolveStaticByName(mirror_class, 2888 Resolver::ResolveStaticByName(
2882 Symbols::AllocateInvocationMirror(), 2889 mirror_class,
2883 Resolver::kIsQualified)); 2890 PrivateCoreLibName(Symbols::AllocateInvocationMirror()),
2891 Resolver::kIsQualified));
2884 ASSERT(!allocation_function.IsNull()); 2892 ASSERT(!allocation_function.IsNull());
2885 2893
2886 // Evaluate the receiver before the arguments. This will be used 2894 // Evaluate the receiver before the arguments. This will be used
2887 // as an argument to the noSuchMethod call. 2895 // as an argument to the noSuchMethod call.
2888 ValueGraphVisitor for_receiver(owner(), temp_index(), loop_depth()); 2896 ValueGraphVisitor for_receiver(owner(), temp_index(), loop_depth());
2889 receiver->Visit(&for_receiver); 2897 receiver->Visit(&for_receiver);
2890 Append(for_receiver); 2898 Append(for_receiver);
2891 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); 2899 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value());
2892 2900
2893 // Allocate the arguments and pass them into the construction 2901 // Allocate the arguments and pass them into the construction
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 Value* existing_argument_names_value = 2975 Value* existing_argument_names_value =
2968 Bind(new ConstantInstr(Array::ZoneHandle())); 2976 Bind(new ConstantInstr(Array::ZoneHandle()));
2969 arguments->Add(PushArgument(existing_argument_names_value)); 2977 arguments->Add(PushArgument(existing_argument_names_value));
2970 // Resolve and call NoSuchMethodError._throwNew. 2978 // Resolve and call NoSuchMethodError._throwNew.
2971 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 2979 const Library& core_lib = Library::Handle(Library::CoreLibrary());
2972 const Class& cls = Class::Handle( 2980 const Class& cls = Class::Handle(
2973 core_lib.LookupClass(Symbols::NoSuchMethodError())); 2981 core_lib.LookupClass(Symbols::NoSuchMethodError()));
2974 ASSERT(!cls.IsNull()); 2982 ASSERT(!cls.IsNull());
2975 const Function& func = Function::ZoneHandle( 2983 const Function& func = Function::ZoneHandle(
2976 Resolver::ResolveStatic(cls, 2984 Resolver::ResolveStatic(cls,
2977 Symbols::ThrowNew(), 2985 PrivateCoreLibName(Symbols::ThrowNew()),
2978 arguments->length(), 2986 arguments->length(),
2979 Array::ZoneHandle(), 2987 Array::ZoneHandle(),
2980 Resolver::kIsQualified)); 2988 Resolver::kIsQualified));
2981 ASSERT(!func.IsNull()); 2989 ASSERT(!func.IsNull());
2982 return new StaticCallInstr(token_pos, 2990 return new StaticCallInstr(token_pos,
2983 func, 2991 func,
2984 Array::ZoneHandle(), // No names. 2992 Array::ZoneHandle(), // No names.
2985 arguments); 2993 arguments);
2986 } 2994 }
2987 2995
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3102 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3095 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3103 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3096 OS::SNPrint(chars, len, kFormat, function_name, reason); 3104 OS::SNPrint(chars, len, kFormat, function_name, reason);
3097 const Error& error = Error::Handle( 3105 const Error& error = Error::Handle(
3098 LanguageError::New(String::Handle(String::New(chars)))); 3106 LanguageError::New(String::Handle(String::New(chars))));
3099 Isolate::Current()->long_jump_base()->Jump(1, error); 3107 Isolate::Current()->long_jump_base()->Jump(1, error);
3100 } 3108 }
3101 3109
3102 3110
3103 } // namespace dart 3111 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698