Граф коммитов

645 Коммитов

Автор SHA1 Сообщение Дата
Tanner Gooding 1deaab5335 Update the repo to support VS2019 and to use C# 8.0 (#7015)
* Updating the build scripts to support VS2019

* Updating LangVersion to 8.0

* Adding some notes about VS2019 support to prerequisites-for-building.md

* Setting UseSharedCompilation=true and BuildingNETCoreAppVertical=true

* Use _VSCOMNTOOLS and workaround some BuildTools test.target checks

* Reverting the build-tools version and adding logic to restore the appropriate RoslynToolset
2019-02-15 10:45:27 -08:00
yowl c404dd1cbb Wasm: Enable field reflection (#7022)
Fixes #6944  

This change enables reflection on fields and in doing so fixes some gaps in the `ExternalReferencesTableNode` which fixes reflecting on some types that were not previously caught in the tests.
2019-02-15 10:02:31 +01:00
Jan Kotas 04fb46f43a Pin CoreRT OS modules in memory
CoreRT is not designed to be unloadable. Unloading modules before process shutdown leads to crashes and memory leaks.

Fixes #6993
2019-02-12 20:18:37 -08:00
Jan Kotas 4b865e6c59 Disable outdated CoreFX test 2019-02-12 18:35:43 -08:00
Tomáš Rylek 175e1e24ef
Exclude System.Runtime.Windows.Runtime[.UI.Xaml] from /r2rframework (#7009)
Based on Simon's advice I have excluded the above two assemblies
from CPAOT compilation as part of the CoreCLR framework.

Thanks

Tomas
2019-02-12 21:37:47 +01:00
Jan Kotas ea667b0b5c Implement LPUTF8Str string marshaling (#6960)
Fixes #6945
2019-02-06 11:44:43 +01:00
Michal Strehovský e41980be48
Change reflection defaults (#6820) 2019-02-06 10:59:58 +01:00
Jan Kotas 921314b2a2 Disable outdated test 2019-02-01 17:43:56 -08:00
Tomáš Rylek 5805d50003
Support for LDVIRTFTN on GVM's requiring instantiating stubs (#6906)
I found out that one bucket of the remaining CoreCLR CPAOT failures
is caused by missing support for instantiating stubs. We must emit
instantiating stubs whenever we hit LDVIRTFTN on a generic method,
otherwise JIT crashes with an assertion failure.

This case was already supposed to be taken care of by means of the
DynamicHelperCell representing the instantiating stub but
the implementation was incomplete. This change properly wires up
the instantiation stub logic and fixes various transitive issues
it uncovered.

Most notably this involved fixing the calls to DynamicHelperCell
to pass around the exact method, rooting the canonical method for
compilation when emitting an instantiating stub and fixing method
fixup signature formatting to include the instantiating & unboxing
stub flag, otherwise we were hitting a spurious assertion failure
regarding output symbol duplicates in the CPAOT object emitter.

Thanks

Tomas
2019-01-30 23:36:22 +01:00
Filip Navara 77ab5dabbd Update CoreFx to preview.19078.2 (master) (#6909)
* Add test exclusions.
2019-01-28 16:53:32 -08:00
Jan Kotas 544ed7fbf8
Disable bad CoreCLR test (#6901)
The test makes an assumption that objects are finalized in a specific order. It is not a safe assumption to make.
2019-01-26 17:57:39 -08:00
Tomáš Rylek 67895ecaee Fix catch clauses referring to a generic method argument (#6895)
* Fix catch clauses referring to a generic method argument

Scrutinizing the CoreCLR Pri#1 results I found a large bucket of
failures caused by mismatched catch clauses for generic exception
types. With tons of help from Jan Vorlicek I tracked this down to
a subtle difference in getMethodInfo flags. I have added one of
the previously failing Pri#1 tests to the CPAOT trivial unit test
suite.

* Set up the method flags unconditionally per JanK's PR feedback

I have audited the corresponding Crossgen code and I must admit
Jan Kotas is right as always - the extra method flags should be set
no matter whether the R2R build mode is active.
2019-01-26 10:23:29 -08:00
Simon Nattress 6c7c6fc195 Support for loading virtual delegates
Callsites that load a virtual method delegate AV in the JIT due to `getCallInfo` returning a stub call kind instead of virtual call kind, which the JIT isn't expecting. Fix `getCallInfo` to behave like CoreCLR's Crossgen.

Tweak the control flow of 'getCallInfo' to more closely resemble what Crossgen does. This makes things easier to reason about since the logic in `getCallInfo` is complicated.

MethodWithToken is now used as a dictionary key and needs implementations for `Equals` and `GetHashCode`

Switch GVMs to use virtual entrypoint to match CoreCLR. With the test case I added to ReadyToRunUnit, the runtime would AV returning the value from the GVM when using regular method entry.

Remove the string constructor special casing in getCallinfo - it was for the CoreRT runtime.
2019-01-25 10:32:31 -08:00
Tomáš Rylek 7834cd7223
Basic infra support for running local CPAOT GC stress tests (#6874)
* Basic infra support for running local CPAOT GC stress tests

This change basically introduces a new option /gcstresslevel
in tests\runtest.cmd akin to a similar option in the CoreCLR-specific
script. I have also bumped up the timeouts to 1 hour as CPAOT
Top200 test suite is currently timing out in ILC compilation of
1~2 tests (typically the bigvtbl tests).

Thanks

Tomas

* Improve comment on /gcstresslevel to clarify it's specific to CPAOT

* Cleanup based on Michal's PR feedback

I have modified the change along Michal's suggestions. I have
removed the explicit setting of environment variables in the
tests\runtest.cmd script and instead I just added logic for forwarding
the gcstresslevel flag. For now I have kept the timeout constant
as an internal detail of the inner runtest script for CoreCLR.

At this moment I haven't made any changes to the build_and_run_test
script; for some reason it didn't work in gcstress mode even before
with the environment variables. I'm going to try to investigate whether
we might be able to get rid of this duality and use the same script
for building CoreCLR CPAOT tests in both scenarios.

Thanks

Tomas
2019-01-24 23:50:37 +01:00
Tomas Rylek c5601bf8b8 Cleanup based on Michal's PR feedback
I have modified the change along Michal's suggestions. I have
removed the explicit setting of environment variables in the
tests\runtest.cmd script and instead I just added logic for forwarding
the gcstresslevel flag. For now I have kept the timeout constant
as an internal detail of the inner runtest script for CoreCLR.

At this moment I haven't made any changes to the build_and_run_test
script; for some reason it didn't work in gcstress mode even before
with the environment variables. I'm going to try to investigate whether
we might be able to get rid of this duality and use the same script
for building CoreCLR CPAOT tests in both scenarios.

Thanks

Tomas
2019-01-24 21:12:27 +01:00
Tomáš Rylek 5346e8d329
Generic lookup fixes (#6798)
1) Add new form of generic lookup for generic non-GC static base.

2) Fix previously missing generic lookup for fields.

2) Fix treatment of generic fields according to CoreCLR.

Thanks

Tomas
2019-01-24 14:32:55 +01:00
Tomas Rylek 06b363f19a Improve comment on /gcstresslevel to clarify it's specific to CPAOT 2019-01-24 10:26:03 +01:00
Tomas Rylek 6e4bc2340e Basic infra support for running local CPAOT GC stress tests
This change basically introduces a new option /gcstresslevel
in tests\runtest.cmd akin to a similar option in the CoreCLR-specific
script. I have also bumped up the timeouts to 1 hour as CPAOT
Top200 test suite is currently timing out in ILC compilation of
1~2 tests (typically the bigvtbl tests).

Thanks

Tomas
2019-01-23 23:38:05 +01:00
Jan Kotas fa416250cb Fix reverse PInvoke UnmanagedType.LPArray+SizeParamIndex marshaling (#6858)
Fixes #6852
2019-01-21 10:33:46 +01:00
yowl 5b103fba85 WASM: Enable reflection for types (#6800) 2019-01-18 09:36:39 +01:00
Tomáš Rylek b34583dc66
CPAOT support for RVA-backed static fields (#6788)
This change adds support for the helper
CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE and fixes RVA field
management. In contrast to Crossgen which selectively copies over
parts of the MSIL file (including the RVA field data), we simply
point the RVA field address to the pre-existing data block in the
MSIL file embedded in the R2R image.

To achieve this goal I had to slightly generalize the section
builder by adding new support for "section start nodes" - symbol
nodes representing the beginning of each PE section. In case of
sections copied from the original MSIL executable, the section
start nodes point at the "original" MSIL section content.

Using this construct I was able to introduce a new node RVAFieldNode
which represents a given RVA field as an offset relative to one
of the section start symbols. Upon codegen, the RVAFieldNode
emits a relocatable pointer-sized record in the R/W data section
which points at the beginning of the RVA field data in the MSIL.

I have also ported JanK's RVA unit test to our base CPAOT test suite.
2019-01-17 22:36:34 +01:00
Jan Kotas ee89a32c63 Disable invalid tests 2019-01-14 18:37:59 -08:00
Koundinya Veluri 110868358d Fix a thread pool deadlock issue (#6822)
Fixes https://github.com/dotnet/corert/issues/6780:
- `ShouldStopProcessingWorkNow` was checking the count of existing threads and decrementing the count of processing threads. Due to differences from CoreCLR, the condition needs to be different. The effect was that when hill climbing decides to crease the thread count goal, `ShouldStop...` stops all threads that were processing work if there are enough existing threads, and even though there are several thread requests, the now-all-waiting threads are not released to process more work, leading to deadlock. The condition in `ShouldAdjustMaxWorkersActive` was also incorrect, fixed both.
- Fixed a few other small things that I saw
2019-01-14 16:50:06 -08:00
Michal Strehovský 7e58a6c0fc
Fix IL scanning of unboxing thunks on byref-like generic types (#6816)
Fixes a compilation failure when compiling ASP.NET with `<RootAllApplicationAssemblies>true</RootAllApplicationAssemblies>`.

The fix is to mirror the dependency that the normal `MethodCodeNode` has for special unboxing thunks.
2019-01-12 19:59:51 +01:00
yowl ef7c9e6c32 wasm: create threadstatics using GetThreadStaticBaseForType (#6769)
Previously the support for `[ThreadStatic]` was incomplete.  This change adds some more tests (the last 3 of which fail prior to these changes).  Fixes #6733 - I've included a call to `Thread.Sleep` to test that the assert is no longer hit.  The sleep time is short so as not to affect the CI, but if its changed to something noticeable, like 10s, it can be seen to take effect.  

Also included is a small comment typo.
2019-01-11 18:01:56 +01:00
Konstantin Baladurin bf484d34ef [CppCodeGen] Enable reflection support (#6700)
* [CppCodeGen] Emit reflection metadata

* [CppCodeGen] Enable Reflection test

* [CppCodeGen] Add reference to constructed type in ImportLdToken

This patch fixes attribute reflection tests that fails due to
missing type metadata.

* [CppCodeGen] Use double indirection for gc statics as runtime expects

* [CppCodeGen] Emit header for nodes as runtime expects

* [CppCodeGen] Fix reloc emitting

We should take into account delta for reloc node

* [CppCodeGen] Fix boxing/unboxing

As we use double for float and int32_t for sbyte and int16 we should
use exact type for boxing/unboxing otherwise we will get incorrect
results.

This patch fixes float box/unbox issues in reflection tests

* [CppCodeGen] Enable generics reflection tests
2019-01-10 13:46:40 -08:00
Konstantin Baladurin 2b0165df59 [CppCodeGen] Enable Delegates tests (#6735)
* [CppCodeGen] Fix ldftn import

ImportLdFtn should generate code that obtains address of actual method not
unboxing stub. Unboxing stubs are used in case of delegate construction.

* [CppCodeGen] Fix ldftn importing in case of virual method of sealed class

* [CppCodeGen] Fix call importing in case of delegate instantiation

Remove unnecessary update of the first argument (firstParameter) of the
delegate initialization function.

* [CppCodeGen] Enable Delegates tests
2019-01-10 13:45:48 -08:00
Tomáš Rylek 57ad558d17
Fix generic lookup cells to be per method context (#6791)
1) Clean up generic lookup tests so that the TH->RTTH helper is
only called from a single method (GetTypeName). This is no longer
strictly necessary as Crossgen started to support the helper
but I believe it to be good for general hygiene.

2) Minor improvements in the R2R test harness to display ordered
sets of whitelisted vs. non-whitelisted jitted methods.

3) It seems to me that GenericLookupSignature should always pass
around the instantiating stub flag as the exact purpose of the
signature is to cater for shared methods with the extra
instantiation argument.

4) Based on JanK's clarification I have fixed the CPAOT compiler
to emit separate generic lookup cells for each context method.

Thanks

Tomas
2019-01-09 23:25:50 +01:00
Filip Navara 06486ca5eb Remove dummy globalization implementation. (#6756) 2019-01-02 05:00:14 -10:00
Jan Kotas 54c61a0f70 Disable outdated tests 2018-12-21 19:27:54 -08:00
Michal Strehovský e7e0c917f2
Do not use R2R helpers for casting and allocation (#6688)
This avoids generation of some of the helpers in favor of RyuJIT generating code that does what the helper would do. While this causes an about 1% regression in size of the generated executable, the benefit is better code density and fewer calls.
2018-12-18 18:02:45 +01:00
Simon Nattress 2dadfbbd2e
Improvements to R2R Test Harness (#6653)
To support multi-core testing, associate the test process's PID with the ETW filter so that only assemblies loaded by the runtime the harness started are considered.

Emit the assembly name for methods that are jitted to allow grouping of methods by their assembly.

Add a new parameter, `--include` which configures the ETW filter to include all assemblies in a given folder, instead of having to specify a large number of assemblies individually.

Bug fixes around path casing causing events to be dropped.
2018-12-07 16:06:42 -08:00
Jan Kotas 0a37ad7e98
Add native library sample (#6645)
* fix nit in StaticLibrary test (#4987)
* add README documentation on building native libraries (#4987)
* Move documentation for building native libraries to samples
* Fix static library build
* Add sources for NativeLibrary sample
2018-12-04 12:43:01 -08:00
Tomáš Rylek 45c45fd04f
Loose port of CoreCLR changes #7895 and #9138 to CPAOT (#6631)
Based on Michal's suggestion I have implemented an approximate
port of the two above CoreCLR changes. These changes improve
performance of GetHashCode on Enum types by avoiding boxing
thanks to transforming the calls to the equivalent method calls
on their underlying types.

My proposed compensation for #9138 is in the signature builder
- we just check whether the MemberRef token we received has
the proper owning type and, when it doesn't, we encode it
explicitly in the signature.

I have created a simple unit test that actually doesn't do much
but I verified by submitting it to R2RDump that I indeed see
direct calls to byte.GetHashCode and int.GetHashCode in the
produced machine code.

Thanks

Tomas
2018-12-04 01:04:53 +01:00
Tomáš Rylek bbb4756e29
Skip native libraries in CPAOT build of CoreCLR framework (#6630)
Currently there's just one native library that gets picked up
by the above wildcard spec - Microsoft.DiaSymReader.Native.amd64 -
so I have excluded it explicitly in the script as I don't expect
this list of exclusions to fluctuate too wildly. We would need
something smarter if we wanted to be able to automatically
orchestrate builds of complete folders (e.g. a UWP app).

Thanks

Tomas
2018-11-30 23:12:08 +01:00
yowl 0e2ba52efa wasm: Fix callback to NativeCallable methods (#6592)
* add transition code
2018-11-26 18:10:54 -08:00
Tomáš Rylek 467715b94e
Add two xunit packages to runtime.depproj to unblock about 90 tests (#6607)
* Add two xunit packages to runtime.depproj to unblock about 90 tests

This change adds the packages "xunit.core" and "xunit.performance.core"
required by some CoreCLR tests to external test dependencies. I have
copied the clauses from external.depproj in CoreCLR and their versions
from dependency.props. This change reduces the number of failures from
346 to 254.

Thanks

Tomas
2018-11-23 14:10:31 +01:00
Simon Nattress cf46e303b1 Use netcore3.0 CoreCLR for R2R testing (#6603)
Replace use of 2.1 runtime with a recent version from master targetting netcoreapp3.0. This version now includes System.Runtime.Intrinsics, which was previously named System.Runtime.Intrinsics.Experimental (and lived in a separate Nuget package) meaning the test drop we used couldn't bind against it.

runtest.cmd /coreclr all /mode readytorun fail rate improved from 489 -> 346 (2001/2347 or 85% pass rate).
2018-11-21 23:13:08 +01:00
Tomáš Rylek eecc9f944c
Further CPAOT fixes for release mode support (#6590)
1) Pass the proper configuration and architecture to msbuild when
restoring XUnitTooling so that it gets restored into the proper
folder - this fixes building the CoreCLR tests in release mode.

2) Set the 'Optimize' property for Microsoft.NetCore.Native.targets
in CoreCLR test and framework assembly build to actually make a
difference w.r.t. release codegen by specifying '-O' to ILC.

3) Update comments in the R2R test scripts to indicate we now
support per-configuration output folders.

Thanks

Tomas

P.S. Top200 tests have approximately the same pass rate in
debug and release mode (debug reports 6~8 errors, release 8~9 errors
in my local testing).

Framework assembly compilation in release mode has somewhat worse
pass rate, 110 out of the 152 assemblies build amounting to about
72% pass rate.
2018-11-18 23:06:10 +01:00
Tomáš Rylek 8dc11b8791
Enable R2R tests in release mode (#6572)
* Enable R2R tests in release mode

This change enables R2R tests in release mode. It seems to me that
previously the tests were disabled in release mode because they
were crashing the CPAOT compiler due to a bug I made months ago -
apparently I put the CanInline method in the wrong class so it got
never exercised. In release mode, when inlining is active, this bug
ended up inlining bits of framework into the test app that we
couldn't express with the available ref tokens.

Thanks

Tomas
2018-11-15 09:15:00 +01:00
Andon Andonov 60bda48e6a
R2R Test Release Build Fix (#6573)
* Update MSBuild properties

* Revert "Disable building tests in official builds (#6565)"

This reverts commit 8aab18c5a5.

* Revert "Fix Linux pipeline (#6566)"

This reverts commit 23be7aa294.
2018-11-13 14:44:12 -08:00
Jan Kotas 81c5d4191b Disabled outdated tests 2018-11-12 21:27:58 -08:00
Michal Strehovský 475110e853
Include custom attributes on properties and events (#6559)
We were generating the metadata, but didn't make sure the custom attributes can be reflection-activated.

Fixes #6554.
2018-11-12 17:00:04 +01:00
Michal Strehovský 5fbe59fc40 Add test for RVA static fields (#6549) 2018-11-09 14:09:56 -08:00
Michal Strehovský d9d1c0901b Disable outdated tests 2018-11-08 09:50:26 -08:00
Tomáš Rylek 93cc8811fe
Exclude code dealing with System.Numeric.Vector`1 from CPAOT compilation (#6527)
I have added a new field layout algorithm for Vector<T> and checks
to abort method compilation when it tries to access this information.
2018-11-08 10:23:39 +01:00
Tomáš Rylek 93ee893418
Bump up default CPAOT test timeout to 2 minutes (#6537)
Early on in CPAOT bring-up I asked Simon to set a short timeout
for test executions as many tests were timing out due to compiler
bugs. This is no longer the case - we only have a handful of
remaining failing tests and some of them are now suffering from
the short timeout. For now I have bumped up the timeout from 30
seconds to 2 minutes and that seems to be fixing all Top200 tests
that used to fail with the -103 exit code (about 5 tests overall).

Thanks

Tomas
2018-11-08 10:20:01 +01:00
yowl 30f2473564 Change the load expression to extend to double when stored typed is float and the requested a double (#6503)
* Change the load expression to extend to double when the type is float and the TypeKind is double.

This extend floats to doubles when doing comparisons such as ceq.  Previously it was bit stuffing the float into a double.

Casing of method name.
Add test to load double const.
2018-11-06 14:34:19 -08:00
Tomáš Rylek 1bb85b989d
Initial support for running tests against CPAOT-built framework (#6530)
* Initial support for running tests against CPAOT-built framework

The pass rate is not super high right now, I'm seeing 109 failing
tests or about 13% pass rate but the main point is that the pass
rate is not zero, we can build on that.

In the AVAILABLE_TYPES R2R node, I added provisions for emitting
exported types. This was one of the issues we were hitting - the
partial facade System.Runtime wasn't properly exporting its type
forwards.

In the PE builder, I dropped copying of all directories per JanK's
suggestion, the latest impulse being a mismatch between the debug
directory and the CPAOT-compiled executable.

* Modify available types to be emitted based on metadata

I have applied JanK's suggestion to change AVAILABLE_TYPES
to be generated based on metadata rather than based on the results
of dependency analysis.

* Addressed Michal's PR feedback

1) Unified DefinedTypeInfo and ExportedTypeInfo to use a common
generic class TypeInfo<THandle> per Michal's suggestion.

2) Fixed exported type traversal to cater for nested forwards.

3) Added a tiny fix I noticed by comparing CPAOT and Crossgen
code - querying method dictionary in a generic lookup should use
the "METHOD_HANDLE", not "METHOD_DICTIONARY" fixup. This increases
the pass rate of Top200 against CPAOT-built framework to about
82% (22 failures out of 126 tests).

Thanks

Tomas
2018-11-06 18:34:12 +01:00
Morgan Brown e0de8c6d6f Raise the timeout in the WebAssembly test to account for slow Firefox first starts on CI machines (#6532) 2018-11-05 15:32:29 -08:00
Tomas Rylek ed44ec15ba Merge branch 'master' of https://github.com/dotnet/corert into MasterRI1031 2018-11-01 01:47:11 +01:00
yowl 6dff8deefa fix apparent typo when retrieving a 64 bit value (#6507)
* fix apparent typo when retrieving a 64 bit value

shift 64 bit ints using 64bit operand
2018-10-31 16:02:36 -07:00
Konstantin Baladurin 698a30e0e4 Partially enable Generics test for CppCodeGen 2018-10-29 15:23:49 +01:00
Jan Kotas 6be7bf6d9e Disabled outdated tests 2018-10-26 22:19:07 -07:00
Jan Kotas 0fddc62a91 Disable outdates StringBuilder test 2018-10-25 11:30:07 -07:00
Tomáš Rylek 78deb182cd
Generic lookup support (#6449)
* Generic lookup support

This change introduces CPAOT support for all three forms of generic
lookup (THISOBJ, CLASSPARAM, METHODPARAM) and the corresponding new
GenericLookupSignature. I have added several unit tests exercising
the new functionality.

* Further fixes for generic lookup support

My initial generic lookup change only dealt with type-based lookup.
During experimentation with framework compilation I hit the need
to also implement method-based generic lookups. This change mostly
expands the initial implementation to also cater for method lookups
by expanding the RuntimeDeterminedTypeHelper and bits of other code
as appropriate.

I have also managed to get a bit more insight into emitting
signatures for instantited methods. CoreCLR runtime doesn't support
direct consumption of mdtMethodSpec tokens in method signatures -
instantiation type arguments for generic methods must always be
explicitly specified in the signature; it however does support
direct consumption of an instantiated OwningType via a mdtTypeSpec.

* Always emit signatures in instance entrypoint table using Def tokens

I found out that method signatures used to encode methods in the
INSTANCE_METHOD_ENTRYPOINTS R2R header table cannot use MemberRef
encoding for methods on instantiated types as it hits an assertion
failure in the CoreCLR runtime in SigMatchesMethodDesc.
This change introduces a boolean parameter the table can use to
specify it forbids ref-based encoding.

* Version resiliency fix - partial resurrection of tokens

During our today meeting JanK, Michal and David finally made me
comprehend the token problem. Propagation of tokens from JIT to
the managed compiler is indeed necessary due to a corner case
regarding version resiliency, however it's thankfully limited to
methods outside of the version bubble.

The problem is as follows: assume we have a "Program" and a
"Library" outside of its version bubble. At IL compilation time
of "Program" using Roslyn, the "Library" looks as follows:

<code>
class Base { void Method(); };
class Derived : Base { void Method(); }
</code>

When "Program" calls "Base.Method()." vs "Derived.Method()",
the appropriate MemberRef tokens representing
"[Library]Base.Method()" and "[Library]Derived.Method()"
get stored into the MSIL.

In the second step, prior to CPAOT compilation, we replace the
"Library" with an updated version where the Method() only exists
in the Base class (this is supposed to be a safe change w.r.t.
version resiliency):

<code>
class Base { void Method(); };
class Derived : Base { }
</code>

When we now run the CPAOT compiler, a lossy transformation takes
place - both IL tokens, "[Library]Base.Method()" and
"[Library]Derived.Method()" get squashed to the same MethodDesc
"[Library]Base.Method()" (because that's where the compiler sees
the method at CPAOT time).

Without explicit token propagation i.e. with just the reverse
synthetic token lookup, we end up encoding one of the methods
(an arbitrary one based on which one we saw last) into both
indirection cell signatures.

This breaks when later, at runtime, someone puts back the original
"Library" version where the Method() sits in both classes
because both R2R signatures contain the same reference so that
the runtime has no way of knowing they should be in fact separate.

As the problem is obviously limited to methods outside of the
version bubble, we can thankfully keep most of the ModuleTokenResolver
and related logic as for types and fields it's completely fine,
we just need to revive a bit of logic propagating tokens from JIT
for methods.

Amusingly enough it turns out that overall it mostly simplifies
the code rather than making it more complex. The gist of my change
regards splitting "ExternalMethodImport" to two classes,
"ExternalMethodImport" and "LocalMethodImport".

This split has several nice properties - for LocalMethodImport,
we always have a _localMethod available but we don't need to
maintain constrained type information - within the version bubble
we can look up all tokens using the ECMA objects so we don't really
need the constrained calls. The various R2R header tables
(method & instance entrypoints, exception info) also mostly need
to only emit local methods.

ExternalMethodImport's newly include the method token information,
propagating it to the method signature encoder - this is necessary
as we no longer record method token mapping in ModuleTokenResolver
which can now only resolve methods within the version bubble.

The change passes the basic R2R unit tests and seems to have a
comparable pass rate w.r.t. CoreCLR Pri#0 tests. I have yet to verify
that it indeed fixes the above described repro case but in general
I believe the change is sound.

The only problem I hit is in the method getFunctionEntryPoint
where the token is not readily available, for now I highlighted it
with a TODO comment; I'm not completely clear on when JIT uses this
method; if it turns out this can be used for cross-bubble calls,
we'll likely need to fix JIT to pass the appropriate token information
to the managed code.

Thanks

Tomas
2018-10-25 09:42:01 +02:00
Tomas Rylek 3edccfd5c9 Merge branch 'master' of https://github.com/dotnet/corert into FI-10-14 2018-10-14 18:03:18 -07:00
Tomáš Rylek d867bba80c
Cross-module signatures, non-compilable methods and instance hashtable fixes (#6428)
Cross-module signature fixes, non-compilable method fixes and various fixes for generic methods

This change fixes the build of the trivial ASP.NET app. The problem
is that, once we start decoding method / type signatures involving
multiple metadata readers, the metadata reader by itself is not
sufficient to decode a handle into a typesystem object, we need
the EcmaModule objects for this purpose. In this change I have added
another lookup table to CompilerTypeSystemContext that can
back-resolve metadata readers to their respective modules.

This change contains my previous non-compilable method fix slightly
polished based on Michal's PR feedback and a bunch of fixes for
generic methods, most notably fixing previously missing emission
of the instance entrypoint header table. I have ported CoreCLR
implementation of version-resilient hashcodes so that the instance
methods are properly discoverable at runtime.

In the process I have slightly cleaned up the implementation of
the entrypoint tables: as these are now "summary nodes", no longer
state machines accumulating the methods during compilation, I have
removed the public "state machine" methods (Add). I have also moved
GetFixupBlob to MethodWithGCInfo so that it can be used from both
entrypoint tables.

I have included my recent fix for missing FrameInfos on x86 in a
slightly improved form - instead of forking all the code asking for
FrameInfos, I have modified its initialization so that, on x86,
where CorInfoImpl passes null, I generate a single-element
pseudo-frame info that lets me unify most of the related code.

Based on investigation of Michal's unit test I have also fixed
several places in method signature emission, token harvesting
and canonicalization. I have added Michal's sample as a new R2R
unit test.

I have also fixed a bug that omitted the constrained type and return type
in method signature formatting so that two external method imports
with different constrained types ended up incorrectly reported as
duplicates.

As Michal pointed out, SignatureContext no longer needs to implement
ISignatureTypeProvider so I removed it. I am not yet directly replacing
SignatureContext with ModuleTokenProvider as I believe their split
may be still useful for the envisioned merged multi-file R2R build.

In my mental view ModuleTokenProvider handles the synthetic token logic
and may ultimately become per input module whereas SignatureContext
semantically represents the [output] compilation module. I fully admit
my knowledge and design ideas in this area are still limited.

Based on Michal's PR feedback I have also switched TypesTableNode over
to use the same version-resilient hashcode calculation logic I implemented
while standing up the instance method table entrypoint R2R header table.
2018-10-11 17:56:25 -07:00
Michal Strehovský 74e5ed9e1d
Implement HandleRef marshalling (#6395)
Contributes to #2570.
2018-10-11 07:40:32 -07:00
Simon Nattress 2031a84d9a Simplify MSBuild command line
* Split the command line out and remove parameters we know aren't needed in R2R mode.
* Wipe the \native folder before compiling to clear out previous compilation attempts.
* Remove some logic that skips native assemblies I was using previously. It's not needed since System.*.dll and Microsoft.*.dll are all managed.
2018-10-10 11:31:22 -07:00
Simon Nattress f74770ef5c Compile CoreCLR framework assemblies
Add /r2rframework switch to runtest.cmd which runs the CPAOT compiler in
ready-to-run mode against the managed framework assemblies in CoreCLR.

I made a couple small bug fixes to unblock compilation of 30 framework
assemblies with code in them. There are also many small facade
assemblies with no code that we put a ready-to-run header in but don't
do anything interesting. Overall, currently, we produce ready-to-run
images for 84 / 214 assemblies.

The produced images are placed in bin\obj\<build>\CoreClrRuntime\native.
This folder also includes the .rsp file to compile specific assemblies
again for investigation.
2018-10-10 11:31:22 -07:00
yowl 7205ff91d5 wasm: fix element addressing for value type array indexing. Fixes #6412 (#6430)
* Use GetElementSize for value and non value types when creating element adresses

Create test for char[] indexing
2018-10-05 18:03:39 -07:00
Simon Nattress d9aecf842d Fix ETW harness name handling around generics
Generic type markers in the ETW events used by the ready-to-run harness messed up the name mangling. Don't consider any generic arguments as part of the name when formatting the method to remove namespaces so we don't mistake a period in the generic type for part of the method's type's namespace.
2018-10-04 10:42:58 -07:00
yowl 5bbe5d59f5 wasm: move function LlvmValueRef retrieval before shadow stack is setup with arguments, partial fix for #6330 (#6374)
* move function ref retrieval before shadow stack is setup with arguments
2018-10-02 16:08:02 -07:00
Simon Nattress 10eb1b0067 Compile against CoreCLR framework
In ready-to-run mode, use the CoreCLR shared framework implementation
assemblies to generate test R2R images instead of the AOT versions
currently used in standard RyuJit mode.

System.Object has a pointer field for the EEType in each object header
in the AOT implementation of System.Private.CoreLib. The CoreCLR
System.Object does not have this field, and instead the runtime adds an
implicit pointer field for the MethodTable. Handle this in the R2R
compiler with a custom layout algorithm for System.Object.

Adjust the test scripting to consume the CoreCLR framework.
Assert if we accidentally pass in the AOT System.Private.CoreLib in R2R
mode.

CoreCLR all tests pass rate improved by 21 tests to 1370/2347 passing
(58.4%).
2018-10-01 15:07:00 -07:00
Morgan Brown cd45c14793
Fix sealed vtable calls on Wasm (#6333)
* Fix calls on sealed vtables by disabling relative pointers for WebAssembly
2018-09-29 19:09:16 -07:00
Tomáš Rylek 1572ba14fb
Static placement fixes (#6363)
Static placement fixes

Our existing CPAOT implementation of statics
placement is incorrect as there's a difference between CoreCLR
and CoreRT in statics allocation algorithm - basically CoreRT
allocates statics per type whereas CoreCLR does that per module.
This change modifies the field layout algorithm to use a loose
managed rewrite of the CoreCLR logic. I have also included Michal's
addition to the ReadyToRunUnit test demonstrating this
behavior.

Thanks

Tomas
2018-09-27 23:46:02 +02:00
Michal Strehovský 82351cc766 Merge branch 'master' into r2r-merge 2018-09-25 14:20:55 +02:00
Tomáš Rylek bc456a0091
Fix test command-line arguments in the CoreCLR test runner script (#6361)
Fix test command-line arguments in the CoreCLR test runner script

Apparently some of the CoreCLR tests were failing with complaints
towards incorrect command-line syntax. I tried to go over the
archived source code for the System.CommandLine package but I have
found no trace of automated splitting of argument values. For this
reason I have adjusted the script to pass multiple --testargs
arguments in such case. I believe that at the end of the day it
simplified the script overall.

Thanks

Tomas
2018-09-24 20:38:50 +02:00
Michal Strehovský ac126222ac Fix reflection with necessary types
When I was testing #6366 in a mode we don't normally test (debug compiler with IL scanner enabled), I hit an assert around inconsistent reflection metadata for a Module type. Turns out we weren't tracking reflection on unconstructable types. Fixed that and added a test.
2018-09-24 16:26:10 +02:00
Simon Nattress 08e9736caf Add /NoCleanup switch to runtest.cmd
Prevent the CoreCLR test suite from cleaning up compiled artifacts and response files when /NoCleanup is pass to runtest.cmd.
2018-09-20 13:16:38 -07:00
Simon Nattress 8cd45b619a Use ReadyToRun harness in CoreCLR tests
* The ready-to-run harness includes time out logic to kill tests that get stuck. Use it to run CoreCLR tests since many tests get stuck in an infinite loop at the moment.
* Add an option to disable ETL tracing when using the harness. Instead, it just runs the app with `Process.Start()` and calls `WaitForExit()`. The CoreCLR tests are too noisy right now to run with ETL on.
* Make some build system changes so that the harness is run from pre-built binaries instead of using `dotnet run`. This is much faster and required for tests running in parallel. Using `dotnet run` on the same project in parallel hits file in use errors.
* Fix harness to allow multiple arguments passed to tests
* Properly kill the test process when it times out
* Reduce the timeout to 30 seconds. None of our tests, when running correctly, approach this timeout so it is still a conservative setting.
2018-09-17 16:49:02 -07:00
Tomáš Rylek 68c595f980
Fix exception handling info in R2R images (#6321)
* Fix exception handling info in R2R images

1) ReadyToRunObjectWriter support for "nested ObjectData" where a given node
can produce an enumeration of subordinate ObjectData items. This is used
to produce the EH info that comes from CorInfoImpl in form of ObjectData
blobs.

2) One other change in ReadyToRunObjectWriter is the newly added support
for modifying the PE header directories - this is needed to publish
the RUNTIME_FUNCTIONS R2R header table in the Exception Directory,
otherwise RtlLookupFunctionEntry doesn't work.

3) Fix the EH info itself in CorInfoImpl as CoreCLR runtime that we're
targeting with the R2R images uses a different encoding than CoreRT.

4) MethodGCInfoNode is created for each funclet and holds the index
of the corresponding FrameInfo which is used to emit the proper unwind
and GC info for each funclet.

5) RuntimeFunctionsTableNode - emit a separate RUNTIME_FUNCTION entry
for each funclet and emit the appropriate final sentinel entry.

6) ReadyToRunCodegenNodeFactory - new helpers, support for personality
routines, rooting exception lookup table.

* Deleted a bit of previously overlooked dead code from R2R object writer

* Minor extra cleanup in the R2R object writer

With the proposed changes, we no longer need to pass around
the SectionBuilder explicitly as we have it in a field.

* Additional cleanup based on Michal's feedback

I have refactored / simplified emission of the exception handling
info. The crucial observation is that, in CoreCLR, the EH info
is a dumb blob that doesn't contain any relocs. We can leverage
this information to simplify the emitter.

I have removed the logic for emitting subordinate ObjectData
nodes from the object writer and from ExceptionInfoLookupTableNode.
I have deleted SyntheticSymbolNode and instead I introduced
a primitive EHInfoNode that gets populated from the lookup table
in LayoutMethodsWithGCInfo.

In ReadyToRunObjectWriter I kept the previous move of object
emission data to the dedicated method EmitObjectData as I believe
it makes the method EmitPortableExecutable easier to read.

I found out MethodEHInfoNode was not used for anything - it was
a leftover from one of my earlier failed attempts to attack
EH info - so I deleted it.

In CorInfoImpl, I moved the EH info emitters into the forked files
CorInfoImpl.RyuJit / ReadyToRun as the EH info is completely
different for the two targeting runtimes.

* Additional MethodGCInfoNode cleanup

In this additional delta I simplified MethodGCInfoNode management.
I changed the logic so that there's just one MethodGCInfoNode per
method; apart from requiring fewer allocations, this let me
drop the delayed factory logic in MethodWithGCInfo.

* Removed obsolete comment

* Addressing Simon's PR feedback
2018-09-14 14:58:34 +02:00
Morgan Brown 296c7356f3
Fix constrained calls and marshaling (#6275)
Codegen fixes required to make Console.WriteLine work on WebAssembly (when combined with #5987 and a matching CoreFX build):

The 'this' pointer for reference types is a byref for constrained virtual calls and needs to be dereferenced.
Enable P/Invoke marshaling. This isn't easy to test directly, but we'll notice the effect as we try to use framework code that P/Invokes (in Console.WriteLine, there's SafeHandle marshaling).
2018-09-06 21:53:46 -07:00
Tanner Gooding 9ca75bb786 Disabling the failing CoreFX tests related to ToString for negative zero 2018-09-06 20:33:14 -07:00
Konstantin Baladurin 3c57906199 [Linux/armel] Fix tests building (#6285)
This patch fixes following msbuild error:

MSBUILD : error MSB1004: Specify the name of the target.
Switch: -target
2018-09-06 11:25:25 -07:00
Simon Nattress 569befaaff Enable thread static fields for r2r
Split the thread static field access in the Jit interface to sort fields into the four tables expected by CoreCLR.
2018-09-05 11:58:51 -07:00
Simon Nattress 8ca402c5a3 Merge branch 'master' into r2r 2018-09-05 11:57:39 -07:00
yowl 755f9d4193 WASM: Add intrinsic implementation for ByReference<T> ctor and fix the Value getter (#5987) 2018-08-31 01:11:12 -07:00
Simon Nattress 05abf70454 Add ready-to-run CoreCLR tests to CI
* Run CoreCLR tests that are known to pass in ready-to-run during CI
* Add a mechanism to easily collect the list of passing / failing tests for use in inclusion / exclusion lists.
2018-08-28 14:57:06 -07:00
Tomáš Rylek e3051b745e
Implementation of reverse type reference lookup (#6167)
* Implementation of reverse type reference lookup

Based on JanK's suggestion, I have implemented the basic logic
for reverse type reference lookup. I have demonstrated basic
functionality of this feature by adding two delegate tests involving
Action and Func<char, char>.

I also had to slightly refactor type signature emitter - my
initial implementation was heavily dependent on parsing an existing
metadata signature but in the resolution process we can hit synthetic
types that don't have such a metadata representation, most notably
for generics.

For this reason I believe we need custom recursive descent into the
type tree and this change includes the initial implementations. For
now I'm keeping the generic signature decoder as it's still used by
method signatures but my current thinking is that it will also become
unneeded at some point and we'll be better of with a custom
implementation matching our exact needs.

Thanks

Tomas

* Addressing part of PR feedback

I have refactored SignatureBuilder to use a big switch over the
TypeDesc.Category. This overall simplified things. I fixed several
signatures to stop emitting type signatures when only looking up
references as signature emission may be a relatively costly process.

I tried to add some provisions to increase robustness of the
reference resolution but for now I'm keeping the reference enumeration
as just hooking up resolveToken is not sufficient to provide a
sufficiently complete mapping from types to tokens.

Thanks

Tomas

* Incomplete changes for shared generic support

* Fix bug in X64 emitter

The MOV(register, register) instruction was implemented incorrectly.
The method GetRexPrefix assumes that the register specified as
parameter is the target, however we were using the other opcode
where the register is the source. I have fixed this inconsistency
and I added code comments to the individual REX values to improve
clarity.

Thanks

Tomas

* Improved support for interface dispatch and unboxing stubs

Based on debugging calls to Dispose on classes and valuetypes and
thanks to help from JanK I finally managed to make calls to dispose
work on both. The change mostly involves propagation of the
new unboxingStub flag, switching over to general MethodEntry
fixups that allow encoding the value of the flag and general
infrastructural plumbing in the R2RCG node factory.

Thanks

Tomas

* Some additional minor fixes for interface dispatch

I removed an apparently incorrect check I had put in CorInfoImpl
previously. I fixed a trivial typo in the DelayLoadHelperThunk.
With these changes I'm again passing all the previous tests
plus the new Dispose on class / struct tests demonstrating
initial vestiges of unboxing stub support. Generic enumeration
still doesn't work for some reason, I'll investigate that next.

Thanks

Tomas

* Removal of reverse lookup in favor of eager lookup

Based on Michal's suggestion I have replaced the reverse lookup
in ReadyToRunCodegenNodeFactory with eager lookup called from
CorInfoImpl.resolveToken. The current implementation seems to be
the minimum enough to compile the 22 trivial unit tests.

Thanks

Tomas

* Initial support for constrained type virtual method calls

Thanks to JanK's help I was finally able to put together
initial support for constrained method calls finally fixing
the call to List<string>.Enumerator.Dispose().

Thanks

Tomas

* Add unit tests for features unblocked by my previous commits

This mostly covers my recent contributions in the field of
unboxing stubs, constrained method calls and token lookup
improvements.

Thanks

Tomas

* Fix rebase conflict

* Addressing [most of] Michal's PR feedback

I have trivially applied the mechanical feedback (fixing the typo
lea -> mov in the X64Emitter comment, applying the good suggestion
to simplify register references by using the X64 namespace and
unifying the VALUETYPE / NULLABLE case in signature encoding.

For the remaining feedback, I'm trying to provide my rationale for
further discussion:

1) Why do we need the || READYTORUN part in CorInfoImpl around line
3100? To let us pass around call site names to interface dispatch
cells - as interface dispatch cells are per call site even though
they might reference the same interface method, we need some way
to distinguish their symbols as we validate symbol uniqueness to
maintain output consistency.

If you're fine with the concept and you're just suggesting there's
an easier way to encode this by means of preprocessor directives,
I don't see that, please enlighten me.

2) Stashing token information in CorInfoImpl - I think the big
problem is signature building where in general we need to dig
arbitrarily deep into composite signatures.

Based on how good your suggestion for using resolveToken seems
to be working, I'm starting to think that it might be easiest to
drop the token propagation from CorInfoImpl and just always
synthesize the tokens based on the pre-recorded information; it
might unify parts of the previously forked NodeFactory bits too.

Once we start mucking with multiple assemblies within a versioning
bubble, I think we have several possible ways to go. As I mentioned
in a comment to the previous Simon's PR, I believe that the
R2RCGNF class has already gotten too big and would merit splitting
into multipler parts.

One of these should be exactly this "token manager" and perhaps
separating it from the node factory into a class of its own might
address some of your concerns; I however still believe that in
general, CoreCLR signatures support reference module override
so that we should be able to use arbitrary token sources across
the entire versioning bubble for the purpose of referencing externals.

Thanks

Tomas

* Move token management logic into a separate class ModuleTokenResolver

In this mostly mechanical change I tried to address part of Michal's
PR feedback by moving the token resolution logic away from the
ReadyToRunCodegenNodeFactory into a separate class. While the change
is mostly mechanical, I believe it nicely demonstrates
the relationship between the two classes and possible future steps
regarding migration of the logic from one to the other. For now
the resolver naturally hangs off the factory, that can easily change
by it becoming a part of the CorInfoImpl.ReadyToRun class.

Thanks

Tomas

* Further propagation of ModuleTokenResolver

This change removes direct references to ReadyToRunCodegenNodeFactory
from those signatures that only needed it for token resolution.

Thanks

Tomas

* Remove unnecessary | READYTORUN in CorInfoImpl

Based on Michal's suggestion I'm removing the | READYTORUN clause
in the conditional directive producing call site name for
interface dispatch cells. I have double-checked that SUPPORT_JIT
is not defined in the project so that the condition is true.

Thanks

Tomas
2018-08-18 12:35:31 +02:00
Simon Nattress 81759cac12
Support readytorun mode for CoreCLR tests (#6232)
* Support readytorun mode for CoreCLR tests

Currently 226 / 1829 tests pass (12.4%) from the KnownGood subset.

* CR Feedback

Break out the two large command lines into a variable so echo and command run use the exact same command line. This prevents the classical problem where we forget to keep the echo in sync with the actually run command line.

Make comparisons case insensitive.
2018-08-17 11:12:14 -07:00
Amy b876a58164
Multi-module compilation (simple case) (#6160)
* Compile single input file specified in the compile option to single output file instead of multiple output files

* Parallelize multi-module with msbuild

* Fix missing binaries error

* Move BuildReadyToRunMultiModule to BuildIntegration folder

* Avoid using additional option moduleFilePaths

* Get multi-module to work without moduleFilePaths

* Fix error by not creating FullVTable

* Don't add EETypes to LibraryRootProvider for ReadyToRun

* Use ecmaTypes from compilationModule instead of eeTypeNode so AvailableTypes table has entries, get correct file extensions

* Disable ReadyToRunMultiModule test for JIT

* Compute AvailableTypes hash for types with namespaces

* Fix merge errors

* Use correct hashcode algorithm, add test for nested type

* Uncomment CheckCanGenerateMethod, remove IlcMultiModule property, remove todos

* Rename ReadyToRunMultiModule
2018-08-16 14:12:24 -07:00
Simon Nattress 7d5373e564
Improve R2R test harness reliability (#6223)
If for some reason (ie a test harness bug or user error) no assembly load events are fired, the harness will see the absence of jitted methods as a sign that all code ran R2R perfectly. Add a smell test that checks we at least saw one test module loaded.

Fix up tabs and some unused variables.
2018-08-15 18:11:29 -07:00
Simon Nattress 3d56b11db6
Build header tables using metadata manager (#6222)
* Build header tables using metadata manager

* Enable MetadataManager to track use of types / methods

* Introduce `AvailableType` which replaces the CoreRT EETypeNode.
Ready-to-run doesn't emit types directly into the image but records
their use and fills a table of available types used for type resolution
between ready-to-run modules by the runtime.

* Add dependency tracking in a few existing places where references to
types are being made. In library compilation mode, the non-private types
will be rooted so they always end up in the available types table.

* Use a single NodeCache for method entrypoints instead of a separate
dictionary for ready-to-run entrypoints. To smooth over the API
differences between the base `NodeFactory` and
`ReadyToRunCodegenNodeFactory`, allow a custom GetOrAdd method that
takes a creator callback.

* Switch over `RuntimeFunctionsTable`, `TypesTable`,
`MethodEntryPointTable` to use metadata manager for the list of types /
methods to emit entries for.
2018-08-14 12:44:10 -07:00
Amy ee5bc9f6ff Add referenced assemblies to ReadyToRun.TestHarness testModules, use System.CommandLine (#6206)
* Add System.Commandline package, fix concurrency error causing test to display as failed

* Add referenced assemblies to testModules, use System.CommandLine
2018-08-14 12:32:34 -07:00
Jan Kotas 23201e12de
Merge pull request #6193 from dotnet/nmirror
Merge nmirror to master
2018-08-09 07:52:19 -07:00
Michal Strehovsky e7fa8d3f52 Add support for reflection invoking ref return methods
This is a port of dotnet/coreclr#17732. Fixes bug 603305.

Per popular demand from people who would like to serialize ref returning properties or use them in data binding, adding support for this in MethodInfo.Invoke. The choice was to make these dereference the result and return it like that. For the corner case of returning a ref to a null, a `NullReferenceException` will be thrown (this behavior has a very unfortunate side effect of slowing down the general Invoke path because we can't throw this exception from a place where we would end up wrapping this in a TargetInvocationException).

I also made tweaks to byref parameters path to fix byref pointer parameters, but this is horribly broken on the CLR so I didn't bother to test it here. Should work.

Also includes a slight size on disk optimization that merges common tails of the static/instance paths of the invoker thunk.

Testing of the calling convention converter portion was done by disabling invoke thunks generation in NUTC and running UnitTests. I also ran it with GCStresss (RH_GCStressThrottleMode=1, RH_GCStress_Mode=1). Let me know if there's more testing needed. This has a huge test matrix for being such a corner case thing.

[tfs-changeset: 1709919]
2018-08-09 05:17:29 -07:00
Morgan Brown 914360af01
Optimize WASM arguments and returns (#6181)
Use LLVM arguments and returns where possible (no GC references) instead of passing them on the shadow stack. The argument optimization saves 3% optimized (5% compressed). The return change adds about 0.5% to the uncompressed file, but saves about 6% compressed. They both save size in debug. This also greatly simplifies debugging and reading code. Also includes a fix to the class constructor runner where it was calling cctors with the wrong signature and some test fixes.
2018-08-07 01:21:02 -07:00
Simon Nattress 26e5a77bfb
Ready To Run Test Support (#6156)
Restore CoreCLR and CoreRun

* To test the ready-to-run binaries produced by ILCompiler, restore Microsoft.NetCore.App, which contains the CoreCLR runtime plus the set of framework assemblies defined by netcoreapp2.1 which should be enough to run most tests.
* Also restore CoreRun.exe, the host used to execute test binaries.

ReadyToRun ETW Test Harness

* Add a test harness to validate ready-to-run binaries properly execute the ready-to-run native code instead of silently falling back to Jit.
* To validate this, The Microsoft.Diagnostics.Tracing (EventTrace) package is used to enable CLR ETW events during test execution. The ModuleLoad event is intercepted to find the module IDs of assemblies relevant to test (recall, all CLR ETW events are machine-wide across all CoreCLR / CLR runtimes currently running). The MethodLoadVerbose events are intercepted and their module ID is matched with those filtered in the ModuleLoad event. This allows us to focus solely on the test binaries and not the dependent framework.
* An optional whitelist file can be provided, whose format is a text file with one method name per line. The output of test failures can be pasted into a whitelist file to create a baseline.

 Ready-to-run test system integration

* Add a new code generator type to runtest.cmd supporting readytorun mode.
* Ready-to-run tests need to know the location of the CoreCLR runtime (they're executed with CoreRun) as well as the ETW test harness test project.
* Add a ready-to-run specific set of tests (from Tomas' private bringup branch) which will only run in ready-to-run mode. This is controlled by the presence of a file named "readytorun" in the test source folder. This works the same way as the web assembly tests, where we opt in until the compiler support is mature enough to run all tests in this mode.
* The ready-to-run tests will run as part of the larger suite when runtest.cmd is invoked. To run just ready-to-run tests, use runtest.cmd /mode readytorun.
2018-08-02 12:50:35 -07:00
Blealtan 62843a047f WASM: Multidimensional array instantiation fix (#6096)
* Handle multidimensional array instantiation (#5421)

newobj instruction on multidimensional array is now processed with
ArrayHelpers.NewObjArray. Enabled instantiating multidimensional arrays.

* Add testing for multidimensional array instantiation.

Only nullity and lengths are checked due to get & set not working on
multidimensional arrays.
2018-08-01 14:19:42 -07:00
Michal Strehovský 10190f1ff7
Update CoreCLR.issues.targets (#6146) 2018-07-28 15:10:26 +02:00
Michal Strehovský 2e533d85ee
Add support for embedding runtime configuration (#6103)
Runtime configuration (e.g. whether to use server GC) can currently be provided either through environment variables at runtime, or through a RhConfig.ini file placed next to the executable. This adds another channel where we burn a blob similar to RhConfig.ini format into the executable. The order of precedence is environment variable > RhConfig.ini > embedded config.

The `ServerGarbageCollection` project property that is used to determine whether to link with a runtime that supports server GC will be also used to control whether to generate a configuration that enables server GC at runtime by default.

Fixes #6100.
2018-07-17 19:59:53 +02:00
Jan Kotas 1e9fc3ace3 Exclude outdated tests 2018-07-15 00:20:01 -07:00
Jan Kotas cd4caf70e3 Regression test for inlined PInvoke with marshalling data (#6067)
Extracted from #6060
2018-07-10 10:35:02 +02:00
Jan Kotas ad60136a15
Fix In,Out marshaling for SafeHandles (#6074)
Fixes #3291 #6071
2018-07-09 18:59:06 -07:00
Jan Kotas ad22792139 Enable PInvoke calli stubs
Fixes #5587
2018-07-02 10:52:55 +02:00
Michal Strehovský 5ddf79df02 Fix bogus assert in ArraySortHelper (#6018)
Fixes #6016.
Resolves #6015.
2018-06-26 07:17:53 -07:00
Andon Andonov 635cf21aca Add cumulative error checking to CoreFX tests (#6014)
* Add cumulative error checking

* Disable regressed tests

* Add issue links
2018-06-25 19:52:16 -07:00
Michal Strehovský c101f3e39d Update CoreCLR.issues.targets (#6003)
These tests started failing after RyuJIT update in #5969.

```
             at System.Diagnostics.Debug.Assert(Boolean condition, String message, String detailMessage)
             at Internal.JitInterface.CorInfoImpl.convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN& pResolvedToken, Boolean mustConvert) in D:\j\workspace\debug_windows_nt28ae10f6\src\JitInterface\src\CorInfoImpl.cs:line 3453
             at Internal.JitInterface.CorInfoImpl._convertPInvokeCalliToCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_RESOLVED_TOKEN& pResolvedToken, Boolean mustConvert) in D:\j\workspace\debug_windows_nt28ae10f6\src\JitInterface\src\CorInfoBase.cs:line 2488
```
2018-06-24 07:04:06 -07:00
Anipik 450de75f4e non shared changes and disabling tests 2018-06-24 02:32:10 -07:00
Michal Strehovský f61d47a928
Merge pull request #5992 from dotnet/nmirror
Merge nmirror to master
2018-06-22 09:23:16 +02:00
Michal Strehovsky 2bcf67a5f1 Allow constructed byref-like types
We were not allowing these because we couldn't properly fill out the vtable (can't really make unboxing thunks to put in the vtable). We actually need the vtable, but only because the generic dictionary lives there and reflection might touch it.

[tfs-changeset: 1705047]
2018-06-21 15:21:18 -07:00
Adeel Mujahid 8d6690c4eb Rev netcoreapp2.0 to netcoreapp2.1 (#5974) 2018-06-20 17:06:28 -07:00
Andon Andonov 39f518734c
Fix CI-breaking change (#5900) 2018-06-05 13:37:36 -07:00
Michal Strehovský 1afa028a1f Make FinalizeTest run last (#5887)
#2695 got closed without any effort to validate things work. While this test has changed since the issue got filed, maybe we can still luck out and hit the issue in the CI (in which case I'll reopen the issue). If not, at least we'll get rid of the comment that references the closed issue.
2018-06-03 14:57:22 -07:00
Andon Andonov e9ad569123
Enable OSX and Linux CoreFX CI tests (#5864)
* Separate Issues on a per OS basis

* Add Linux exclusions

* Fix -p flag

* Add OSX exclusions for all-green

* Final Test Definitions

* Enable tests in runtest

* Unify OSX and Linux issues

* Update docs to reflect changes

* Remove Threading.Tasks.Tests and intermittent test failures

* Prune test list to include only System.Collections.Tests
2018-05-31 14:55:07 -07:00
Andon Andonov b3fdede4ff
Enable OSX and Linux CoreFX CI tests (#5860) 2018-05-29 09:58:50 -07:00
Andon Andonov e30bb91516
Usability improvements - Testing Documentation and scripts (#5836)
* Update testing documentation

* Add repro testing instructions

* Change incorrect instructions
2018-05-24 13:00:57 -07:00
Andon Andonov 83bd931f4e
Add additional support to CoreFX testing for CI (#5823)
* Add RSP file support

Incremental CI Improvements

Add JSON validation

* Define broad test exclusions

Remove duplicate test names

* Add OSX and Linux URLs

* Revert exit commands

* Change test log output directory and disable test execution printing

* Remove exclusions to test CI failure

* Disable simple and multimodule tests during CoreFX

* Revert "Remove exclusions to test CI failure"

This reverts commit 162a354365.

* Change exit code to test test result reporting

* Add exclusions

* Add removed exclusions

* Minor shell script fixes
2018-05-22 15:03:00 -07:00
Andon Andonov 5fca3b1c48
Staging Commit - Netci.groovy refactor and addition of a CoreFX CI job (#5817)
* Return success directly when calling runtests with /corefx flag enabled

* Rename normal scenario to coreclr and fix build failures
2018-05-18 10:52:42 -07:00
yowl 09437ab725 Double/Float casting and comparisons, push floats as 64bit to stack (#5813)
Fix double cast
push floats and doubles to stack as double
add some more tests around float/double comparisons
2018-05-17 13:45:36 -07:00
Michal Strehovský 12361f7a61 Add possibility to opt out of strict `Enum.GetValues` semantic
Fixes 39 System.Collections tests.
2018-05-11 18:18:50 +02:00
Jeff Greene 832b86f068 fix dup instruction result to no longer reference the original memory in WASM (#5784)
fix dup instruction result to no longer reference the original memory
 added additional dup test cases
2018-05-10 15:39:48 -07:00
Andon Andonov becb08ebde
Change x64 call to vcvarsall (#5763) 2018-05-01 17:25:35 -07:00
Michal Strehovský aa517a501c Devirtualize delegate creation to sealed virtuals (#5749)
These could be in sealed vtable slots.
2018-04-25 20:45:26 -07:00
Jeff Greene aad951a27e Enable Interface dispatch for WASM (#5748)
Interface dispatch
2018-04-25 17:46:50 -07:00
Jan Kotas 7b63138ee4
Fix struct marshaling bugs (#5707)
- Enable struct Marshal APIs for reference types
- Fix mismatched argument order for native to managed marshaling
- Fix sizes reported by Marshal.SizeOf APIs
- Delete some unnecessary wrappers and fixed a few typos

Fixes #5674 and #5217
2018-04-17 09:20:00 -07:00
Michal Strehovský 657a366640
Use canonical method IL in scanner's ImportCall (#5686)
Simulates what JitInterface operates on.
2018-04-12 22:10:19 +02:00
Andon Andonov 55cb81aff1 Fix test scripts (#5687)
Add an optional extended description…
2018-04-12 10:07:55 -07:00
Andon Andonov 88c56dbf1d Quality of Life improvements to CoreFX testing infra (#5651)
* QoL Improvements

* Test Cleanup

* Add OS detection to non-Windows tests
2018-04-09 14:53:18 -07:00
Morgan Brown a1d1dc873f
Initialize modules and run StartupCodeMain in wasm (#5621)
Code to call InitializeModules on startup and associated bug fixes and workarounds. Handles mismatched struct calling conventions between LLVM and Clang and works around the dup opcode incorrectly reloading values. Enables StartupCodeMain and fix associated bugs in pinvokes. Implements main return codes
2018-04-06 19:35:17 -07:00
Michal Strehovský 74615b4e92
Get rid of compiler warning in StaticLibrary test (#5636)
Gets rid of `LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library [d:\git\rt\tests\src\Simple\StaticLibrary\StaticLibrary.csproj]`.
2018-03-28 20:41:15 +02:00
Andon Andonov 4fe753e766 Update CoreFX Test Binaries URL (#5628) 2018-03-27 10:50:51 -07:00
Michal Strehovský 539b297a3c
Merge pull request #5577 from dotnet/master
Merge master to nmirror
2018-03-19 19:09:35 +01:00
Michal Strehovsky 670505fafe Implement support for System.Reflection.Pointer in dynamic invocation scenarios
Since pointer types cannot be boxed, reflection invented a `System.Reflection.Pointer` type that can be used in places where an object reference is required. This implements support for the `Pointer` type in:
* Delegate.DynamicInvoke for Project N and CoreRT
* MethodBase.Invoke for Project N and CoreRT

The MethodBase change is most annoying because it requires us to do extra work due to not being able to instantiate generics over pointer types (the invoke thunks are otherwise generic). We need to unwrap the pointed to types and compensate for that in the thunk. This also means we now create instantiations over void (for void pointers), but meh.

Also fixes two bugs found on the way (so that I get the whole trifecta of IL2IL, NUTC, and binder work):

* Pointer type hashcodes were generated wrong by the binder for pointer types deeper than level 1
* The null to default(pointer) conversion didn't work (this also affected pointer typed field setters)

Fixes bug 457960.

[tfs-changeset: 1692475]
2018-03-19 00:53:25 -07:00
Jeremy Koritzinsky 31651b1066 Make Server GC component optional (#5565)
Make the Server GC an optional component by building two flavors of the runtime and selecting a specific one in the build via the `ServerGarbageCollection` MSBuild property. Don't build the Server GC flavor for Web Assembly.

Fixes #5182, Fixes #5306.
2018-03-19 08:43:52 +01:00
Andon Andonov bf6b0572c9
Enable CoreFX tests on CoreRT (#5329)
* Generate Test projects - Intermittent checkin

* Intermittent check-in running exe, tests need restoring

* Add Test utitilites project

* End-to-End test build Windows

* Change structure

* Fix RDXML and add reflectable types

* Add json parsing and xml logs

* End-to-end test run and display

* Helper project style changes

* Remove direct dll references add package dependencies

* Stylistic changes + deps

* Style fixup

* XML reader escape

* Dependency and comment cleanup

* Respond to PR feedback

* Intermittent checkin - Build helper projects

Shell scripts

* Building and working shell scripts

* End-to-end build and run

* Add error checking

* Style Fixup

* Address PR comments

* Revert line change

* Remove Net.Security.Tests

* OSX Changes

* Update URL; update dependencies

* Remove Collections.Immutable and update to long-lasting URL
2018-03-14 14:51:25 -07:00
Michal Strehovský 82cfd0f1b2
Fix interface dispatch with CppCodegen (#5533)
This got broken when sorting got introduced to stabilize the executable image. Instead of relying on implicit ordering of nodes, use order specified in the map.
2018-03-13 23:09:29 +01:00
Michal Strehovský ac0e783737
Fix empty dispatch map optimization and unnormalized vtables (#5531)
Since we currently allow unnormalized things in the dependency graph (see #5264), we need to ensure scanner produces a dependency graph that can be queried for unnormalized vtable slices.

This fixes a regression in a ASP.NET scenario. Also fixes #5508.
2018-03-13 08:10:38 +01:00
Jan Kotas 842f475917
Remove libuuid usage (#5521)
Related to https://github.com/dotnet/coreclr/pull/16643
2018-03-08 15:48:14 -08:00
Toni Solarin-Sodara 998d168987 Add tests for building native shared and static libraries (#5443)
* add preliminary Library test project (#4985)

* update library test and make it pass on Windows (#4985)

* rename Library test project to SharedLibrary (#4985)

* update sharedlib test, make it pass on darwin (#4985)

* update msbuild tag names (#4985)

* move native runner rsp file to native intermediate output path (#4985)

* add test for static library, make it pass on unix (#4985)

* update static library test, make it pass on Windows

* skip shared library test for linux (#4985)

* fix StaticLibrary linux build (#4985)

* update unix linker args when building StaticLibrary native binary (#4985)

* add copyright headers to all newly added source files (#4985)

* fix multimodule build errors for native library builds (#4985)

* add comment explaining owning module of native library startup method (#4985)

* set owning module of native library startup method to gen'd module (#4985)

* remove unneeded System.Linq import (#4985)
2018-03-07 07:09:22 -08:00
Morgan Brown 1911656238
Static constructors for WebAssembly (#5425)
* Implement static constructor triggering. Also includes several bug fixes found in the process:
* Don't make the ClassConstructorRunner depend on module intialization
* Moves non-GC statics and thread statics from globals to the type's data regions. GC statics can't be moved until we can call InitializeModules on startup.
* Devirtualizing interface calls to structs in order to be able to compile the class constructor runner.
* Add a prolog block before Block0 to allow branching to Block0, which happens in retail builds
* Correct use of unreachable in traps and at the end of finally blocks to fix more retail build problems
* Stop reusing spill slots when a spilled value is spilled again. This avoids cases where the spills feeding into a block don't use the same slot
* Enable thunks for NativeCallable methods and call RhpReversePInvoke for them
* Fix alignment for cases where a small type is followed by a larger one
* Workaround for Emscripten atomics bug
2018-03-06 04:15:09 -08:00
Morgan Brown ce9cd701b1
Automatic WebAssembly test execution (#5492)
* Automatically execute WebAssembly tests on Windows by using emrun to launch a headless instance of Firefox (which doesn't interfere with any other Firefox usage). This should cut down on manual testing and help us move toward CI integration.
2018-03-05 16:50:28 -08:00
Blealtan beff0a43b2 Implement intrinsic call to RuntimeHelpers.InitializeArray for WASM (#5377)
* Implement intrinsic call to InitializeArray.

RuntimeHelpers.InitializeArray is implemented as a call to LLVM
intrinsic llvm.memcpy.p0i8.p0i8.i32, which copies from generated global
constant to provided target array.

Currently the base size of the array object is hardcoded to 8, since no
EEType is provided in the intrinsic call.

Fix #5345.

Add testing code for InitializeArray in HelloWasm.

Roslyn generates RuntimeHelpers.InitializeArray for arrays of integral
types with initializer of length greater or equal than 3. Here we use
this feature to generate a call to RuntimeHelpers.InitializeArray for
test.

Catagorize array argument types in InitializeArray

Differently handle vectors, multidimensional arrays and object typed
arrays in InitializeArray intrinsic.
2018-02-27 19:30:54 -08:00
Jan Kotas 7d27b46388
Update buildtools (#5426) 2018-02-22 16:04:26 -08:00
Michal Strehovský 1c7f5604f6
Update CoreCLR tests (#5412)
Picks up the latest version of Pri0 tests (as of yesterday).

There was a massive cleanup of Pri0 tests on the CoreCLR side so we now run only about 2000 tests. Hopefully, they're more representative now. Most of what we picked as "Top200" was no longer part of the Pri0 suite, so I made a new one.

We might want to consider switching to Pri1 for the rolling builds.
2018-02-20 09:56:22 +01:00
Michal Strehovský 104cae1e7e
Fix build-and-run-test.cmd for VS 2017 (#5411)
We stopped supporting VS 2015 a while ago, but running CoreCLR tests didn't actually work without it because we forgot to update a place.
2018-02-19 18:31:04 +01:00
Blealtan eba7180dc2 Implement break opcode as llvm.debugtrap (#5344)
* Implement break opcode as llvm.debugtrap.

In Emscripten, `llvm.debugtrap` is implemented as a round-trip call to
`debugger;` statement JavaScript which will invoke debugger in browsers;
and in LLVM it's implemented as `unreachable` instruction of WASM. This
should be a better match than `llvm.trap` on `break` opcode semantics.

Fix #4511

Set IsDebuggerPresent to TRUE in case of WASM. Although
`Debugger._isDebuggerAttached` is not set, this modify itself will allow
`Debugger.Break` to work.

Add test in HelloWasm for `Debugger.Break`.
2018-02-06 20:27:11 -08:00
Jeff Greene e89bb7a087 Fixed ldind failure and properly zext unsigned types that are smaller than 32bit (#5342) 2018-02-03 17:53:26 -08:00
Christian Scheuer f19daaae78 Add support for building wasm on OSX and Ubuntu 16 (#5297)
* Enable wasm building on OSX.

Upgrade libLLVM to 4.0.0 and LLVMSharp to 5.0.0

LLVM upgrade: Fix 'Use still stuck around after Def is destroyed' of the deleted basic blocks

Add wasm support in runtest.sh

Remove HelloWasm.csproj reference to .ilproj on non-windows OS because of dependency on ilasm

Fix LinkNative target to execute correct commands for Unix wasm builds.

Added support for building on Ubuntu 16.04.3

Update documentation on how to build WebAssembly.
2018-02-03 16:47:18 -08:00
Blealtan 3470b34c12 Implement castclass & isinst for WebAssembly (#5325)
* Implement castclass & isinst for wasm (#4510)

Implement castclass and isinst opcodes in ILToWebAssemblyImporter by
doing related function calls to methods in System.Runtime.TypeCast.

Fix #4510

Add castclass & isinst test in HelloWasm.

This includes three types of casting:
* castclass/isinst to classes.
* castclass/isinst to interfaces.
* castclass/isinst to array types.

For now, the second and third part of test is failing due to runtime
implementation problems which should be further digged into.
2018-02-02 21:15:17 -08:00
Morgan Brown 6bc23d91d5
Implement localloc for WebAssembly (#5298)
* Implements localloc and fixes other issues required to make Int32.ToString work (which relies on stack allocation, Spans and various value type special cases). Includes:
* Allocating localloc buffers on the C++ stack since they're guaranteed not to have GC references and LLVM might be able to optimize them a bit better
* Handling newobj for value types by allocating them in a spill slot
* Implementing the ByReference.get_Value intrinsic
* Fixing various shadow stack management bugs around calls. In particular, return values are now spilled to avoid the next call overwriting them.
* A few new tests
2018-01-31 03:15:19 -08:00
Andon Andonov 637a3dc7d7 Update Unix external test instructions and add root test dir to test search (#5313) 2018-01-29 20:09:48 -08:00
Jeff Greene 74a131922d Implemented Array instructions for WebAssembly (#5172)
implemented array instructions, implemented internal calling convention, switched to managed runtime calls, Refactored call to not require stack operations, finished work to map pinvokes into the same generated methods/signatures
2018-01-28 20:03:39 -08:00
Michal Strehovský 6b1a2a9623
Rename AdditionalNativeLibrary to NativeLibrary (#5280)
And AdditionalNativeFramework to NativeFramework, as discussed in https://github.com/dotnet/corert/pull/5273#pullrequestreview-90536352.
2018-01-23 20:19:53 +01:00
Michal Strehovský 48183632f6 Make reflection tracking work with unnormalized VirtualMethodUse 2018-01-19 13:31:59 +01:00
Morgan Brown e32aeceee7
Implement WebAssembly delegates (#5143)
* Implement WebAssembly delegates and fix other minor codegen issues.
2018-01-13 04:48:48 -08:00
Michal Strehovský e00a6d9137 Update CoreCLR.issues.targets (#5233)
These two tests now succeed after David's a2f4510705.

The remaining two are testing another known corner case.
2018-01-10 08:34:04 -08:00
Michal Strehovský 42e586596d
Add handling of method parameter custom attributes (#5188)
We need to apply the same rules as elsewhere to make the attributes reflectable.
2018-01-03 18:32:39 +01:00
Michal Strehovský eff2c4584c
Update CoreCLR.issues.targets (#5187)
System.Runtime.CompilerServices.Unsafe is now an OOB library, same as Microsoft.CodeAnalysis that is blocking the test above.
2018-01-03 13:08:03 +01:00
Michal Strehovský a60adb8cda Update CoreCLR.issues.targets (#5184) 2018-01-02 07:51:12 -08:00
Wayde Reitsma 875551cf87 Implement cpobj opcode for wasm (#5151)
* Implement cpobj opcode for wasm

Implements the ILToWebAssembly.ImportCpObj method using an LLVM load and
store.

Adds a test for for wasm cpobj to the HelloWasm test using an IL
project.
2017-12-30 20:52:16 -07:00
Jan Kotas 39a8b6ac90
Fix RhGetCodeTarget for Unix x64 (#5168) 2017-12-29 19:08:36 -08:00
Michal Strehovský ab4222fba0 Ensure reflection has access to instance methods on byref-like types (#5165)
* Ensure reflection has access to instance methods on byref-like types

Adding the test uncovered a subtle issue. When rooting a virtual method for reflection, we should root the virtual method use of the slot defining method (not e.g. the `ToString` method on the byref-like type - we don't have virtual method use information for that).

* Disable part that doesn't work on Unix
2017-12-29 12:11:16 -08:00
Michal Strehovský 2a0ded50fd Add test coverage for the "reflection metadata from use" feature 2017-12-29 12:41:32 +01:00
Morgan Brown 843f6ab347
Link WebAssembly runtime (#5141)
* Changes to hook up the portable runtime and bootstrapper. Includes implementing allocation using RhpNewFast as well as some floating point codegen fixes required to make the new code compile.
Removes usage of buggy dladdr API in WebAssembly, fixes order of conditional branch expressions, which fixes printing when C# optimizations are enabled, adds debug and release flags to emcc, updates WebAssembly documentation to reflect the new build flavor and linking steps. Adds thunks for RuntimeExport methods to fix linker errors for missing runtime exports.
2017-12-27 03:49:39 -07:00
Michal Strehovský a7d9fbeb6c
Remove reference to WASM workaround (#5078) 2017-12-08 12:09:36 +01:00
Jeff Greene 8300e1f69f Added real support for Unbox stubs to WebAssembly (#5052)
* Added real support for Unbox stubs to WebAssembly
2017-12-08 02:44:13 -08:00
Morgan Brown 3d25db5b1c
Build runtime and libraries for WebAssembly (#4876)
* Fix issues building the runtime, corelib and type loader for WebAssembly

* Fix test infrastructure to allow running with the wasm flavor
2017-12-04 22:45:38 -08:00
Jeff Greene d80ed0826b enabled thread static fields in WebAssembly (#4999)
* enabled thread static fields, changed vtable dispatch to not be dependent on EETypeNode, added typed node factory
2017-11-30 00:19:32 -08:00
Michal Strehovský 741a88c0cb
Enable generation of stack trace data for simple tests (#5002) 2017-11-23 16:03:46 +01:00
Jeff Greene 4eada9a5ec Added support for calling methods via virtual slots in WASM (#4931)
* Added support for calling methods via virtual slots
2017-11-16 18:59:49 -08:00
Jan Kotas 35d86cb247 Fix CppCodeGen break with latest XCode (#4926)
Latest XCode errors on ordered comparison of pointer with integer

Also, fixed some unnecessary always-true comparisons that the C++ compiler emitted warnings for.
2017-11-14 13:13:22 +01:00
Jeff Greene 9a819d14db added support for box/unbox/unbox_any for WASM using malloc (#4731) 2017-11-06 00:23:49 -08:00
Jeff Greene ff7decc2fd implement newobj for WASM using malloc (#4872)
implemented newobj for WASM using malloc
2017-11-04 16:55:48 -07:00
Morgan Brown f760ef3415
Revert "implemented newobj for WASM using malloc (#4808)" (#4864)
This reverts commit 3b9a7fc3fc.
2017-11-03 02:18:19 -07:00
Jeff Greene 3b9a7fc3fc implemented newobj for WASM using malloc (#4808)
implemented newobj using malloc, added evaluation stack spillage and cut down on unneeded llvm casts
2017-10-31 17:41:14 -07:00
Simon Nattress 51ae3d9c5f Disable ETW events on Linux CoreCLR tests 2017-10-30 17:38:44 -07:00
Simon Nattress 5d7e4af8df
Stabilize object file images (#4818)
* Determinism test harness

Add a /determinism mode to runtest.cmd that will invoke ILC twice with different random determinism seeds. This causes graph expansion to be randomized based on seed (though deterministic for a given seed).

* Add Utf8String.CompareTo

Implementation taken from S.P.CoreLib. All the loop unrolling optimizations were excluded; we re-implement them if this function becomes a perf bottleneck.

* Define the mechanisms for determinism

To ensure deterministic output, all nodes that are emitted to the binary are sorted after compilation when retrieving the final marked nodes list. The overall approach is to sort nodes of the same type together (ie, all EETypeNodes come before NonGcStaticsNodes). Within nodes of the same type, a comparison function uses a CompilerComparer to compare the key identifying data of a node. For example, an EETypeNode is defined by a TypeDesc. The CompilerComparer provides a stable comparison function for comparing various type system primitives. Some nodes need to be emitted in an early and specific order for compiler correctness; this is provided by partitioning all sorted nodes into two phases: the first phase containined specifically ordered nodes, and a second phase for all other nodes whose ordering in the output binary doesn't matter.

Add SortableDependencyNode abstract class which provides the sortability layer on top of a DependencyNodeCore. Both ObjectNode and EmbeddedObjectNode derive from SortableDependencyNode to provide sortability across all nodes that are emitted to the output binary.

Introduce `ISortableSymbolNode` to provide sortability for nodes that are currently referred to in the compiler via the ISymbolNode interface. Such nodes are actually `ObjectNode` or `EmbeddedObjectNode` instances that we've lost type information for. Instances that implement `ISortableSymbolNode` redirect to the matching SortableDependencyNode methods.

Add `EmbeddedDataContainerNode` as a base class of `ArrayOfEmbeddedDataNode` to allow comparison of different instantiations.

Refactor the interface dispatch map index calculation so it's done when the dispatch map is emitted at the end of compilation. Previously it was done when the indirection cell in the dispatch map array got marked. This mechanism is incompatible with generating stable dispatch map indices.  The arrays of embedded nodes now stabilize IDs as they emit their final data. This introduces an output ordering dependency - OptionalEETypeNodes must be emitted after the dispatch map since they encode dispatch map indices. Manually enforce this with C++ code generation, since it doesn't emit the real dispatch map structure and builds its own.

Modify InterfaceDispatchMapNode to use the type name in name mangling instead of an index into the dispatch map table.

Modify ObjectDumper to also amit a sha256 hash of each node's data. This dump is used to diff the map files and prove determinism.

* Fill out ordering functions for all nodes

Most of these are not very interesting. Here's the overall approach:

- Every different type of node needs a unique ClassCode. These were generated using Math.Random.
- The various metadata / native layout nodes plus arrays of EmbeddedObjectNodes get placed in the Ordered phase with specific ordering of each.
- All other nodes go in the Unordered phase
- To order nodes of the same type, the data that represents the key for the node in NodeFactory is compared. Ie, for an EEType, that would be its defining TypeDesc, whereas a FrozenStringNode is defined by the string it represents).
- The marked nodes list also contains raw DependencyNodeCore<T> nodes, which aren't emitted. Those are all shuffled after the emitted nodes and not sorted amongst themselves. That hasn't proven to be a problem with determinism and saves a bunch of hopefully unnecessary comparisons.
2017-10-30 09:41:15 -07:00
Juan Antonio Cano 5aed5155ac Emit switch in wasm (#4769)
* Implement switch opcode Fix #4519
2017-10-23 13:17:08 -07:00
Jeff Greene e1f8363287 Added support for ldsfld/stsfld/ldsflda/ldflda including general value type support (#4729)
Added support for ldsfld/stsfld/ldsflda/ldflda including general value type support, throw on invalid branches to the first basicblock in a routine and ensure type sameness for icmp
2017-10-20 16:22:16 -07:00
Faizur Rahman c6995b38cb Add support for marshalling struct with delegates (#4737) 2017-10-17 18:41:04 -07:00
Morgan Brown b9b6c5db47 WebAssembly instance method support (#4695)
* Fix instance method parameter management and a couple of codegen issues that showed up when more methods started compiling. Includes implementing ldfld for instance fields (progress toward #4530) and the leave opcode. This is enough to make the String.Length getter work.
2017-10-17 13:27:08 -07:00
Jeremy Koritzinsky 18f3c7773c Implement Shift Opcodes for WebAssembly (#4721)
* Implement shift opcodes

* Fix HelloWasm test.

* FIx HelloWasm test program.
2017-10-14 21:12:29 -07:00
Juan Antonio Cano ea81a1844f Implement neg (float/integer) and not IL instructions. Fixes #4524 and #4525 (#4725)
* Implement neg (float/integer) and not IL instructions. Fixes #4524 and #4525

* Neg and not basic tests added to HelloWasm.
Name parameter updated in LLVM build methods to reflect the operation being built.
Use PushExpression method instead of direct push to stack.
2017-10-14 17:19:24 -07:00
Jeff Greene c79eba2eed implemented ldobj/stobj in terms of ldind/stind (#4709) 2017-10-10 18:29:35 -07:00
Jeff Greene baeebd4f5f added support for stind in WASM (#4702) 2017-10-10 17:05:02 -07:00
Morgan Brown 8f423ff109 Add the -prelease switch to vswhere in build scripts to allow them to find prerelease versions of Visual Studio. This fixes building on a machine that only has C++ installed in a preview build of VS 2017. (#4696) 2017-10-09 22:20:25 -07:00
Jan Kotas 2e4be5436b Use Tls12 to download CoreCLR tests (#4682) 2017-10-06 04:40:15 -07:00
Jan Kotas d1223d2c92 Delete VS2015 support (#4660) 2017-10-03 19:12:19 -07:00
t-jekor 18eab60696 Enable CLR Thread Pool via a MSBuild flag (default enabled on Unix)
This PR completes, adds tests for, and enables the CLR Thread Pool on Unix. It also adds Windows implementations for the low level primitives used in the CLR Thread Pool.

The thread pool is enabled by setting the MSBuild property FeaturePortableThreadPool to true, which is the default on Unix.

Supersedes #4039.
Rebased and squashed replacement for original PR #4124.
2017-09-29 07:33:57 -07:00
Morgan Brown 6622ebe8d8 Fix strings for WebAssembly (#4592)
Changes that allow loading a printing a frozen string. Includes:

* Implement ldnull and ldind
* Fix brtrue and brfalse for pointers
* Fix the polarity of ceq and friends
* Change functions we can't compile into traps so that they don't break LLVM
* Put call arguments in the right order
* Miscellaneous stack canonicalization fixes (we'll have to revisit this in a more comprehensive way soon)
* Minor diagnosability improvements
2017-09-25 21:16:50 -07:00
Sergiy Kuryata fe8a3e7ed4 Enable Server GC (#4591)
This change adds support for Server GC.
To enable the Server GC for an application, the RH_UseServerGC environment variable (which is already supported by the runtime) should be set to 1.
2017-09-22 00:13:14 -07:00
Adeel 8059fcb69a Avoid linefeed in /proc/self/coredump_filter
On Alpine Linux, the default shell is ash. To build .NET Core, we
explicitly install bash.

If we run the following command:

```sh
echo 0x3F > /proc/self/coredump_filter
```

in bash, it raises the exception:

> echo: write error: Invalid argument

while with ask, it works fine.

Problem is that, when `echo` is run from `bash`, it adds a trailing
linefeed which kernel seems to reject.

Adding `-n` avoids adding the linefeed.

Original exception while building CoreRT:

```sh
chmod +x /corert/Tools/dotnetcli//dotnet
/corert/bin/Linux.x64.Debug/ILCompiler.DependencyAnalysisFramework.Tests/RunTests.sh: line 67: echo: write error: Invalid argument
/corert/Tools/dotnetcli//dotnet xunit.console.netcore.exe ILCompiler.DependencyAnalysisFramework.Tests.dll  -xml testResults.xml -notrait Benchmark=true -notrait category=nontests -notrait category=nonlinuxtests  -notrait category=OuterLoop -notrait category=failing
```
2017-09-21 03:58:45 +03:00
dotnet-bot 792a29f98a ProjectX: Add real element type and element count to preinitialized data for array fields
For static array fields, the real element type which can be a descendent of the declaring type must be added to the preinitilizeded data. The element count should also be there.

[tfs-changeset: 1674701]
2017-09-18 14:09:12 -07:00
Morgan Brown 699b5a08e9 Fix LLVM NuGet binary placement and clean up changes 2017-09-14 17:24:46 -07:00
Morgan Brown 2552e22abc Adds a WASM test and test infrastructure changes and fixes to support it. 2017-09-14 17:24:46 -07:00
Michal Strehovský 94bc6911da Update RyuJIT (#4407)
Picks up:

* dotnet/coreclr#13561
* dotnet/coreclr#13577


Fixes #3608.
2017-08-28 12:10:19 -07:00
Michal Strehovský 4c446d524a Generate portable PDBs by default for managed projects (#4362) 2017-08-22 16:36:31 -07:00
Yi Zhang (CLR) 1105f175e7 Preinitialized data support for value types (#4281) 2017-08-11 13:51:49 -07:00
Jeremy Koritzinsky 33467fd891 [Unix ThreadPool] Dedicated Wait Thread (#3807)
* Added a dedicated wait thread to the thread pool following similar design principles as CoreCLR

* Fixed project file

* Fix missing return.

* Use the RuntimeThread APIs instead of the Interop-level APIs to create the WaitThread.

* Moved callback execution and unregistering to the thread pool

* Encapsulated signaling the user provided wait handle to ensure it only happens once.

* Handle the blocking case by not queuing the unregistration of the wait on the threadpool when the handle is invalid and instead unregistering directly.

* Rename WaitThread to ClrThreadPool.WaitThread and remove Unix suffix since (in theory), we will be able to move this to work on Windows as well in the future.

* Cache WaitHandle array and timeout and only recreate when the list of RegisteredWaitHandles is changed

* Fixed ClrThreadPool class modifiers in ClrThreadPool.WaitThread.cs

* Fixed reference to WaitThread class

* Fixed reference to WaitThread class

* Re-architected WaitThread to use a partial section of the array of wait handles to wait on and queue all removals to happen on the wait thread itself.

* Fixed compile error in WaitAny

* Make ClrThreadPool.WaitThread non-static and add scaffolding code to ensure handles can be unregistered by the user from the right WaitThread

* Fixed possible indxing errors, prevented double remove requests, and renamed some methods to be more descriptive

* Add comments

* PR feedback

* PR feedback

* Add a lock around selecting a wait thread to register the wait handle on

* ClrThreadPool is no longer static in master

* Only process removals before calling WaitAny, not after

* Try-Finally in ProcessRemovals

* Remove safeToDisposeHandleEvent as per PR feedback

* Added try-finally in UnregisterWait

* Refactor SetEvent into WaitHandle so as to not have direct dependencies on the Unix Wait Subsystem

* waitHandles.Length -> numWaitHandles in WaitAnyCore

* Added try finally in PerformCallback and added a way to ensure Unregister only returns true once

* Refactored timeout to actually account for previous waits when calculating timeout

* Account for handles that timeout while doing other work than waiting

* Changed removals aglorithm to fill nulls in while removing instead of doing so in a later loop

* Create 1st Wait Thread lazily

* Refactor RegisteredWaitHandle. Made wait threads time out. Start wait
threads outside of global lock.

* Fix wait thread accessibility

* Fix registered wait initialization to match CoreCLR

* Removed the lock from RegisteredWait in favor of a CompareExchange flag

* Replaced CompareExchanges with volatile loads and Exchanges

* Fix asserts in WaitSubsystem

* Fix bounds in safe wait handle release

* Added Wait Thread tests.

* Added more wait thread tests and fixed code style.

* Remove resolved TODO.

* Uninterruptible waits on wait handles where supported. Internalize CanUnregister. Return true on first unregister call even if automatically unregistered eariler

* Fix typos

* Add basic recursive event to handle overlapping callbacks

* Fix repeating timer timeout

* Remove dependency on Environment.TickCount from RegisteredWait

* Fixed test

* Fix race conditions on callbacks + unregister based on PR feedback

* Only timeout on change event when there are no user waits

* Fix overload call

* Remove code used for initial debugging

* Double times used in test to allow for about 50 ms window for test timing instead of 25 ms

* Move RegisteredWait into RegisteredWaitHandle

* Unregister on wait thread before callback

* Add test and code to ensure events are not observed on wait thread after an unregistration, even if it is non-blocking.

* Fixed incorrect timeout class

* Expand time frame for failing test to 100ms from 50ms. Add another assert to ensure it's working correctly

* Use event setting for test instead of timeout.

* Cleaned up leftover variables in test

* Only use sync context when wait is uninterruptible

* Make IsBlocking setter private.

* Fixed blocking unregisters.

* PR Renames

* Remove unneeded _unregisterSignaled member.

* Add debug check of _numRequestedCallbacks.

* Add argument verification for top of range.

* Clean up tests per PR feedback.

* Add CheckedWait helper.

* Added dispose-after-unregister test.

* Added block comment stating the reasoning behind not having a blocking wait on removal in unregister.

* Added finalizer to RegisteredWaitHandle.

* Changed overlapping callback test to use events instead of sleeps in the job.

* Refactor timeout times in tests and add comment to ClrThreadPool constant.

* Move updating the user's supplied unregister event to be in the callback lock.

* Added lots of comments and fixed an accessibility modifier

* Clean up tests and argument validation. Lazily create event for blocking unregistration.

* Only grab sync context if wait is interruptible.

* Fixed comment.

* Unregister event will be signaled even if handle has already been unregistered

* Fix timeout checks.

* Added test and code to make it pass for blocking unregistering a handle after it has been removed from the list but is still executing a callback.

* Add an event to wait for the handle to be removed from the list. User code will not get control back until it is safe to dispose the handle.

* Refactor internal event handles

* Changed sleep times for test

* Implement cache for internally used AutoResetEvent

* Exceptions in unregister rollback RegisteredWaitHandle state.

* Change defaults of UserUnregisterWaitHandle and UserUnregisterWaitHandleValue to null and IntPtr.Zero respectively
2017-08-04 14:32:23 -07:00
Michal Strehovský 044dbc5b4d Fix ILASM warnings for PreInitDataTest (#4051)
Reordering inputs to ILASM silences these warnings:

```
1>PreInitData64.il(11): warning : Reference to undeclared extern
assembly 'mscorlib'. Attempting autodetect
[d:\git\rt\tests\src\Simple\PreInitData\PreInitData.ilproj]
1>PreInitData64.il(15): warning : Reference to undeclared extern
assembly 'System.Private.CoreLib'. Attempting autodetect
[d:\git\rt\tests\src\Simple\PreInitData\PreInitData.ilproj]
1>PreInitData64.il(15): warning : Failed to autodetect assembly
'System.Private.CoreLib'
[d:\git\rt\tests\src\Simple\PreInitData\PreInitData.ilproj]
```
2017-06-30 20:06:25 -07:00
Michal Strehovský a9e89026c8 Update CoreCLR.issues.targets (#4040)
Once we pick up test assets after dotnet/coreclr#12537 this test will be
passing - moving the test to the category of tests that are waiting for
test update.
2017-06-30 11:21:32 -07:00
Michal Strehovský b33350e4fe Fix `runtest.cmd /multimodule` (#3998)
CLI update moved outputs out of the Product directory. This should fix
the rolling build failure.
2017-06-27 17:39:31 -07:00
Jan Kotas 79f64c17f8 More CLI update follow up fixes (#3990)
* Fix TFS build break

* Pass CoreRT_BuildOS to tests

Fixes #3982
2017-06-27 08:16:10 -07:00
Jan Kotas 555bcbcb54 Update CoreRT build to use latest .NET CLI and build tools (#3916)
- Pick up latest .NET Core 2.0 CLI and buildtools
- Remove all project.json references and convert everything to msbuild projects
- Stick to vanilla .NET CLI project shape as much as possible. Minimize dependencies on buildtools special behaviors
2017-06-24 11:10:44 -07:00
Faizur Rahman 6ea23dec10 Merge pull request #3921 from shrah/null_check
Add null check for inline string marshalling
2017-06-20 16:09:53 -07:00
Faizur Rahman 9df11fa0ca Add null check for inline string marshalling 2017-06-19 15:42:48 -07:00
Sergiy Kuryata f613261b65 Fix interface handling in CorInfoImpl.resolveVirtualMethod (#3922)
Without this fix, the CoreRT compiler generated the following code for the
test that I am adding:

call    Interfaces!_NewHelper_Interfaces_BringUpTest_SomeClass
mov     rcx,rax
call
Interfaces!Interfaces_BringUpTest_SomeAbstractBaseClass__get_SomeValue

As you can see, it ends up calling an abstract method on the base class.

With this fix, the interface call is resolved correctly:

call    Interfaces!_NewHelper_Interfaces_BringUpTest_SomeClass
mov     rcx,rax
call    Interfaces!Interfaces_BringUpTest_SomeClass__get_SomeValue
2017-06-19 14:10:44 -07:00