Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/super expression #468

Merged
merged 5 commits into from
Nov 21, 2024

Conversation

TobiasWienand
Copy link
Contributor

With this, 7 new JSOperations become compilable:

  1. CallSuperConstructor
  2. SetSuperProperty
  3. GetSuperProperty
  4. SetComputedSuperProperty
  5. GetComputedSuperProperty
  6. CallSuperMethod
  7. UpdateSuperProperty

I verified correctness with Tests/FuzzilliTests/CompilerTests/super.js

Lifts to semantically equivalent code. (No side effects like with delete).

It is probably not a lot of effort to implement the remaining super cases but it is lower down the priority list.

The enabled JSOperations are: CallSuperConstructor, SetSuperProperty, GetSuperProperty, SetComputedSuperProperty, GetComputedSuperProperty, CallSuperMethod, UpdateSuperProperty
Copy link
Collaborator

@saelo saelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks! Just one question/suggestion

@@ -1633,7 +1633,7 @@ final class CallSuperConstructor: JsOperation {
}

init(numArguments: Int) {
super.init(numInputs: numArguments, firstVariadicInput: 0, attributes: [.isVariadic, .isCall], requiredContext: [.javascript, .method])
super.init(numInputs: numArguments, numOutputs: 1, firstVariadicInput: 0, attributes: [.isVariadic, .isCall], requiredContext: [.javascript, .method])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? Do we need to handle the return value of this, or could we just convert it to this instead if we really need it? (AFAIK the return value will just be this)

guard !callSuperConstructor.isOptional else {
throw CompilerError.unsupportedFeatureError("Optional chaining is not supported in super constructor calls")
}
return emit(CallSuperConstructor(numArguments: arguments.count), withInputs: arguments).output
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this why you need CallSuperConstructor to now return a value? I wonder if we should just do this instead:

// The "return" value of invoking the super constructor is just |this|
emit(CallSuperConstructor(numArguments: arguments.count), withInputs: arguments)
return emit(LoadThis())

WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah even simpler, I think you can just do return lookupIdentifier("this"); since this must be available inside class constructors/methods (see

map("this", to: parameters.removeFirst())
)

@saelo saelo merged commit 5798638 into googleprojectzero:main Nov 21, 2024
2 of 3 checks passed
@saelo
Copy link
Collaborator

saelo commented Nov 21, 2024

Nice, thanks! 🎉

parthdt pushed a commit to parthdt/fuzzilli that referenced this pull request Dec 14, 2024
The enabled JSOperations are: CallSuperConstructor, SetSuperProperty, GetSuperProperty, SetComputedSuperProperty, GetComputedSuperProperty, CallSuperMethod, UpdateSuperProperty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants