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

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

Issue 1371453002: Precompile invoke-field-dispatchers for closures. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/precompiler.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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/precompiler.h" 5 #include "vm/precompiler.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/log.h" 9 #include "vm/log.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 if (!target.is_static()) { 394 if (!target.is_static()) {
395 // Super call (should not enqueue selector) or dynamic call with a 395 // Super call (should not enqueue selector) or dynamic call with a
396 // CHA prediction (should enqueue selector). 396 // CHA prediction (should enqueue selector).
397 selector = call_site.target_name(); 397 selector = call_site.target_name();
398 AddSelector(selector); 398 AddSelector(selector);
399 } 399 }
400 } else { 400 } else {
401 // A dynamic call. 401 // A dynamic call.
402 selector = call_site.target_name(); 402 selector = call_site.target_name();
403 AddSelector(selector); 403 AddSelector(selector);
404 if (selector.raw() == Symbols::Call().raw()) {
405 // Potential closure call.
406 AddClosureCall(call_site);
407 }
404 } 408 }
405 } else if (entry.IsField()) { 409 } else if (entry.IsField()) {
406 // Potential need for field initializer. 410 // Potential need for field initializer.
407 field ^= entry.raw(); 411 field ^= entry.raw();
408 AddField(field); 412 AddField(field);
409 } else if (entry.IsInstance()) { 413 } else if (entry.IsInstance()) {
410 // Potential const object. 414 // Potential const object.
411 cls = entry.clazz(); 415 cls = entry.clazz();
412 AddClass(cls); 416 AddClass(cls);
413 } 417 }
414 } 418 }
415 } 419 }
416 } 420 }
417 421
418 422
423 void Precompiler::AddClosureCall(const ICData& call_site) {
424 const Array& arguments_descriptor =
425 Array::Handle(Z, call_site.arguments_descriptor());
426 const Type& function_impl =
427 Type::Handle(Z, I->object_store()->function_impl_type());
428 const Class& cache_class =
429 Class::Handle(Z, function_impl.type_class());
430 const Function& dispatcher = Function::Handle(Z,
431 cache_class.GetInvocationDispatcher(Symbols::Call(),
432 arguments_descriptor,
433 RawFunction::kInvokeFieldDispatcher,
434 true /* create_if_absent */));
435 AddFunction(dispatcher);
436 }
437
438
419 void Precompiler::AddField(const Field& field) { 439 void Precompiler::AddField(const Field& field) {
420 if (field.is_static()) { 440 if (field.is_static()) {
421 // Potential const object. Uninitialized field will harmlessly do a 441 // Potential const object. Uninitialized field will harmlessly do a
422 // redundant add of the Null class. 442 // redundant add of the Null class.
423 const Object& value = Object::Handle(Z, field.StaticValue()); 443 const Object& value = Object::Handle(Z, field.StaticValue());
424 const Class& cls = Class::Handle(Z, value.clazz()); 444 const Class& cls = Class::Handle(Z, value.clazz());
425 AddClass(cls); 445 AddClass(cls);
426 446
427 if (field.has_initializer()) { 447 if (field.has_initializer()) {
428 if (field.HasPrecompiledInitializer()) return; 448 if (field.HasPrecompiledInitializer()) return;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 for (intptr_t j = 0; j < closures.Length(); j++) { 640 for (intptr_t j = 0; j < closures.Length(); j++) {
621 function ^= closures.At(j); 641 function ^= closures.At(j);
622 ASSERT(function.HasCode()); 642 ASSERT(function.HasCode());
623 } 643 }
624 } 644 }
625 } 645 }
626 } 646 }
627 } 647 }
628 648
629 } // namespace dart 649 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698