| Index: runtime/vm/jit_optimizer.cc
|
| diff --git a/runtime/vm/jit_optimizer.cc b/runtime/vm/jit_optimizer.cc
|
| index 010b25c47a1e3c9dccf922ab0cadb5b027db468c..842506320317addf7af94b5e340d089a13636fba 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()));
|
| @@ -1339,7 +1285,8 @@ 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);
|
| + const bool can_deopt =
|
| + Optimizer::SpecializeTestCidsForNumericTypes(results, type);
|
| TestCidsInstr* test_cids = new (Z) TestCidsInstr(
|
| call->token_pos(), Token::kIS, new (Z) Value(left), *results,
|
| can_deopt ? call->deopt_id() : Thread::kNoDeoptId);
|
|
|