| 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 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 __ Bind(&done); | 1336 __ Bind(&done); |
| 1337 HandleResult(node, EAX); | 1337 HandleResult(node, EAX); |
| 1338 } | 1338 } |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 | 1341 |
| 1342 void OptimizingCodeGenerator::VisitBinaryOpNode(BinaryOpNode* node) { | 1342 void OptimizingCodeGenerator::VisitBinaryOpNode(BinaryOpNode* node) { |
| 1343 // Operators "&&" and "||" cannot be overloaded, therefore inline them | 1343 // Operators "&&" and "||" cannot be overloaded, therefore inline them |
| 1344 // instead of calling the operator. | 1344 // instead of calling the operator. |
| 1345 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 1345 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
| 1346 // TODO(srdjan): Test in checked mode if they are Booleans otherwise |
| 1347 // throw exception. |
| 1346 if (FLAG_enable_type_checks) { | 1348 if (FLAG_enable_type_checks) { |
| 1347 CodeGenerator::VisitBinaryOpNode(node); | 1349 CodeGenerator::VisitBinaryOpNode(node); |
| 1348 return; | 1350 return; |
| 1349 } | 1351 } |
| 1350 GenerateLogicalBinaryOp(node); | 1352 GenerateLogicalBinaryOp(node); |
| 1351 return; | 1353 return; |
| 1352 } | 1354 } |
| 1353 | 1355 |
| 1354 const ICData& ic_data = node->ICDataAtId(node->id()); | 1356 const ICData& ic_data = node->ICDataAtId(node->id()); |
| 1355 if (ic_data.NumberOfChecks() == 0) { | 1357 if (ic_data.NumberOfChecks() == 0) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 node->left(), | 1405 node->left(), |
| 1404 node->id(), | 1406 node->id(), |
| 1405 node->token_index(), | 1407 node->token_index(), |
| 1406 number_of_arguments, | 1408 number_of_arguments, |
| 1407 no_optional_argument_names); | 1409 no_optional_argument_names); |
| 1408 HandleResult(node, EAX); | 1410 HandleResult(node, EAX); |
| 1409 return; | 1411 return; |
| 1410 } | 1412 } |
| 1411 | 1413 |
| 1412 | 1414 |
| 1415 // Optimized for Smi only. |
| 1413 void OptimizingCodeGenerator::VisitIncrOpLocalNode(IncrOpLocalNode* node) { | 1416 void OptimizingCodeGenerator::VisitIncrOpLocalNode(IncrOpLocalNode* node) { |
| 1414 if (FLAG_enable_type_checks) { | 1417 if (FLAG_enable_type_checks) { |
| 1415 classes_for_locals_->SetLocalType(node->local(), Class::ZoneHandle()); | 1418 const AbstractType& local_type = node->local().type(); |
| 1416 CodeGenerator::VisitIncrOpLocalNode(node); | 1419 if (!local_type.IsNumberInterface() && !local_type.IsIntInterface()) { |
| 1417 return; | 1420 // Local does not accept a Smi (only Smi's interfaces are public). |
| 1421 classes_for_locals_->SetLocalType(node->local(), Class::ZoneHandle()); |
| 1422 CodeGenerator::VisitIncrOpLocalNode(node); |
| 1423 return; |
| 1424 } |
| 1418 } | 1425 } |
| 1419 const ICData& ic_data = node->ICDataAtId(node->id()); | 1426 const ICData& ic_data = node->ICDataAtId(node->id()); |
| 1420 if (ic_data.NumberOfChecks() == 0) { | 1427 if (ic_data.NumberOfChecks() == 0) { |
| 1421 DeoptimizationBlob* deopt_blob = | 1428 DeoptimizationBlob* deopt_blob = |
| 1422 AddDeoptimizationBlob(node, kDeoptNoTypeFeedback); | 1429 AddDeoptimizationBlob(node, kDeoptNoTypeFeedback); |
| 1423 __ jmp(deopt_blob->label()); | 1430 __ jmp(deopt_blob->label()); |
| 1424 return; | 1431 return; |
| 1425 } | 1432 } |
| 1426 const char* kOptMessage = "Inlines IncrOpLocal"; | 1433 const char* kOptMessage = "Inlines IncrOpLocal"; |
| 1427 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); | 1434 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); |
| (...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3109 | 3116 |
| 3110 | 3117 |
| 3111 void OptimizingCodeGenerator::VisitTryCatchNode(TryCatchNode* node) { | 3118 void OptimizingCodeGenerator::VisitTryCatchNode(TryCatchNode* node) { |
| 3112 // TODO(srdjan): Set classes for locals. | 3119 // TODO(srdjan): Set classes for locals. |
| 3113 classes_for_locals_->Clear(); | 3120 classes_for_locals_->Clear(); |
| 3114 CodeGenerator::VisitTryCatchNode(node); | 3121 CodeGenerator::VisitTryCatchNode(node); |
| 3115 } | 3122 } |
| 3116 | 3123 |
| 3117 | 3124 |
| 3118 void OptimizingCodeGenerator::VisitUnaryOpNode(UnaryOpNode* node) { | 3125 void OptimizingCodeGenerator::VisitUnaryOpNode(UnaryOpNode* node) { |
| 3119 if (FLAG_enable_type_checks) { | 3126 // TODO(srdjan): Test in checked mode if value is Boolean, throw error |
| 3127 // otherwise. |
| 3128 if (FLAG_enable_type_checks && node->kind() == Token::kNOT) { |
| 3120 CodeGenerator::VisitUnaryOpNode(node); | 3129 CodeGenerator::VisitUnaryOpNode(node); |
| 3121 return; | 3130 return; |
| 3122 } | 3131 } |
| 3123 // TODO(srdjan): Jump directly to labels instead of returning a boolean. | 3132 // TODO(srdjan): Jump directly to labels instead of returning a boolean. |
| 3124 if (node->kind() == Token::kNOT) { | 3133 if (node->kind() == Token::kNOT) { |
| 3125 // Only a true bool returns false, everything else is true. | 3134 // Only a true bool returns false, everything else is true. |
| 3126 CodeGenInfo info(node->operand()); | 3135 CodeGenInfo info(node->operand()); |
| 3127 VisitLoadOne(node->operand(), EDX); | 3136 VisitLoadOne(node->operand(), EDX); |
| 3128 Label done; | 3137 Label done; |
| 3129 __ LoadObject(EAX, Bool::ZoneHandle(Bool::True())); | 3138 __ LoadObject(EAX, Bool::ZoneHandle(Bool::True())); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3152 } | 3161 } |
| 3153 } | 3162 } |
| 3154 // TODO(srdjan): Implement unary kSUB (negate) Mint. | 3163 // TODO(srdjan): Implement unary kSUB (negate) Mint. |
| 3155 CodeGenerator::VisitUnaryOpNode(node); | 3164 CodeGenerator::VisitUnaryOpNode(node); |
| 3156 } | 3165 } |
| 3157 | 3166 |
| 3158 | 3167 |
| 3159 } // namespace dart | 3168 } // namespace dart |
| 3160 | 3169 |
| 3161 #endif // defined TARGET_ARCH_IA32 | 3170 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |