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

Zhe Su james.su at gmail.com
Mon Mar 2 03:44:12 PST 2009


I see. Thanks.

On Mon, Mar 2, 2009 at 7:28 PM, Zoltan Herczeg <zherczeg at inf.u-szeged.hu>wrote:

> Why do you want to use the original context pointer? The context is
> something like "current machine state". It is important for JS function
> return, exception handling, and many other things. It is not a global
> pointer, like JSGlobalData (JSContextGroupRef), it points to the current
> context.
>
> Zoltan
>
> > Thanks for your answer. Then, in the callback function (such as
> > GetPropertyCallback), is it ok to use the original context pointer
> created
> > at beginning? Or the ctx passed to the callback must be used instead?
> >
> > Regards
> > James Su
> >
> > On Mon, Mar 2, 2009 at 4:52 PM, Zoltan Herczeg
> > <zherczeg at inf.u-szeged.hu>wrote:
> >
> >> Hi,
> >>
> >> 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.
> >>
> >> Zoltan
> >>
> >> > 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
> >> >
> >>
> >>
> >> _______________________________________________
> >> webkit-dev mailing list
> >> webkit-dev at lists.webkit.org
> >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >>
> > _______________________________________________
> > webkit-dev mailing list
> > webkit-dev at lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090302/e1cc6e91/attachment.html>


More information about the webkit-dev mailing list