platform/upstream/dotnet/runtime.git
17 months agoRe-enable disabled BigInteger tests. (#87640)
Eirik Tsarpalis [Thu, 15 Jun 2023 22:45:21 +0000 (23:45 +0100)]
Re-enable disabled BigInteger tests. (#87640)

17 months agoAdd regression testing for #76802. (#87632)
Eirik Tsarpalis [Thu, 15 Jun 2023 21:26:38 +0000 (22:26 +0100)]
Add regression testing for #76802. (#87632)

17 months agoImplement ExperimentalAttribute (#85444)
Igor Velikorossov [Thu, 15 Jun 2023 21:13:20 +0000 (07:13 +1000)]
Implement ExperimentalAttribute (#85444)

Resolves #77869

17 months agoAdd DOTNET_JitDisasmWithCodeBytes (#87580)
Bruce Forstall [Thu, 15 Jun 2023 21:09:24 +0000 (14:09 -0700)]
Add DOTNET_JitDisasmWithCodeBytes (#87580)

Setting this to non-zero will display the generated code bytes in the disassembly listings.

e.g.,
```
49B910577431FA7F0000 mov      r9, 0x7FFA31745710
```

By default, it is not set and the code bytes are not displayed.

This change splits this off from the DEBUG-only `DOTNET_JitDasmWithAddress` setting.

It is available in Release.

17 months agoIgnore CORJIT_FLAG_VECTOR512_THROTTLING sometimes under stress (#87631)
Bruce Forstall [Thu, 15 Jun 2023 21:09:00 +0000 (14:09 -0700)]
Ignore CORJIT_FLAG_VECTOR512_THROTTLING sometimes under stress (#87631)

17 months agoAdd missing API docs to RateLimiting (#87627)
Brennan [Thu, 15 Jun 2023 19:53:35 +0000 (12:53 -0700)]
Add missing API docs to RateLimiting (#87627)

17 months agoEnsure the JIT consistently does opportunistic queries for its optimizations (#87620)
Tanner Gooding [Thu, 15 Jun 2023 19:35:55 +0000 (12:35 -0700)]
Ensure the JIT consistently does opportunistic queries for its optimizations (#87620)

17 months ago[mono][exceptions] Don't attempt to catch StackOverflowException (#87601)
Vlad Brezae [Thu, 15 Jun 2023 19:18:21 +0000 (22:18 +0300)]
[mono][exceptions] Don't attempt to catch StackOverflowException (#87601)

* [mono][exceptions] Don't attempt to catch StackOverflowException

* [mono][exceptions] Don't invoke ToString when logging StackOveflowException

Invoking ToString can trigger method compilations and put pressure on the stack space. Instead, build the output directly from the `exc->trace_ips` with already existing methods.

* Remove unused variable

17 months ago[mono][interp] Refactor icall opcodes (#87269)
Vlad Brezae [Thu, 15 Jun 2023 19:17:59 +0000 (22:17 +0300)]
[mono][interp] Refactor icall opcodes (#87269)

* [mono][interp] Use MINT_CALLI_NAT_FAST opcode instead of MINT_ICALL_*

MINT_ICALL_* opcodes are pretty much dead and untested

* [mono][interp] Remove duplicated code

* [mono][interp] Add new generic icall opcode

Having the signature hardcoded in the opcode seems overkill for icalls.

* [mono][interp] Remove per signature CALLI opcodes

* Remove code in jiterp

* [mono][interp] Rename defines

* [mono][interp] Opcode data consistency

* [mono][interp] Fix jiterp build

17 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 220168...
dotnet bot [Thu, 15 Jun 2023 17:01:09 +0000 (19:01 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201684 (#87613)

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201520

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201520

17 months agoSHAKE128 and SHAKE256
Kevin Jones [Thu, 15 Jun 2023 16:49:11 +0000 (12:49 -0400)]
SHAKE128 and SHAKE256

17 months agoFix parameter ordering and value in gtNewColonNode (#87366)
Huo Yaoyuan [Thu, 15 Jun 2023 16:27:27 +0000 (00:27 +0800)]
Fix parameter ordering and value in gtNewColonNode (#87366)

17 months agoStop setting HelixResultsDestinationDir (#86413)
Bruce Forstall [Thu, 15 Jun 2023 15:33:58 +0000 (08:33 -0700)]
Stop setting HelixResultsDestinationDir (#86413)

Use the default, which is `$(BUILD_SOURCESDIRECTORY)\artifacts\helixresults`

Fixes #75169

17 months agoFix mcs missing flags (#87584)
Bruce Forstall [Thu, 15 Jun 2023 15:04:57 +0000 (08:04 -0700)]
Fix mcs missing flags (#87584)

When a new JIT flag is added, it needs to be added to spmidumphelper.cpp as well.

17 months ago[mono][simd] Add MONO_TYPE_I and MONO_TYPE_U types for OP_NEGATION on amd64 (#87607)
Milos Kotlar [Thu, 15 Jun 2023 14:54:39 +0000 (16:54 +0200)]
[mono][simd] Add MONO_TYPE_I and MONO_TYPE_U types for OP_NEGATION on amd64 (#87607)

* Add MONO_TYPE_I and MONO_TYPE_U types for OP_NEGATION on amd64

* Use TYPE_I64 for MONO_TYPE_I and MONO_TYPE_U types

17 months agoAvoid linking to non-existent System.Net.Security.Native on tvOS (#87605)
Filip Navara [Thu, 15 Jun 2023 14:15:33 +0000 (16:15 +0200)]
Avoid linking to non-existent System.Net.Security.Native on tvOS (#87605)

17 months ago`UnsafeAccessorAttribute` non-generic support (#86932)
Aaron Robinson [Thu, 15 Jun 2023 13:59:49 +0000 (06:59 -0700)]
`UnsafeAccessorAttribute` non-generic support (#86932)

* CoreCLR and NativeAOT

* Add UnsafeAccessorAttribute API

* Implement IL generation for all accessor paths

* Implement static/instance field lookup - non-generic

* Implement static/instance method lookup - non-generic

* Defined ambiguity logic with respect to
custom modifiers.
- First pass ignore custom modifiers
- If ambiguity detected, rerun algorithm but
  require precise matching of custom modifiers.
- If there is no clear match throw AmbiguousImplementationException.

* Cleanup memory management confusion
with ILStubResolver.

* Fix non-standard C++

* Remove CORINFO_MODULE_ALLACCESS scope

* Remove enum METHOD_TYPE.

* Update BOTR on TypeDesc

17 months agoAdd managed entry points for raising Contention events (#87087)
Koundinya Veluri [Thu, 15 Jun 2023 13:36:33 +0000 (06:36 -0700)]
Add managed entry points for raising Contention events (#87087)

* Add managed entry points for raising Contention events

- Added the events similarly to how the PortableThreadPool events are currently set up. They may need further tweaking to make them work from NativeAOT.
- The events are not raised anywhere from the managed side yet, it's expected that they will eventually be raised by a new Lock type and at least by NativeAOT's Lock

17 months agoRemove some unnecessary Substrings (#87479)
Stephen Toub [Thu, 15 Jun 2023 12:40:56 +0000 (08:40 -0400)]
Remove some unnecessary Substrings (#87479)

* Remove some unnecessary Substrings

* Address PR feedback

17 months agoMake the soure generator format enums using their identifiers rather than numeric...
Eirik Tsarpalis [Thu, 15 Jun 2023 12:32:19 +0000 (13:32 +0100)]
Make the soure generator format enums using their identifiers rather than numeric values. (#87557)

* Make the soure generator format enums using their identifiers rather than numeric values.

* Address feedback

17 months ago[RISC-V][JIT] Fix FCVT (#87591)
Dong-Heon Jung [Thu, 15 Jun 2023 11:54:42 +0000 (20:54 +0900)]
[RISC-V][JIT] Fix FCVT (#87591)

17 months ago[RISC-V] Fix struct passing on reflection calls (#87535)
t-mustafin [Thu, 15 Jun 2023 11:53:56 +0000 (14:53 +0300)]
[RISC-V] Fix struct passing on reflection calls (#87535)

17 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 220139...
dotnet bot [Thu, 15 Jun 2023 10:08:46 +0000 (12:08 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201397 (#87570)

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2200838

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2200838

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201000

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201000

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201301

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201301

17 months agoJitdump fixes (#87547)
David Mason [Thu, 15 Jun 2023 07:03:13 +0000 (00:03 -0700)]
Jitdump fixes (#87547)

17 months agoPackage static libraries into NativeAOT runtime pack (#87594)
Michal Strehovský [Thu, 15 Jun 2023 06:27:14 +0000 (15:27 +0900)]
Package static libraries into NativeAOT runtime pack (#87594)

The iOS one only gets them because of the TargetsMobile condition. This condition is not true for bionic.

17 months agoReport warnings for COM interfaces with instance properties or events (#87492)
Jeremy Koritzinsky [Thu, 15 Jun 2023 04:01:05 +0000 (21:01 -0700)]
Report warnings for COM interfaces with instance properties or events (#87492)

17 months agoEnable option to use the Windows ThreadPool (#85373)
Eduardo Velarde [Thu, 15 Jun 2023 01:50:10 +0000 (18:50 -0700)]
Enable option to use the Windows ThreadPool (#85373)

When running on Windows, enable an option to switch between the Portable thread pool and the Windows thread pool.

This change targets NativeAOT, CoreCLR, and Mono.

Windows threadpool remains as the default for NativeAOT on Windows. For any other case the Portable thread pool remains the default.

Tests with the Windows thread pool enabled were added to the System.Threading.Threadpool solution.

Trimming is enabled to remove the unused thread pool.
---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Koundinya Veluri <kouvel@users.noreply.github.com>
17 months ago[wasm] Don't use `_WasmDevel=true` when publishing (#87544)
Ankit Jain [Thu, 15 Jun 2023 01:24:46 +0000 (21:24 -0400)]
[wasm] Don't use `_WasmDevel=true` when publishing (#87544)

* [wasm] Add missing Wasm.Build.Tests.Blazor.AppsettingsTests to list of tests to run

* [wasm] CI: Trigger only wasm jobs on workload-testing.targets changes, since only wasm is using this currently

* [wasm] host: Add `--no-silent` command line parameter

- this is the equivalent to `--verbose`
- The default is "silent" behavior

Cannot use `--verbose` because that conflicts with `dotnet run`.

* [wasm] WBT: Update template tests to use `--no-silent` with `dotnet run`

.. which would be useful in debugging tests.

* [wasm] Don't use _WasmDevel=true whenever publishing

`_WasmDevel=true` causes the optimization flags to be `-O0`.

- This *was* automatically set whenever `Configuration=Debug`, and
`WasmBuildNative=true`, which is useful when relinking in inner loop.
- But when publishing, and relinking/AOT, `-O0` results in larger output.

* Update src/mono/wasm/host/JSEngineHost.cs

* Address feedback from @ilonatommy

17 months agoExtend Task.FromResult default task optimization to 16 byte unmanaged types (#87541)
Stephen Toub [Thu, 15 Jun 2023 01:14:55 +0000 (21:14 -0400)]
Extend Task.FromResult default task optimization to 16 byte unmanaged types (#87541)

* Extend Task.FromResult default task optimization to 16 byte unmanaged types

For years, async methods / Task.FromResult has cached a `Task<T>` for `default(T)`, however it was only used when the result value was null.  Earlier in this release we extended that optimization to also use the default task when the value was 1, 2, 4, or 8 bytes (and not a reference type).  This extends that further to also handle types that are 16 bytes, so as to include types like Decimal, Guid, Int128, and DateTimeOffset.

* Fix tests to accomodate additional use of default cached task

17 months agoFix a warning. (#87573)
Zoltan Varga [Wed, 14 Jun 2023 23:11:01 +0000 (19:11 -0400)]
Fix a warning. (#87573)

17 months ago[iOS][maccatalyst] Reenable MacCatalyst and Simulator CI runs (#84930)
Mitchell Hwang [Wed, 14 Jun 2023 23:05:39 +0000 (19:05 -0400)]
[iOS][maccatalyst] Reenable MacCatalyst and Simulator CI runs (#84930)

This reverts commit 67b6e81d9d2fca8544d37f04998d352bdc0fd69e.

Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
Co-authored-by: Meri Khamoyan <merikhamoyan@microsoft.com>
17 months agoRemove a couple of asserts, which are no longer valid, from getMaxVectorTByteLength...
Tanner Gooding [Wed, 14 Jun 2023 22:30:12 +0000 (15:30 -0700)]
Remove a couple of asserts, which are no longer valid, from getMaxVectorTByteLength (#87504)

17 months agoFix StrictlyBlittable check to work for "source Compilation" references. (#87507)
Jeremy Koritzinsky [Wed, 14 Jun 2023 22:06:53 +0000 (15:06 -0700)]
Fix StrictlyBlittable check to work for "source Compilation" references. (#87507)

17 months agoHandle a null operation type (for example if the null literal is being cast/assigned...
Jeremy Koritzinsky [Wed, 14 Jun 2023 22:06:07 +0000 (15:06 -0700)]
Handle a null operation type (for example if the null literal is being cast/assigned to a ComImport interface type). (#87566)

Co-authored-by: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
17 months ago[browser][debugger][MT] Make operations on dictionary thread-safe follow-up (#87474)
Ilona Tomkowicz [Wed, 14 Jun 2023 22:05:51 +0000 (00:05 +0200)]
[browser][debugger][MT] Make operations on dictionary thread-safe follow-up (#87474)

* Revert unintentionally removed logging.

* Fix

17 months ago[main] Update dependencies from dotnet/roslyn-analyzers (#87272)
dotnet-maestro[bot] [Wed, 14 Jun 2023 20:12:43 +0000 (15:12 -0500)]
[main] Update dependencies from dotnet/roslyn-analyzers (#87272)

* Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20230607.1

Microsoft.CodeAnalysis.Analyzers , Microsoft.CodeAnalysis.NetAnalyzers
 From Version 3.3.5-beta1.23275.7 -> To Version 3.3.5-beta1.23307.1

* Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20230608.2

Microsoft.CodeAnalysis.Analyzers , Microsoft.CodeAnalysis.NetAnalyzers
 From Version 3.3.5-beta1.23275.7 -> To Version 3.3.5-beta1.23308.2

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months ago[Mono] Update Mono build README.md (#87517)
Fan Yang [Wed, 14 Jun 2023 19:58:14 +0000 (15:58 -0400)]
[Mono] Update Mono build README.md (#87517)

Added one more useful switch `-p:KeepNativeSymbols=true`

17 months ago[ComInterfaceGenerator] Warn on visibility of interface and StringMarshallingCustomTy...
Jackson Schuster [Wed, 14 Jun 2023 16:56:58 +0000 (09:56 -0700)]
[ComInterfaceGenerator] Warn on visibility of interface and StringMarshallingCustomType (#87065)

The generated code is in file scoped classes, so the interface and StringMarshallingCustomType need to be at least internal visibility. These changes warn if that condition isn't met.

Originally, I expected to report a diagnostic, but still generate code for the interface. This required some changes to DiagnosticOr<T> to allow it to hold both a diagnostic and a value if the diagnostic didn't cause failure. In the end those changes weren't necessary, but I left them because I can see them being valuable at some point in the future.

Completes #84662

17 months agoAllow bigger json parsing to JsonDocument (#87343)
Egor Boyarkin [Wed, 14 Jun 2023 15:35:53 +0000 (18:35 +0300)]
Allow bigger json parsing to JsonDocument (#87343)

* Allow bigger json parsing to JsonDocument

* Use single constant and assert it on .NET 6

* Force ArrayPool.Rent to throw if it's impossible to enlarge

17 months agoAdd delay load hook for singlefilehost and enable delay load of version.dll (#87495)
Elinor Fung [Wed, 14 Jun 2023 13:40:36 +0000 (06:40 -0700)]
Add delay load hook for singlefilehost and enable delay load of version.dll (#87495)

`coreclr` delay loads `version.dll` and adds a hook such that it loads from the system directory. In single-file, we lost this behaviour since it uses static library version of `coreclr`. This adds the same mechanism to single-file.

17 months agoFix typo in object.h (#87553)
Eric Mutta [Wed, 14 Jun 2023 13:02:58 +0000 (16:02 +0300)]
Fix typo in object.h (#87553)

17 months ago[mono][jit] Disable passing SIMD args in SIMD regs on arm64. (#87540)
Zoltan Varga [Wed, 14 Jun 2023 11:40:49 +0000 (07:40 -0400)]
[mono][jit] Disable passing SIMD args in SIMD regs on arm64. (#87540)

It has the following problems:
- the gshared versions of SIMD types like Vector<T_INT> are not marked
  as SIMD, so there is a calling convention mismatch if the callee is
  generic shared.
- the gsharedvt code doesn't support it, i.e. it asserts in get_arg_slots ().
- the dyncall code might not support it either.

Fixes https://github.com/dotnet/runtime/issues/87277.

17 months ago[QUIC] Fix rooted connection when hanshake failed (#87328)
Marie Píchová [Wed, 14 Jun 2023 11:34:21 +0000 (13:34 +0200)]
[QUIC] Fix rooted connection when hanshake failed (#87328)

* Added tests

* Fixed logging and minor typos

* Fix

* Fix test

* "Added asserts checking GCHandle state"

* Exclude test from mono

* Removed unnecessary _disposed checks

17 months ago[mono][wasm] marshal-ilgen is dropped when not required (#86035)
Jan Dupej [Wed, 14 Jun 2023 10:51:44 +0000 (12:51 +0200)]
[mono][wasm] marshal-ilgen is dropped when not required (#86035)

* Replicating naricc's PInvokeScanner.

* MarshalingPInvokeScanner now detects and outputs incompatible assemblies.

* Allowing void return type.

* PInvoke

* Two-pass searching in progress.

* Second pass resolves inconclusive types.

* Cleanup.

* Modifying the wasm toolchain to omit marshal-ilgen when possible.

* Hopefully fix incorrect app dir.

* Added definitions to MarshalingPInvokeScannerPath hopefully where needed.

* Adding definitions of MarshalingPInvokeScannerPath to more locations.

* Adding missing references to PInvoke scanner.

* Changed task ordering, assemblies list.

* Removed metadata load context.

* Fixed code analyzer issues.

* Fixed file name.

* Moved MarshalingPInvokeScanner to MonoTargetsTask.

* Removed BlazorApp.

* Implemented more marshaling validation rules, removed warning message that got "promoted" to an error.

* Catching bad image exceptions, giving reason for requiring marshal-ilgen.

* Cleaned up references to standalone MarshalingPInvokeScanner project, now that the analyzer is in MonoTargtesTask.

* More cleanup.

* Fixed P/Invoke return value in marshal-lightweight.

* Removed incompatible assemblies listing.

* Restoring minimal functionality to marshal-ilgen-stub.

* Addressed feedback.

* Tweaked identification of blittable types. Added explanation to Compatibility enum.

* Moved PInvokeCollector.cs and SignatureMapper.cs back to WasmAppBuilder.

* Addressed feedback.

17 months agoFaster optimized frozen dictionary creation (1/n) (#87510)
Adam Sitnik [Wed, 14 Jun 2023 10:37:44 +0000 (12:37 +0200)]
Faster optimized frozen dictionary creation (1/n) (#87510)

* every strategy needs an array of keys, we can create it up-front and iterate over it rather than the dictionary to get min and max lengths (1-2% gain)

* Instead of ensuring that at least 95% of data is good, we stop when we know that at least 5% is bad (13-14% gain)

* toggle the direction and re-use the comparer and hashset (3% time gain, 12% allocations reduction)

17 months agoFix GetILFunctionBody for dynamic methods (#87530)
David Mason [Wed, 14 Jun 2023 09:55:48 +0000 (02:55 -0700)]
Fix GetILFunctionBody for dynamic methods (#87530)

17 months ago[QUIC] Moved a test using external server to outerloop (#87476)
Marie Píchová [Wed, 14 Jun 2023 07:56:39 +0000 (09:56 +0200)]
[QUIC] Moved a test using external server to outerloop (#87476)

* Moved tests using external server to outerloop

* Removed unnecessary code

17 months agoRemove test exclusions for Json tests (#87457)
Michal Strehovský [Wed, 14 Jun 2023 07:34:09 +0000 (16:34 +0900)]
Remove test exclusions for Json tests (#87457)

17 months agoSPMI: Unify error handling path for replay and asmdiffs (#87464)
Jakob Botsch Nielsen [Wed, 14 Jun 2023 07:07:18 +0000 (09:07 +0200)]
SPMI: Unify error handling path for replay and asmdiffs (#87464)

For asmdiffs we would go into the success path always when the base JIT
succeeded. This meant that if the diff JIT missed we would confusingly
print an error message

    ERROR: method xyz is missing a compileResult, cannot do diffing

even though the "base success, diff miss" case is quite common and
expected. This change makes us take the same error path if either of the
JIT results failed, and then moves the JIT1 unique error handling into
an earlier check.

17 months ago[API Proposal]: Add overload for EventSource primitives (#83751)
Andy Gocke [Wed, 14 Jun 2023 05:58:00 +0000 (22:58 -0700)]
[API Proposal]: Add overload for EventSource primitives (#83751)

I've seen a lot of calls to the varargs EventSource overload that have to manually
suppress the trim warning because they only use primitive types.

Adding this overload solves two problems:
  1. Users won't get a warning if their usage is safe.
  2. Users won't have to suppress a warning.

17 months agoGenerate fewer GenericMethodHashtable entries (#87466)
Michal Strehovský [Wed, 14 Jun 2023 05:06:43 +0000 (14:06 +0900)]
Generate fewer GenericMethodHashtable entries (#87466)

GenericMethodHashtable is a hashtable of all method generic dictionaries statically present in the image. In practice, we don't need a database of all of them - only those that are reflection-visible, or have a type loader template. This PR implements that.

Saves 0.2% on BasicMinimalApi. A bit less than I hoped for but since I already have this...

17 months agoFix DependencyContext splitting on semi-colon (#87518)
Eric Erhardt [Wed, 14 Jun 2023 02:47:39 +0000 (20:47 -0600)]
Fix DependencyContext splitting on semi-colon (#87518)

* Fix DependencyContext splitting on semi-colon

https://github.com/dotnet/runtime/commit/5e67657e20665c32c2bd5c4ac1c8b1af78c9677e introduced a bug in DependencyContextPaths where the static array is not initialized before it is being used in the Create static method.

This fix removes the static array since it is only used once.

- Don't cache the semicolon array since it is only used once at startup
- Skip test on netfx since it doesn't work.

17 months agoImprove the performance of the type loader through various tweaks (#85743)
David Wrighton [Tue, 13 Jun 2023 22:25:50 +0000 (15:25 -0700)]
Improve the performance of the type loader through various tweaks (#85743)

* Skip type validation by default in ReadyToRun images
- Technically, this is a breaking change, so I've provided a means for disabling the type validation skip
- The model is that the C# compile won't get these details wrong, so disable the checks when run through crossgen2. The idea is that we'll get these things checked during normal, non-R2R usage of the app, and publish won't check these details.

* Replace expensive lookups of generic parameter and nested class data with R2R optimized forms

* Store index of MethodDesc as well as ChunkIndex. Makes MethodDesc::GetTemporaryEntryPoint *much* faster

* Optimize the path for computing if a method is eligible for tiered compilation

* Remove CanShareVtableChunksFrom concept
- it was only needed to support NGen

* Fix up some more issues

* Bring back late virtual propagation in the presence of covariant overrides only

* Check correct flag on EEClass

* Drive by fix for GetRestoredSlot. We don't need the handling of unrestored slots anymore

* Fix composite build with new tables

* Uniquify the mangled names

* Add more __

* Initial pass at type skip verifation checker

* Fix logging and some correctness issues

* Enable the more of type checking
- Notably, the recursive stuff now works
- Also fix a bug in constraint checking involving open types in the type system

* Fix build breaks involving new feature of GenericParameterDesc

* Add documentation for R2R format changes
Fix command line parameter to be more reasonable, and allow logging on command
Fix the rest of issues noted in crossgen2 testing

* Fix implementation of CompareMethodContraints. instead of using IsGeneric map, check to see if the method is generic in the first place. It turns out we have an efficient way to check in every place that matters

* Fix nits noticed by Aaron

* Add some const correctness to the world

* Fix issues noted by Michal, as well as remaining constrain checking issues

* Code review details

* Code review from trylek

17 months agoAdd Diagnostics for ComClassGenerator (#87436)
Jackson Schuster [Tue, 13 Jun 2023 22:13:48 +0000 (15:13 -0700)]
Add Diagnostics for ComClassGenerator (#87436)

Adds diagnostics to ComClassGenerator for invalid uses of GeneratedComClass

17 months ago[mono][jit] Add JIT support for the methods in Vector128<T> on amd64. (#86546)
Zoltan Varga [Tue, 13 Jun 2023 22:00:41 +0000 (18:00 -0400)]
[mono][jit] Add JIT support for the methods in Vector128<T> on amd64. (#86546)

* [mono][jit] Add JIT support for the methods in Vector128<T> on amd64.

* Avoid emitting OP_NOT_NULL opcodes in non-llvm mode, they are not used, and they keep their inputs alive.

* Return true for IsSupported for non 128 bit types even if the operations are not supported.

* Fix windows support.

* Add support for some binary operations.

* Disable Dot for integer types.

* Add support for Create.

* Fix some typos in the intrinsics tests.

* Enable As methods.

* Enable Abs/AndNot. Simplify INSERT_R8.

* Add more methods.

* Add compare methods.

* Add CreateScalar/CreateScalarUnsafe.

* Add Sqrt/Sum.

* Fix GetElement/WithElement<long>.

* Implement some of the convert methods, disable the rest.

* Fix GetElement<int>.

* Require SSE41.

* Fix OP_EXTRACT_I1.

* Fix INSERT_R8.

* Improve OP_NEGATION R4/R8.

17 months agoShrink ManifestEnvelope.MaxChunkSize to hold extended data (#87322)
ms-hujia [Tue, 13 Jun 2023 21:49:14 +0000 (05:49 +0800)]
Shrink ManifestEnvelope.MaxChunkSize to hold extended data (#87322)

17 months agoEmit additional attributes with global qualifier (#87497)
Jeremy Koritzinsky [Tue, 13 Jun 2023 21:36:39 +0000 (14:36 -0700)]
Emit additional attributes with global qualifier (#87497)

17 months agoSubject src-gen serializer to full number-handling test (#87484)
Eirik Tsarpalis [Tue, 13 Jun 2023 21:10:48 +0000 (22:10 +0100)]
Subject src-gen serializer to full number-handling test (#87484)

* Subject src-gen serializer to full number-handling tests

* Make failing tests pass

* Revert API break and use contract APIs instead

* React to test infra changes

* Fix rebase conflicts & ensure all tests are passing.

---------

Co-authored-by: Layomi Akinrinade <laakinri@microsoft.com>
17 months agoUpdate debugging-vscode.md (#87338)
Dan Moseley [Tue, 13 Jun 2023 21:01:37 +0000 (14:01 -0700)]
Update debugging-vscode.md (#87338)

17 months ago[wasm] Change optimization flag to workaround llvm issue (#87473)
Radek Doulik [Tue, 13 Jun 2023 20:39:58 +0000 (22:39 +0200)]
[wasm] Change optimization flag to workaround llvm issue (#87473)

17 months ago[wasm] Fix perf pipeline (#87469)
Ankit Jain [Tue, 13 Jun 2023 20:05:47 +0000 (16:05 -0400)]
[wasm] Fix perf pipeline (#87469)

* [wasm] Use the current `test-main.js` instead of the one for 7.0

* [wasm] perf: Add `--module` arg for v8, to support the es6 module

* [wasm] perf: Use tar for BrowserWasm for perf runs

.. because the new image does not have `zip` installed.

* remove debug bits

17 months agoFix break from wchar_t usage in disableddotnetruntime (#87509)
Elinor Fung [Tue, 13 Jun 2023 20:04:43 +0000 (13:04 -0700)]
Fix break from wchar_t usage in disableddotnetruntime (#87509)

17 months ago[RISC-V][JIT] Fix encoding of CallGCregs (#87467)
Dong-Heon Jung [Tue, 13 Jun 2023 19:18:09 +0000 (04:18 +0900)]
[RISC-V][JIT] Fix encoding of CallGCregs (#87467)

- It fixes what Encoding and Decoding logic handle CallGCregs differently.

17 months ago[main] Update dependencies from dotnet/runtime dotnet/icu dotnet/xharness dotnet...
dotnet-maestro[bot] [Tue, 13 Jun 2023 18:13:31 +0000 (13:13 -0500)]
[main] Update dependencies from dotnet/runtime dotnet/icu dotnet/xharness dotnet/emsdk dotnet/cecil dotnet/sdk (#87375)

* Update dependencies from https://github.com/dotnet/sdk build 20230610.2

Microsoft.DotNet.ApiCompat.Task
 From Version 8.0.100-preview.6.23309.13 -> To Version 8.0.100-preview.6.23310.2

* Update dependencies from https://github.com/dotnet/runtime build 20230609.7

Microsoft.NET.ILLink.Tasks , Microsoft.NET.Sdk.IL , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.ILAsm , runtime.native.System.IO.Ports , System.Text.Json
 From Version 8.0.0-preview.6.23304.2 -> To Version 8.0.0-preview.6.23309.7

* Update dependencies from https://github.com/dotnet/sdk build 20230612.2

Microsoft.DotNet.ApiCompat.Task
 From Version 8.0.100-preview.6.23309.13 -> To Version 8.0.100-preview.6.23312.2

* Update dependencies from https://github.com/dotnet/icu build 20230612.1

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 8.0.0-preview.6.23305.2 -> To Version 8.0.0-preview.6.23312.1

* Update dependencies from https://github.com/dotnet/xharness build 20230612.1

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 8.0.0-prerelease.23307.1 -> To Version 8.0.0-prerelease.23312.1

* Update dependencies from https://github.com/dotnet/emsdk build 20230612.1

Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport
 From Version 8.0.0-preview.6.23307.1 -> To Version 8.0.0-preview.6.23312.1

* Update dependencies from https://github.com/dotnet/cecil build 20230612.1

Microsoft.DotNet.Cecil
 From Version 0.11.4-alpha.23306.1 -> To Version 0.11.4-alpha.23312.1

* Update dependencies from https://github.com/dotnet/sdk build 20230613.1

Microsoft.DotNet.ApiCompat.Task
 From Version 8.0.100-preview.6.23309.13 -> To Version 8.0.100-preview.6.23313.1

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months ago[main] Update dependencies from dnceng/internal/dotnet-optimization (#87124)
dotnet-maestro[bot] [Tue, 13 Jun 2023 18:13:03 +0000 (13:13 -0500)]
[main] Update dependencies from dnceng/internal/dotnet-optimization (#87124)

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230604.4

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23304.4

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230605.4

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23305.4

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230606.3

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23306.3

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230607.4

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23307.4

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230608.6

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23308.6

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230609.6

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23309.6

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230610.6

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23310.6

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230611.2

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23303.6 -> To Version 1.0.0-prerelease.23311.2

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months agoDon't return `0` from `getMaxVectorByteLength` when intrinsics are disabled (#87420)
Tanner Gooding [Tue, 13 Jun 2023 17:43:42 +0000 (10:43 -0700)]
Don't return `0` from `getMaxVectorByteLength` when intrinsics are disabled (#87420)

17 months agoFix WCHAR definition on non-Windows for nativeaot (#87465)
Elinor Fung [Tue, 13 Jun 2023 15:47:43 +0000 (08:47 -0700)]
Fix WCHAR definition on non-Windows for nativeaot (#87465)

This fixes enabling of runtime events on non-Windows. The GC events that don't go
through ETW::GCLog are now fired/collected on non-Windows.

There is still work needed to pull in the ETW::GCLog implementation on non-Windows

17 months agoFix missing GC counter data on non-Windows (#87430)
Elinor Fung [Tue, 13 Jun 2023 15:47:05 +0000 (08:47 -0700)]
Fix missing GC counter data on non-Windows (#87430)

This sets FEATURE_EVENT_TRACE on non-Windows platforms as well, such that GC counter
information is tracked and provided when requested.

This does not fully enable runtime event tracing via EventPipe on non-Windows.

17 months agoCombine two table lookups into one while formatting Guid on Arm64 (#87126)
SwapnilGaikwad [Tue, 13 Jun 2023 15:28:53 +0000 (16:28 +0100)]
Combine two table lookups into one while formatting Guid on Arm64 (#87126)

* Combine two table lookups into one while formatting Guid on Arm64

* Add a comment to explain the combined table look-up and hex indices

17 months agoClone files on OSX-like platforms when possible, instead of copying the whole file...
Hamish Arblaster [Tue, 13 Jun 2023 14:58:17 +0000 (00:58 +1000)]
Clone files on OSX-like platforms when possible, instead of copying the whole file (#79243)

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Dan Moseley <danmose@microsoft.com>
17 months agoRedirect ActiveIssue on a test (#87468)
Michal Strehovský [Tue, 13 Jun 2023 13:34:48 +0000 (22:34 +0900)]
Redirect ActiveIssue on a test (#87468)

17 months ago [browser][debugger][MT] Make operations on dictionary thread-safe. (#87405)
Ilona Tomkowicz [Tue, 13 Jun 2023 11:57:38 +0000 (13:57 +0200)]
 [browser][debugger][MT] Make operations on dictionary thread-safe. (#87405)

* `ConcurrentDicionary` should be thread-safe.

Co-authored-by: Ankit Jain <radical@gmail.com>
---------

Co-authored-by: Ankit Jain <radical@gmail.com>
17 months agoFold const WithElement to CNS_VEC (#86212)
Jasper [Tue, 13 Jun 2023 11:53:59 +0000 (13:53 +0200)]
Fold const WithElement to CNS_VEC (#86212)

Co-authored-by: Egor Bogatov <egorbo@gmail.com>
17 months ago[wasm] Disable the PackedSimd.Shuffle intrinsic. (#86025)
Zoltan Varga [Tue, 13 Jun 2023 11:21:12 +0000 (07:21 -0400)]
[wasm] Disable the PackedSimd.Shuffle intrinsic. (#86025)

LLVM crashes if the underlying intrinsic has a non-constant
shuffle argument, and we can't guarantee that.

Co-authored-by: Radek Doulik <radek.doulik@gmail.com>
17 months ago[wasm] Add PackedSimd load and load scalar methods (#87052)
Radek Doulik [Tue, 13 Jun 2023 11:09:08 +0000 (13:09 +0200)]
[wasm] Add PackedSimd load and load scalar methods (#87052)

* [wasm] Add PackedSimd load and load scalar methods

* Fix build

17 months agoJIT: Handle commas in physical promotion (#87401)
Jakob Botsch Nielsen [Tue, 13 Jun 2023 10:06:26 +0000 (12:06 +0200)]
JIT: Handle commas in physical promotion (#87401)

Physical promotion was not properly handling accounting in the presence
of commas and was not properly handling struct commas during
replacement.

17 months agoUse INS_inc for Interlocked.Increment (#87442)
Egor Bogatov [Tue, 13 Jun 2023 09:21:18 +0000 (11:21 +0200)]
Use INS_inc for Interlocked.Increment (#87442)

17 months agoProperly check ISAs for static readonly simd fields (#87402)
Egor Bogatov [Tue, 13 Jun 2023 09:21:02 +0000 (11:21 +0200)]
Properly check ISAs for static readonly simd fields (#87402)

17 months agoEnsure that types of ignored or inaccessible properties are not included by the sourc...
Eirik Tsarpalis [Tue, 13 Jun 2023 08:30:27 +0000 (09:30 +0100)]
Ensure that types of ignored or inaccessible properties are not included by the source generator. (#87383)

17 months agoApplyStartupHook diagnostic IPC command (#86813)
Justin Anderson [Tue, 13 Jun 2023 07:28:19 +0000 (00:28 -0700)]
ApplyStartupHook diagnostic IPC command (#86813)

17 months agoThe CLA bot can now be rerun with a comment. Fix broken CLA links. (#86825)
Jeff Handley [Tue, 13 Jun 2023 05:55:57 +0000 (22:55 -0700)]
The CLA bot can now be rerun with a comment. Fix broken CLA links. (#86825)

17 months ago[NativeAOT] Avoid redundant unwind info lookup during stackwalks (#87419)
Jan Kotas [Tue, 13 Jun 2023 04:56:15 +0000 (21:56 -0700)]
[NativeAOT] Avoid redundant unwind info lookup during stackwalks (#87419)

Unwind info was looked up twice on non-Windows: Once during initial frame inspection
and second during the actual unwind. Cache the lookup results from the
initial frame inspection and use them from the actual unwind later, same
as it is done on Windows.

17 months agoUpdate HelloiOS.app publish folder path. (#87439)
Parker Bibus [Tue, 13 Jun 2023 03:51:19 +0000 (20:51 -0700)]
Update HelloiOS.app publish folder path. (#87439)

17 months agoFix neutral cultures created with the underscore (#87411)
Tarek Mahmoud Sayed [Tue, 13 Jun 2023 03:34:04 +0000 (20:34 -0700)]
Fix neutral cultures created with the underscore (#87411)

17 months agoWarn when user code casts between runtime-based COM interop types and source-generate...
Jeremy Koritzinsky [Tue, 13 Jun 2023 03:10:33 +0000 (20:10 -0700)]
Warn when user code casts between runtime-based COM interop types and source-generated COM interop types (#87425)

17 months agoDisable StressTestDeepNestingOfLoops for NonBacktracking engine (#87369)
Dan Moseley [Tue, 13 Jun 2023 02:05:13 +0000 (19:05 -0700)]
Disable StressTestDeepNestingOfLoops for NonBacktracking engine (#87369)

* Disable hanging RE test

* feedback

* Oops

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Update testing.md

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
17 months agoadd RID for Debian 12 (#87433)
Tomas Weinfurt [Tue, 13 Jun 2023 01:32:17 +0000 (03:32 +0200)]
add RID for Debian 12 (#87433)

17 months agoFix determinism stress perf, by using the ConditionalWeakTable as a static, not as...
David Wrighton [Tue, 13 Jun 2023 01:24:47 +0000 (18:24 -0700)]
Fix determinism stress perf, by using the ConditionalWeakTable as a static, not as an instance method (#87447)

17 months agoAdapt Tarjan generic cycle detector for use in Crossgen2 (#71426)
Tomáš Rylek [Tue, 13 Jun 2023 00:49:39 +0000 (02:49 +0200)]
Adapt Tarjan generic cycle detector for use in Crossgen2 (#71426)

This change modifies Crossgen2 to use the generic cycle detector
originally implemented for NativeAOT to trim infinite generic
expansion as observed in the LanguageExt public nuget package
and tracked by the issue

https://github.com/dotnet/runtime/issues/66079

For now the generic cycle detector is opt-in as it's relatively costly
in terms of compiler performance and it seems to be a relatively
niche case. We can follow up by optimizing the detector if it turns
out to be more prevalent or if we make the call to turn it on by
default, I have mentioned several options for that in the PR.

Thanks

Tomas

17 months agoUpgrading Vector256/512 Shuffle() with VBMI support (#87083)
DeepakRajendrakumaran [Mon, 12 Jun 2023 23:18:39 +0000 (16:18 -0700)]
Upgrading Vector256/512 Shuffle() with VBMI support (#87083)

* Upgrading Shuffle()

* Simplifying 'needsZero' initialization. Should be initialized to 'false' for (simdSize == 32) IMO

* Review Changes

* Another review fix.

17 months agoConfigure ComInterfaceGenerator to be referenced by default (#87422)
Jeremy Koritzinsky [Mon, 12 Jun 2023 22:30:59 +0000 (15:30 -0700)]
Configure ComInterfaceGenerator to be referenced by default (#87422)

17 months agoAccount for CORINFO_HELP_VIRTUAL_FUNC_PTR in GT_LABEL; avoid double resolving (#87395)
Jakob Botsch Nielsen [Mon, 12 Jun 2023 21:25:19 +0000 (23:25 +0200)]
Account for CORINFO_HELP_VIRTUAL_FUNC_PTR in GT_LABEL; avoid double resolving (#87395)

In the helper-based tailcall mechanism it is possible that we expand the
target call into two actual calls: first, a call to
CORINFO_HELP_VIRTUAL_FUNC_PTR to compute the target, and second a call
to that target. We were not taking into account that the return address
needed for the tailcall mechanism needs to be from the second call.

In this particular case the runtime does not request the JIT to pass the
target; that means we end up resolving the target from both the caller
and from the CallTailCallTarget stub. Ideally the JIT would be able to
eliminate the CORINFO_HELP_VIRTUAL_FUNC_PTR call in the caller since it
turns out to be unused, but that requires changes in DCE (and is
somewhat non-trivial, as we have to preserve a null-check).

A simpler way to improve the case is to just change the runtime to
always request the target from the JIT for GVMs, which means the
CallTailCallTarget stub no longer needs to resolve it. That also has the
effect of fixing the original issue, but I have left the original fix in
as well.

Fix #87393

17 months agoFix Double.NegativeZero (#87364)
skyoxZ [Mon, 12 Jun 2023 20:49:10 +0000 (04:49 +0800)]
Fix Double.NegativeZero (#87364)

17 months agoChange the stresslog message layout to support extra-large modules and modules loaded...
Jeremy Koritzinsky [Mon, 12 Jun 2023 20:24:08 +0000 (13:24 -0700)]
Change the stresslog message layout to support extra-large modules and modules loaded at far-apart addresses that use the stresslog (#83855)

17 months ago[browser][MT] GC, threadpool and some JS interop improvements (#86759)
Pavel Savara [Mon, 12 Jun 2023 19:43:16 +0000 (21:43 +0200)]
[browser][MT] GC, threadpool and some JS interop improvements (#86759)

17 months agoFix #61604 by simply removing the possibility of throwing an exception in those cases...
David Wrighton [Mon, 12 Jun 2023 19:14:25 +0000 (12:14 -0700)]
Fix #61604 by simply removing the possibility of throwing an exception in those cases (#87355)

17 months agoFix name mangling issue where two subtly different MethodWithToken instances which...
David Wrighton [Mon, 12 Jun 2023 19:14:02 +0000 (12:14 -0700)]
Fix name mangling issue where two subtly different MethodWithToken instances which only differ by OwningType had the same mangled name (#87353)

17 months agoAdd a JsonConverter.Type property. (#87382)
Eirik Tsarpalis [Mon, 12 Jun 2023 18:55:10 +0000 (19:55 +0100)]
Add a JsonConverter.Type property. (#87382)

17 months agoClean up code, use DiagnosticInfo in LibraryImportGenerator, Cache well known attribu...
Jackson Schuster [Mon, 12 Jun 2023 18:36:56 +0000 (11:36 -0700)]
Clean up code, use DiagnosticInfo in LibraryImportGenerator, Cache well known attribute types in StubEnvironment (#87348)

Remove unused usings and simplify access to CodeAnalysis.Location.

Cache the attributes searched for in incremental stub calculations.

Add warning if unsafe blocks are not allowed.

Removes assert in ComMethodInfo that was throwing when editing files in the test project.

Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
17 months agoMove System.Transactions.Local over to using source-generated COM instead of built...
Jeremy Koritzinsky [Mon, 12 Jun 2023 18:08:06 +0000 (11:08 -0700)]
Move System.Transactions.Local over to using source-generated COM instead of built-in COM whenever possible. (#87351)

Co-authored-by: Shay Rojansky <roji@roji.org>