native_pointer_to_jsval should not lose low-order bits (plus random style nits).

This commit is contained in:
Brendan Eich 2008-06-11 17:21:15 -07:00
parent c58ac03421
commit a64ed1a5ee
3 changed files with 17 additions and 10 deletions

View File

@ -54,18 +54,18 @@ js_GetRecorder(JSContext* cx)
JSBool ok =
#endif
JS_ExecuteScript(cx, JS_GetGlobalObject(cx), script, &result);
JS_ASSERT(ok && JSVAL_IS_OBJECT(result));
JS_ASSERT(ok && !JSVAL_IS_PRIMITIVE(result));
return tm->recorder = JSVAL_TO_OBJECT(result);
}
jsval
js_CallRecorder(JSContext* cx, const char* fn, uintN argc, jsval* argv)
js_CallRecorder(JSContext* cx, const char* name, uintN argc, jsval* argv)
{
jsval rval;
#ifdef DEBUG
JSBool ok =
#endif
JS_CallFunctionName(cx, js_GetRecorder(cx), fn, argc, argv, &rval);
JS_CallFunctionName(cx, js_GetRecorder(cx), name, argc, argv, &rval);
JS_ASSERT(ok);
return rval;
}

View File

@ -60,18 +60,26 @@ struct JSTraceMonitor {
#define TRACE_TRIGGER_MASK 0x3f
jsval js_CallRecorder(JSContext* cx, const char* fn, uintN argc, jsval* argv);
jsval js_CallRecorder(JSContext* cx, const char* fn, jsval a);
jsval js_CallRecorder(JSContext* cx, const char* fn, jsval a, jsval b);
jsval
js_CallRecorder(JSContext* cx, const char* name, uintN argc, jsval* argv);
jsval
js_CallRecorder(JSContext* cx, const char* name, jsval a);
jsval
js_CallRecorder(JSContext* cx, const char* name, jsval a, jsval b);
/*
* The recorder needs to keep track of native machine addresses. This mapping
* only works for aligned pointers.
* The recorder needs to keep track of native machine addresses, including
* bytecode addresses which are currently arbitrarily byte-aligned. Therefore
* we cannot use PRIVATE_TO_JSVAL, which assumes at least (0 mod 2) alignment
* and unconditionally sets the least significant (JSVAL_INT) bit. Instead, we
* risk lopping off the most significant bit (or bits on 64-bit systems).
*/
static inline jsval
native_pointer_to_jsval(void* p)
{
return INT_TO_JSVAL(((uint32)p) >> 2);
return INT_TO_JSVAL(JS_PTR_TO_UINT32(p));
}
#endif /* jstracer_h___ */

View File

@ -68,7 +68,6 @@
b) != JSVAL_TRUE; \
JS_END_MACRO
static inline void
prim_push_stack(JSContext* cx, JSFrameRegs& regs, jsval& v)
{