Skip to content

Commit da81b5d

Browse files
committedJan 8, 2016
Generalize test for nil.
1 parent 161a645 commit da81b5d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

Diff for: ‎vm/oop.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
9393

9494
// Indicates the mask to use to check if a value is ruby false.
9595
// This mask matches both false and nil ONLY.
96-
#define FALSE_MASK 0xf
96+
#define FALSE_MASK 0xf
97+
98+
// The bits that identify any nil value.
99+
#define NIL_MASK 0x1f
97100

98101
#define CBOOL(v) (((uintptr_t)(v) & FALSE_MASK) != (uintptr_t)cFalse)
99102
#define RBOOL(v) ((v) ? cTrue : cFalse)
@@ -586,7 +589,7 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
586589
void wait(STATE);
587590

588591
bool nil_p() const {
589-
return this == reinterpret_cast<ObjectHeader*>(cNil);
592+
return (reinterpret_cast<intptr_t>(this) & NIL_MASK) == reinterpret_cast<intptr_t>(cNil);
590593
}
591594

592595
bool true_p() const {

0 commit comments

Comments
 (0)
Please sign in to comment.