| 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/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 3208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3219 instance_call()->ArgumentCount(), | 3219 instance_call()->ArgumentCount(), |
| 3220 instance_call()->argument_names(), | 3220 instance_call()->argument_names(), |
| 3221 deopt_id(), | 3221 deopt_id(), |
| 3222 instance_call()->token_pos(), | 3222 instance_call()->token_pos(), |
| 3223 locs(), | 3223 locs(), |
| 3224 complete()); | 3224 complete()); |
| 3225 } | 3225 } |
| 3226 #endif | 3226 #endif |
| 3227 | 3227 |
| 3228 | 3228 |
| 3229 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( |
| 3230 const ICData& ic_data) { |
| 3231 bool is_string = true; |
| 3232 bool is_integer = true; |
| 3233 bool is_double = true; |
| 3234 |
| 3235 const intptr_t num_checks = ic_data.NumberOfChecks(); |
| 3236 for (intptr_t i = 0; i < num_checks; i++) { |
| 3237 const intptr_t cid = ic_data.GetReceiverClassIdAt(i); |
| 3238 is_string = is_string && RawObject::IsStringClassId(cid); |
| 3239 is_integer = is_integer && RawObject::IsIntegerClassId(cid); |
| 3240 is_double = is_double && (cid == kDoubleCid); |
| 3241 } |
| 3242 |
| 3243 if (is_string) { |
| 3244 return Type::StringType(); |
| 3245 } else if (is_integer) { |
| 3246 return Type::IntType(); |
| 3247 } else if (is_double) { |
| 3248 return Type::Double(); |
| 3249 } |
| 3250 |
| 3251 return Type::null(); |
| 3252 } |
| 3253 |
| 3254 |
| 3255 Definition* PolymorphicInstanceCallInstr::Canonicalize(FlowGraph* flow_graph) { |
| 3256 if (!HasSingleRecognizedTarget() || with_checks()) { |
| 3257 return this; |
| 3258 } |
| 3259 |
| 3260 const Function& target = Function::Handle(ic_data().GetTargetAt(0)); |
| 3261 if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) { |
| 3262 const AbstractType& type = |
| 3263 AbstractType::Handle(ComputeRuntimeType(ic_data())); |
| 3264 if (!type.IsNull()) { |
| 3265 return flow_graph->GetConstant(type); |
| 3266 } |
| 3267 } |
| 3268 |
| 3269 return this; |
| 3270 } |
| 3271 |
| 3272 |
| 3273 Definition* StaticCallInstr::Canonicalize(FlowGraph* flow_graph) { |
| 3274 if (!FLAG_precompiled_mode) { |
| 3275 return this; |
| 3276 } |
| 3277 |
| 3278 if (function().recognized_kind() == MethodRecognizer::kObjectRuntimeType) { |
| 3279 if (input_use_list() == NULL) { |
| 3280 // This function has only environment uses. In precompiled mode it is |
| 3281 // fine to remove it - because we will never deoptimize. |
| 3282 return flow_graph->constant_dead(); |
| 3283 } |
| 3284 } |
| 3285 |
| 3286 return this; |
| 3287 } |
| 3288 |
| 3289 |
| 3229 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, | 3290 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, |
| 3230 bool optimizing) const { | 3291 bool optimizing) const { |
| 3231 return MakeCallSummary(zone); | 3292 return MakeCallSummary(zone); |
| 3232 } | 3293 } |
| 3233 | 3294 |
| 3234 | 3295 |
| 3235 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3296 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3236 const ICData* call_ic_data = NULL; | 3297 const ICData* call_ic_data = NULL; |
| 3237 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || | 3298 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || |
| 3238 (ic_data() == NULL)) { | 3299 (ic_data() == NULL)) { |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3861 set_native_c_function(native_function); | 3922 set_native_c_function(native_function); |
| 3862 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3923 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
| 3863 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3924 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
| 3864 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3925 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
| 3865 set_is_bootstrap_native(is_bootstrap_native); | 3926 set_is_bootstrap_native(is_bootstrap_native); |
| 3866 } | 3927 } |
| 3867 | 3928 |
| 3868 #undef __ | 3929 #undef __ |
| 3869 | 3930 |
| 3870 } // namespace dart | 3931 } // namespace dart |
| OLD | NEW |