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

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

Issue 8412004: Fix excessive reoptimization (guard test lost somehow). Fixes problems in Dart. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/code_index_table.h" 7 #include "vm/code_index_table.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
11 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
12 #include "vm/exceptions.h" 12 #include "vm/exceptions.h"
13 #include "vm/ic_data.h" 13 #include "vm/ic_data.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/resolver.h" 15 #include "vm/resolver.h"
16 #include "vm/runtime_entry.h" 16 #include "vm/runtime_entry.h"
17 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
18 #include "vm/verifier.h" 18 #include "vm/verifier.h"
19 19
20 namespace dart { 20 namespace dart {
21 21
22 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches"); 22 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches");
23 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); 23 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization");
24 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); 24 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling");
25 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); 25 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code.");
26 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls."); 26 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls.");
27 DECLARE_FLAG(bool, deoptimization_counter_threshold);
27 28
28 29
29 const Array& CodeGenerator::ArgumentsDescriptor( 30 const Array& CodeGenerator::ArgumentsDescriptor(
30 int num_arguments, 31 int num_arguments,
31 const Array& optional_arguments_names) { 32 const Array& optional_arguments_names) {
32 const intptr_t num_named_args = 33 const intptr_t num_named_args =
33 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length(); 34 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length();
34 const intptr_t num_pos_args = num_arguments - num_named_args; 35 const intptr_t num_pos_args = num_arguments - num_named_args;
35 36
36 // Build the argument descriptor array, which consists of the total number of 37 // Build the argument descriptor array, which consists of the total number of
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 760 }
760 761
761 762
762 // Only unoptimized code has invocation counter threshold checking. 763 // Only unoptimized code has invocation counter threshold checking.
763 // Once the invocation counter threshold is reached any entry into the 764 // Once the invocation counter threshold is reached any entry into the
764 // unoptimized code is redirected to this function. 765 // unoptimized code is redirected to this function.
765 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) { 766 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) {
766 ASSERT(arguments.Count() == 767 ASSERT(arguments.Count() ==
767 kOptimizeInvokedFunctionRuntimeEntry.argument_count()); 768 kOptimizeInvokedFunctionRuntimeEntry.argument_count());
768 const Function& function = Function::CheckedHandle(arguments.At(0)); 769 const Function& function = Function::CheckedHandle(arguments.At(0));
770 if (function.deoptimization_counter() >=
771 FLAG_deoptimization_counter_threshold) {
772 // TODO(srdjan): Investigate excessive deoptimization.
773 function.set_invocation_counter(0);
774 return;
775 }
769 if (function.is_optimizable()) { 776 if (function.is_optimizable()) {
770 ASSERT(!Code::Handle(function.code()).is_optimized()); 777 ASSERT(!Code::Handle(function.code()).is_optimized());
771 const Code& unoptimized_code = Code::Handle(function.code()); 778 const Code& unoptimized_code = Code::Handle(function.code());
772 // Compilation patches the entry of unoptimized code. 779 // Compilation patches the entry of unoptimized code.
773 Compiler::CompileOptimizedFunction(function); 780 Compiler::CompileOptimizedFunction(function);
774 const Code& optimized_code = Code::Handle(function.code()); 781 const Code& optimized_code = Code::Handle(function.code());
775 ASSERT(!optimized_code.IsNull()); 782 ASSERT(!optimized_code.IsNull());
776 ASSERT(!unoptimized_code.IsNull()); 783 ASSERT(!unoptimized_code.IsNull());
777 } else { 784 } else {
778 // TODO(5442338): Abort as this should not happen. 785 // TODO(5442338): Abort as this should not happen.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 } 955 }
949 } 956 }
950 } 957 }
951 // The cache is null terminated, therefore the loop above should never 958 // The cache is null terminated, therefore the loop above should never
952 // terminate by itself. 959 // terminate by itself.
953 UNREACHABLE(); 960 UNREACHABLE();
954 return Code::null(); 961 return Code::null();
955 } 962 }
956 963
957 } // namespace dart 964 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698