Chromium Code Reviews| 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 // TODO(srdjan): Expand inline caches to detect Smi/double operations, so that | 748 // TODO(srdjan): Expand inline caches to detect Smi/double operations, so that |
| 749 // we do not have to call the instance method, and therefore could guarantee | 749 // we do not have to call the instance method, and therefore could guarantee |
| 750 // that the result is a Smi at the end. | 750 // that the result is a Smi at the end. |
| 751 void OptimizingCodeGenerator::GenerateSmiBinaryOp(BinaryOpNode* node) { | 751 void OptimizingCodeGenerator::GenerateSmiBinaryOp(BinaryOpNode* node) { |
| 752 const char* kOptMessage = "Inlines BinaryOp for Smi"; | 752 const char* kOptMessage = "Inlines BinaryOp for Smi"; |
| 753 Label done; | 753 Label done; |
| 754 const Token::Kind kind = node->kind(); | 754 const Token::Kind kind = node->kind(); |
| 755 if ((kind == Token::kADD) || | 755 if ((kind == Token::kADD) || |
| 756 (kind == Token::kSUB) || | 756 (kind == Token::kSUB) || |
| 757 (kind == Token::kMUL) || | 757 (kind == Token::kMUL) || |
| 758 (kind == Token::kTRUNCDIV) || | |
| 758 (kind == Token::kBIT_AND) || | 759 (kind == Token::kBIT_AND) || |
| 759 (kind == Token::kBIT_OR) || | 760 (kind == Token::kBIT_OR) || |
| 760 (kind == Token::kBIT_XOR)) { | 761 (kind == Token::kBIT_XOR)) { |
| 761 TraceOpt(node, kOptMessage); | 762 TraceOpt(node, kOptMessage); |
| 762 // Check if both arguments are expected to be Smi. | 763 // Check if both arguments are expected to be Smi. |
| 763 const ICData& ic_data = node->ICDataAtId(node->id()); | 764 const ICData& ic_data = node->ICDataAtId(node->id()); |
| 764 ASSERT(ic_data.NumberOfArgumentsChecked() == 2); | 765 ASSERT(ic_data.NumberOfArgumentsChecked() == 2); |
| 765 ASSERT(ic_data.NumberOfChecks() > 0); | 766 ASSERT(ic_data.NumberOfChecks() > 0); |
| 766 Function& target = Function::Handle(); | 767 Function& target = Function::Handle(); |
| 767 GrowableArray<const Class*> classes; | 768 GrowableArray<const Class*> classes; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 case Token::kBIT_OR: { | 852 case Token::kBIT_OR: { |
| 852 // No overflow check. | 853 // No overflow check. |
| 853 __ orl(EAX, EDX); | 854 __ orl(EAX, EDX); |
| 854 break; | 855 break; |
| 855 } | 856 } |
| 856 case Token::kBIT_XOR: { | 857 case Token::kBIT_XOR: { |
| 857 // No overflow check. | 858 // No overflow check. |
| 858 __ xorl(EAX, EDX); | 859 __ xorl(EAX, EDX); |
| 859 break; | 860 break; |
| 860 } | 861 } |
| 862 case Token::kTRUNCDIV: { | |
| 863 // Handle Divide by Zero elsewhere | |
| 864 __ cmpl(EDX, Immediate(0)); | |
| 865 __ j(EQUAL, overflow_label); | |
| 866 // Move right to ECX, left is in EAX. | |
| 867 __ movl(ECX, EDX); | |
| 868 __ SmiUntag(ECX); | |
| 869 __ SmiUntag(EAX); | |
| 870 // Sign extend EAX -> EDX:EAX. | |
| 871 __ cdq(); | |
| 872 __ idivl(ECX); | |
| 873 __ SmiTag(EAX); | |
|
sra1
2011/12/13 21:12:08
MIN_SMI / -1 is not a Smi.
| |
| 874 break; | |
| 875 } | |
| 861 default: | 876 default: |
| 862 UNREACHABLE(); | 877 UNREACHABLE(); |
| 863 } | 878 } |
| 864 } else if (kind == Token::kSHL) { | 879 } else if (kind == Token::kSHL) { |
| 865 GenerateSmiShiftBinaryOp(node); | 880 GenerateSmiShiftBinaryOp(node); |
| 866 } else { | 881 } else { |
| 867 TraceNotOpt(node, kOptMessage); | 882 TraceNotOpt(node, kOptMessage); |
| 868 node->left()->Visit(this); | 883 node->left()->Visit(this); |
| 869 node->right()->Visit(this); | 884 node->right()->Visit(this); |
| 870 CodeGenerator::GenerateBinaryOperatorCall(node->id(), | 885 CodeGenerator::GenerateBinaryOperatorCall(node->id(), |
| (...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2719 void OptimizingCodeGenerator::VisitTryCatchNode(TryCatchNode* node) { | 2734 void OptimizingCodeGenerator::VisitTryCatchNode(TryCatchNode* node) { |
| 2720 // TODO(srdjan): Set classes for locals. | 2735 // TODO(srdjan): Set classes for locals. |
| 2721 classes_for_locals_->Clear(); | 2736 classes_for_locals_->Clear(); |
| 2722 CodeGenerator::VisitTryCatchNode(node); | 2737 CodeGenerator::VisitTryCatchNode(node); |
| 2723 } | 2738 } |
| 2724 | 2739 |
| 2725 | 2740 |
| 2726 } // namespace dart | 2741 } // namespace dart |
| 2727 | 2742 |
| 2728 #endif // defined TARGET_ARCH_IA32 | 2743 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |