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

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

Issue 867383002: Implement bitLength intrinsic on x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 // Argument is Smi (receiver). 787 // Argument is Smi (receiver).
788 void Intrinsifier::Smi_bitNegate(Assembler* assembler) { 788 void Intrinsifier::Smi_bitNegate(Assembler* assembler) {
789 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Index. 789 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Index.
790 __ notq(RAX); 790 __ notq(RAX);
791 __ andq(RAX, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. 791 __ andq(RAX, Immediate(~kSmiTagMask)); // Remove inverted smi-tag.
792 __ ret(); 792 __ ret();
793 } 793 }
794 794
795 795
796 void Intrinsifier::Smi_bitLength(Assembler* assembler) { 796 void Intrinsifier::Smi_bitLength(Assembler* assembler) {
797 // TODO(sra): Implement using bsrq. 797 ASSERT(kSmiTagShift == 1);
798 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Index.
799 // XOR with sign bit to complement bits if value is negative.
800 __ movq(RCX, RAX);
801 __ sarq(RCX, Immediate(63)); // All 0 or all 1.
Lasse Reichstein Nielsen 2015/01/25 11:26:53 If you shift RAX instead of RCX here, would the de
srdjan 2015/01/26 18:43:18 Thanks for the comment. In theory yes, but with In
802 __ xorq(RAX, RCX);
803 // BSR does not write the destination register if source is zero. Put a 1 in
804 // the Smi tag bit to ensure BSR writes to destination register.
805 __ orq(RAX, Immediate(kSmiTagMask));
806 __ bsrq(RAX, RAX);
807 __ SmiTag(RAX);
808 __ ret();
798 } 809 }
799 810
800 811
801 void Intrinsifier::Bigint_setNeg(Assembler* assembler) { 812 void Intrinsifier::Bigint_setNeg(Assembler* assembler) {
802 __ movq(RAX, Address(RSP, + 1 * kWordSize)); 813 __ movq(RAX, Address(RSP, + 1 * kWordSize));
803 __ movq(RCX, Address(RSP, + 2 * kWordSize)); 814 __ movq(RCX, Address(RSP, + 2 * kWordSize));
804 __ StoreIntoObject(RCX, FieldAddress(RCX, Bigint::neg_offset()), RAX, false); 815 __ StoreIntoObject(RCX, FieldAddress(RCX, Bigint::neg_offset()), RAX, false);
805 __ ret(); 816 __ ret();
806 } 817 }
807 818
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 // Set return value to Isolate::current_tag_. 2020 // Set return value to Isolate::current_tag_.
2010 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 2021 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
2011 __ ret(); 2022 __ ret();
2012 } 2023 }
2013 2024
2014 #undef __ 2025 #undef __
2015 2026
2016 } // namespace dart 2027 } // namespace dart
2017 2028
2018 #endif // defined TARGET_ARCH_X64 2029 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/assembler_x64_test.cc ('K') | « runtime/vm/disassembler_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698