Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/code_patcher.h" | 7 #include "vm/code_patcher.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/log.h" | 10 #include "vm/log.h" |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 AddClass(superclass); | 502 AddClass(superclass); |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 | 506 |
| 507 void Precompiler::CheckForNewDynamicFunctions() { | 507 void Precompiler::CheckForNewDynamicFunctions() { |
| 508 Library& lib = Library::Handle(Z); | 508 Library& lib = Library::Handle(Z); |
| 509 Class& cls = Class::Handle(Z); | 509 Class& cls = Class::Handle(Z); |
| 510 Array& functions = Array::Handle(Z); | 510 Array& functions = Array::Handle(Z); |
| 511 Function& function = Function::Handle(Z); | 511 Function& function = Function::Handle(Z); |
| 512 Function& function2 = Function::Handle(Z); | |
| 513 String& selector = String::Handle(Z); | 512 String& selector = String::Handle(Z); |
| 514 String& selector2 = String::Handle(Z); | 513 String& selector2 = String::Handle(Z); |
| 515 String& selector3 = String::Handle(Z); | 514 String& selector3 = String::Handle(Z); |
| 516 | 515 |
| 517 for (intptr_t i = 0; i < libraries_.Length(); i++) { | 516 for (intptr_t i = 0; i < libraries_.Length(); i++) { |
| 518 lib ^= libraries_.At(i); | 517 lib ^= libraries_.At(i); |
| 519 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | 518 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
| 520 while (it.HasNext()) { | 519 while (it.HasNext()) { |
| 521 cls = it.GetNextClass(); | 520 cls = it.GetNextClass(); |
| 522 | 521 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 } | 573 } |
| 575 | 574 |
| 576 // Handle the implicit call type conversions. | 575 // Handle the implicit call type conversions. |
| 577 if (Field::IsGetterName(selector)) { | 576 if (Field::IsGetterName(selector)) { |
| 578 selector2 = Field::NameFromGetter(selector); | 577 selector2 = Field::NameFromGetter(selector); |
| 579 selector3 = Symbols::Lookup(selector2); | 578 selector3 = Symbols::Lookup(selector2); |
| 580 if (IsSent(selector2)) { | 579 if (IsSent(selector2)) { |
| 581 // Call-through-getter. | 580 // Call-through-getter. |
| 582 // Function is get:foo and somewhere foo is called. | 581 // Function is get:foo and somewhere foo is called. |
| 583 AddFunction(function); | 582 AddFunction(function); |
| 583 | |
| 584 AddImplicitClosure(function, selector3); | |
|
rmacnak
2015/10/14 17:07:33
This one wants an invoke-field dispatcher, not a m
Florian Schneider
2015/10/14 17:55:54
Yes, I wrongly thought I missed a case here, but I
| |
| 584 } | 585 } |
| 585 selector3 = Symbols::LookupFromConcat(Symbols::ClosurizePrefix(), | 586 selector3 = Symbols::LookupFromConcat(Symbols::ClosurizePrefix(), |
| 586 selector2); | 587 selector2); |
| 587 if (IsSent(selector3)) { | 588 if (IsSent(selector3)) { |
| 588 // Hash-closurization. | 589 // Hash-closurization. |
| 589 // Function is get:foo and somewhere get:#foo is called. | 590 // Function is get:foo and somewhere get:#foo is called. |
| 590 AddFunction(function); | 591 AddFunction(function); |
| 591 | 592 |
| 592 function2 = function.ImplicitClosureFunction(); | 593 AddImplicitClosure(function, selector3); |
| 593 AddFunction(function2); | |
| 594 } | 594 } |
| 595 } else if (Field::IsSetterName(selector)) { | 595 } else if (Field::IsSetterName(selector)) { |
| 596 selector2 = Symbols::LookupFromConcat(Symbols::ClosurizePrefix(), | 596 selector2 = Symbols::LookupFromConcat(Symbols::ClosurizePrefix(), |
| 597 selector); | 597 selector); |
| 598 if (IsSent(selector2)) { | 598 if (IsSent(selector2)) { |
| 599 // Hash-closurization. | 599 // Hash-closurization. |
| 600 // Function is set:foo and somewhere get:#set:foo is called. | 600 // Function is set:foo and somewhere get:#set:foo is called. |
| 601 AddFunction(function); | 601 AddFunction(function); |
| 602 | 602 |
| 603 function2 = function.ImplicitClosureFunction(); | 603 AddImplicitClosure(function, selector2); |
| 604 AddFunction(function2); | |
| 605 } | 604 } |
| 606 } else if (function.kind() == RawFunction::kRegularFunction) { | 605 } else if (function.kind() == RawFunction::kRegularFunction) { |
| 607 selector2 = Field::LookupGetterSymbol(selector); | 606 selector2 = Field::LookupGetterSymbol(selector); |
| 608 if (IsSent(selector2)) { | 607 if (IsSent(selector2)) { |
| 609 // Closurization. | 608 // Closurization. |
| 610 // Function is foo and somewhere get:foo is called. | 609 // Function is foo and somewhere get:foo is called. |
| 611 function2 = function.ImplicitClosureFunction(); | 610 AddImplicitClosure(function, selector2); |
| 612 AddFunction(function2); | |
| 613 } | 611 } |
| 614 selector2 = Symbols::LookupFromConcat(Symbols::ClosurizePrefix(), | 612 selector2 = Symbols::LookupFromConcat(Symbols::ClosurizePrefix(), |
| 615 selector); | 613 selector); |
| 616 if (IsSent(selector2)) { | 614 if (IsSent(selector2)) { |
| 617 // Hash-closurization. | 615 // Hash-closurization. |
| 618 // Function is foo and somewhere get:#foo is called. | 616 // Function is foo and somewhere get:#foo is called. |
| 619 function2 = function.ImplicitClosureFunction(); | 617 AddImplicitClosure(function, selector2); |
| 620 AddFunction(function2); | |
| 621 } | 618 } |
| 622 } | 619 } |
| 623 } | 620 } |
| 624 } | 621 } |
| 625 } | 622 } |
| 626 } | 623 } |
| 627 | 624 |
| 628 | 625 |
| 626 void Precompiler::AddImplicitClosure(const Function& function, | |
| 627 const String& selector) { | |
| 628 AddFunction(Function::Handle(function.ImplicitClosureFunction())); | |
|
rmacnak
2015/10/14 17:07:34
Handle(Z, ...
Florian Schneider
2015/10/14 17:55:54
I removed this helper again to not create extra ha
| |
| 629 AddFunction(Function::Handle(function.GetMethodExtractor(selector))); | |
| 630 } | |
| 631 | |
| 632 | |
| 629 void Precompiler::DropUncompiledFunctions() { | 633 void Precompiler::DropUncompiledFunctions() { |
| 630 Library& lib = Library::Handle(Z); | 634 Library& lib = Library::Handle(Z); |
| 631 Class& cls = Class::Handle(Z); | 635 Class& cls = Class::Handle(Z); |
| 632 Array& functions = Array::Handle(Z); | 636 Array& functions = Array::Handle(Z); |
| 633 Function& function = Function::Handle(Z); | 637 Function& function = Function::Handle(Z); |
| 634 GrowableObjectArray& retained_functions = GrowableObjectArray::Handle(Z); | 638 GrowableObjectArray& retained_functions = GrowableObjectArray::Handle(Z); |
| 635 GrowableObjectArray& closures = GrowableObjectArray::Handle(Z); | 639 GrowableObjectArray& closures = GrowableObjectArray::Handle(Z); |
| 636 | 640 |
| 637 for (intptr_t i = 0; i < libraries_.Length(); i++) { | 641 for (intptr_t i = 0; i < libraries_.Length(); i++) { |
| 638 lib ^= libraries_.At(i); | 642 lib ^= libraries_.At(i); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 for (intptr_t j = 0; j < closures.Length(); j++) { | 822 for (intptr_t j = 0; j < closures.Length(); j++) { |
| 819 function ^= closures.At(j); | 823 function ^= closures.At(j); |
| 820 visitor->VisitFunction(function); | 824 visitor->VisitFunction(function); |
| 821 } | 825 } |
| 822 } | 826 } |
| 823 } | 827 } |
| 824 } | 828 } |
| 825 } | 829 } |
| 826 | 830 |
| 827 } // namespace dart | 831 } // namespace dart |
| OLD | NEW |