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

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

Issue 2002583002: Background compiler should validate CHA decisions before committing the code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 7 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 | « no previous file | runtime/vm/cha.h » ('j') | 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) 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/aot_optimizer.h" 5 #include "vm/aot_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/branch_optimizer.h" 8 #include "vm/branch_optimizer.h"
9 #include "vm/cha.h" 9 #include "vm/cha.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 const Class& type_class = Class::Handle(type.type_class()); 2053 const Class& type_class = Class::Handle(type.type_class());
2054 // Could be an interface check? 2054 // Could be an interface check?
2055 if (CHA::IsImplemented(type_class)) return false; 2055 if (CHA::IsImplemented(type_class)) return false;
2056 // Check if there are subclasses. 2056 // Check if there are subclasses.
2057 if (CHA::HasSubclasses(type_class)) { 2057 if (CHA::HasSubclasses(type_class)) {
2058 return false; 2058 return false;
2059 } 2059 }
2060 2060
2061 // Private classes cannot be subclassed by later loaded libs. 2061 // Private classes cannot be subclassed by later loaded libs.
2062 if (!type_class.IsPrivate()) { 2062 if (!type_class.IsPrivate()) {
2063 if (FLAG_use_cha_deopt || isolate()->all_classes_finalized()) { 2063 if (isolate()->all_classes_finalized()) {
2064 if (FLAG_trace_cha) { 2064 if (FLAG_trace_cha) {
2065 THR_Print(" **(CHA) Typecheck as class equality since no " 2065 THR_Print(" **(CHA) Typecheck as class equality since no "
2066 "subclasses: %s\n", 2066 "subclasses: %s\n",
2067 type_class.ToCString()); 2067 type_class.ToCString());
2068 } 2068 }
2069 if (FLAG_use_cha_deopt) { 2069 ASSERT(!FLAG_use_cha_deopt);
2070 thread()->cha()->AddToLeafClasses(type_class);
2071 }
2072 } else { 2070 } else {
2073 return false; 2071 return false;
2074 } 2072 }
2075 } 2073 }
2076 const intptr_t num_type_args = type_class.NumTypeArguments(); 2074 const intptr_t num_type_args = type_class.NumTypeArguments();
2077 if (num_type_args > 0) { 2075 if (num_type_args > 0) {
2078 // Only raw types can be directly compared, thus disregarding type 2076 // Only raw types can be directly compared, thus disregarding type
2079 // arguments. 2077 // arguments.
2080 const intptr_t num_type_params = type_class.NumTypeParameters(); 2078 const intptr_t num_type_params = type_class.NumTypeParameters();
2081 const intptr_t from_index = num_type_args - num_type_params; 2079 const intptr_t from_index = num_type_args - num_type_params;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 const Array& args_desc_array = Array::Handle(Z, 2447 const Array& args_desc_array = Array::Handle(Z,
2450 ArgumentsDescriptor::New(instr->ArgumentCount(), 2448 ArgumentsDescriptor::New(instr->ArgumentCount(),
2451 instr->argument_names())); 2449 instr->argument_names()));
2452 ArgumentsDescriptor args_desc(args_desc_array); 2450 ArgumentsDescriptor args_desc(args_desc_array);
2453 const Function& function = Function::Handle(Z, 2451 const Function& function = Function::Handle(Z,
2454 Resolver::ResolveDynamicForReceiverClass( 2452 Resolver::ResolveDynamicForReceiverClass(
2455 receiver_class, 2453 receiver_class,
2456 instr->function_name(), 2454 instr->function_name(),
2457 args_desc)); 2455 args_desc));
2458 if (!function.IsNull()) { 2456 if (!function.IsNull()) {
2457 intptr_t subclasses = 0;
2459 if (!thread()->cha()->HasOverride(receiver_class, 2458 if (!thread()->cha()->HasOverride(receiver_class,
2460 instr->function_name())) { 2459 instr->function_name(),
2460 &subclasses)) {
2461 if (FLAG_trace_cha) { 2461 if (FLAG_trace_cha) {
2462 THR_Print(" **(CHA) Instance call needs no check, " 2462 THR_Print(" **(CHA) Instance call needs no check, "
2463 "no overrides of '%s' '%s'\n", 2463 "no overrides of '%s' '%s'\n",
2464 instr->function_name().ToCString(), receiver_class.ToCString()); 2464 instr->function_name().ToCString(), receiver_class.ToCString());
2465 } 2465 }
2466 2466
2467 // Create fake IC data with the resolved target. 2467 // Create fake IC data with the resolved target.
2468 const ICData& ic_data = ICData::Handle( 2468 const ICData& ic_data = ICData::Handle(
2469 ICData::New(flow_graph_->function(), 2469 ICData::New(flow_graph_->function(),
2470 instr->function_name(), 2470 instr->function_name(),
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 2776
2777 // Discard the environment from the original instruction because the store 2777 // Discard the environment from the original instruction because the store
2778 // can't deoptimize. 2778 // can't deoptimize.
2779 instr->RemoveEnvironment(); 2779 instr->RemoveEnvironment();
2780 ReplaceCall(instr, store); 2780 ReplaceCall(instr, store);
2781 return true; 2781 return true;
2782 } 2782 }
2783 2783
2784 2784
2785 } // namespace dart 2785 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/cha.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698