Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d37d5e4
Make SString generic on an encoding traits type.
jkoritzinsky May 23, 2022
42fa6ab
Merge branch 'main' of github.com:dotnet/runtime into sstring-explici…
jkoritzinsky May 23, 2022
f913366
Fix linux build
jkoritzinsky May 24, 2022
32ddf53
Rename a few things to reduce the overall number of changes.
jkoritzinsky May 24, 2022
b2588e6
Fix linux build.
jkoritzinsky May 24, 2022
bc07888
A few more changes to reduce diffs.
jkoritzinsky May 24, 2022
8ebc5df
More diff reduction
jkoritzinsky May 24, 2022
0a5056c
Various fixes for SString. Reimplement the move semantics on SBuffer …
jkoritzinsky May 25, 2022
26f4944
Fix base type member usage with templates
jkoritzinsky May 26, 2022
824aa67
Store the result of GetPathToLoad in a local so we don't trash GetLas…
jkoritzinsky May 26, 2022
b146aae
Fix reuse bug in assembly loading.
jkoritzinsky May 27, 2022
e95cbef
Merge branch 'main' of github.com:dotnet/runtime into sstring-explici…
jkoritzinsky Jun 2, 2022
1a4d621
Merge branch 'sstring-explicit-encoding' of github.com:jkoritzinsky/r…
jkoritzinsky Jun 2, 2022
7b87012
Remove outdated comment
jkoritzinsky Jun 2, 2022
a7dcfad
Fix unix build
jkoritzinsky Jun 2, 2022
c445d35
Fix immutable empty shortcut and additional cleanup.
jkoritzinsky Jun 6, 2022
84876d8
Add static_assert message
jkoritzinsky Jun 6, 2022
2f01a7a
Fix cast issue on 32-bit
jkoritzinsky Jun 7, 2022
5aa2896
Fix default constructor to correctly mark UTF8/ASCII default EStrings…
jkoritzinsky Jun 7, 2022
b4d2fbd
Various fixes
jkoritzinsky Jun 7, 2022
bcfd0b7
Fix canary and buffer sharing handling. Fix another constructor that …
jkoritzinsky Jun 8, 2022
5a22849
Merge branch 'main' into sstring-explicit-encoding
jkoritzinsky Jun 8, 2022
7523a1f
Fix build break
jkoritzinsky Jun 9, 2022
a6fc06d
Fix super-large array rank error case handling.
jkoritzinsky Jun 9, 2022
5f53cc7
Fix some typos from bad find-replace in nativeaot code
jkoritzinsky Jun 9, 2022
93e98cf
Merge branch 'main' of github.com:dotnet/runtime into sstring-explici…
jkoritzinsky Jun 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/coreclr/binder/applicationcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ namespace BINDER_SPACE
//
m_pTrustedPlatformAssemblyMap = new SimpleNameToFileNameMap();

sTrustedPlatformAssemblies.Normalize();

for (SString::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); )
{
SString fileName;
Expand All @@ -110,7 +108,7 @@ namespace BINDER_SPACE
break;
}

const SimpleNameToFileNameMapEntry *pExistingEntry = m_pTrustedPlatformAssemblyMap->LookupPtr(simpleName.GetUnicode());
const SimpleNameToFileNameMapEntry *pExistingEntry = m_pTrustedPlatformAssemblyMap->LookupPtr(simpleName);

if (pExistingEntry != nullptr)
{
Expand All @@ -135,7 +133,7 @@ namespace BINDER_SPACE
{
GO_WITH_HRESULT(E_OUTOFMEMORY);
}
wcscpy_s(wszSimpleName, simpleName.GetCount() + 1, simpleName.GetUnicode());
wcscpy_s(wszSimpleName, simpleName.GetCount() + 1, simpleName);
}
else
{
Expand All @@ -147,7 +145,7 @@ namespace BINDER_SPACE
{
GO_WITH_HRESULT(E_OUTOFMEMORY);
}
wcscpy_s(wszFileName, fileName.GetCount() + 1, fileName.GetUnicode());
wcscpy_s(wszFileName, fileName.GetCount() + 1, fileName);

SimpleNameToFileNameMapEntry mapEntry;
mapEntry.m_wszSimpleName = wszSimpleName;
Expand All @@ -168,7 +166,6 @@ namespace BINDER_SPACE
//
// Parse PlatformResourceRoots
//
sPlatformResourceRoots.Normalize();
for (SString::Iterator i = sPlatformResourceRoots.Begin(); i != sPlatformResourceRoots.End(); )
{
SString pathName;
Expand All @@ -191,7 +188,6 @@ namespace BINDER_SPACE
//
// Parse AppPaths
//
sAppPaths.Normalize();
for (SString::Iterator i = sAppPaths.Begin(); i != sAppPaths.End(); )
{
SString pathName;
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/binder/assemblybindercommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ namespace BINDER_SPACE
// Try to find corelib in the TPA
StackSString sCoreLibSimpleName(CoreLibName_W);
StackSString sTrustedPlatformAssemblies = Configuration::GetKnobStringValue(W("TRUSTED_PLATFORM_ASSEMBLIES"));
sTrustedPlatformAssemblies.Normalize();

bool found = false;
for (SString::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); )
Expand All @@ -309,7 +308,7 @@ namespace BINDER_SPACE

if (simpleName.EqualsCaseInsensitive(sCoreLibSimpleName))
{
sCoreLib = fileName;
sCoreLib = (LPCWSTR)fileName;
found = true;
break;
}
Expand Down Expand Up @@ -859,7 +858,8 @@ namespace BINDER_SPACE
SString assemblyFileName(simpleName);
assemblyFileName.Append(candidates[i]);

SString assemblyFilePath(Bundle::AppBundle->BasePath());
SString assemblyFilePath;
Bundle::AppBundle->BasePath().ConvertToUnicode(assemblyFilePath);
assemblyFilePath.Append(assemblyFileName);

BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(assemblyFileName, /* pathIsBundleRelative */ true);
Expand Down Expand Up @@ -891,7 +891,7 @@ namespace BINDER_SPACE

// Is assembly on TPA list?
SimpleNameToFileNameMap * tpaMap = pApplicationContext->GetTpaList();
const SimpleNameToFileNameMapEntry *pTpaEntry = tpaMap->LookupPtr(simpleName.GetUnicode());
const SimpleNameToFileNameMapEntry *pTpaEntry = tpaMap->LookupPtr(simpleName);
if (pTpaEntry != nullptr)
{
if (pTpaEntry->m_wszNIFileName != nullptr)
Expand Down Expand Up @@ -1011,7 +1011,7 @@ namespace BINDER_SPACE

// Obtain assembly meta data
{
LPCTSTR szAssemblyPath = const_cast<LPCTSTR>(assemblyPath.GetUnicode());
LPCTSTR szAssemblyPath = static_cast<LPCTSTR>(assemblyPath);

hr = BinderAcquirePEImage(szAssemblyPath, &pPEImage, bundleFileLocation);
IF_FAIL_GO(hr);
Expand Down
30 changes: 15 additions & 15 deletions src/coreclr/binder/assemblyname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,29 @@ namespace BINDER_SPACE
));

{
StackSString culture;
culture.SetUTF8(amd.szLocale);
culture.Normalize();
StackEString<EncodingUTF8> culture(amd.szLocale);
SString cultureUnicode(culture.MoveToUnicode());

SString::CIterator itr = culture.Begin();
if (culture.Find(itr, L';'))
SString::CIterator itr = cultureUnicode.Begin();
if (cultureUnicode.Find(itr, L';'))
{
culture = SString(culture, culture.Begin(), itr-1);
cultureUnicode = SString(cultureUnicode, cultureUnicode.Begin(), itr-1);
}

SetCulture(culture);
SetCulture(cultureUnicode);
}

{
StackSString assemblyName;
assemblyName.SetUTF8(pAssemblyName);
assemblyName.Normalize();
StackEString<EncodingUTF8> assemblyName(pAssemblyName);
SString assemblyNameUnicode(assemblyName.MoveToUnicode());

COUNT_T assemblyNameLength = assemblyName.GetCount();
if (assemblyNameLength == 0 || assemblyNameLength >= MAX_PATH_FNAME)
{
IF_FAIL_GO(FUSION_E_INVALID_NAME);
}

SetSimpleName(assemblyName);
SetSimpleName(assemblyNameUnicode);
}

// See if the assembly[def] is retargetable (ie, for a generic assembly).
Expand Down Expand Up @@ -159,10 +157,12 @@ namespace BINDER_SPACE
HRESULT AssemblyName::Init(const AssemblyNameData &data)
{
DWORD flags = data.IdentityFlags;
m_simpleName.SetUTF8(data.Name);
MAKE_WIDEPTR_FROMUTF8(pSimpleName, data.Name);
m_simpleName.Set(pSimpleName);
m_version.SetFeatureVersion(data.MajorVersion, data.MinorVersion);
m_version.SetServiceVersion(data.BuildNumber, data.RevisionNumber);
m_cultureOrLanguage.SetUTF8(data.Culture);
MAKE_WIDEPTR_FROMUTF8(pCulture, data.Culture);
m_cultureOrLanguage.Set(pCulture);

m_publicKeyOrTokenBLOB.Set(data.PublicKeyOrToken, data.PublicKeyOrTokenLength);
if ((flags & BINDER_SPACE::AssemblyIdentity::IDENTITY_FLAG_PUBLIC_KEY) != 0)
Expand Down Expand Up @@ -204,13 +204,13 @@ namespace BINDER_SPACE
BOOL AssemblyName::IsCoreLib()
{
// TODO: Is this simple comparison enough?
return SString::_wcsicmp(GetSimpleName().GetUnicode(), CoreLibName_W) == 0;
return StaticStringHelpers::_wcsicmp(GetSimpleName(), CoreLibName_W) == 0;
}

bool AssemblyName::IsNeutralCulture()
{
return m_cultureOrLanguage.IsEmpty()
|| SString::_wcsicmp(m_cultureOrLanguage.GetUnicode(), s_neutralCulture) == 0;
|| StaticStringHelpers::_wcsicmp(m_cultureOrLanguage, s_neutralCulture) == 0;
}

ULONG AssemblyName::Hash(DWORD dwIncludeFlags)
Expand Down
22 changes: 11 additions & 11 deletions src/coreclr/binder/bindertracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace BinderTracing
// Use the error message that would be reported in the file load exception
StackSString errorMsg;
if (mvidMismatch)
errorMsg.LoadResource(CCompRC::Error, IDS_HOST_ASSEMBLY_RESOLVER_ASSEMBLY_ALREADY_LOADED_IN_CONTEXT);
LoadResource(errorMsg, CCompRC::Error, IDS_HOST_ASSEMBLY_RESOLVER_ASSEMBLY_ALREADY_LOADED_IN_CONTEXT);

const BindResult::AttemptResult *inContextAttempt = bindResult.GetAttempt(true /*foundInContext*/);
const BindResult::AttemptResult *appAssembliesAttempt = bindResult.GetAttempt(false /*foundInContext*/);
Expand All @@ -229,11 +229,11 @@ namespace BinderTracing
TraceStage(Stage::FindInLoadContext,
isLastAttempt && FAILED(m_hr) && SUCCEEDED(inContextAttempt->HResult) ? m_hr : inContextAttempt->HResult,
inContextAttempt->Assembly,
mvidMismatch && isLastAttempt ? errorMsg.GetUnicode() : nullptr);
mvidMismatch && isLastAttempt ? (LPCWSTR)errorMsg : nullptr);
}

if (appAssembliesAttempt != nullptr)
TraceStage(Stage::ApplicationAssemblies, FAILED(m_hr) && SUCCEEDED(appAssembliesAttempt->HResult) ? m_hr : appAssembliesAttempt->HResult, appAssembliesAttempt->Assembly, mvidMismatch ? errorMsg.GetUnicode() : nullptr);
TraceStage(Stage::ApplicationAssemblies, FAILED(m_hr) && SUCCEEDED(appAssembliesAttempt->HResult) ? m_hr : appAssembliesAttempt->HResult, appAssembliesAttempt->Assembly, mvidMismatch ? (LPCWSTR)errorMsg : nullptr);
}

void ResolutionAttemptedOperation::TraceStage(Stage stage, HRESULT hr, BINDER_SPACE::Assembly *resultAssembly, const WCHAR *customError)
Expand All @@ -246,7 +246,7 @@ namespace BinderTracing
if (resultAssembly != nullptr)
{
resultAssembly->GetAssemblyName()->GetDisplayName(resultAssemblyName, AssemblyName::INCLUDE_VERSION | AssemblyName::INCLUDE_PUBLIC_KEY_TOKEN);
resultAssemblyPath = resultAssembly->GetPEImage()->GetPath();
resultAssemblyPath.Set(resultAssembly->GetPEImage()->GetPath());
}

Result result;
Expand All @@ -258,7 +258,7 @@ namespace BinderTracing
}
else if (!m_exceptionMessage.IsEmpty())
{
errorMsg = m_exceptionMessage;
errorMsg.Set(m_exceptionMessage);
result = Result::Exception;
}
else
Expand All @@ -278,7 +278,7 @@ namespace BinderTracing
result = Result::IncompatibleVersion;

{
SString errorMsgUtf8(SString::Utf8, "Requested version");
EString<EncodingUTF8> errorMsgUtf8("Requested version");
if (m_assemblyNameObject != nullptr)
{
const auto &reqVersion = m_assemblyNameObject->GetVersion();
Expand All @@ -289,7 +289,7 @@ namespace BinderTracing
reqVersion->GetRevision());
}

errorMsgUtf8.AppendUTF8(" is incompatible with found version");
errorMsgUtf8.Append(" is incompatible with found version");
if (resultAssembly != nullptr)
{
const auto &foundVersion = resultAssembly->GetAssemblyName()->GetVersion();
Expand All @@ -299,17 +299,17 @@ namespace BinderTracing
foundVersion->GetBuild(),
foundVersion->GetRevision());
}
errorMsg.Set(errorMsgUtf8.GetUnicode());
errorMsg.Set(errorMsgUtf8.MoveToUnicode());
}
break;

case FUSION_E_REF_DEF_MISMATCH:
result = Result::MismatchedAssemblyName;
errorMsg.Printf(W("Requested assembly name '%s' does not match found assembly name"), m_assemblyName.GetUnicode());
errorMsg.Printf(W("Requested assembly name '%s' does not match found assembly name"), (LPCWSTR)m_assemblyName);
if (resultAssembly != nullptr)
{
errorMsg.Append(W(" '"));
errorMsg.Append(resultAssemblyName.GetUnicode());
errorMsg.Append(resultAssemblyName);
errorMsg.Append(W("'"));
}

Expand Down Expand Up @@ -359,7 +359,7 @@ namespace BinderTracing
else if (resultAssembly != nullptr)
{
result = Result::Success;
resultAssemblyPath = resultAssembly->GetPath();
resultAssemblyPath.Set(resultAssembly->GetPath());
resultAssembly->GetDisplayName(resultAssemblyName);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/binder/defaultassemblybinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ HRESULT DefaultAssemblyBinder::BindUsingPEImage( /* in */ PEImage *pPEImage,
//
const SString& simpleName = pAssemblyName->GetSimpleName();
SimpleNameToFileNameMap* tpaMap = GetAppContext()->GetTpaList();
if (tpaMap->LookupPtr(simpleName.GetUnicode()) != NULL)
if (tpaMap->LookupPtr(simpleName) != NULL)
{
// The simple name of the assembly being requested to be bound was found in the TPA list.
// Now, perform the actual bind to see if the assembly was really in the TPA assembly list or not.
Expand Down
9 changes: 4 additions & 5 deletions src/coreclr/binder/inc/applicationcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ namespace BINDER_SPACE
}
static count_t Hash(const key_t &str)
{
SString ssKey(SString::Literal, str);
return ssKey.HashCaseInsensitive();
return SL(str).HashCaseInsensitive();
}
static BOOL Equals(const key_t &lhs, const key_t &rhs) { LIMITED_METHOD_CONTRACT; return (SString::_wcsicmp(lhs, rhs) == 0); }
static BOOL Equals(const key_t &lhs, const key_t &rhs) { LIMITED_METHOD_CONTRACT; return (StaticStringHelpers::_wcsicmp(lhs, rhs) == 0); }

void OnDestructPerEntryCleanupAction(const SimpleNameToFileNameMapEntry & e)
{
Expand Down Expand Up @@ -115,8 +114,8 @@ namespace BINDER_SPACE
FailureCache *m_pFailureCache;
CRITSEC_COOKIE m_contextCS;

StringArrayList m_platformResourceRoots;
StringArrayList m_appPaths;
StringArrayList m_platformResourceRoots;
StringArrayList m_appPaths;

SimpleNameToFileNameMap * m_pTrustedPlatformAssemblyMap;
};
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/binder/inc/assemblybindercommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ namespace BINDER_SPACE
/* in */ bool excludeAppPaths,
/* out */ Assembly **ppAssembly);

static HRESULT BindToSystem(/* in */ SString &systemDirectory,
static HRESULT BindToSystem(/* in */ SString &systemDirectory,
/* out */ Assembly **ppSystemAssembly);

static HRESULT BindToSystemSatellite(/* in */ SString &systemDirectory,
/* in */ SString &simpleName,
/* in */ SString &cultureName,
/* out */ Assembly **ppSystemAssembly);
/* out */ Assembly **ppSystemAssembly);

static HRESULT GetAssembly(/* in */ SString &assemblyPath,
static HRESULT GetAssembly(/* in */ SString &assemblyPath,
/* in */ BOOL fIsInTPA,
/* out */ Assembly **ppAssembly,
/* in */ BundleFileLocation bundleFileLocation = BundleFileLocation::Invalid());
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/binder/inc/assemblyhashtraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace BINDER_SPACE

typedef AssemblyName* key_t;

// GetKey, Equals and Hash can throw due to SString
// GetKey, Equals and Hash can throw due to EString
static const bool s_NoThrow = false;

static key_t GetKey(element_t pAssemblyEntry)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/binder/textualidentityparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace BINDER_SPACE
{
UINT cbPublicKeyOrTokenBLOB = publicKeyOrTokenBLOB.GetSize();
WCHAR *pwzpublicKeyOrToken =
publicKeyOrToken.OpenUnicodeBuffer(cbPublicKeyOrTokenBLOB * 2);
publicKeyOrToken.OpenBuffer(cbPublicKeyOrTokenBLOB * 2);

BinToUnicodeHex(publicKeyOrTokenBLOB, cbPublicKeyOrTokenBLOB, pwzpublicKeyOrToken);
publicKeyOrToken.CloseBuffer(cbPublicKeyOrTokenBLOB * 2);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/classlibnative/bcltype/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void SystemNative::GenericFailFast(STRINGREF refMesgString, EXCEPTIONREF refExce
if (gc.refExceptionForWatsonBucketing != NULL)
{
GetExceptionMessage(gc.refExceptionForWatsonBucketing, msg);
argExceptionString = msg.GetUnicode();
argExceptionString = msg;
}

Thread *pThread = GetThread();
Expand Down
Loading