Skip to content

Commit 3fb8fb8

Browse files
committed
[MERGE #5612 @jackhorton] Fix a number of Intl-related GitHub and test262 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.
2 parents 6d96d5b + 3a6ae50 commit 3fb8fb8

18 files changed

+31193
-31278
lines changed

deps/Chakra.ICU/Chakra.ICU.Build.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
UCONFIG_NO_REGULAR_EXPRESSIONS=1;
2828
UCONFIG_NO_SERVICE=1;
2929
%(PreprocessorDefinitions)
30-
</PreprocessorDefinitions>
30+
</PreprocessorDefinitions>
3131

3232
<!-- Default ICU Configuration (see source\common\common.vcxproj) -->
3333
<!-- Note that we already configure most of what common.vcxproj handles elsewhere -->
@@ -36,6 +36,9 @@
3636
_CRT_SECURE_NO_DEPRECATE;
3737
%(PreprocessorDefinitions)
3838
</PreprocessorDefinitions>
39+
40+
<!-- Some ICU files use embedded UTF-8 -->
41+
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
3942
</ClCompile>
4043
</ItemDefinitionGroup>
4144
</Project>

deps/Chakra.ICU/Chakra.ICU.i18n.vcxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
%(AdditionalIncludeDirectories);
3232
$(IcuSourceDirectory)\common
3333
</AdditionalIncludeDirectories>
34-
35-
<!-- Some ICU files use embedded UTF-8 -->
36-
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
3734
</ClCompile>
3835
<Link Condition="'$(ChakraICU)'=='shared'">
3936
<SubSystem>Console</SubSystem>

lib/Runtime/Base/JnDirectFields.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ ENTRY(tagPublicLibraryCode)
518518
ENTRY(winglob)
519519
ENTRY(platform)
520520
ENTRY(formatToParts)
521+
ENTRY(FallbackSymbol)
522+
523+
// This symbol is not part of the regular Symbol API and is only used in rare circumstances in Intl.js for backwards compatibility
524+
// with the Intl v1 spec. It is visible to the user only using Object.getOwnPropertySymbols(Intl.NumberFormat.call(new Intl.NumberFormat())).
525+
ENTRY_SYMBOL(_intlFallbackSymbol, _u("Intl.FallbackSymbol"))
521526

522527
ENTRY(NumberFormat)
523528
ENTRY(__currency)

lib/Runtime/ByteCode/ByteCodeCacheReleaseFileVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.
66

7-
// {39DEDDF4-EEE4-43E8-A2C8-2550A26007D6}
7+
// {DD4E773A-2839-44A0-8B4E-9283A700135A}
88
const GUID byteCodeCacheReleaseFileVersion =
9-
{ 0x39DEDDF4, 0xEEE4, 0x43E8, { 0xA2, 0xC8, 0x25, 0x50, 0xA2, 0x60, 0x07, 0xD6 } };
9+
{ 0xDD4E773A, 0x2839, 0x44A0, { 0x8B, 0x4E, 0x92, 0x83, 0xA7, 0x00, 0x13, 0x5A } };

lib/Runtime/Library/EngineInterfaceObject.cpp

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -317,30 +317,43 @@ namespace Js
317317
{
318318
EngineInterfaceObject_CommonFunctionProlog(function, callInfo);
319319

320-
if (callInfo.Count >= 2 && JavascriptFunction::Is(args.Values[1]))
320+
AssertOrFailFast((callInfo.Count == 3 || callInfo.Count == 4) && JavascriptFunction::Is(args[1]) && JavascriptString::Is(args[2]));
321+
322+
JavascriptFunction *func = JavascriptFunction::UnsafeFromVar(args[1]);
323+
JavascriptString *methodName = JavascriptString::UnsafeFromVar(args[2]);
324+
325+
func->GetFunctionProxy()->SetIsPublicLibraryCode();
326+
327+
// use GetSz rather than GetString because we use wcsrchr below, which expects a null-terminated string
328+
const char16 *methodNameBuf = methodName->GetSz();
329+
charcount_t methodNameLength = methodName->GetLength();
330+
const char16 *shortName = wcsrchr(methodNameBuf, _u('.'));
331+
charcount_t shortNameOffset = 0;
332+
if (shortName != nullptr)
321333
{
322-
JavascriptFunction* func = JavascriptFunction::FromVar(args.Values[1]);
323-
func->GetFunctionProxy()->SetIsPublicLibraryCode();
334+
shortName++;
335+
shortNameOffset = static_cast<charcount_t>(shortName - methodNameBuf);
336+
}
324337

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

340-
return func;
340+
bool creatingConstructor = true;
341+
if (callInfo.Count == 4)
342+
{
343+
AssertOrFailFast(JavascriptBoolean::Is(args[3]));
344+
creatingConstructor = JavascriptBoolean::UnsafeFromVar(args[3])->GetValue();
341345
}
342346

343-
return scriptContext->GetLibrary()->GetUndefined();
347+
if (!creatingConstructor)
348+
{
349+
FunctionInfo *info = func->GetFunctionInfo();
350+
info->SetAttributes((FunctionInfo::Attributes) (info->GetAttributes() | FunctionInfo::Attributes::ErrorOnNew));
351+
352+
AssertOrFailFast(func->GetDynamicType()->GetTypeHandler()->IsDeferredTypeHandler());
353+
DynamicTypeHandler::SetInstanceTypeHandler(func, scriptContext->GetLibrary()->GetDeferredFunctionWithLengthTypeHandler());
354+
}
355+
356+
return func;
344357
}
345358

346359
/*

0 commit comments

Comments
 (0)