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

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

Issue 2548943002: VM: Treat dynamic calls consistently in the treeshaker. (Closed)
Patch Set: Created 4 years 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/aot_optimizer.h" 7 #include "vm/aot_optimizer.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/branch_optimizer.h" 10 #include "vm/branch_optimizer.h"
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 MegamorphicCache& cache = MegamorphicCache::Handle(Z); 834 MegamorphicCache& cache = MegamorphicCache::Handle(Z);
835 String& selector = String::Handle(Z); 835 String& selector = String::Handle(Z);
836 Field& field = Field::Handle(Z); 836 Field& field = Field::Handle(Z);
837 Class& cls = Class::Handle(Z); 837 Class& cls = Class::Handle(Z);
838 Instance& instance = Instance::Handle(Z); 838 Instance& instance = Instance::Handle(Z);
839 Code& target_code = Code::Handle(Z); 839 Code& target_code = Code::Handle(Z);
840 for (intptr_t i = 0; i < pool.Length(); i++) { 840 for (intptr_t i = 0; i < pool.Length(); i++) {
841 if (pool.InfoAt(i) == ObjectPool::kTaggedObject) { 841 if (pool.InfoAt(i) == ObjectPool::kTaggedObject) {
842 entry = pool.ObjectAt(i); 842 entry = pool.ObjectAt(i);
843 if (entry.IsICData()) { 843 if (entry.IsICData()) {
844 // A dynamic call.
844 call_site ^= entry.raw(); 845 call_site ^= entry.raw();
845 for (intptr_t j = 0; j < call_site.NumberOfChecks(); j++) { 846 ASSERT(!call_site.is_static_call());
846 target = call_site.GetTargetAt(j); 847 selector = call_site.target_name();
847 AddFunction(target); 848 AddSelector(selector);
848 if (!target.is_static()) { 849 if (selector.raw() == Symbols::Call().raw()) {
849 // Super call (should not enqueue selector) or dynamic call with a 850 // Potential closure call.
850 // CHA prediction (should enqueue selector). 851 const Array& arguments_descriptor =
851 selector = call_site.target_name(); 852 Array::Handle(Z, call_site.arguments_descriptor());
852 AddSelector(selector); 853 AddClosureCall(arguments_descriptor);
853 }
854 }
855 if (call_site.NumberOfChecks() == 0) {
856 // A dynamic call.
857 selector = call_site.target_name();
858 AddSelector(selector);
859 if (selector.raw() == Symbols::Call().raw()) {
860 // Potential closure call.
861 AddClosureCall(call_site);
862 }
863 } 854 }
864 } else if (entry.IsMegamorphicCache()) { 855 } else if (entry.IsMegamorphicCache()) {
865 // A dynamic call. 856 // A dynamic call.
866 cache ^= entry.raw(); 857 cache ^= entry.raw();
867 selector = cache.target_name(); 858 selector = cache.target_name();
868 AddSelector(selector); 859 AddSelector(selector);
860 if (selector.raw() == Symbols::Call().raw()) {
861 // Potential closure call.
862 const Array& arguments_descriptor =
863 Array::Handle(Z, cache.arguments_descriptor());
864 AddClosureCall(arguments_descriptor);
865 }
869 } else if (entry.IsField()) { 866 } else if (entry.IsField()) {
870 // Potential need for field initializer. 867 // Potential need for field initializer.
871 field ^= entry.raw(); 868 field ^= entry.raw();
872 AddField(field); 869 AddField(field);
873 } else if (entry.IsInstance()) { 870 } else if (entry.IsInstance()) {
874 // Const object, literal or args descriptor. 871 // Const object, literal or args descriptor.
875 instance ^= entry.raw(); 872 instance ^= entry.raw();
876 if (entry.IsAbstractType()) { 873 if (entry.IsAbstractType()) {
877 AddType(AbstractType::Cast(entry)); 874 AddType(AbstractType::Cast(entry));
878 } else { 875 } else {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 private: 1058 private:
1062 Precompiler* precompiler_; 1059 Precompiler* precompiler_;
1063 Object& subinstance_; 1060 Object& subinstance_;
1064 }; 1061 };
1065 1062
1066 ConstObjectVisitor visitor(this, I); 1063 ConstObjectVisitor visitor(this, I);
1067 instance.raw()->VisitPointers(&visitor); 1064 instance.raw()->VisitPointers(&visitor);
1068 } 1065 }
1069 1066
1070 1067
1071 void Precompiler::AddClosureCall(const ICData& call_site) { 1068 void Precompiler::AddClosureCall(const Array& arguments_descriptor) {
1072 const Array& arguments_descriptor =
1073 Array::Handle(Z, call_site.arguments_descriptor());
1074 const Class& cache_class = 1069 const Class& cache_class =
1075 Class::Handle(Z, I->object_store()->closure_class()); 1070 Class::Handle(Z, I->object_store()->closure_class());
1076 const Function& dispatcher = Function::Handle( 1071 const Function& dispatcher = Function::Handle(
1077 Z, cache_class.GetInvocationDispatcher( 1072 Z, cache_class.GetInvocationDispatcher(
1078 Symbols::Call(), arguments_descriptor, 1073 Symbols::Call(), arguments_descriptor,
1079 RawFunction::kInvokeFieldDispatcher, true /* create_if_absent */)); 1074 RawFunction::kInvokeFieldDispatcher, true /* create_if_absent */));
1080 AddFunction(dispatcher); 1075 AddFunction(dispatcher);
1081 } 1076 }
1082 1077
1083 1078
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 3288
3294 ASSERT(FLAG_precompiled_mode); 3289 ASSERT(FLAG_precompiled_mode);
3295 const bool optimized = function.IsOptimizable(); // False for natives. 3290 const bool optimized = function.IsOptimizable(); // False for natives.
3296 DartPrecompilationPipeline pipeline(zone, field_type_map); 3291 DartPrecompilationPipeline pipeline(zone, field_type_map);
3297 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); 3292 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized);
3298 } 3293 }
3299 3294
3300 #endif // DART_PRECOMPILER 3295 #endif // DART_PRECOMPILER
3301 3296
3302 } // namespace dart 3297 } // 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