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

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

Issue 1709273003: Make function lookup in classes thread-safe: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: d Created 4 years, 10 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
« no previous file with comments | « runtime/vm/resolver.h ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/resolver.h" 5 #include "vm/resolver.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/log.h" 10 #include "vm/log.h"
(...skipping 17 matching lines...) Expand all
28 const ArgumentsDescriptor& args_desc) { 28 const ArgumentsDescriptor& args_desc) {
29 // Figure out type of receiver first. 29 // Figure out type of receiver first.
30 const Class& cls = Class::Handle(receiver.clazz()); 30 const Class& cls = Class::Handle(receiver.clazz());
31 return ResolveDynamicForReceiverClass(cls, function_name, args_desc); 31 return ResolveDynamicForReceiverClass(cls, function_name, args_desc);
32 } 32 }
33 33
34 34
35 RawFunction* Resolver::ResolveDynamicForReceiverClass( 35 RawFunction* Resolver::ResolveDynamicForReceiverClass(
36 const Class& receiver_class, 36 const Class& receiver_class,
37 const String& function_name, 37 const String& function_name,
38 const ArgumentsDescriptor& args_desc) { 38 const ArgumentsDescriptor& args_desc,
39 bool allow_add) {
39 40
40 Function& function = 41 Function& function = Function::Handle(
41 Function::Handle(ResolveDynamicAnyArgs(receiver_class, function_name)); 42 ResolveDynamicAnyArgs(receiver_class, function_name, allow_add));
42 43
43 if (function.IsNull() || 44 if (function.IsNull() ||
44 !function.AreValidArguments(args_desc, NULL)) { 45 !function.AreValidArguments(args_desc, NULL)) {
45 // Return a null function to signal to the upper levels to dispatch to 46 // Return a null function to signal to the upper levels to dispatch to
46 // "noSuchMethod" function. 47 // "noSuchMethod" function.
47 if (FLAG_trace_resolving) { 48 if (FLAG_trace_resolving) {
48 String& error_message = 49 String& error_message =
49 String::Handle(Symbols::New("function not found")); 50 String::Handle(Symbols::New("function not found"));
50 if (!function.IsNull()) { 51 if (!function.IsNull()) {
51 // Obtain more detailed error message. 52 // Obtain more detailed error message.
52 function.AreValidArguments(args_desc, &error_message); 53 function.AreValidArguments(args_desc, &error_message);
53 } 54 }
54 THR_Print("ResolveDynamic error '%s': %s.\n", 55 THR_Print("ResolveDynamic error '%s': %s.\n",
55 function_name.ToCString(), 56 function_name.ToCString(),
56 error_message.ToCString()); 57 error_message.ToCString());
57 } 58 }
58 return Function::null(); 59 return Function::null();
59 } 60 }
60 return function.raw(); 61 return function.raw();
61 } 62 }
62 63
63 64
64 RawFunction* Resolver::ResolveDynamicAnyArgs( 65 RawFunction* Resolver::ResolveDynamicAnyArgs(
65 const Class& receiver_class, 66 const Class& receiver_class,
66 const String& function_name) { 67 const String& function_name,
68 bool allow_add) {
67 Class& cls = Class::Handle(receiver_class.raw()); 69 Class& cls = Class::Handle(receiver_class.raw());
68 if (FLAG_trace_resolving) { 70 if (FLAG_trace_resolving) {
69 THR_Print("ResolveDynamic '%s' for class %s\n", 71 THR_Print("ResolveDynamic '%s' for class %s\n",
70 function_name.ToCString(), 72 function_name.ToCString(),
71 String::Handle(cls.Name()).ToCString()); 73 String::Handle(cls.Name()).ToCString());
72 } 74 }
73 75
74 const bool is_getter = Field::IsGetterName(function_name); 76 const bool is_getter = Field::IsGetterName(function_name);
75 String& field_name = String::Handle(); 77 String& field_name = String::Handle();
76 if (is_getter) { 78 if (is_getter) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 Function& function = Function::Handle(); 121 Function& function = Function::Handle();
120 while (!cls.IsNull()) { 122 while (!cls.IsNull()) {
121 function ^= cls.LookupDynamicFunction(function_name); 123 function ^= cls.LookupDynamicFunction(function_name);
122 if (!function.IsNull()) { 124 if (!function.IsNull()) {
123 return function.raw(); 125 return function.raw();
124 } 126 }
125 // Getter invocation might actually be a method extraction. 127 // Getter invocation might actually be a method extraction.
126 if (FLAG_lazy_dispatchers) { 128 if (FLAG_lazy_dispatchers) {
127 if (is_getter && function.IsNull()) { 129 if (is_getter && function.IsNull()) {
128 function ^= cls.LookupDynamicFunction(field_name); 130 function ^= cls.LookupDynamicFunction(field_name);
129 if (!function.IsNull()) { 131 if (!function.IsNull() && allow_add) {
130 // We were looking for the getter but found a method with the same 132 // We were looking for the getter but found a method with the same
131 // name. Create a method extractor and return it. 133 // name. Create a method extractor and return it.
132 // The extractor does not exist yet, so using GetMethodExtractor is 134 // The extractor does not exist yet, so using GetMethodExtractor is
133 // not necessary here. 135 // not necessary here.
134 function ^= function.CreateMethodExtractor(function_name); 136 function ^= function.CreateMethodExtractor(function_name);
135 return function.raw(); 137 return function.raw();
136 } 138 }
137 } 139 }
138 } 140 }
139 cls = cls.SuperClass(); 141 cls = cls.SuperClass();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 THR_Print("ResolveStaticAllowPrivate error '%s': %s.\n", 253 THR_Print("ResolveStaticAllowPrivate error '%s': %s.\n",
252 function_name.ToCString(), 254 function_name.ToCString(),
253 error_message.ToCString()); 255 error_message.ToCString());
254 } 256 }
255 return Function::null(); 257 return Function::null();
256 } 258 }
257 return function.raw(); 259 return function.raw();
258 } 260 }
259 261
260 } // namespace dart 262 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/resolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698