Skip to content

String literal mangling fix - #2

Closed
A-And wants to merge 38 commits into
masterfrom
StringLoadFix
Closed

A-And wants to merge 38 commits into
masterfrom
StringLoadFix

Conversation

@A-And

@A-And A-And commented Aug 25, 2016 •

Copy link
Copy Markdown
Owner

No description provided.

jkotas and others added 30 commits August 23, 2016 06:26
This was a helper function meant to ease
the transition over to unified Type/TypeInfo's.
Now it's purpose has been served.
Get rid CastToType() helper in Reflection.Core
SG tool is not able to deal with duplicate SerializationException definition in CoreLib. Remote it for now until it is fixed.

[tfs-changeset: 1623722]
CR: JKotas

SemaphoreSlim and ConcurrentUnifier variations called Lock.Acquire directly, but then used Monitor.IsEntered to check whether the lock is held.  Fix the code to use Lock.IsAcquired instead of  Monitor.IsEntered.  Also remove dead copies of ConcurrentUnifier* files.

[tfs-changeset: 1623728]
Avoid unnecessary allocations in TextInfo.ChangeCase on Windows:

- ChangeCase(char, bool) allocates a temporary string from the source
char. Instead, pass the address of the source char to avoid the
intermediate string allocation.

- ChangeCase(string, bool) allocates a temporary char[] buffer, then
creates a new string from that buffer. Instead, use
string.FastAllocateString to avoid the intermediate buffer
allocation, which aligns with the Unix implementation in CoreCLR.
I'll leave the interop and constraint validator work
to their respective owners. It's low-pri work and
I don't want to keep guessing the correct behavior
there.
Wean Reflection.Core off the Extensibility types.
Remove CORERT ifdef around Math.Abs implementation and made the behavior match other .NET implementations

Fixes bug #247525

[tfs-changeset: 1623767]
An unnecessary intermediate char[] allocation can be avoided by calling
`new string(c, 1)` instead of `new string(new char[] { c })`.
Now we just have to make them work...
Finished Reflection surface area in N Corelib.
System\Threading\Tasks\DebugHelperRooter.cs was workaround for a bug that was fixed long time ago. Also fixed casing for future.cs while I was on it.

[tfs-changeset: 1623785]
CR: JKotas, SergeyK

*  Mark the SyncTable class with [EagerStaticClassConstruction] to avoid static constructor checks.  Construction ordering should be unimportant since we do not use Monitor.Enter during runtime initialization.
*  Remove the type check for the Lock type from Monitor.Enter code path.  The Lock type is internal and internal code must use Lock.Acquire instead.  Add a debug assert verifying the object is not of the Lock type.
*  Put the AggressiveInlining attribute on two performance-critical functions, which NUTC does not inline.  At least GetSyncEntryIndex is expected to be inlined; reported this issue to the NUTC team.
*  In ObjectHeader.GetSyncEntryIndex use a bit shift trick to save one of two branches.

With these changes uncontended lock performance in ProjectN becomes around 92% of CLR thick lock performance and 82% of CLR thin lock performance (assuming no cache misses for thick locks).

[tfs-changeset: 1623787]
Add section on how to file security bugs
…f available.

SGen will try to find types by simply looking for it in all of the loaded assemblies. This fails if we find the type twice (basically a bug in the FX, but those happen). This change modifies this code to try CCI as the last chance. We try to find a type forwarder for the affected type. If we do find it, we simply follow it, since that will pick the right assembly (and thus the right version of the type).

Also revert the hack to work around the issue which is now fixed.

[tfs-changeset: 1623908]
These apis on System.Type are now functional.

    GetConstructors()
    GetEvents()
    GetFields()
    GetMembers()
    GetMethods()
    GetNestedTypes()
    GetProperties()

    GetConstructors(BindingFlags bindingAttr);
    GetEvents(BindingFlags bindingAttr);
    GetFields(BindingFlags bindingAttr);
    GetMembers(BindingFlags bindingAttr);
    GetMethods(BindingFlags bindingAttr);
    GetNestedTypes(BindingFlags bindingAttr);
    GetProperties(BindingFlags bindingAttr);

    GetEvent(string name);
    GetField(string name);
    GetMember(string name);
    GetMethod(string name);
    GetNestedType(string name);
    GetProperty(string name);

    GetEvent(string name, BindingFlags bindingAttr);
    GetField(string name, BindingFlags bindingAttr);
    GetMember(string name, BindingFlags bindingAttr);
    GetMethod(string name, BindingFlags bindingAttr);
    GetNestedType(string name, BindingFlags bindingAttr);
    GetProperty(string name, BindingFlags bindingAttr);

This was brought up by embedding a cut down version
of System.Reflection.TypeExtensions inside Reflection.Core.

These aren't the final implementations as there's perf
work to do, but these apis are used everywhere
(and assemblies that switch to the new contracts will
be rediverted to them whether want to be or not)
so we need to get them up and running to keep things
flowing.
Initial bringup for Type.GetX() members.
Use handleMultiplier in JitInterface ObjectToHandle instead of a literal
value to match the implementation of HandleToObject incase we ever make
the multiplier architecture specific.
Gee, I don't think we have enough apis to do this - should
we propose a few more?

Anyhow, this was done by moving the CustomAttributeExtensions
class from System.Reflection.Extensions.dll into Corelib.

We also needed to move CustomAttributeInstantiator
from S.P.R.Execution to Corelib (with a typeforwarder.)

Though CustomAttributeExtensions is supposed to be the
"bandaid" api, it actually has the nicest apis so now
it gets to be near the bottom of the stack (with
XInfo.CustomAttributes being the lowest-level primitive.)

Everything else is legacy api that we threw out in
.Net Core.
atsushikan and others added 8 commits August 24, 2016 15:50
Bring up the apis to retrieve custom attributes.
…ith the rest of the .Net Native toolchain.

[tfs-changeset: 1624133]
Port dotnet/coreclr#6907 from CoreCLR.

Remove EncodingCache and cache UTF32BE in a static field.
Double quotes were not getting escaped and causing CPP codegen to crash
@A-And A-And closed this Aug 25, 2016
A-And added a commit that referenced this pull request Nov 4, 2017
A-And added a commit that referenced this pull request Jan 30, 2018
A-And pushed a commit that referenced this pull request Aug 21, 2018
The issue is that the RhpRethrow stubs do not initialize the values of m_kind for the ExInfo objects they allocate on stack. Depending on the kind of garbage that gets assigned to m_kind, the stack iterator either takes the code path of reporting the gcroots of the RhpRethrow callsite, or takes the code path with the RemapHardwareFaultToGCSafePoint (if m_kind ends up getting a HW exception flag).

The piece of code that initializes the m_kind field of the ExInfo object on rethrows is in ExceptionHandling.cs, and there’s a window of opportunity where GC collection can happen before m_kind gets initialized correctly.

The bug needs the following conditions to occur:
    1) Garbage value in ExInfo.m_kind before initialization causes the stack iterator to take one code path, then after initialization take the other code path.
    2) GC collection happens in the middle, before m_kind gets properly initialized
    3) Gc roots reported in each of the 2 different code paths are different
    4) The GC collection in step #2 causes a relocation of a reference object of interest.

The fix is to just initialize the field to something deterministic that makes sense (zero in that case). This would cause the stack iterator to use the gcroots reporting of the RhpRethrow callsite, until the field is initialized to a more meaningful value (ex: in case of a rethrow of a HW exception) where we would apply the correct algorithm to determine a more correct gcroots reporting point to use based on where execution is headed (ex: use the gcroots reporting point of a finally block if the rethrow is for a HW exception, and in a catch block)

[tfs-changeset: 1709684]
A-And pushed a commit that referenced this pull request Oct 3, 2018
The ProjectN compiler never finishes compiling an app from an external use. The issue turns out to be due to the debug recording generation for a huge generic expansion. There are actually two problems:

1. The generic complexity computation is improper for the huge generic expansion in the failing case. The complexity computed was 0 and the compiler didn’t know it’s huge.

2. We are missing the check against the generic complexity in some places where UDT debug records are prepared.

Fixing #1 at this point is tricky since it may cause wide asm diffs where normal calls become USG calls.

Fixing #2 means the UDT types in the debug$T section for huge generic instantiations will fall back to USG or canonical records, so will the debug$S records for associated static fields. The debug$T change should only affect native debugging. The debug$S change can affect managed debugging but only for huge generic instantiations.

We've decided #2 is probably the less risky way to unblock the user in the next release and it's fixed by this change for both ProjectN and ProjectX.

[tfs-changeset: 1711506]
A-And pushed a commit that referenced this pull request Oct 3, 2018
* Fix ServiceController name population perf

* Split tests

* Remove dead field

* Remove new use of DangerousGetHandle

* SafeHandle all the things!

* VSB #1

* VSB #2

* Fix GLE

* Initialize machineName in ctor

* Test for empty name ex

* Null names

* Inadvertent edit

* Unix build

* Move interop into class

* Reverse SafeHandle for HAllocGlobal

* Fix tests

* Disable test for NETFX

* CR feedback

* Pattern matching on VSB

* Direct call

* typo

Signed-off-by: dotnet-bot <[email protected]>
A-And pushed a commit that referenced this pull request Nov 12, 2018
In this part I have mechanically moved parts of CorInfoImpl
to be forked to both CorInfoImpl.RyuJit and CorInfoImpl.ReadyToRun.
I decided not to move getFieldInfo for now as it's a lengthy
method and right now I'm only changing one line in it so that
conditional compilation should be sufficient. We can fork it
later if the changes become more pronounced e.g. due to the
differences in thread static bases.

The full list of methods I'm moving in this change is as follows:

(*) ComputeLookup
(*) getReadyToRunHelper
(*) getReadyToRunDelegateCtorHelper
(*) GetHelperFtnUncached
(*) getFunctionEntryPoint
(*) constructStringLiteral

Apart from the mechanical move I have made a few other minor
changes:

1) I have changed the hard-coded CORINFO_RUNTIME_ABI to a
symbolic constant that is defined in CII.RJ and CII.RTR. In
this one simple case I have already "executed" the split
by putting the appropriate constant into each file, otherwise
I left the moved methods unchanged for now.

2) I have made one additional change I overlooked in my
previous cleanup change: I modified getHelperFtn by adding
optional support for indirection cells that are used for
the helpers in R2R.

As mentioned above, for now I assume that I'll deal with the
differences in getCallInfo and getFieldInfo using #ifdef
READYTORUN.

Thanks

Tomas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants