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

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

Issue 2246083003: AOT: Optimize even large functions. Ensures all calls are optimized static calls, switchable calls … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 4 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/object.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) 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 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 // Now that all functions have been compiled, we can switch to an instance 1903 // Now that all functions have been compiled, we can switch to an instance
1904 // call sequence that loads the Code object and entry point directly from 1904 // call sequence that loads the Code object and entry point directly from
1905 // the ic data array instead indirectly through a Function in the ic data 1905 // the ic data array instead indirectly through a Function in the ic data
1906 // array. Iterate all the object pools and rewrite the ic data from 1906 // array. Iterate all the object pools and rewrite the ic data from
1907 // (cid, target function, count) to (cid, target code, entry point), and 1907 // (cid, target function, count) to (cid, target code, entry point), and
1908 // replace the ICLookupThroughFunction stub with ICLookupThroughCode. 1908 // replace the ICLookupThroughFunction stub with ICLookupThroughCode.
1909 1909
1910 class SwitchICCallsVisitor : public FunctionVisitor { 1910 class SwitchICCallsVisitor : public FunctionVisitor {
1911 public: 1911 public:
1912 explicit SwitchICCallsVisitor(Zone* zone) : 1912 explicit SwitchICCallsVisitor(Zone* zone) :
1913 zone_(zone),
1913 code_(Code::Handle(zone)), 1914 code_(Code::Handle(zone)),
1914 pool_(ObjectPool::Handle(zone)), 1915 pool_(ObjectPool::Handle(zone)),
1915 entry_(Object::Handle(zone)), 1916 entry_(Object::Handle(zone)),
1916 ic_(ICData::Handle(zone)), 1917 ic_(ICData::Handle(zone)),
1917 target_(Function::Handle(zone)), 1918 target_code_(Code::Handle(zone)) {
1918 target_code_(Code::Handle(zone)),
1919 entry_point_(Smi::Handle(zone)) {
1920 } 1919 }
1921 1920
1922 void Visit(const Function& function) { 1921 void Visit(const Function& function) {
1923 if (!function.HasCode()) { 1922 if (!function.HasCode()) {
1924 return; 1923 return;
1925 } 1924 }
1926 1925
1927 code_ = function.CurrentCode(); 1926 code_ = function.CurrentCode();
1928 pool_ = code_.object_pool(); 1927 pool_ = code_.object_pool();
1929 for (intptr_t i = 0; i < pool_.Length(); i++) { 1928 for (intptr_t i = 0; i < pool_.Length(); i++) {
1930 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue; 1929 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue;
1931 entry_ = pool_.ObjectAt(i); 1930 entry_ = pool_.ObjectAt(i);
1932 if (entry_.IsICData()) { 1931 if (entry_.IsICData()) {
1932 // The only IC calls generated by precompilation are for switchable
1933 // calls.
1933 ic_ ^= entry_.raw(); 1934 ic_ ^= entry_.raw();
1934 1935 ic_.ResetSwitchable(zone_);
1935 if (ic_.NumArgsTested() != 1) continue;
1936
1937 for (intptr_t j = 0; j < ic_.NumberOfChecks(); j++) {
1938 entry_ = ic_.GetTargetOrCodeAt(j);
1939 if (entry_.IsFunction()) {
1940 target_ ^= entry_.raw();
1941 ASSERT(target_.HasCode());
1942 target_code_ = target_.CurrentCode();
1943 entry_point_ =
1944 Smi::FromAlignedAddress(target_code_.UncheckedEntryPoint());
1945 ic_.SetCodeAt(j, target_code_);
1946 ic_.SetEntryPointAt(j, entry_point_);
1947 } else {
1948 // We've already seen and switched this ICData.
1949 ASSERT(entry_.IsCode());
1950 }
1951 }
1952 } else if (entry_.raw() == 1936 } else if (entry_.raw() ==
1953 StubCode::ICLookupThroughFunction_entry()->code()) { 1937 StubCode::ICLookupThroughFunction_entry()->code()) {
1954 target_code_ = StubCode::ICLookupThroughCode_entry()->code(); 1938 target_code_ = StubCode::ICLookupThroughCode_entry()->code();
1955 pool_.SetObjectAt(i, target_code_); 1939 pool_.SetObjectAt(i, target_code_);
1956 } 1940 }
1957 } 1941 }
1958 } 1942 }
1959 1943
1960 private: 1944 private:
1945 Zone* zone_;
1961 Code& code_; 1946 Code& code_;
1962 ObjectPool& pool_; 1947 ObjectPool& pool_;
1963 Object& entry_; 1948 Object& entry_;
1964 ICData& ic_; 1949 ICData& ic_;
1965 Function& target_;
1966 Code& target_code_; 1950 Code& target_code_;
1967 Smi& entry_point_;
1968 }; 1951 };
1969 1952
1970 ASSERT(!I->compilation_allowed()); 1953 ASSERT(!I->compilation_allowed());
1971 SwitchICCallsVisitor visitor(Z); 1954 SwitchICCallsVisitor visitor(Z);
1972 VisitFunctions(&visitor); 1955 VisitFunctions(&visitor);
1973 #endif 1956 #endif
1974 } 1957 }
1975 1958
1976 1959
1977 void Precompiler::DedupStackmaps() { 1960 void Precompiler::DedupStackmaps() {
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 CompilationPipeline::New(thread->zone(), function); 2930 CompilationPipeline::New(thread->zone(), function);
2948 2931
2949 ASSERT(FLAG_precompiled_mode); 2932 ASSERT(FLAG_precompiled_mode);
2950 const bool optimized = function.IsOptimizable(); // False for natives. 2933 const bool optimized = function.IsOptimizable(); // False for natives.
2951 return PrecompileFunctionHelper(pipeline, function, optimized); 2934 return PrecompileFunctionHelper(pipeline, function, optimized);
2952 } 2935 }
2953 2936
2954 #endif // DART_PRECOMPILER 2937 #endif // DART_PRECOMPILER
2955 2938
2956 } // namespace dart 2939 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698