| 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.
|
|
|