OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 } | 1857 } |
1858 // Reduce the chance of triggering optimization while the function is | 1858 // Reduce the chance of triggering optimization while the function is |
1859 // being optimized in the background. INT_MIN should ensure that it | 1859 // being optimized in the background. INT_MIN should ensure that it |
1860 // takes long time to trigger optimization. | 1860 // takes long time to trigger optimization. |
1861 // Note that the background compilation queue rejects duplicate entries. | 1861 // Note that the background compilation queue rejects duplicate entries. |
1862 function.set_usage_counter(INT_MIN); | 1862 function.set_usage_counter(INT_MIN); |
1863 BackgroundCompiler::EnsureInit(thread); | 1863 BackgroundCompiler::EnsureInit(thread); |
1864 ASSERT(isolate->background_compiler() != NULL); | 1864 ASSERT(isolate->background_compiler() != NULL); |
1865 isolate->background_compiler()->CompileOptimized(function); | 1865 isolate->background_compiler()->CompileOptimized(function); |
1866 // Continue in the same code. | 1866 // Continue in the same code. |
1867 arguments.SetReturn(Code::Handle(zone, function.CurrentCode())); | 1867 const Code& code = Code::Handle(zone, function.CurrentCode()); |
| 1868 ASSERT(!code.IsDisabled()); |
| 1869 arguments.SetReturn(code); |
1868 return; | 1870 return; |
1869 } | 1871 } |
1870 } | 1872 } |
1871 | 1873 |
1872 // Reset usage counter for reoptimization before calling optimizer to | 1874 // Reset usage counter for reoptimization before calling optimizer to |
1873 // prevent recursive triggering of function optimization. | 1875 // prevent recursive triggering of function optimization. |
1874 function.set_usage_counter(0); | 1876 function.set_usage_counter(0); |
1875 if (FLAG_trace_compiler || FLAG_trace_optimizing_compiler) { | 1877 if (FLAG_trace_compiler || FLAG_trace_optimizing_compiler) { |
1876 if (function.HasOptimizedCode()) { | 1878 if (function.HasOptimizedCode()) { |
1877 THR_Print("ReCompiling function: '%s' \n", | 1879 THR_Print("ReCompiling function: '%s' \n", |
1878 function.ToFullyQualifiedCString()); | 1880 function.ToFullyQualifiedCString()); |
1879 } | 1881 } |
1880 } | 1882 } |
1881 const Error& error = Error::Handle( | 1883 const Error& error = Error::Handle( |
1882 zone, Compiler::CompileOptimizedFunction(thread, function)); | 1884 zone, Compiler::CompileOptimizedFunction(thread, function)); |
1883 if (!error.IsNull()) { | 1885 if (!error.IsNull()) { |
1884 Exceptions::PropagateError(error); | 1886 Exceptions::PropagateError(error); |
1885 } | 1887 } |
1886 const Code& optimized_code = Code::Handle(zone, function.CurrentCode()); | 1888 const Code& optimized_code = Code::Handle(zone, function.CurrentCode()); |
1887 ASSERT(!optimized_code.IsNull()); | 1889 ASSERT(!optimized_code.IsNull()); |
1888 } | 1890 } |
1889 arguments.SetReturn(Code::Handle(zone, function.CurrentCode())); | 1891 const Code& code = Code::Handle(zone, function.CurrentCode()); |
| 1892 ASSERT(!code.IsDisabled()); |
| 1893 arguments.SetReturn(code); |
1890 #else | 1894 #else |
1891 UNREACHABLE(); | 1895 UNREACHABLE(); |
1892 #endif // !DART_PRECOMPILED_RUNTIME | 1896 #endif // !DART_PRECOMPILED_RUNTIME |
1893 } | 1897 } |
1894 | 1898 |
1895 | 1899 |
1896 // The caller must be a static call in a Dart frame, or an entry frame. | 1900 // The caller must be a static call in a Dart frame, or an entry frame. |
1897 // Patch static call to point to valid code's entry point. | 1901 // Patch static call to point to valid code's entry point. |
1898 DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) { | 1902 DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) { |
1899 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); | 1903 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); |
(...skipping 28 matching lines...) Expand all Loading... |
1928 caller_code, | 1932 caller_code, |
1929 current_target_code); | 1933 current_target_code); |
1930 caller_code.SetStaticCallTargetCodeAt(frame->pc(), current_target_code); | 1934 caller_code.SetStaticCallTargetCodeAt(frame->pc(), current_target_code); |
1931 if (FLAG_trace_patching) { | 1935 if (FLAG_trace_patching) { |
1932 OS::PrintErr("FixCallersTarget: caller %#" Px " " | 1936 OS::PrintErr("FixCallersTarget: caller %#" Px " " |
1933 "target '%s' -> %#" Px "\n", | 1937 "target '%s' -> %#" Px "\n", |
1934 frame->pc(), | 1938 frame->pc(), |
1935 target_function.ToFullyQualifiedCString(), | 1939 target_function.ToFullyQualifiedCString(), |
1936 current_target_code.UncheckedEntryPoint()); | 1940 current_target_code.UncheckedEntryPoint()); |
1937 } | 1941 } |
| 1942 ASSERT(!current_target_code.IsDisabled()); |
1938 arguments.SetReturn(current_target_code); | 1943 arguments.SetReturn(current_target_code); |
1939 } | 1944 } |
1940 | 1945 |
1941 | 1946 |
1942 // The caller tried to allocate an instance via an invalidated allocation | 1947 // The caller tried to allocate an instance via an invalidated allocation |
1943 // stub. | 1948 // stub. |
1944 DEFINE_RUNTIME_ENTRY(FixAllocationStubTarget, 0) { | 1949 DEFINE_RUNTIME_ENTRY(FixAllocationStubTarget, 0) { |
1945 #if !defined(DART_PRECOMPILED_RUNTIME) | 1950 #if !defined(DART_PRECOMPILED_RUNTIME) |
1946 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); | 1951 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); |
1947 StackFrame* frame = iterator.NextFrame(); | 1952 StackFrame* frame = iterator.NextFrame(); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 2349 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
2345 const TypedData& new_data = | 2350 const TypedData& new_data = |
2346 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 2351 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
2347 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 2352 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
2348 typed_data_cell.SetAt(0, new_data); | 2353 typed_data_cell.SetAt(0, new_data); |
2349 arguments.SetReturn(new_data); | 2354 arguments.SetReturn(new_data); |
2350 } | 2355 } |
2351 | 2356 |
2352 | 2357 |
2353 } // namespace dart | 2358 } // namespace dart |
OLD | NEW |