Closed Bug 851913 Opened 11 years ago Closed 8 years ago

IonMonkey: support arrow functions

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 988993

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

Attachments

(1 file, 1 obsolete file)

In bug 848062, I couldn't immediately make Ion emit correct code for a script containing an arrow function. This followup bug is to fix that.
Attached patch v1 (obsolete) — Splinter Review
Assignee: general → jorendorff
Attachment #726350 - Flags: review?(nicolas.b.pierron)
Comment on attachment 726350 [details] [diff] [review]
v1

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

That's the way to go, still some details to to make it cleaner.

::: js/src/ion/IonBuilder.cpp
@@ +6942,5 @@
> +        if (type != JSVAL_TYPE_OBJECT && type != JSVAL_TYPE_NULL && type != JSVAL_TYPE_UNDEFINED)
> +            return abort("Arrow function in script with maybe-primitive 'this'");
> +
> +        MInstruction *thisValue = MBox::New(current->getSlot(info().thisSlot()));
> +        current->add(thisValue);

You can remove the MBox::New and follow the suggestion made in (1), i-e:

MDefinition *thisValue = current->getSlot(info().thisSlot());
ins = MBoundLambda::New(current->scopeChain(), fun, thisValue);

You don't need to do a current->add as you are not creating any new instruction.

::: js/src/ion/IonBuilder.h
@@ +294,5 @@
>  
>      MDefinition *createThisScripted(MDefinition *callee);
>      MDefinition *createThisScriptedSingleton(HandleFunction target, MDefinition *callee);
>      MDefinition *createThis(HandleFunction target, MDefinition *callee);
> +    MDefinition *getThis();

This function is never defined.

::: js/src/ion/MIR.h
@@ +3668,5 @@
>  };
>  
> +class MBoundLambda
> +  : public MBinaryInstruction,
> +    public SingleObjectPolicy

(1) Having a Binary Instruction with a SingleObjectPolicy is a bit weird.  I usually prefer when the type policy match the number of operands, such as:

  : public MBinaryInstruction,
    public MixPolicy< ObjectPolicy<0>, BoxPolicy<1> >

In addition, this will remove the fact that we are manually boxing in IonBuilder.
Attachment #726350 - Flags: review?(nicolas.b.pierron)
Attached patch v2Splinter Review
OK, here's take 2.
Attachment #726350 - Attachment is obsolete: true
Attachment #730265 - Flags: review?(nicolas.b.pierron)
Comment on attachment 730265 [details] [diff] [review]
v2

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

::: js/src/ion/IonBuilder.cpp
@@ +6920,5 @@
>  
> +    MInstruction *ins;
> +    if (fun->isArrow()) {
> +        if (!info().fun())
> +            return abort("bound arrow function at toplevel");

nit: Add a comment above the if describing why we have this abort.

::: js/src/ion/MIR.h
@@ +3678,5 @@
> +    }
> +    JSFunction *fun() const {
> +        return fun_;
> +    }
> +    MDefinition *getThisValue() const {

nit: remove the get in this function name.
Attachment #730265 - Flags: review?(nicolas.b.pierron) → review+
Any particular reason why this hasn't landed?
Flags: needinfo?(jorendorff)
Ah er. Hmm. Well, it's super bitrotted. This was 9 months ago, it'll need a new review for sure.

(Note that this only makes ion able to emit a call to create an arrow function, without much of an eye for the speed of that operation, just trying not to kick the whole method out of ion. It doesn't help with calling arrow functions.)

It's a good cause though. Working on it.
Flags: needinfo?(jorendorff)
Is this a dupe of bug 988993?
(In reply to Guilherme Lima from comment #7)
> Is this a dupe of bug 988993?

Yes, thanks.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: