Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: runtime/vm/opt_code_generator_ia32.cc

Issue 8996024: Fix a bug in intrinsified Array_setIndexed type check. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 if (CodeGenerator::IsResultNeeded(node)) { 802 if (CodeGenerator::IsResultNeeded(node)) {
803 if (IsResultInEaxRequested(node)) { 803 if (IsResultInEaxRequested(node)) {
804 node->info()->set_result_returned_in_eax(true); 804 node->info()->set_result_returned_in_eax(true);
805 } else { 805 } else {
806 __ pushl(EAX); 806 __ pushl(EAX);
807 } 807 }
808 } 808 }
809 } 809 }
810 810
811 811
812 void OptimizingCodeGenerator::GenerateDoubleUnaryOp(UnaryOpNode* node) {
813 const Register kOperandRegister = ECX;
814 const Register kTempRegister = EBX;
815 const Register kResultRegister = EAX;
816 const ICData& ic_data = node->ICDataAtId(node->id());
817 DeoptReasonId deopt_reason_id = ic_data.NumberOfChecks() == 0 ?
818 kDeoptNoTypeFeedback : kDeoptUnaryOp;
819 DeoptimizationBlob* deopt_blob =
820 AddDeoptimizationBlob(node, kOperandRegister, deopt_reason_id);
821 CodeGenInfo info(node->operand());
822 VisitLoadOne(node->operand(), kOperandRegister);
823 if (ic_data.NumberOfChecks() == 0) {
824 // No type feedback.
825 __ jmp(deopt_blob->label());
826 return;
827 }
828 // TODO(srdjan): check if we could reuse a temporary object instead of
829 // allocating a new one.
830 const Code& stub =
831 Code::Handle(StubCode::GetAllocationStubForClass(double_class_));
832 const ExternalLabel label(double_class_.ToCString(), stub.EntryPoint());
833 __ pushl(kOperandRegister);
834 GenerateCall(node->token_index(), &label);
835 ASSERT(kResultRegister == EAX);
836 __ popl(kOperandRegister);
837
838 ASSERT(ic_data.NumberOfChecks() == 1);
839 CheckIfDoubleOrSmi(kOperandRegister,
840 kTempRegister,
841 deopt_blob->label(),
842 deopt_blob->label());
siva 2011/12/20 01:38:00 Should this check happen before we call the alloca
srdjan 2011/12/20 02:06:33 Done
843 __ movsd(XMM0, FieldAddress(kOperandRegister, Double::value_offset()));
844 __ xorps(XMM1, XMM1); // 0.0 -> XMM1.
845 __ subsd(XMM1, XMM0);
846 __ movsd(FieldAddress(kResultRegister, Double::value_offset()), XMM1);
847 if (CodeGenerator::IsResultNeeded(node)) {
848 if (node->info() != NULL) {
849 node->info()->set_is_temp(true);
850 node->info()->set_is_class(&double_class_);
851 }
852 if (IsResultInEaxRequested(node)) {
853 ASSERT(kResultRegister == EAX);
854 node->info()->set_result_returned_in_eax(true);
855 } else {
856 __ pushl(kResultRegister);
857 }
858 }
859 }
860
861
812 // TODO(srdjan): Expand inline caches to detect Smi/double operations, so that 862 // TODO(srdjan): Expand inline caches to detect Smi/double operations, so that
813 // we do not have to call the instance method, and therefore could guarantee 863 // we do not have to call the instance method, and therefore could guarantee
814 // that the result is a Smi at the end. 864 // that the result is a Smi at the end.
815 void OptimizingCodeGenerator::GenerateSmiBinaryOp(BinaryOpNode* node) { 865 void OptimizingCodeGenerator::GenerateSmiBinaryOp(BinaryOpNode* node) {
816 const char* kOptMessage = "Inlines BinaryOp for Smi"; 866 const char* kOptMessage = "Inlines BinaryOp for Smi";
817 Label done; 867 Label done;
818 const Token::Kind kind = node->kind(); 868 const Token::Kind kind = node->kind();
819 if ((kind == Token::kADD) || 869 if ((kind == Token::kADD) ||
820 (kind == Token::kSUB) || 870 (kind == Token::kSUB) ||
821 (kind == Token::kMUL) || 871 (kind == Token::kMUL) ||
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 } 2996 }
2947 2997
2948 if ((node->kind() == Token::kSUB) || (node->kind() == Token::kBIT_NOT)) { 2998 if ((node->kind() == Token::kSUB) || (node->kind() == Token::kBIT_NOT)) {
2949 if (AtIdNodeHasOnlyClass(node, node->id(), smi_class_)) { 2999 if (AtIdNodeHasOnlyClass(node, node->id(), smi_class_)) {
2950 const ICData& ic_data = node->ICDataAtId(node->id()); 3000 const ICData& ic_data = node->ICDataAtId(node->id());
2951 ASSERT(ic_data.NumberOfArgumentsChecked() == 1); 3001 ASSERT(ic_data.NumberOfArgumentsChecked() == 1);
2952 GenerateSmiUnaryOp(node); 3002 GenerateSmiUnaryOp(node);
2953 return; 3003 return;
2954 } 3004 }
2955 } 3005 }
2956 // TODO(srdjan): Implement unary kSUB (negate) for doubles and Mint. 3006 if (node->kind() == Token::kSUB) {
3007 if (AtIdNodeHasReceiverClass(node, node->id(), double_class_)) {
3008 const ICData& ic_data = node->ICDataAtId(node->id());
3009 ASSERT(ic_data.NumberOfArgumentsChecked() == 1);
3010 GenerateDoubleUnaryOp(node);
3011 return;
3012 }
3013 }
3014 // TODO(srdjan): Implement unary kSUB (negate) Mint.
2957 CodeGenerator::VisitUnaryOpNode(node); 3015 CodeGenerator::VisitUnaryOpNode(node);
2958 } 3016 }
2959 3017
2960 3018
2961 } // namespace dart 3019 } // namespace dart
2962 3020
2963 #endif // defined TARGET_ARCH_IA32 3021 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698