| Index: runtime/vm/assembler_ia32.h
|
| diff --git a/runtime/vm/assembler_ia32.h b/runtime/vm/assembler_ia32.h
|
| index 6d147905d53996805ac85f6178bb3a92723ecd4a..6201cae2ba83b8f26a812172ca4b61044bda2812 100644
|
| --- a/runtime/vm/assembler_ia32.h
|
| +++ b/runtime/vm/assembler_ia32.h
|
| @@ -839,13 +839,25 @@ class Assembler : public ValueObject {
|
| static const char* FpuRegisterName(FpuRegister reg);
|
|
|
| // Smis that do not fit into 17 bits (16 bits of payload) are unsafe.
|
| - static bool IsSafe(const Object& object) {
|
| - return !object.IsSmi() ||
|
| - Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw()));
|
| - }
|
| static bool IsSafeSmi(const Object& object) {
|
| - return object.IsSmi() &&
|
| - Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw()));
|
| + if (!object.IsSmi()) {
|
| + return false;
|
| + }
|
| +
|
| + if (Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw()))) {
|
| + return true;
|
| + }
|
| +
|
| + // Single bit smis (powers of two) and corresponding masks are safe.
|
| + const intptr_t value = Smi::Cast(object).Value();
|
| + if (Utils::IsPowerOfTwo(value) || Utils::IsPowerOfTwo(value + 1)) {
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| + }
|
| + static bool IsSafe(const Object& object) {
|
| + return !object.IsSmi() || IsSafeSmi(object);
|
| }
|
|
|
| private:
|
|
|