[webkit-dev] Question about JavaScriptCore's JSEvaluateScript function.

Zoltan Herczeg zherczeg at inf.u-szeged.hu
Mon Mar 2 00:52:21 PST 2009


that is intended, since the context pointer is the current
CallFrame/ExecState. WebKit creates its own stack (called RegisterFile) to
run JavaScript. The stack base of the current function is pointed by
CallFrame (similar to ebp in x86, or fp in ARM architectures). When you
call a JS function, several important pointers are stored on the top of
the stack, like return value, current code block, previous call frame, and
these values are accessed through the CallFrame pointer. It is essential
for JavaScriptCore, there is no workaround.


> Hi,
>   Recently, I'm writing an application which uses JavaScriptCore to
> execute
> javascript code. I just encountered a problem when using JSEvaluateScript
> function to evaluate a piece of script. When executing the script, some
> callbacks provided by my code will be called, but I found that the context
> received by callbacks are different than the context I created and passed
> to
> JSEvaluateScript function.
> Attached is a test program.
> Below is the output of this program on my system (ubuntu 8.04 64bit with
> latest webkit svn):
> Create context 0x7faf5d567e88, global object 0x7faf5d530000
> InitializeCallback(ctx=0x7faf5d567e88, obj=0x7faf5d532400)
> HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532400,
> prop=prototype)
> CallAsConstructorCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532400)
> InitializeCallback(ctx=0x7faf50c4b0c0, obj=0x7faf5d532440)
> SetPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440, prop=prop1)
> HasPropertyCallback(ctx=0x7faf50c4b048, obj=0x7faf5d532440, prop=prop1)
> FinalizeCallback(obj=0x7faf5d532400)
> FinalizeCallback(obj=0x7faf5d532440)
> You can see that, the callback functions received several different
> context
> pointers comparing to the one created at first beginning.
> Is it an intend behavior or a bug of webkit? And how can I avoid or
> workaround this problem?
> Thanks a lot.
> James Su
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

More information about the webkit-dev mailing list