Chromium Code Reviews| Index: runtime/vm/jit_optimizer.cc |
| diff --git a/runtime/vm/jit_optimizer.cc b/runtime/vm/jit_optimizer.cc |
| index 151e187e1e5c7a1399fb2464b7729e493c05247d..1a12f58efd32fd381eb5e8037c8323efeefb44a6 100644 |
| --- a/runtime/vm/jit_optimizer.cc |
| +++ b/runtime/vm/jit_optimizer.cc |
| @@ -19,6 +19,7 @@ |
| #include "vm/il_printer.h" |
| #include "vm/intermediate_language.h" |
| #include "vm/object_store.h" |
| +#include "vm/optimizer.h" |
| #include "vm/parser.h" |
| #include "vm/resolver.h" |
| #include "vm/scopes.h" |
| @@ -1241,61 +1242,6 @@ bool JitOptimizer::TypeCheckAsClassEquality(const AbstractType& type) { |
| } |
| -static bool CidTestResultsContains(const ZoneGrowableArray<intptr_t>& results, |
| - intptr_t test_cid) { |
| - for (intptr_t i = 0; i < results.length(); i += 2) { |
| - if (results[i] == test_cid) return true; |
| - } |
| - return false; |
| -} |
| - |
| - |
| -static void TryAddTest(ZoneGrowableArray<intptr_t>* results, |
| - intptr_t test_cid, |
| - bool result) { |
| - if (!CidTestResultsContains(*results, test_cid)) { |
| - results->Add(test_cid); |
| - results->Add(result); |
| - } |
| -} |
| - |
| - |
| -// Tries to add cid tests to 'results' so that no deoptimization is |
| -// necessary. |
| -// TODO(srdjan): Do also for other than 'int' type. |
| -static bool TryExpandTestCidsResult(ZoneGrowableArray<intptr_t>* results, |
| - const AbstractType& type) { |
| - ASSERT(results->length() >= 2); // At least on eentry. |
| - const ClassTable& class_table = *Isolate::Current()->class_table(); |
| - if ((*results)[0] != kSmiCid) { |
| - const Class& cls = Class::Handle(class_table.At(kSmiCid)); |
| - const Class& type_class = Class::Handle(type.type_class()); |
| - const bool smi_is_subtype = |
| - cls.IsSubtypeOf(Object::null_type_arguments(), type_class, |
| - Object::null_type_arguments(), NULL, NULL, Heap::kOld); |
| - results->Add((*results)[results->length() - 2]); |
| - results->Add((*results)[results->length() - 2]); |
| - for (intptr_t i = results->length() - 3; i > 1; --i) { |
| - (*results)[i] = (*results)[i - 2]; |
| - } |
| - (*results)[0] = kSmiCid; |
| - (*results)[1] = smi_is_subtype; |
| - } |
| - |
| - ASSERT(type.IsInstantiated() && !type.IsMalformedOrMalbounded()); |
| - ASSERT(results->length() >= 2); |
| - if (type.IsIntType()) { |
| - ASSERT((*results)[0] == kSmiCid); |
| - TryAddTest(results, kMintCid, true); |
| - TryAddTest(results, kBigintCid, true); |
| - // Cannot deoptimize since all tests returning true have been added. |
| - return false; |
| - } |
| - |
| - return true; // May deoptimize since we have not identified all 'true' tests. |
| -} |
| - |
| - |
| // TODO(srdjan): Use ICData to check if always true or false. |
| void JitOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { |
| ASSERT(Token::IsTypeTestOperator(call->token_kind())); |
| @@ -1324,7 +1270,9 @@ void JitOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { |
| Bool::ZoneHandle(Z, InstanceOfAsBool(unary_checks, type, results)); |
| if (as_bool.IsNull()) { |
| if (results->length() == number_of_checks * 2) { |
| - const bool can_deopt = TryExpandTestCidsResult(results, type); |
| + bool int_type_only = true; |
|
Vyacheslav Egorov (Google)
2017/05/23 16:00:31
const bool kIntTypesOnly = true;
erikcorry
2017/05/24 13:37:16
Gone
|
| + const bool can_deopt = |
| + Optimizer::TryExpandTestCidsResult(results, type, int_type_only); |
| TestCidsInstr* test_cids = new (Z) TestCidsInstr( |
| call->token_pos(), Token::kIS, new (Z) Value(left), *results, |
| can_deopt ? call->deopt_id() : Thread::kNoDeoptId); |