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

Unified Diff: runtime/vm/intrinsifier_ia32.cc

Issue 23645003: Esoteric bit operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier_ia32.cc
diff --git a/runtime/vm/intrinsifier_ia32.cc b/runtime/vm/intrinsifier_ia32.cc
index 251ba782474e3e31120821250e107478322d08db..5f59d6facb17c15d5ad2330429dd65b6f8d91732 100644
--- a/runtime/vm/intrinsifier_ia32.cc
+++ b/runtime/vm/intrinsifier_ia32.cc
@@ -1087,6 +1087,22 @@ void Intrinsifier::Smi_bitNegate(Assembler* assembler) {
}
+void Intrinsifier::Smi_bitLength(Assembler* assembler) {
+ ASSERT(kSmiTagShift == 1);
+ __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Index.
+ // XOR with sign bit to complement bits if value is negative.
+ __ movl(ECX, EAX);
+ __ sarl(ECX, Immediate(31)); // All 0 or all 1.
+ __ xorl(EAX, ECX);
+ // BSR does not write the destination register if source is zero. Put a 1 in
+ // the Smi tag bit to ensure BSR writes to destination register.
+ __ orl(EAX, Immediate(kSmiTagMask));
+ __ bsrl(EAX, EAX);
+ __ SmiTag(EAX);
+ __ ret();
+}
+
+
// Check if the last argument is a double, jump to label 'is_smi' if smi
// (easy to convert to double), otherwise jump to label 'not_double_smi',
// Returns the last argument in EAX.
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698