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

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

Issue 2453463006: Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."" (Closed)
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intrinsifier_arm.cc » ('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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 3213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3224 instance_call()->ArgumentCount(), 3224 instance_call()->ArgumentCount(),
3225 instance_call()->argument_names(), 3225 instance_call()->argument_names(),
3226 deopt_id(), 3226 deopt_id(),
3227 instance_call()->token_pos(), 3227 instance_call()->token_pos(),
3228 locs(), 3228 locs(),
3229 complete()); 3229 complete());
3230 } 3230 }
3231 #endif 3231 #endif
3232 3232
3233 3233
3234 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType(
3235 const ICData& ic_data) {
3236 bool is_string = true;
3237 bool is_integer = true;
3238 bool is_double = true;
3239
3240 const intptr_t num_checks = ic_data.NumberOfChecks();
3241 for (intptr_t i = 0; i < num_checks; i++) {
3242 const intptr_t cid = ic_data.GetReceiverClassIdAt(i);
3243 is_string = is_string && RawObject::IsStringClassId(cid);
3244 is_integer = is_integer && RawObject::IsIntegerClassId(cid);
3245 is_double = is_double && (cid == kDoubleCid);
3246 }
3247
3248 if (is_string) {
3249 return Type::StringType();
3250 } else if (is_integer) {
3251 return Type::IntType();
3252 } else if (is_double) {
3253 return Type::Double();
3254 }
3255
3256 return Type::null();
3257 }
3258
3259
3260 Definition* PolymorphicInstanceCallInstr::Canonicalize(FlowGraph* flow_graph) {
3261 if (!HasSingleRecognizedTarget() || with_checks()) {
3262 return this;
3263 }
3264
3265 const Function& target = Function::Handle(ic_data().GetTargetAt(0));
3266 if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) {
3267 const AbstractType& type =
3268 AbstractType::Handle(ComputeRuntimeType(ic_data()));
3269 if (!type.IsNull()) {
3270 return flow_graph->GetConstant(type);
3271 }
3272 }
3273
3274 return this;
3275 }
3276
3277
3278 Definition* StaticCallInstr::Canonicalize(FlowGraph* flow_graph) {
3279 if (!FLAG_precompiled_mode) {
3280 return this;
3281 }
3282
3283 if (function().recognized_kind() == MethodRecognizer::kObjectRuntimeType) {
3284 if (input_use_list() == NULL) {
3285 // This function has only environment uses. In precompiled mode it is
3286 // fine to remove it - because we will never deoptimize.
3287 return flow_graph->constant_dead();
3288 }
3289 }
3290
3291 return this;
3292 }
3293
3294
3234 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, 3295 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone,
3235 bool optimizing) const { 3296 bool optimizing) const {
3236 return MakeCallSummary(zone); 3297 return MakeCallSummary(zone);
3237 } 3298 }
3238 3299
3239 3300
3240 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3301 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3241 const ICData* call_ic_data = NULL; 3302 const ICData* call_ic_data = NULL;
3242 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || 3303 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() ||
3243 (ic_data() == NULL)) { 3304 (ic_data() == NULL)) {
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3866 set_native_c_function(native_function); 3927 set_native_c_function(native_function);
3867 function().SetIsNativeAutoSetupScope(auto_setup_scope); 3928 function().SetIsNativeAutoSetupScope(auto_setup_scope);
3868 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 3929 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
3869 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); 3930 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver);
3870 set_is_bootstrap_native(is_bootstrap_native); 3931 set_is_bootstrap_native(is_bootstrap_native);
3871 } 3932 }
3872 3933
3873 #undef __ 3934 #undef __
3874 3935
3875 } // namespace dart 3936 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intrinsifier_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698