2008-09-15 Gavin Barraclough <barraclough@apple.com>
[WebKit-https.git] / JavaScriptCore / VM / Machine.cpp
index 8a7a001..379dd2e 100644 (file)
@@ -53,6 +53,7 @@
 #include "debugger.h"
 #include "operations.h"
 #include "SamplingTool.h"
+#include "StringObjectThatMasqueradesAsUndefined.h"
 #include <stdio.h>
 
 #if PLATFORM(DARWIN)
@@ -572,6 +573,10 @@ Machine::Machine()
     m_jsArrayVptr = jsArray->vptr();
     static_cast<JSCell*>(jsArray)->~JSCell();
 
+    StringObjectThatMasqueradesAsUndefined* jsStringObjectThatMasqueradesAsUndefined = new (storage) StringObjectThatMasqueradesAsUndefined(StringObjectThatMasqueradesAsUndefined::VPtrStealingHack);
+    m_jsStringObjectThatMasqueradesAsUndefinedVptr = jsStringObjectThatMasqueradesAsUndefined->vptr();
+    static_cast<JSCell*>(jsStringObjectThatMasqueradesAsUndefined)->~JSCell();
+
     JSString* jsString = new (storage) JSString(JSString::VPtrStealingHack);
     m_jsStringVptr = jsString->vptr();
     static_cast<JSCell*>(jsString)->~JSCell();
@@ -5401,10 +5406,11 @@ void Machine::cti_op_debug(CTI_ARGS)
 JSValue* Machine::cti_op_eq_null(CTI_ARGS)
 {
     JSValue* src = ARG_src1;
+    
     if (src->isUndefinedOrNull())
         return jsBoolean(true);
 
-    return jsBoolean(!JSImmediate::isImmediate(src) && static_cast<JSCell*>(src)->masqueradeAsUndefined());
+    return jsBoolean(ARG_exec->machine()->doesMasqueradesAsUndefined(src));
 }
 
 JSValue* Machine::cti_op_neq_null(CTI_ARGS)
@@ -5413,7 +5419,7 @@ JSValue* Machine::cti_op_neq_null(CTI_ARGS)
     if (src->isUndefinedOrNull())
         return jsBoolean(false);
 
-    return jsBoolean(JSImmediate::isImmediate(src) || !static_cast<JSCell*>(src)->masqueradeAsUndefined());
+    return jsBoolean(!ARG_exec->machine()->doesMasqueradesAsUndefined(src));
 }
 
 void* Machine::cti_vm_throw(CTI_ARGS)