Chromium Code Reviews| 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/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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1347 if (cache != NULL && | 1347 if (cache != NULL && |
| 1348 cache->InstanceOfHasClassRange(type, &lower_limit, &upper_limit)) { | 1348 cache->InstanceOfHasClassRange(type, &lower_limit, &upper_limit)) { |
| 1349 // left.instanceof(type) => | 1349 // left.instanceof(type) => |
| 1350 // _classRangeCheck(left.cid, lower_limit, upper_limit) | 1350 // _classRangeCheck(left.cid, lower_limit, upper_limit) |
| 1351 | 1351 |
| 1352 LoadClassIdInstr* left_cid = | 1352 LoadClassIdInstr* left_cid = |
| 1353 new (Z) LoadClassIdInstr(new (Z) Value(left)); | 1353 new (Z) LoadClassIdInstr(new (Z) Value(left)); |
| 1354 InsertBefore(call, left_cid, NULL, FlowGraph::kValue); | 1354 InsertBefore(call, left_cid, NULL, FlowGraph::kValue); |
| 1355 ConstantInstr* lower_cid = | 1355 ConstantInstr* lower_cid = |
| 1356 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(lower_limit))); | 1356 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(lower_limit))); |
| 1357 | |
| 1358 if (lower_limit == upper_limit) { | |
|
Vyacheslav Egorov (Google)
2017/08/25 07:59:15
Does it make sense to do a similar optimization fo
alexmarkov
2017/08/29 22:45:32
I think you're right - 'as' and 'is' checks should
| |
| 1359 StrictCompareInstr* check_cid = new (Z) StrictCompareInstr( | |
| 1360 call->token_pos(), Token::kEQ_STRICT, new (Z) Value(left_cid), | |
| 1361 new (Z) Value(lower_cid), /* number_check = */ false, | |
| 1362 Thread::kNoDeoptId); | |
| 1363 ReplaceCall(call, check_cid); | |
| 1364 return; | |
| 1365 } | |
| 1366 | |
| 1357 ConstantInstr* upper_cid = | 1367 ConstantInstr* upper_cid = |
| 1358 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(upper_limit))); | 1368 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(upper_limit))); |
| 1359 | 1369 |
| 1360 ZoneGrowableArray<PushArgumentInstr*>* args = | 1370 ZoneGrowableArray<PushArgumentInstr*>* args = |
| 1361 new (Z) ZoneGrowableArray<PushArgumentInstr*>(3); | 1371 new (Z) ZoneGrowableArray<PushArgumentInstr*>(3); |
| 1362 PushArgumentInstr* arg = | 1372 PushArgumentInstr* arg = |
| 1363 new (Z) PushArgumentInstr(new (Z) Value(left_cid)); | 1373 new (Z) PushArgumentInstr(new (Z) Value(left_cid)); |
| 1364 InsertBefore(call, arg, NULL, FlowGraph::kEffect); | 1374 InsertBefore(call, arg, NULL, FlowGraph::kEffect); |
| 1365 args->Add(arg); | 1375 args->Add(arg); |
| 1366 arg = new (Z) PushArgumentInstr(new (Z) Value(lower_cid)); | 1376 arg = new (Z) PushArgumentInstr(new (Z) Value(lower_cid)); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2088 FlowGraph::kEffect); | 2098 FlowGraph::kEffect); |
| 2089 current_iterator()->RemoveCurrentFromGraph(); | 2099 current_iterator()->RemoveCurrentFromGraph(); |
| 2090 } | 2100 } |
| 2091 } | 2101 } |
| 2092 } | 2102 } |
| 2093 } | 2103 } |
| 2094 | 2104 |
| 2095 #endif // DART_PRECOMPILER | 2105 #endif // DART_PRECOMPILER |
| 2096 | 2106 |
| 2097 } // namespace dart | 2107 } // namespace dart |
| OLD | NEW |