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

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

Issue 2147293002: Rebinding super calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Implement rebinding super calls after hot reload. Created 4 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/isolate_reload_test.cc ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "vm/isolate_reload.h" 7 #include "vm/isolate_reload.h"
8 #include "vm/log.h" 8 #include "vm/log.h"
9 #include "vm/resolver.h" 9 #include "vm/resolver.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 static const Function* static_call_target = NULL; 550 static const Function* static_call_target = NULL;
551 551
552 void ICData::Reset() const { 552 void ICData::Reset() const {
553 if (is_static_call()) { 553 if (is_static_call()) {
554 const Function& old_target = Function::Handle(GetTargetAt(0)); 554 const Function& old_target = Function::Handle(GetTargetAt(0));
555 if (old_target.IsNull()) { 555 if (old_target.IsNull()) {
556 FATAL("old_target is NULL.\n"); 556 FATAL("old_target is NULL.\n");
557 } 557 }
558 static_call_target = &old_target; 558 static_call_target = &old_target;
559
560 const String& selector = String::Handle(old_target.name());
561 Function& new_target = Function::Handle();
559 if (!old_target.is_static()) { 562 if (!old_target.is_static()) {
560 // TODO(johnmccutchan): Improve this. 563 if (old_target.kind() == RawFunction::kConstructor) {
561 TIR_Print("Cannot rebind super-call to %s from %s\n", 564 return; // Super constructor call.
562 old_target.ToCString(), 565 }
563 Object::Handle(Owner()).ToCString()); 566 Function& caller = Function::Handle();
564 return; 567 caller ^= Owner();
568 ASSERT(!caller.is_static());
569 Class& cls = Class::Handle(caller.Owner());
570 if (cls.raw() == old_target.Owner()) {
571 // Dispatcher.
572 if (caller.IsImplicitClosureFunction()) {
573 return; // Tear-off.
574 }
575 if (caller.kind() == RawFunction::kNoSuchMethodDispatcher) {
576 // TODO(rmacnak): noSuchMethod might have been redefined.
577 return;
578 }
579 const Function& caller_parent =
580 Function::Handle(caller.parent_function());
581 if (!caller_parent.IsNull()) {
582 if (caller_parent.kind() == RawFunction::kInvokeFieldDispatcher) {
583 return; // Call-through-getter.
584 }
585 }
586 FATAL2("Unexpected dispatcher-like call site: %s from %s\n",
587 selector.ToCString(), caller.ToQualifiedCString());
588 }
589 // Super call.
590 cls = cls.SuperClass();
591 while (!cls.IsNull()) {
592 // TODO(rmacnak): Should use Resolver::ResolveDynamicAnyArgs to handle
593 // method-extractors and call-through-getters, but we're in a no
594 // safepoint scope here.
595 new_target = cls.LookupDynamicFunction(selector);
596 if (!new_target.IsNull()) {
597 break;
598 }
599 cls = cls.SuperClass();
600 }
601 } else {
602 // This can be incorrect if the call site was an unqualified invocation.
603 const Class& cls = Class::Handle(old_target.Owner());
604 new_target = cls.LookupStaticFunction(selector);
565 } 605 }
566 const String& selector = String::Handle(old_target.name()); 606
567 const Class& cls = Class::Handle(old_target.Owner()); 607 const Array& args_desc_array = Array::Handle(arguments_descriptor());
568 const Function& new_target = 608 ArgumentsDescriptor args_desc(args_desc_array);
569 Function::Handle(cls.LookupStaticFunction(selector)); 609 if (new_target.IsNull() ||
570 if (new_target.IsNull()) { 610 !new_target.AreValidArguments(args_desc, NULL)) {
571 // TODO(johnmccutchan): Improve this. 611 // TODO(rmacnak): Patch to a NSME stub.
572 TIR_Print("Cannot rebind static call to %s from %s\n", 612 TIR_Print("Cannot rebind static call to %s from %s\n",
573 old_target.ToCString(), 613 old_target.ToCString(),
574 Object::Handle(Owner()).ToCString()); 614 Object::Handle(Owner()).ToCString());
575 return; 615 return;
576 } 616 }
577 ClearAndSetStaticTarget(new_target); 617 ClearAndSetStaticTarget(new_target);
578 } else { 618 } else {
579 ClearWithSentinel(); 619 ClearWithSentinel();
580 } 620 }
581 } 621 }
582 622
583 #endif // !PRODUCT 623 #endif // !PRODUCT
584 624
585 } // namespace dart. 625 } // namespace dart.
OLDNEW
« no previous file with comments | « runtime/vm/isolate_reload_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698