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

[Merged by Bors] - Set function names in object literal methods #2460

Closed
wants to merge 4 commits into from

Conversation

raskad
Copy link
Member

@raskad raskad commented Nov 24, 2022

This Pull Request changes the following:

@raskad raskad added enhancement New feature or request parser Issues surrounding the parser vm Issues and PRs related to the Boa Virtual Machine. labels Nov 24, 2022
@raskad raskad added this to the v0.17.0 milestone Nov 24, 2022
@github-actions
Copy link

github-actions bot commented Nov 24, 2022

Test262 conformance changes

Test result main count PR count difference
Total 93,831 93,831 0
Passed 69,640 69,664 +24
Ignored 18,472 18,472 0
Failed 5,719 5,695 -24
Panics 0 0 0
Conformance 74.22% 74.24% +0.03%
Fixed tests (24):
test/language/expressions/object/fn-name-fn.js [strict mode] (previously Failed)
test/language/expressions/object/fn-name-fn.js (previously Failed)
test/language/expressions/object/fn-name-gen.js [strict mode] (previously Failed)
test/language/expressions/object/fn-name-gen.js (previously Failed)
test/language/expressions/object/fn-name-arrow.js [strict mode] (previously Failed)
test/language/expressions/object/fn-name-arrow.js (previously Failed)
test/language/expressions/object/fn-name-accessor-get.js [strict mode] (previously Failed)
test/language/expressions/object/fn-name-accessor-get.js (previously Failed)
test/language/expressions/object/fn-name-cover.js [strict mode] (previously Failed)
test/language/expressions/object/fn-name-cover.js (previously Failed)
test/language/expressions/object/fn-name-accessor-set.js [strict mode] (previously Failed)
test/language/expressions/object/fn-name-accessor-set.js (previously Failed)
test/language/expressions/object/method-definition/fn-name-fn.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/fn-name-fn.js (previously Failed)
test/language/expressions/object/method-definition/name-name-prop-string.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/name-name-prop-string.js (previously Failed)
test/language/expressions/object/method-definition/fn-name-gen.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/fn-name-gen.js (previously Failed)
test/language/expressions/object/method-definition/name-name-prop-symbol.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/name-name-prop-symbol.js (previously Failed)
test/language/expressions/object/method-definition/generator-name-prop-symbol.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/generator-name-prop-symbol.js (previously Failed)
test/language/expressions/object/method-definition/generator-name-prop-string.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/generator-name-prop-string.js (previously Failed)

@codecov
Copy link

codecov bot commented Nov 24, 2022

Codecov Report

Merging #2460 (fb14478) into main (5435ae0) will increase coverage by 0.97%.
The diff coverage is 53.90%.

@@            Coverage Diff             @@
##             main    #2460      +/-   ##
==========================================
+ Coverage   51.04%   52.01%   +0.97%     
==========================================
  Files         346      343       -3     
  Lines       35846    35295     -551     
==========================================
+ Hits        18297    18359      +62     
+ Misses      17549    16936     -613     
Impacted Files Coverage Δ
boa_engine/src/vm/code_block.rs 33.10% <0.00%> (-0.28%) ⬇️
boa_engine/src/vm/flowgraph/mod.rs 0.00% <0.00%> (ø)
boa_engine/src/vm/opcode/mod.rs 60.86% <ø> (ø)
boa_interner/src/sym.rs 100.00% <ø> (ø)
boa_engine/src/bytecompiler/mod.rs 52.31% <20.83%> (-0.36%) ⬇️
boa_ast/src/expression/mod.rs 49.51% <30.00%> (-2.10%) ⬇️
...rser/expression/primary/function_expression/mod.rs 61.22% <33.33%> (+1.22%) ⬆️
boa_ast/src/property.rs 43.28% <66.66%> (+2.65%) ⬆️
boa_engine/src/vm/opcode/set/property.rs 64.51% <80.00%> (+2.97%) ⬆️
...arser/expression/primary/object_initializer/mod.rs 66.03% <88.09%> (+1.93%) ⬆️
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Just some small nitpicks, everything else looks perfect.

@@ -177,7 +177,7 @@ impl CodeBlock {
let opcode: Opcode = self.code[*pc].try_into().expect("invalid opcode");
*pc += size_of::<Opcode>();
match opcode {
Opcode::RotateLeft | Opcode::RotateRight => {
Opcode::RotateLeft | Opcode::RotateRight | Opcode::SetFunctionName => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Opcode::RotateLeft | Opcode::RotateRight | Opcode::SetFunctionName => {
Opcode::SetFunctionName => {
let operand = self.read::<u8>(*pc);
*pc += size_of::<u8>();
match operand {
0 => "prefix: none",
1 => "prefix: get",
2 => "prefix: set",
}
}
Opcode::RotateLeft | Opcode::RotateRight => {

I think it would be good to print the prefix, instead of a number

@@ -45,7 +45,7 @@ impl CodeBlock {

pc += size_of::<Opcode>();
match opcode {
Opcode::RotateLeft | Opcode::RotateRight => {
Opcode::RotateLeft | Opcode::RotateRight | Opcode::SetFunctionName => {
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Maybe making it a static method of SetFunctionName struct to avoid code duplication.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Looking good! Thanks!

let value = AssignmentExpression::new(None, true, self.allow_yield, self.allow_await)
let name = property_name
.literal()
.filter(|name| name != &Sym::__PROTO__)
Copy link
Member

Choose a reason for hiding this comment

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

Since Sym is Copy, I would suggest to either dereference name, or use copied():

Suggested change
.filter(|name| name != &Sym::__PROTO__)
.filter(|name| *name != Sym::__PROTO__)

Even though I guess it's equivalent, it more clearly shows intent of comparing the symbol value, and not the reference.

@raskad
Copy link
Member Author

raskad commented Nov 26, 2022

bors r+

bors bot pushed a commit that referenced this pull request Nov 26, 2022
This Pull Request changes the following:

- Implement `SetFunctionName` opcode based on [`SetFunctionName`](https://tc39.es/ecma262/#sec-setfunctionname)
@bors
Copy link

bors bot commented Nov 26, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Set function names in object literal methods [Merged by Bors] - Set function names in object literal methods Nov 26, 2022
@bors bors bot closed this Nov 26, 2022
@bors bors bot deleted the object-literal-function-names branch November 26, 2022 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser Issues surrounding the parser vm Issues and PRs related to the Boa Virtual Machine.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants