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

Unified Diff: runtime/vm/assembler_ia32.h

Issue 490023004: On ia32 allow powers of two and corresponding full bit masks as safe smis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698