Skip to content

Commit ecbc1f2

Browse files
committed
Fix a number of test262 Intl issues
1 parent 2e9a8a8 commit ecbc1f2

File tree

7 files changed

+388
-329
lines changed

7 files changed

+388
-329
lines changed

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/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)