-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Share more code/ideas between JsBuiltIns and Intl #5698
Conversation
Also cc @rhuanjl as the writer of so many of these builtins :) |
@@ -88,7 +88,7 @@ LSC_ERROR_MSG( 1077, ERRDestructNotInit, "Destructuring declarations cannot have | |||
LSC_ERROR_MSG(1079, ERRInvalidNewTarget, "Invalid use of the 'new.target' keyword") | |||
LSC_ERROR_MSG(1080, ERRForInNoInitAllowed, "for-in loop head declarations cannot have an initializer") | |||
LSC_ERROR_MSG(1081, ERRForOfNoInitAllowed, "for-of loop head declarations cannot have an initializer") | |||
LSC_ERROR_MSG(1082, ERRNonSimpleParamListInStrictMode, "Cannot apply strict mode on functions with non-simple parameter list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change requires some baseline/test expectation updates it seems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I had only tested the array folder before putting it up last night because I was tired.
@@ -8,6 +8,7 @@ STRING(Quotes, _u("\"\"")) | |||
STRING(Whack, _u("/")) | |||
STRING(CommaDisplay, _u(",")) | |||
STRING(CommaSpaceDisplay, _u(", ")) | |||
STRING(Dot, _u(".")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What uses this? I don't see any other references in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its used when building up the full display string as library->GetDotString()
c65e524
to
1380b6b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more code we can share between these, the better.
Thanks for tagging me. This looks like some very nice cleanup - also nice to see the stack trace issues fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (args.Info.Count == 4) | ||
{ | ||
AssertOrFailFast(JavascriptBoolean::Is(args.Values[3])); | ||
isConstructor = JavascriptBoolean::UnsafeFromVar(args.Values[3])->GetValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use ::FromVar and drop the AssertOrFailFast ::Is checks in this function in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got into a pattern with it in Intl as a modification of what was already there and then didn't think about it more. Combined with operator[]
for ArgumentsReader, we could probably get rid of all of the arguments-related asserts... may make that a future PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure; can you put up an issue to have the failfast in ArgumentsReader operator[]
? That'd be a pretty good change to have.
…or use by JsBuiltIns
…ctions, and allow __chakraLibrary functions to be constructors
1380b6b
to
5625176
Compare
5625176
to
0accefd
Compare
…d Intl Merge pull request #5698 from jackhorton:jsbuiltins/cleanup Fixes #5644 Fixes #5643 Fixes an unlogged issue where all JsBuiltIns were constructable by default. This mainly merged a lot of the code between tagPublicLibraryFunction, registerFunction, and registerChakraLibraryFunction. However, there are a number of smaller updates too: 1. Stopped creating a new ScriptFunction on each JsBuiltIn registration. As far as I can tell, the only reason this existed before was to get a ScriptFunction without any framedisplay/environment, but since that can be set manually, its cheaper to just set it on the existing ScriptFunction. 1. Intl functions no longer have to duplicate their name in the tagPublicLibraryCode argument and in script. I have edited a few Intl functions to confirm it works -- not sure if its worth it to go through and make all of the functions anonymous now. I also wanted to investigate changing JavascriptLibrary::InitializeFunction to not set the name attribute for these anonymous jsbuiltin functions since the name will always be overridden, but I am not sure if its possible. 1. function length is now set using default parameters rather than manually/after the fact. Not sure if I like this better or worse than having the function macro list the length and have it set it explicitly. We could theoretically do the same optimization in InitializeFunction to avoid the extra property set. 1. JsBuiltIns now uses a shared/projected enum for function registration like Intl. 1. Ran into an error when using default parameters for functions marked explicitly as "use strict," and I found the error message misleading, so I changed it to be the same as V8's which I found clearer. 1. CheckArrayAndGetLen never hit its error case and reported a slightly worse-looking runtime/accidental error as a result when this == null Still need to run this through test262 to make sure there are no regressions.
FWIW LGTM |
Fixes #5644
Fixes #5643
Fixes an unlogged issue where all JsBuiltIns were constructable by default.
This mainly merged a lot of the code between tagPublicLibraryFunction, registerFunction, and registerChakraLibraryFunction. However, there are a number of smaller updates too:
Still need to run this through test262 to make sure there are no regressions.