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

Side by Side Diff: src/arm/codegen-arm.cc

Issue 160584: Add support to the CFG builder for non-short-circuited binary... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 months 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
« no previous file with comments | « src/arm/codegen-arm.h ('k') | src/cfg.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // Slow case: call the runtime. 690 // Slow case: call the runtime.
691 frame_->EmitPush(r0); 691 frame_->EmitPush(r0);
692 frame_->CallRuntime(Runtime::kToBool, 1); 692 frame_->CallRuntime(Runtime::kToBool, 1);
693 // Convert the result (r0) to a condition code. 693 // Convert the result (r0) to a condition code.
694 __ cmp(r0, Operand(Factory::false_value())); 694 __ cmp(r0, Operand(Factory::false_value()));
695 695
696 cc_reg_ = ne; 696 cc_reg_ = ne;
697 } 697 }
698 698
699 699
700 class GenericBinaryOpStub : public CodeStub {
701 public:
702 GenericBinaryOpStub(Token::Value op,
703 OverwriteMode mode,
704 int constant_rhs = CodeGenerator::kUnknownIntValue)
705 : op_(op),
706 mode_(mode),
707 constant_rhs_(constant_rhs),
708 specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)) { }
709
710 private:
711 Token::Value op_;
712 OverwriteMode mode_;
713 int constant_rhs_;
714 bool specialized_on_rhs_;
715
716 static const int kMaxKnownRhs = 0x40000000;
717
718 // Minor key encoding in 16 bits.
719 class ModeBits: public BitField<OverwriteMode, 0, 2> {};
720 class OpBits: public BitField<Token::Value, 2, 6> {};
721 class KnownIntBits: public BitField<int, 8, 8> {};
722
723 Major MajorKey() { return GenericBinaryOp; }
724 int MinorKey() {
725 // Encode the parameters in a unique 16 bit value.
726 return OpBits::encode(op_)
727 | ModeBits::encode(mode_)
728 | KnownIntBits::encode(MinorKeyForKnownInt());
729 }
730
731 void Generate(MacroAssembler* masm);
732 void HandleNonSmiBitwiseOp(MacroAssembler* masm);
733
734 static bool RhsIsOneWeWantToOptimizeFor(Token::Value op, int constant_rhs) {
735 if (constant_rhs == CodeGenerator::kUnknownIntValue) return false;
736 if (op == Token::DIV) return constant_rhs >= 2 && constant_rhs <= 3;
737 if (op == Token::MOD) {
738 if (constant_rhs <= 1) return false;
739 if (constant_rhs <= 10) return true;
740 if (constant_rhs <= kMaxKnownRhs && IsPowerOf2(constant_rhs)) return true;
741 return false;
742 }
743 return false;
744 }
745
746 int MinorKeyForKnownInt() {
747 if (!specialized_on_rhs_) return 0;
748 if (constant_rhs_ <= 10) return constant_rhs_ + 1;
749 ASSERT(IsPowerOf2(constant_rhs_));
750 int key = 12;
751 int d = constant_rhs_;
752 while ((d & 1) == 0) {
753 key++;
754 d >>= 1;
755 }
756 return key;
757 }
758
759 const char* GetName() {
760 switch (op_) {
761 case Token::ADD: return "GenericBinaryOpStub_ADD";
762 case Token::SUB: return "GenericBinaryOpStub_SUB";
763 case Token::MUL: return "GenericBinaryOpStub_MUL";
764 case Token::DIV: return "GenericBinaryOpStub_DIV";
765 case Token::MOD: return "GenericBinaryOpStub_MOD";
766 case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR";
767 case Token::BIT_AND: return "GenericBinaryOpStub_BIT_AND";
768 case Token::BIT_XOR: return "GenericBinaryOpStub_BIT_XOR";
769 case Token::SAR: return "GenericBinaryOpStub_SAR";
770 case Token::SHL: return "GenericBinaryOpStub_SHL";
771 case Token::SHR: return "GenericBinaryOpStub_SHR";
772 default: return "GenericBinaryOpStub";
773 }
774 }
775
776 #ifdef DEBUG
777 void Print() {
778 if (!specialized_on_rhs_) {
779 PrintF("GenericBinaryOpStub (%s)\n", Token::String(op_));
780 } else {
781 PrintF("GenericBinaryOpStub (%s by %d)\n",
782 Token::String(op_),
783 constant_rhs_);
784 }
785 }
786 #endif
787 };
788
789
790 void CodeGenerator::GenericBinaryOperation(Token::Value op, 700 void CodeGenerator::GenericBinaryOperation(Token::Value op,
791 OverwriteMode overwrite_mode, 701 OverwriteMode overwrite_mode,
792 int constant_rhs) { 702 int constant_rhs) {
793 VirtualFrame::SpilledScope spilled_scope; 703 VirtualFrame::SpilledScope spilled_scope;
794 // sp[0] : y 704 // sp[0] : y
795 // sp[1] : x 705 // sp[1] : x
796 // result : r0 706 // result : r0
797 707
798 // Stub is entered with a call: 'return address' is in lr. 708 // Stub is entered with a call: 'return address' is in lr.
799 switch (op) { 709 switch (op) {
(...skipping 5616 matching lines...) Expand 10 before | Expand all | Expand 10 after
6416 int CompareStub::MinorKey() { 6326 int CompareStub::MinorKey() {
6417 // Encode the two parameters in a unique 16 bit value. 6327 // Encode the two parameters in a unique 16 bit value.
6418 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); 6328 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15));
6419 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); 6329 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0);
6420 } 6330 }
6421 6331
6422 6332
6423 #undef __ 6333 #undef __
6424 6334
6425 } } // namespace v8::internal 6335 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.h ('k') | src/cfg.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698