Closed Bug 1113685 Opened 10 years ago Closed 8 years ago

TypeError: function Call*MethodIfWrapped() is not a function

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: 446240525, Assigned: evilpie)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

This doesn't look right:

js> (function*(){yield 1})().next.call({})
typein:1:9 TypeError: CallStarGeneratorMethodIfWrapped method called on incompatible Object
js> newGlobal().eval("(function*(){yield 1})")().next.call({})
typein:2:0 TypeError: function CallStarGeneratorMethodIfWrapped() {
typein:2:0     [native code]
typein:2:0 } is not a function

and

js> Int8Array.prototype.find.call({})
typein:4:0 TypeError: CallTypedArrayMethodIfWrapped method called on incompatible Object
js> newGlobal().Int8Array.prototype.find.call({})
typein:5:0 TypeError: function CallTypedArrayMethodIfWrapped() {
typein:5:0     [native code]
typein:5:0 } is not a function
I know, kind of annoying to fix.
FWIW, I was also aware of this when I added the CallNonGenericSelfHostedMethod infrastructure and even discussed it with Jason:

15:32 <jandem>     jorendorff: ok that works beautifully; the CrossCompartmentWrapper generator test passes now. Just the error message is a bit confusing if you pass an incompatible object: CallLegacyGeneratorMethodIfWrapped method called on incompatible Array
15:33 <jorendorff> sold
15:33 <jorendorff> I literally do not care about that error message

http://logs.glob.uno/?c=mozilla%23jsapi&s=14+Oct+2014&e=14+Oct+2014#c490686
We should care about this error message.  A web developer running into this will have no clue what's going on and how to fix their code...
Assignee: nobody → evilpies
Attached patch WIP (obsolete) — Splinter Review
I almost got this working. However for the cross-compartment case we don't get the proper name.

> newGlobal().Uint8Array.prototype.findIndex.call({})
TypeError: TypedArrayFindIndex method called on incompatible Object
> Uint8Array.prototype.findIndex.call({})
TypeError: findIndex method called on incompatible Object

There must be some way to get the proper cloned function that already has the right name. Otherwise we could apply _SetCanonicalName to every function that uses CallXXXMethodIfWrapped.
Comment on attachment 8717565 [details] [diff] [review]
WIP

Review of attachment 8717565 [details] [diff] [review]:
-----------------------------------------------------------------

Doesn't intrinsic_ActiveFunction do pretty much exactly what you want here? (In that it returns the function whose name is needed.)

If I'm not overlooking something, then just extracting that into a function called by intrinsic_ActiveFunction and ReportIncompatibleSelfHostedMethod would work, no?
\o/ ActiveFunction was the right idea, seems to be working now.
Attachment #8717565 - Attachment is obsolete: true
Attachment #8717658 - Flags: review?(till)
Comment on attachment 8717658 [details] [diff] [review]
Report the right name when calling selfhosted functions on incompatible objects

Review of attachment 8717658 [details] [diff] [review]:
-----------------------------------------------------------------

Very nice, thank you! r=me with dead code removed.

::: js/src/vm/SelfHosting.cpp
@@ +1396,5 @@
> +    // because they always call the different CallXXXMethodIfWrapped methods,
> +    // which would be reported as the called function instead.
> +
> +    MOZ_ASSERT(args.length() > 0);
> +    RootedPropertyName name(cx, args[args.length() - 1].toString()->asAtom().asPropertyName());

This isn't used anymore.
Attachment #8717658 - Flags: review?(till) → review+
https://hg.mozilla.org/mozilla-central/rev/9d9527de1caa
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Blocks: jserror
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: