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

Add proposal-promise-any #6641

Merged
merged 27 commits into from
Apr 21, 2021
Merged

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented Mar 16, 2021

Closes #6301
FIxes #6299

@Kingwl Kingwl changed the title Add AggregateError Ctor and prototype Add proposal-promise-any Mar 16, 2021
@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 16, 2021

Thanks for carrying on with this.

FYI on test fails:

  1. 2 of them are for the bytecode regen, did you run tools/regenByteCode.py with flags? For a regen before checking in the code it needs to be run without flags.
  2. The windows/MSVC ones are to do with tests in tests/DebuggerCommon that check what properties various objects have - the baseline files need AggregateError adding in a stack of places - slightly tedious, can generate the files by running each failing test with ch or can manually update them.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 17, 2021

did you run tools/regenByteCode.py with flags

Yep. It will fail without flags. And I haven't find out why.

can generate the files by running each failing test with ch or can manually update them.

Okay, Thanks.

There's already existed test262. Should we add more test about that?

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 17, 2021

did you run tools/regenByteCode.py with flags

Yep. It will fail without flags. And I haven't find out why.

If you're on windows it needs to be run in a developer command prompt as it calls MsBuild; on macOS/Linux I can't think of it reason for it to fail.

When run fully it generates 4 files - covering each combination of: x64 or x86 with Jit OR no Jit. Your PR currently has updates for x64 Jit and x86 jit but doesn't have the versions for noJit.

can generate the files by running each failing test with ch or can manually update them.

Okay, Thanks.

There's already existed test262. Should we add more test about that?

I was commenting on the existing test cases that are failing (because they're checking properties of the GlobalObject and not expecting to find AggregateError) we'll need new test cases as well BUT I was wrong - much easier fix don't need to update all the tests - just add AggregateError to this list to take it out of these tests:

[
"#__proto__",
"globalThis",
"Array",
"ArrayBuffer",
"Atomics",
"Boolean",
"chWriteTraceEvent",
"CollectGarbage",
"console",
"DataView",
"Date",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"Error",
"escape",
"eval",
"EvalError",
"Float32Array",
"Float64Array",
"Function",
"Infinity",
"Int16Array",
"Int32Array",
"Int8Array",
"Intl",
"isFinite",
"isNaN",
"JSON",
"Map",
"Math",
"NaN",
"Number",
"Object",
"parseFloat",
"parseInt",
"print",
"Promise",
"Proxy",
"RangeError",
"read",
"readbuffer",
"readline",
"ReferenceError",
"Reflect",
"RegExp",
"Set",
"SharedArrayBuffer",
"String",
"Symbol",
"SyntaxError",
"TypeError",
"Uint16Array",
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray",
"undefined",
"unescape",
"URIError",
"WeakMap",
"WeakSet",
"WebAssembly",
"WScript",
].forEach(function (name) {

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 17, 2021

Yeah. I know about that. I mean: I saw we have 262test. And should I add some case even they has overlapping with test262.
Thanks!

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 17, 2021

Yeah. I know about that. I mean: I saw we have 262test. And should I add some case even they has overlapping with test262.
Thanks!

We do need specific tests; test262 is not run on check in - the test262 folder just tests part of the harness.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 17, 2021

Okay. I think I'd better copy some tests from test262.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 23, 2021

Sorry I'm not sure what TTD is. And what should I do for TTD. Would you mind give some suggestion? thanks!

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 23, 2021

TTD = "Time Travel Debug" it is support for running javascript backwards for debugging purposes - it's a unique feature of Chakracore - sadly I'm not sure if anyone uses it at the moment BUT I'd like to keep it working if we can.

TTD Snap methods save the current JS state out to a file, Inflate methods take information from the file to recreate a specific JS state. So you'll probably need Snap/Inflate support for AggregateError. Perhaps look at how Snap/Inflate work for something containing a list of Promises.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 23, 2021

Seems the spec has some changes between this and the previous PR.

According the latest spec. We needn't extends JavascriptError anymore. I'll update these soon.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 23, 2021

Seems the spec has some changes between this and the previous PR.

According the latest spec. We needn't extends JavascriptError anymore. I'll update these soon.

That sounds strange to me, I thought one of the key purposes of AggregateError (instead of an Array of Errors) was so it would test true as instanceOf Error is that no longer the case?

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 23, 2021

Nope. That's not related about runtime behavior. It's talk about the implementations in this PR -> class JavascriptAggregateError : public JavascriptError

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 23, 2021

Nope. That's not related about runtime behavior. It's talk about the implementation of this PR -> class JavascriptAggregateError : public JavascriptError

If there's no detectable runtime difference the implementation doesn't matter - spec details about implementation are only authoritative if runtime can detect them.

That said - I'd need to check the details but I imagine having it internally extend JavascriptError makes sense for a lot of reasons - is there a disadvantage you're aware of? Or an observable instance of incorrect runtime behaviour?

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 23, 2021

One reason is that all the previous Errors directly reference to JavascriptError. And the property errors is just a property (In my memory, there's a internal slots and a getter { to create a array from the internal slots } before).
As the result. We just use the JavascriptError and set the property.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 23, 2021

BTW: Should this behind a flag?

@MadProbe
Copy link
Contributor

This proposal is stage 4, no need in a flag.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 23, 2021

This proposal is stage 4, no need in a flag.

Sometimes it's good to have a flag even for a stage 4 proposal/feature - if it introduces a bug or a strange issue can be helpful for debugging to turn it off OR if the bug is too serious to be able to disable the feature and a ship a version without it - hopefully unnecessary but useful to have there with any particularly invasive features.

@pleath
Copy link
Contributor

pleath commented Mar 23, 2021

+1. I'd suggest keeping any non-trivial feature behind a flag, at least until it's been successfully released. Even then, there can be surprising compat impact out in the world, and it's nice to be able to flip the switch to off while you investigate.

@Kingwl Kingwl marked this pull request as ready for review March 24, 2021 07:06
@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 24, 2021

I think this one is basically done. But there's something I'm not sure:

  • In ES^PromiseAsync.js. Seems the test done before everything tests finished.
  • I have try to copy all tests of promise.any from test262. but there's tooooo many cases...

@rhuanjl rhuanjl self-assigned this Mar 24, 2021
Copy link
Collaborator

@rhuanjl rhuanjl left a comment

Choose a reason for hiding this comment

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

I've not finished - but I've raised several points that need addressing above - found some spec deviations and a few segfaults/hard crashes as well as some less important style points.

lib/Runtime/Library/JavascriptPromise.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptPromise.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptPromise.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptPromise.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptError.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptLibrary.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptLibrary.cpp Show resolved Hide resolved
lib/Runtime/Library/JavascriptLibrary.cpp Outdated Show resolved Hide resolved
lib/Runtime/Library/JavascriptError.cpp Outdated Show resolved Hide resolved
test/Error/error_cause_with_aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Show resolved Hide resolved
@Kingwl
Copy link
Contributor Author

Kingwl commented Apr 1, 2021

PTAL. Major issues has been resolved (I think).

@rhuanjl
Copy link
Collaborator

rhuanjl commented Apr 2, 2021

I'm sorry I merged another PR with a bytecode regen - you will need to fix the merge conflict and then re-run the bytecode regen script.

@Kingwl
Copy link
Contributor Author

Kingwl commented Apr 14, 2021

PTAL.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Apr 15, 2021

Thanks for the further updates, I'll aim to pull this down and re-review tomorrow, sorry for the delay - not a small diff.

Copy link
Collaborator

@rhuanjl rhuanjl left a comment

Choose a reason for hiding this comment

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

Mostly looking good now - one serious bug which needs fixing + a test adding.

And it would be good if the AggregateError tests could be a bit nicer (similar format and clarity etc. to the other test files)

lib/Runtime/Library/JavascriptPromise.cpp Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
Comment on lines 114 to 125
var case9 = {
[Symbol.iterator]() {
return {
next() {
return undefined;
}
}
}
};
assert.throws(() => {
var obj = new AggregateError(case9);
}, TypeError);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The next few tests appear to be about iterators that don't provide objects -would be good to specify that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I'm not sure what‘s the point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically that I'd like it to be clearer when re-reading the test file what it's doing/what these cases are for.

It appears from reading them that they're testing behaviour when an iterator doesn't provide an object - but there's no comment description saying that that is what they're doing/why they're here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the response. I have tried to add some comments above the case. Does they seems enough?

test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/Error/aggregate_error.js Outdated Show resolved Hide resolved
test/es6/ES6Promise.js Show resolved Hide resolved
test/Error/error_cause_with_aggregate_error.js Outdated Show resolved Hide resolved
@Kingwl
Copy link
Contributor Author

Kingwl commented Apr 20, 2021

Thanks for the review. I would like to take a look in few days.

@rhuanjl rhuanjl merged commit 8220c85 into chakra-core:master Apr 21, 2021
@rhuanjl
Copy link
Collaborator

rhuanjl commented Apr 21, 2021

Thanks for all your work on this @Kingwl

@Kingwl
Copy link
Contributor Author

Kingwl commented Apr 21, 2021

Thanks for your review!

@Kingwl Kingwl deleted the proposal-promise-any branch April 22, 2021 02:54
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.

Implement Promise.any and AggregateError
4 participants