| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/opt_code_generator.h" | 8 #include "vm/opt_code_generator.h" |
| 9 | 9 |
| 10 #include "vm/assembler_macros.h" | 10 #include "vm/assembler_macros.h" |
| (...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 node->left(), | 1348 node->left(), |
| 1349 node->id(), | 1349 node->id(), |
| 1350 node->token_index(), | 1350 node->token_index(), |
| 1351 number_of_arguments, | 1351 number_of_arguments, |
| 1352 no_optional_argument_names); | 1352 no_optional_argument_names); |
| 1353 HandleResult(node, EAX); | 1353 HandleResult(node, EAX); |
| 1354 return; | 1354 return; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 | 1357 |
| 1358 // Optimized for Smi only. | |
| 1359 void OptimizingCodeGenerator::VisitIncrOpLocalNode(IncrOpLocalNode* node) { | |
| 1360 if (FLAG_enable_type_checks) { | |
| 1361 const AbstractType& local_type = node->local().type(); | |
| 1362 if (!local_type.IsNumberInterface() && !local_type.IsIntInterface()) { | |
| 1363 // Local does not accept a Smi (only Smi's interfaces are public). | |
| 1364 classes_for_locals_->SetLocalType(node->local(), Class::ZoneHandle()); | |
| 1365 CodeGenerator::VisitIncrOpLocalNode(node); | |
| 1366 return; | |
| 1367 } | |
| 1368 } | |
| 1369 const ICData& ic_data = node->ICDataAtId(node->id()); | |
| 1370 if (ic_data.NumberOfChecks() == 0) { | |
| 1371 DeoptimizationBlob* deopt_blob = | |
| 1372 AddDeoptimizationBlob(node, kDeoptNoTypeFeedback); | |
| 1373 __ jmp(deopt_blob->label()); | |
| 1374 return; | |
| 1375 } | |
| 1376 const char* kOptMessage = "Inlines IncrOpLocal"; | |
| 1377 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); | |
| 1378 if (!AtIdNodeHasClassAt(node, node->id(), smi_class_, 0)) { | |
| 1379 classes_for_locals_->SetLocalType(node->local(), Class::ZoneHandle()); | |
| 1380 TraceNotOpt(node, kOptMessage); | |
| 1381 CodeGenerator::VisitIncrOpLocalNode(node); | |
| 1382 return; | |
| 1383 } | |
| 1384 TraceOpt(node, kOptMessage); | |
| 1385 | |
| 1386 GenerateLoadVariable(EAX, node->local()); | |
| 1387 if (!node->prefix() && IsResultNeeded(node)) { | |
| 1388 // Preserve as result. | |
| 1389 __ movl(ECX, EAX); | |
| 1390 } | |
| 1391 const int int_value = (node->kind() == Token::kINCR) ? 1 : -1; | |
| 1392 const Immediate smi_value = | |
| 1393 Immediate(reinterpret_cast<int32_t>(Smi::New(int_value))); | |
| 1394 DeoptimizationBlob* deopt_blob = AddDeoptimizationBlob(node, kDeoptIncrLocal); | |
| 1395 __ testl(EAX, Immediate(kSmiTagMask)); | |
| 1396 __ j(NOT_ZERO, deopt_blob->label()); | |
| 1397 __ addl(EAX, smi_value); | |
| 1398 __ j(OVERFLOW, deopt_blob->label()); | |
| 1399 GenerateStoreVariable(node->local(), EAX, EDX); | |
| 1400 if (IsResultNeeded(node)) { | |
| 1401 if (node->info() != NULL) { | |
| 1402 node->info()->set_is_class(&smi_class_); | |
| 1403 } | |
| 1404 if (node->prefix()) { | |
| 1405 __ pushl(EAX); | |
| 1406 } else { | |
| 1407 __ pushl(ECX); | |
| 1408 } | |
| 1409 } | |
| 1410 classes_for_locals_->SetLocalType(node->local(), smi_class_); | |
| 1411 } | |
| 1412 | |
| 1413 | |
| 1414 // Debugging helper method, used in assert only. | 1358 // Debugging helper method, used in assert only. |
| 1415 static bool HaveSameClassesInICData(const ICData& a, const ICData& b) { | 1359 static bool HaveSameClassesInICData(const ICData& a, const ICData& b) { |
| 1416 if (a.NumberOfChecks() != b.NumberOfChecks()) { | 1360 if (a.NumberOfChecks() != b.NumberOfChecks()) { |
| 1417 return false; | 1361 return false; |
| 1418 } | 1362 } |
| 1419 if (a.NumberOfChecks() == 0) { | 1363 if (a.NumberOfChecks() == 0) { |
| 1420 return true; | 1364 return true; |
| 1421 } | 1365 } |
| 1422 if (a.num_args_tested() != b.num_args_tested()) { | 1366 if (a.num_args_tested() != b.num_args_tested()) { |
| 1423 return false; | 1367 return false; |
| (...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3091 } | 3035 } |
| 3092 } | 3036 } |
| 3093 // TODO(srdjan): Implement unary kSUB (negate) Mint. | 3037 // TODO(srdjan): Implement unary kSUB (negate) Mint. |
| 3094 CodeGenerator::VisitUnaryOpNode(node); | 3038 CodeGenerator::VisitUnaryOpNode(node); |
| 3095 } | 3039 } |
| 3096 | 3040 |
| 3097 | 3041 |
| 3098 } // namespace dart | 3042 } // namespace dart |
| 3099 | 3043 |
| 3100 #endif // defined TARGET_ARCH_IA32 | 3044 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |