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

Implemented every, some, includes, and reduce for array.prototype as JsBuiltIn #5723

Merged
merged 14 commits into from
Oct 4, 2018

Conversation

yullin-ms
Copy link
Contributor

Implemented every, some, includes, and reduce for array.prototype as JsBuiltIn

@jackhorton
Copy link
Contributor

Oh no, I wrote all of my initial comments on your other PR. Please cross-reference as needed :)

@jackhorton
Copy link
Contributor

PS, for rebasing, I find it easiest to make the bytecode updates completely separate. So, when you have local changes, git add . && git reset *.bc.* to stage all of the non-bytecode changes. Then, when rebasing (specifically with interactive mode, git rebase -i), you can just drop the bytecode commit because it will almost certainly conflict.

@yullin-ms yullin-ms force-pushed the arrayEverySomeIncludesReduce branch 2 times, most recently from a65f6fd to e2a493e Compare September 22, 2018 05:35
@rhuanjl
Copy link
Collaborator

rhuanjl commented Sep 22, 2018

Just thought I should note; I experimented with an Array.prototype.every implementation ages ago: rhuanjl@71ee608

That was in response to this discussion on node-chakracore: nodejs/node-chakracore#527

But I did not submit it as it actually showed a performance regression - I tried re-running the case from that issue today but it doesn't run at all with the latest node-chakracore with cc master so can't check the performance impact of this on it anymore.

@yullin-ms
Copy link
Contributor Author

@rhuanjl Thank you for the input, do you know of a another way to repro the testing in that previous discussion?

@kfarnung
Copy link
Contributor

@rhuanjl I don't think I'd block on that. I can take a look separately and see why it's not working with the latest node-chakracore, it did build successfully with 10.6.0, but I haven't tried with a newer version.

@dilijev dilijev added the Bytecode-Update This PR updates bytecode and will cause merge conflicts with other PRs with this label label Sep 24, 2018
Copy link
Contributor

@sigatrev sigatrev left a comment

Choose a reason for hiding this comment

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

LGTM. have you run test262 to confirm there are no regressions in spec compliance?

lib/Runtime/Library/JsBuiltIn/JsBuiltIn.js Show resolved Hide resolved
lib/Runtime/Library/JsBuiltIn/JsBuiltIn.js Outdated Show resolved Hide resolved
@@ -363,27 +365,245 @@
platform.registerFunction(platform.FunctionKind.Array_forEach, function (callbackfn, thisArg = undefined) {
// ECMAScript 2017 #sec-array.prototype.foreach

//Let O be ? ToObject(this value).
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for adding the spec comments.

@akroshg
Copy link
Contributor

akroshg commented Sep 24, 2018

    CHAKRATEL_LANGSTATS_INC_BUILTINCOUNT(Array_Prototype_reduce);

Not sure - but do we put assert here that we should not reach here unless we have disabled the jsbuiltins?


Refers to: lib/Runtime/Library/JavascriptArray.cpp:9916 in e2a493e. [](commit_id = e2a493e, deletion_comment = False)

@rhuanjl
Copy link
Collaborator

rhuanjl commented Sep 24, 2018

@kfarnung I just wanted to flag it as whilst that test doesn't run at all now when I experimented with a Jsbuiltin Array.prototype.every before - intending to improve its performance it actually made it worse.

return undefined;
});

platform.registerFunction(platform.FunctionKind.Array_some, function (callbackfn, thisArg = undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

spoken in person, but please check the typedarray performance change on these apis.

@yullin-ms yullin-ms force-pushed the arrayEverySomeIncludesReduce branch 2 times, most recently from d4db7c0 to 53017fb Compare September 24, 2018 22:35
@duongnhn
Copy link
Contributor

@dotnet-bot test this please

Copy link
Contributor

@sethbrenith sethbrenith left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@akroshg akroshg left a comment

Choose a reason for hiding this comment

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

:shipit:

@yullin-ms
Copy link
Contributor Author

@dotnet-bot test Windows 10 x64_debug

@dilijev dilijev closed this Sep 25, 2018
@dilijev dilijev reopened this Sep 25, 2018
@dilijev dilijev changed the base branch from master to master-ci September 25, 2018 17:44
@dilijev
Copy link
Contributor

dilijev commented Sep 25, 2018

Temporarily retargeted this PR to master-ci to use a different Jenkins server. Please target back to master before merging.

@yullin-ms yullin-ms changed the base branch from master-ci to master September 25, 2018 18:12
@yullin-ms yullin-ms changed the base branch from master to master-ci September 25, 2018 18:13
@yullin-ms yullin-ms force-pushed the arrayEverySomeIncludesReduce branch from 318beb1 to dc65f46 Compare September 25, 2018 23:11
@yullin-ms yullin-ms changed the base branch from master-ci to master September 26, 2018 16:58
@dilijev
Copy link
Contributor

dilijev commented Sep 26, 2018

    CHAKRATEL_LANGSTATS_INC_BUILTINCOUNT(Array_Prototype_reduce);

Also, how would we have ENABLE_JS_BUILTINS but !IsJsBuiltInEnabled?


In reply to: 424076344 [](ancestors = 424076344)


Refers to: lib/Runtime/Library/JavascriptArray.cpp:9916 in dc65f46. [](commit_id = dc65f46, deletion_comment = False)

JavascriptError::ThrowTypeError(scriptContext, VBSERR_ActionNotSupported);
if (typedArrayBase)
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_EmptyArrayAndInitValueNotPresent, _u("TypedArray.prototype.reduce"));
Copy link
Contributor

@dilijev dilijev Sep 26, 2018

Choose a reason for hiding this comment

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

TypedArray [](start = 111, length = 10)

TypedArray is a synthetic/catch-all type (not a user visible type) -- would this error message be confusing?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's pretty well-known for a type that never actually shows up in JS code (it's on MDN, for example). Elsewhere in this file we use [TypedArray] to hint at it not being a real type; would that be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jackhorton We spoke on this [TypedArray] vs TypeArray, I'm curious on your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

V8 doesnt say TypedArray" in its error, but the TypedArray constructor is technically visible. Also, the actual method is TypedArray.prototype.reduce -- all of the actual constructors (UInt8Array, etc) get it from the TypedArray prototype. So I voted in favor of just calling it what MDN calls it, which is TypedArray.prototype.reduce

Copy link
Contributor

@dilijev dilijev left a comment

Choose a reason for hiding this comment

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

:shipit:

@sigatrev
Copy link
Contributor

Also, how would we have ENABLE_JS_BUILTINS but !IsJsBuiltInEnabled?

ENABLE_JS_BUILTINS is a compile-time macro. IsJsBuiltInEnabled is controlled by the -jsBuiltIns flag.

yullin-ms and others added 13 commits September 28, 2018 16:13
…recursive loop to iterative in MayHaveSideEffectOnNode to avoid a stack overflow.

Merge pull request chakra-core#5739 from wyrichte:build/wyrichte/stack_overflow_1
Merge pull request chakra-core#5733 from yullin-ms:argLenAndConstOptPhaseTwo

This is to do inline arg optimization when we do argument length and argument constant optimizations
… not number for float type specialization

Merge pull request chakra-core#5743 from nhat-nguyen:BailOutFloatTypeSpec
…ackArgsOpt

Merge pull request chakra-core#5744 from nhat-nguyen:stackargs

`DoStackArgsOpt` takes a `topFunc` parameter but doesn't use it.

It seems like the intention is to pass it to `IsStackArgsEnabled`, but `topFunc` is actually referenced inside `IsStackArgsEnabled` through a pointer in m_func, making passing in the argument unnecessary.
@yullin-ms yullin-ms force-pushed the arrayEverySomeIncludesReduce branch from dc65f46 to 540a95d Compare October 4, 2018 17:56
@yullin-ms yullin-ms force-pushed the arrayEverySomeIncludesReduce branch from 540a95d to 45c0553 Compare October 4, 2018 17:59
yullin-ms added a commit to yullin-ms/ChakraCore that referenced this pull request Oct 4, 2018
…, and reduce for array.prototype as JsBuiltIn

Merge pull request chakra-core#5723 from yullin-ms:arrayEverySomeIncludesReduce

Implemented every, some, includes, and reduce for array.prototype as JsBuiltIn
@dilijev dilijev merged commit 45c0553 into chakra-core:master Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bytecode-Update This PR updates bytecode and will cause merge conflicts with other PRs with this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.