| 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 #ifndef DART_PRECOMPILED_RUNTIME | 4 #ifndef DART_PRECOMPILED_RUNTIME |
| 5 #include "vm/jit_optimizer.h" | 5 #include "vm/jit_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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(type_cid))); | 1387 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(type_cid))); |
| 1388 | 1388 |
| 1389 StrictCompareInstr* check_cid = | 1389 StrictCompareInstr* check_cid = |
| 1390 new (Z) StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, | 1390 new (Z) StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, |
| 1391 new (Z) Value(left_cid), new (Z) Value(cid), | 1391 new (Z) Value(left_cid), new (Z) Value(cid), |
| 1392 false); // No number check. | 1392 false); // No number check. |
| 1393 ReplaceCall(call, check_cid); | 1393 ReplaceCall(call, check_cid); |
| 1394 return; | 1394 return; |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 InstanceOfInstr* instance_of = | 1397 InstanceOfInstr* instance_of = new (Z) InstanceOfInstr( |
| 1398 new (Z) InstanceOfInstr(call->token_pos(), new (Z) Value(left), | 1398 call->token_pos(), new (Z) Value(left), new (Z) Value(type_args), |
| 1399 new (Z) Value(type_args), type, call->deopt_id()); | 1399 NULL, // TODO(regis): Pass function type args. |
| 1400 type, call->deopt_id()); |
| 1400 ReplaceCall(call, instance_of); | 1401 ReplaceCall(call, instance_of); |
| 1401 } | 1402 } |
| 1402 | 1403 |
| 1403 | 1404 |
| 1404 // TODO(srdjan): Apply optimizations as in ReplaceWithInstanceOf (TestCids). | 1405 // TODO(srdjan): Apply optimizations as in ReplaceWithInstanceOf (TestCids). |
| 1405 void JitOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) { | 1406 void JitOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) { |
| 1406 ASSERT(Token::IsTypeCastOperator(call->token_kind())); | 1407 ASSERT(Token::IsTypeCastOperator(call->token_kind())); |
| 1407 Definition* left = call->ArgumentAt(0); | 1408 Definition* left = call->ArgumentAt(0); |
| 1408 Definition* type_args = call->ArgumentAt(1); | 1409 Definition* type_args = call->ArgumentAt(1); |
| 1409 const AbstractType& type = | 1410 const AbstractType& type = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1427 push->RemoveFromGraph(); | 1428 push->RemoveFromGraph(); |
| 1428 } | 1429 } |
| 1429 // Remove call, replace it with 'left'. | 1430 // Remove call, replace it with 'left'. |
| 1430 call->ReplaceUsesWith(left); | 1431 call->ReplaceUsesWith(left); |
| 1431 ASSERT(current_iterator()->Current() == call); | 1432 ASSERT(current_iterator()->Current() == call); |
| 1432 current_iterator()->RemoveCurrentFromGraph(); | 1433 current_iterator()->RemoveCurrentFromGraph(); |
| 1433 return; | 1434 return; |
| 1434 } | 1435 } |
| 1435 } | 1436 } |
| 1436 AssertAssignableInstr* assert_as = new (Z) AssertAssignableInstr( | 1437 AssertAssignableInstr* assert_as = new (Z) AssertAssignableInstr( |
| 1437 call->token_pos(), new (Z) Value(left), new (Z) Value(type_args), type, | 1438 call->token_pos(), new (Z) Value(left), new (Z) Value(type_args), |
| 1438 Symbols::InTypeCast(), call->deopt_id()); | 1439 NULL, // TODO(regis): Pass function type arguments. |
| 1440 type, Symbols::InTypeCast(), call->deopt_id()); |
| 1439 ReplaceCall(call, assert_as); | 1441 ReplaceCall(call, assert_as); |
| 1440 } | 1442 } |
| 1441 | 1443 |
| 1442 | 1444 |
| 1443 bool JitOptimizer::LookupMethodFor(int class_id, | 1445 bool JitOptimizer::LookupMethodFor(int class_id, |
| 1444 const ArgumentsDescriptor& args_desc, | 1446 const ArgumentsDescriptor& args_desc, |
| 1445 const String& name, | 1447 const String& name, |
| 1446 Function* fn_return) { | 1448 Function* fn_return) { |
| 1447 if (class_id < 0) return false; | 1449 if (class_id < 0) return false; |
| 1448 if (class_id >= I->class_table()->NumCids()) return false; | 1450 if (class_id >= I->class_table()->NumCids()) return false; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 // Discard the environment from the original instruction because the store | 1868 // Discard the environment from the original instruction because the store |
| 1867 // can't deoptimize. | 1869 // can't deoptimize. |
| 1868 instr->RemoveEnvironment(); | 1870 instr->RemoveEnvironment(); |
| 1869 ReplaceCall(instr, store); | 1871 ReplaceCall(instr, store); |
| 1870 return true; | 1872 return true; |
| 1871 } | 1873 } |
| 1872 | 1874 |
| 1873 | 1875 |
| 1874 } // namespace dart | 1876 } // namespace dart |
| 1875 #endif // DART_PRECOMPILED_RUNTIME | 1877 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |