JS_CallFunctionName seems to be broken

VERIFIED WONTFIX

Status

()

Core
JavaScript Engine
P3
normal
VERIFIED WONTFIX
19 years ago
17 years ago

People

(Reporter: clayton, Assigned: brendan)

Tracking

({js1.5})

Trunk
x86
Windows NT
js1.5
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

19 years ago
While testing the JS 1.5 pre (JS_15b1_991216_BRANCH) I recognized that
JS_CallFunctionName seems to be broken.

Could this be a side effect of the new function treatment? (auto-cloning)

Compiling a simple script

function a()
{}

and trying to execute it with JS_CallFunctionName() results in returning
"false".

This is done with one single global object without prototype chain. (So this is
the trivial case)

Till Vollmer, Technical Product Manager
Hyperwave Software R & D, Albrechtgasse 9/2, A-8010 Graz, Austria
Tel. +43 316 82 09 18-39, Fax +43 316 82 09 18-99
mailto:tvollmer@hyperwave.com
http://www.hyperwave.com

Updated

19 years ago
Assignee: mccabe → rogerl

Comment 1

19 years ago
Passing this one on to Roger.

Updated

19 years ago
Status: NEW → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → INVALID

Comment 2

19 years ago
I can't reproduce the problem here.  Attaching a testcase which *does not* show
the problem, and marking invalid.

Feel free to re-open if you can reporduce the bug.

Comment 3

19 years ago
Created attachment 4187 [details]
testcase (main.c)

Comment 4

19 years ago
Created attachment 4188 [details]
gnu Makefile for testcase (Makefile)

Comment 5

19 years ago
Testcase produces the following output on my system:

(gdb) run
Starting program: /home/rginda/src/tests/js_callfunc/main
1
undefined

Updated

19 years ago
Status: RESOLVED → REOPENED

Comment 6

19 years ago
Sorry for the to unspecific problem report:
The problem only arises if you ONLY JS_CompileScript() and than directly call
JS_CallFunctionName() without evaluating or executing it first. This was working
prior to the 1.5 engine. (Consider a script that has only one function in it)

The reason is simple:
Because of the new auto-cloning functions are not really defined as
Properties on compile time, they are only atoms. On execution
(opcode:JSOP_DEFFUN in jsinterp.c) they will be defined as real
properties.

But JS_CallFunctionName uses JS_GetProperty to find the function, which
is not working anymore, when you do not evaluate it first.

I am not sure if this is a bug or just a change of behaviour. Calling
JS_Evaluate() after compiling and than again calling JS_CallFunctionName would
execute the script twice: First to only define the function property and than to
really execute the function.

Updated

19 years ago
Resolution: INVALID → ---

Comment 7

19 years ago
Clearing INVALID resolution due to reopen.

Updated

19 years ago
Keywords: js1.5
(Assignee)

Updated

19 years ago
Assignee: rogerl → brendan
Status: REOPENED → NEW
(Assignee)

Comment 8

19 years ago
Why don't I just take this, since I perpetrated JSOP_DEFFUN (for good reason).

/be
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
Target Milestone: M13
(Reporter)

Comment 9

19 years ago
Thanks Brendan.  Happy to have you looking at it.  Roger has a backlog of stuff
on his plate right now, too.   = C =
(Assignee)

Updated

19 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago19 years ago
Resolution: --- → WONTFIX
(Assignee)

Comment 10

19 years ago
Till, this is a change of behavior as you say, and an API incompatibility, but I
don't see how to avoid it and keep both ECMA compliance, and brutal sharing (an
important Mozilla optimization) working.

You write "Calling JS_Evaluate() after compiling and than again calling
JS_CallFunctionName would execute the script twice", but I wanted to set your
mind at ease: the script needs to be executed once only (by JS_ExecuteScript,
not JS_EvaluateScript or one of its variants), but that execution does *not*
execute the function.  You execute a function's code by invoking it, not by
evaluating its declaring statement or expression.

With XUL brutal sharing in Mozilla, we have a similar issue: we compile event
handlers once but must bind clones of each handler function to many target
objects in different windows.  So we have to call JS API entry points beyond
JS_Compile*, particularly JS_CloneFunctionObject and JS_DefineProperty.

Please mail me or post to the .jseng newsgroup if you find this API change to be
a great hardship, and cannot use JS_ExecuteScript after compiling, or (simpler)
just JS_Evaluate*Script (which is short for compile + execute).

/be

Comment 11

19 years ago
Marking Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.