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

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

Issue 1195573006: Handle field-invocation and method-extraction in the runtime when --lazy_dispatchers=false. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/code_generator.cc ('k') | runtime/vm/object.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) 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/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Only invoke the function if its arguments are compatible. 144 // Only invoke the function if its arguments are compatible.
145 const ArgumentsDescriptor args_desc(arguments_descriptor); 145 const ArgumentsDescriptor args_desc(arguments_descriptor);
146 if (function.AreValidArgumentCounts(args_desc.Count(), 146 if (function.AreValidArgumentCounts(args_desc.Count(),
147 args_desc.NamedCount(), 147 args_desc.NamedCount(),
148 NULL)) { 148 NULL)) {
149 // The closure or non-closure object (receiver) is passed as implicit 149 // The closure or non-closure object (receiver) is passed as implicit
150 // first argument. It is already included in the arguments array. 150 // first argument. It is already included in the arguments array.
151 return InvokeFunction(function, arguments, arguments_descriptor); 151 return InvokeFunction(function, arguments, arguments_descriptor);
152 } 152 }
153 } 153 }
154 // There is no compatible 'call' method, so invoke noSuchMethod. 154
155 // There is no compatible 'call' method, see if there's a getter.
156 if (instance.IsClosure()) {
157 // Special case: closures are implemented with a call getter instead of a
158 // call method. If the arguments didn't match, go to noSuchMethod instead
159 // of infinitely recursing on the getter.
160 } else {
161 const String& getter_name = String::Handle(Symbols::New("get:call"));
162 Class& cls = Class::Handle(instance.clazz());
163 while (!cls.IsNull()) {
164 function ^= cls.LookupDynamicFunction(getter_name);
165 if (!function.IsNull()) {
166 // Getters don't have a stack overflow check, so do one in C++.
167
168 Isolate* isolate = Isolate::Current();
169 #if defined(USING_SIMULATOR)
170 uword stack_pos = Simulator::Current()->get_register(SPREG);
171 #else
172 uword stack_pos = Isolate::GetCurrentStackPointer();
173 #endif
174 if (stack_pos < isolate->saved_stack_limit()) {
175 const Instance& exception =
176 Instance::Handle(isolate->object_store()->stack_overflow());
177 return UnhandledException::New(exception, Stacktrace::Handle());
178 }
179
180 const Array& getter_arguments = Array::Handle(Array::New(1));
181 getter_arguments.SetAt(0, instance);
182 const Object& getter_result =
183 Object::Handle(DartEntry::InvokeFunction(function,
184 getter_arguments));
185 if (getter_result.IsError()) {
186 return getter_result.raw();
187 }
188 ASSERT(getter_result.IsNull() || getter_result.IsInstance());
189
190 arguments.SetAt(0, getter_result);
191 return InvokeClosure(arguments, arguments_descriptor);
192 }
193 cls = cls.SuperClass();
194 }
195 }
196
197 // No compatible method or getter so invoke noSuchMethod.
155 return InvokeNoSuchMethod(instance, 198 return InvokeNoSuchMethod(instance,
156 Symbols::Call(), 199 Symbols::Call(),
157 arguments, 200 arguments,
158 arguments_descriptor); 201 arguments_descriptor);
159 } 202 }
160 203
161 204
162 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, 205 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver,
163 const String& target_name, 206 const String& target_name,
164 const Array& arguments, 207 const Array& arguments,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 const Array& args = Array::Handle(Array::New(kNumArguments)); 572 const Array& args = Array::Handle(Array::New(kNumArguments));
530 args.SetAt(0, map); 573 args.SetAt(0, map);
531 args.SetAt(1, key); 574 args.SetAt(1, key);
532 args.SetAt(2, value); 575 args.SetAt(2, value);
533 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, 576 const Object& result = Object::Handle(DartEntry::InvokeFunction(function,
534 args)); 577 args));
535 return result.raw(); 578 return result.raw();
536 } 579 }
537 580
538 } // namespace dart 581 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698