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/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 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 } | 1898 } |
1899 | 1899 |
1900 | 1900 |
1901 void Precompiler::SwitchICCalls() { | 1901 void Precompiler::SwitchICCalls() { |
1902 #if !defined(TARGET_ARCH_DBC) | 1902 #if !defined(TARGET_ARCH_DBC) |
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 ICCallThroughFunction stub with ICCallThroughCode. |
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 zone_(zone), |
1914 code_(Code::Handle(zone)), | 1914 code_(Code::Handle(zone)), |
1915 pool_(ObjectPool::Handle(zone)), | 1915 pool_(ObjectPool::Handle(zone)), |
1916 entry_(Object::Handle(zone)), | 1916 entry_(Object::Handle(zone)), |
1917 ic_(ICData::Handle(zone)), | 1917 ic_(ICData::Handle(zone)), |
1918 target_code_(Code::Handle(zone)) { | 1918 target_code_(Code::Handle(zone)) { |
1919 } | 1919 } |
1920 | 1920 |
1921 void Visit(const Function& function) { | 1921 void Visit(const Function& function) { |
1922 if (!function.HasCode()) { | 1922 if (!function.HasCode()) { |
1923 return; | 1923 return; |
1924 } | 1924 } |
1925 | 1925 |
1926 code_ = function.CurrentCode(); | 1926 code_ = function.CurrentCode(); |
1927 pool_ = code_.object_pool(); | 1927 pool_ = code_.object_pool(); |
1928 for (intptr_t i = 0; i < pool_.Length(); i++) { | 1928 for (intptr_t i = 0; i < pool_.Length(); i++) { |
1929 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue; | 1929 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue; |
1930 entry_ = pool_.ObjectAt(i); | 1930 entry_ = pool_.ObjectAt(i); |
1931 if (entry_.IsICData()) { | 1931 if (entry_.IsICData()) { |
1932 // The only IC calls generated by precompilation are for switchable | 1932 // The only IC calls generated by precompilation are for switchable |
1933 // calls. | 1933 // calls. |
1934 ic_ ^= entry_.raw(); | 1934 ic_ ^= entry_.raw(); |
1935 ic_.ResetSwitchable(zone_); | 1935 ic_.ResetSwitchable(zone_); |
1936 } else if (entry_.raw() == | 1936 } else if (entry_.raw() == |
1937 StubCode::ICLookupThroughFunction_entry()->code()) { | 1937 StubCode::ICCallThroughFunction_entry()->code()) { |
1938 target_code_ = StubCode::ICLookupThroughCode_entry()->code(); | 1938 target_code_ = StubCode::ICCallThroughCode_entry()->code(); |
1939 pool_.SetObjectAt(i, target_code_); | 1939 pool_.SetObjectAt(i, target_code_); |
1940 } | 1940 } |
1941 } | 1941 } |
1942 } | 1942 } |
1943 | 1943 |
1944 private: | 1944 private: |
1945 Zone* zone_; | 1945 Zone* zone_; |
1946 Code& code_; | 1946 Code& code_; |
1947 ObjectPool& pool_; | 1947 ObjectPool& pool_; |
1948 Object& entry_; | 1948 Object& entry_; |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 CompilationPipeline::New(thread->zone(), function); | 2930 CompilationPipeline::New(thread->zone(), function); |
2931 | 2931 |
2932 ASSERT(FLAG_precompiled_mode); | 2932 ASSERT(FLAG_precompiled_mode); |
2933 const bool optimized = function.IsOptimizable(); // False for natives. | 2933 const bool optimized = function.IsOptimizable(); // False for natives. |
2934 return PrecompileFunctionHelper(pipeline, function, optimized); | 2934 return PrecompileFunctionHelper(pipeline, function, optimized); |
2935 } | 2935 } |
2936 | 2936 |
2937 #endif // DART_PRECOMPILER | 2937 #endif // DART_PRECOMPILER |
2938 | 2938 |
2939 } // namespace dart | 2939 } // namespace dart |
OLD | NEW |