Closed Bug 306617 Opened 19 years ago Closed 19 years ago

The generic function dispatcher should imitate Function.call

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mrbkap, Assigned: mrbkap)

Details

(Keywords: fixed1.8, js1.5)

Attachments

(1 file)

Problems with the latest checkin.
-- null shouldn't throw.
-- this may be miscomputed.

Shaver's patch would have done better, except that we still wouldn't have the
desired compatibility. Patch in a minute.
Attached patch Use ComputeThis.Splinter Review
Use ComputeThis for total compatibility and safety!
Attachment #194470 - Flags: superreview?(shaver)
Attachment #194470 - Flags: review?(brendan)
Comment on attachment 194470 [details] [diff] [review]
Use ComputeThis.


>+    /*
>+     * Follow Function.prototype.apply and .call by using the global object as
>+     * the 'this' param if no args.Match Function.protype.call.
>+     */

Random garbage at the end of the comment?

Gotta run, but I'll review for real when I get back.
Comment on attachment 194470 [details] [diff] [review]
Use ComputeThis.

>+    /*
>+     * We know that argv[0] is valid because JS_DefineFunctions, which is our
>+     * only (indirect) referrer, defined us as requiring at least one argument
>+     * (notice how it passes fs->nargs + 1 as the next-to-last argument to
>+     * JS_DefineFunction).
>+     */
>+    if (JSVAL_IS_PRIMITIVE(argv[0])) {
>         /*
>          * Make sure that this is an object, as required by the generic
>          * functions.

s/an object/& or null/

>+
>+    /*
>+     * Follow Function.prototype.apply and .call by using the global object as
>+     * the 'this' param if no args.Match Function.protype.call.

Trailing junk starting at "Match".

Thanks for fixing this, shaver and I owe you.

/be
Attachment #194470 - Flags: review?(brendan) → review+
Comment on attachment 194470 [details] [diff] [review]
Use ComputeThis.

sr+thanks=shaver
Attachment #194470 - Flags: superreview?(shaver) → superreview+
This needs to go in ASAP.

/be
Flags: blocking1.8b4+
Keywords: js1.5
Attachment #194470 - Flags: approval1.8b4+
Fix checked into MOZILLA_1_8_BRANCH and trunk.
Status: NEW → RESOLVED
Closed: 19 years ago
Keywords: fixed1.8
Resolution: --- → FIXED
Flags: testcase-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: