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

Fix a number of Intl-related GitHub and test262 issues, add support for ICU 62.1 #5612

Merged
merged 4 commits into from
Aug 28, 2018

Conversation

jackhorton
Copy link
Contributor

@jackhorton jackhorton commented Aug 20, 2018

Fixes #637
Fixes #5603
Fixes #3427
Fixes #3513
Fixes #3692

Adds build support for ICU 62.1 by enabling /utf-8 in all ICU files rather than just i18n

@rhuanjl's function.length PR took our pass rate from 486 to 530; this further increases it to 580 (compared to V8's 582 and SpiderMonkey's 597). The remaining failures are all known, but slightly more complicated issues, where we shell out to ICU when the spec wants us to do something particularly snowflake-y -- V8 fails most of these tests as well. The remaining ~350 tests are for features that we don't implement and V8/SM either haven't implemented or have turned off by default.

For what its worth, some of the features we haven't implemented are extremely straightforward -- the Intl version of String.prototype.toLocale{Lower|Upper}Case and {Typed}Array.prototype.toLocaleString are tiny. Fixing those tests (by implementing those features) would bump us up to 596.

@jackhorton jackhorton self-assigned this Aug 20, 2018
info->SetAttributes((FunctionInfo::Attributes) (info->GetAttributes() | FunctionInfo::Attributes::ErrorOnNew));

func->SetAttributes(PropertyIds::prototype, PropertyConfigurable);
func->DeleteProperty(PropertyIds::prototype, PropertyOperationFlags::PropertyOperation_Force);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that DeleteProperty doesn't respect PropertyOperation_Force, at least not the way I thought it should. It makes it so the operation doesn't throw, but it doesn't bypass configurability. I can change that if we all agree that force should bypass any other restrictions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is used by library code only, are there any cases of non-configurable prototype properties? Do you construct lambdas which go through this path?

Just out of caution I would be inclined to leave Force as it is, but it does sound like the intention is that it skips those kinds of restrictions, at least for adding properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't currently put any lambdas through this codepath, but theres nothing stopping us from doing so in the future. Additionally, we don't install anything on the prototypes of functions that go through this particular code path, where the prototype gets deleted. Constructor's prototypes get modified, but they don't hit this.

@jackhorton
Copy link
Contributor Author

/cc @zenparsing

@@ -36,6 +36,9 @@
_CRT_SECURE_NO_DEPRECATE;
%(PreprocessorDefinitions)
</PreprocessorDefinitions>

<!-- Some ICU files use embedded UTF-8 -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW, as of ICU v59, all of the source files are supposed to be encoded as UTF-8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it makes more sense in Chakra.ICU.Build.props anyways.


// If we passed the previous check, we should reset the status to U_ZERO_ERROR (in case it was U_UNSUPPORTED_ERROR)
status = U_ZERO_ERROR;
if (strcmp(ucal_getType(cal, &status), "gregorian") == 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks Jack! 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see much documentation for this; are we expected to free/release the string returned by ucal_getType? Or is it static?

Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea what the error scenarios are too? If status ends up not being success, is the returned string guaranteed to be nullptr or otherwise safe? Should we be checking the status code prior to using the returned value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can assert right after getType, though I believe anything that returns a const char * returns a static string that shouldn't be freed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I would agree that the documentation is rather lacking for this ICU API.

The API will return a static string that does not need to be free'ed. The only way status would be set to a failure state is if the incoming parameter is already a failure. The API itself doesn't modify the status variable.

I've filed a ticket on upstream ICU to improve the docs for this function:
https://unicode-org.atlassian.net/browse/ICU-20082
(Thanks for the feedback! :) )

Copy link
Collaborator

@jefgen jefgen left a comment

Choose a reason for hiding this comment

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

FWIW, LGTM.
Thanks for fixing #5603 👍
(cc: @Microsoft/target-dev as FYI.)


func->GetFunctionProxy()->SetIsPublicLibraryCode();

const char16 *methodNameBuf = methodName->GetSz();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't expect the intl js code to do anything too zany here, but is it worth using GetString instead of GetSz? Since we're passing the length around anyway either should work, and I know that @sethbrenith has made some good points that it is typically better hygiene to use the GetString version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use wcsrchr below, which doesn't take a length parameter. It used to be GetString and we always call it on literal strings, but in case we ever call it on a non-literal-string in the future, the wcsrchr would start searching past the end of the string we actually wanted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, this runs on Intl initialization, so its not particularly hot. I can add a comment for it.

@MSLaguana
Copy link
Contributor

Looks like some TTD tests are complaining about this change.

@jackhorton
Copy link
Contributor Author

Yeah, which is odd. I will try to run the TTD tests locally with ICU enabled -- i hope its not actually an xplat-only failure.

@jackhorton
Copy link
Contributor Author

Last of the low-hanging fruit is done 🔥

image

@zenparsing
Copy link
Contributor

@jackhorton 🔥, indeed

info->SetAttributes((FunctionInfo::Attributes) (info->GetAttributes() | FunctionInfo::Attributes::ErrorOnNew));

AssertOrFailFast(func->GetDynamicType()->GetTypeHandler()->IsDeferredTypeHandler());
DynamicTypeHandler::SetInstanceTypeHandler(func, scriptContext->GetLibrary()->GetDeferredFunctionTypeHandlerNoPrototype());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pleath @boingoing Thoughts on this way of making sure these builtins don't have prototypes, rather than forcefully deleting the prototype property?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jackhorton I added that type in #5405 and was now planning on renaming it in #5610 (as other function types say "prototype" in their name if they have one and don't mention it if they don't whereas they explicitly mention if they have a length - which this does)

Just an FYI that if 5610 is merged before this and this used here will need to rename it here (unless I drop the name change from 5610)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was going to wait to merge this until we got 5610 and fromEntries merged so that you dont have to keep rebasing/re-bytecode-genning on top of all of our changes. I wanted to wait for some more opinion on 5610 but I may just merge it today.

@dilijev
Copy link
Contributor

dilijev commented Aug 24, 2018

Coming back to this now; sorry for the delay.

@dilijev dilijev added the Bytecode-Update This PR updates bytecode and will cause merge conflicts with other PRs with this label label Aug 25, 2018
ENTRY(FallbackSymbol)

// This symbol is not part of the regular Symbol API and is only used in rare circumstances in Intl.js for backwards compatibility
// with the Intl v1 spec. It is visible to the user only using Object.getOwnPropertySymbols(Intl.NumberFormat.call(new Intl.NumberFormat())).
Copy link
Contributor

Choose a reason for hiding this comment

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

It is visible to the user only using Object.getOwnPropertySymbols(Intl.NumberFormat.call(new Intl.NumberFormat())). [](start = 26, length = 115)

is it supposed to be visible to the user this way?

Copy link

Choose a reason for hiding this comment

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

is it supposed to be visible to the user this way?

Nope

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. We have never had the correct behavior here so I just tried to emulate what the other engines do. I believe both V8 and SM showed the symbol through GetOwnPropertySymbols (since the symbol is defined on this, without being an internal property, I am not sure how it could have ever not been user-visible? Perhaps I am missing something.)

Copy link

Choose a reason for hiding this comment

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

Ah, you're correct. I was under the incorrect impression that this was using a private symbol that Dan was alluding to here. It's weird that the spec chose to expose this publicly.

I am not sure how it could have ever not been user-visible?

One way would be for the spec to define the lookup using a WeakMap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rest of the spec works off of internal slots; if FallbackSymbol were an internal slot, then that should serve the same purpose, no? Regardless, my understanding was that the fallback symbol was put in place because intl v2 broke a specific library that was using Intl in a relatively odd way, but since at least Edge has never gotten this behavior correct, I assume that the fallback behavior is too rare to be worth trying to update at this point.

@@ -4,6 +4,6 @@
//-------------------------------------------------------------------------------------------------------
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.

// {39DEDDF4-EEE4-43E8-A2C8-2550A26007D6}
// d338af4b-9ef1-48f9-b103-7b2ea58a9478
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: format of this comment

Copy link
Contributor

@dilijev dilijev Aug 25, 2018

Choose a reason for hiding this comment

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

nit: you shouldn't need a bytecode GUID update because master is in development mode. (Doesn't hurt though.)


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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Meh. Thats the least painful part of the bytecode song and dance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also that format is whats generated by the powershell updater script i put in core\tools

@chakrabot chakrabot merged commit 3a6ae50 into chakra-core:master Aug 28, 2018
chakrabot pushed a commit that referenced this pull request Aug 28, 2018
…t262 issues, add support for ICU 62.1

Merge pull request #5612 from jackhorton:intl/lots-of-fixes

Fixes #637
Fixes #5603
Fixes #3427
Fixes #3513
Fixes #3692

Adds build support for ICU 62.1 by enabling /utf-8 in all ICU files rather than just i18n

@rhuanjl's function.length PR took our pass rate from 486 to 530; this further increases it to 580 (compared to V8's 582 and SpiderMonkey's 597). The remaining failures are all known, but slightly more complicated issues, where we shell out to ICU when the spec wants us to do something particularly snowflake-y -- V8 fails most of these tests as well. The remaining ~350 tests are for features that we don't implement and V8/SM either haven't implemented or have turned off by default.

For what its worth, some of the features we haven't implemented are extremely straightforward -- the Intl version of String.prototype.toLocale{Lower|Upper}Case and {Typed}Array.prototype.toLocaleString are tiny. Fixing those tests (by implementing those features) would bump us up to 596.
@jackhorton jackhorton deleted the intl/lots-of-fixes branch August 28, 2018 15:53
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 Intl-ICU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants