Skip to content

Commit

Permalink
[MERGE #5612 @jackhorton] Fix a number of Intl-related GitHub and tes…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jackhorton committed Aug 28, 2018
2 parents 6d96d5b + 3a6ae50 commit 3fb8fb8
Show file tree
Hide file tree
Showing 18 changed files with 31,193 additions and 31,278 deletions.
5 changes: 4 additions & 1 deletion deps/Chakra.ICU/Chakra.ICU.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
UCONFIG_NO_REGULAR_EXPRESSIONS=1;
UCONFIG_NO_SERVICE=1;
%(PreprocessorDefinitions)
</PreprocessorDefinitions>
</PreprocessorDefinitions>

<!-- Default ICU Configuration (see source\common\common.vcxproj) -->
<!-- Note that we already configure most of what common.vcxproj handles elsewhere -->
Expand All @@ -36,6 +36,9 @@
_CRT_SECURE_NO_DEPRECATE;
%(PreprocessorDefinitions)
</PreprocessorDefinitions>

<!-- Some ICU files use embedded UTF-8 -->
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
</Project>
3 changes: 0 additions & 3 deletions deps/Chakra.ICU/Chakra.ICU.i18n.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
%(AdditionalIncludeDirectories);
$(IcuSourceDirectory)\common
</AdditionalIncludeDirectories>

<!-- Some ICU files use embedded UTF-8 -->
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link Condition="'$(ChakraICU)'=='shared'">
<SubSystem>Console</SubSystem>
Expand Down
5 changes: 5 additions & 0 deletions lib/Runtime/Base/JnDirectFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@ ENTRY(tagPublicLibraryCode)
ENTRY(winglob)
ENTRY(platform)
ENTRY(formatToParts)
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())).
ENTRY_SYMBOL(_intlFallbackSymbol, _u("Intl.FallbackSymbol"))

ENTRY(NumberFormat)
ENTRY(__currency)
Expand Down
4 changes: 2 additions & 2 deletions lib/Runtime/ByteCode/ByteCodeCacheReleaseFileVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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}
// {DD4E773A-2839-44A0-8B4E-9283A700135A}
const GUID byteCodeCacheReleaseFileVersion =
{ 0x39DEDDF4, 0xEEE4, 0x43E8, { 0xA2, 0xC8, 0x25, 0x50, 0xA2, 0x60, 0x07, 0xD6 } };
{ 0xDD4E773A, 0x2839, 0x44A0, { 0x8B, 0x4E, 0x92, 0x83, 0xA7, 0x00, 0x13, 0x5A } };
51 changes: 32 additions & 19 deletions lib/Runtime/Library/EngineInterfaceObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,30 +317,43 @@ namespace Js
{
EngineInterfaceObject_CommonFunctionProlog(function, callInfo);

if (callInfo.Count >= 2 && JavascriptFunction::Is(args.Values[1]))
AssertOrFailFast((callInfo.Count == 3 || callInfo.Count == 4) && JavascriptFunction::Is(args[1]) && JavascriptString::Is(args[2]));

JavascriptFunction *func = JavascriptFunction::UnsafeFromVar(args[1]);
JavascriptString *methodName = JavascriptString::UnsafeFromVar(args[2]);

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

// use GetSz rather than GetString because we use wcsrchr below, which expects a null-terminated string
const char16 *methodNameBuf = methodName->GetSz();
charcount_t methodNameLength = methodName->GetLength();
const char16 *shortName = wcsrchr(methodNameBuf, _u('.'));
charcount_t shortNameOffset = 0;
if (shortName != nullptr)
{
JavascriptFunction* func = JavascriptFunction::FromVar(args.Values[1]);
func->GetFunctionProxy()->SetIsPublicLibraryCode();
shortName++;
shortNameOffset = static_cast<charcount_t>(shortName - methodNameBuf);
}

if (callInfo.Count >= 3 && JavascriptString::Is(args.Values[2]))
{
JavascriptString* customFunctionName = JavascriptString::FromVar(args.Values[2]);
// tagPublicFunction("Intl.Collator", Collator); in Intl.js calls TagPublicLibraryCode the expected name is Collator so we need to calculate the offset
const char16 * shortName = wcsrchr(customFunctionName->GetString(), _u('.'));
uint shortNameOffset = 0;
if (shortName != nullptr)
{
// JavascriptString length is bounded by uint max
shortName++;
shortNameOffset = static_cast<uint>(shortName - customFunctionName->GetString());
}
func->GetFunctionProxy()->EnsureDeserialized()->SetDisplayName(customFunctionName->GetString(), customFunctionName->GetLength(), shortNameOffset);
}
func->GetFunctionProxy()->EnsureDeserialized()->SetDisplayName(methodNameBuf, methodNameLength, shortNameOffset);

return func;
bool creatingConstructor = true;
if (callInfo.Count == 4)
{
AssertOrFailFast(JavascriptBoolean::Is(args[3]));
creatingConstructor = JavascriptBoolean::UnsafeFromVar(args[3])->GetValue();
}

return scriptContext->GetLibrary()->GetUndefined();
if (!creatingConstructor)
{
FunctionInfo *info = func->GetFunctionInfo();
info->SetAttributes((FunctionInfo::Attributes) (info->GetAttributes() | FunctionInfo::Attributes::ErrorOnNew));

AssertOrFailFast(func->GetDynamicType()->GetTypeHandler()->IsDeferredTypeHandler());
DynamicTypeHandler::SetInstanceTypeHandler(func, scriptContext->GetLibrary()->GetDeferredFunctionWithLengthTypeHandler());
}

return func;
}

/*
Expand Down
Loading

0 comments on commit 3fb8fb8

Please sign in to comment.