Skip to content

Commit 2a51d98

Browse files
committed
Merge branch 'main' of github.com:dotnet/runtime into gs-cookie-bb
2 parents 19ec2c0 + 3e0afa6 commit 2a51d98

File tree

498 files changed

+6473
-3107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

498 files changed

+6473
-3107
lines changed

docs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Design Docs
2626

2727
- [.NET Globalization Invariant Mode](design/features/globalization-invariant-mode.md)
2828
- [WASM Globalization Icu](design/features/globalization-icu-wasm.md)
29-
- [Cross-Platform Cryptography](design/features/cross-platform-cryptography.md)
3029
- Many more under [design/features](design/features/)
3130

3231
The Book of the Runtime is a set of chapters that go in depth into various

docs/workflow/building/libraries/webassembly-instructions.md

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,20 @@
1-
# Build for WebAssembly
1+
# Build libraries for WebAssembly
22

33
## Prerequisites
44

55
If you haven't already done so, please read [this document](../../README.md#Build_Requirements) to understand the build requirements for your operating system.
66

7-
The **correct version** of Emscripten SDK (emsdk) needs to be installed.
8-
* Run `make -C src/mono/wasm provision-wasm` to install emsdk into `src/mono/wasm/emsdk`.
9-
* Alternatively follow the [installation guide](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install).
10-
Do not install `latest` but rather specific version e.g. `./emsdk install 2.0.23`. See [emscripten-version.txt](../../../../src/mono/wasm/emscripten-version.txt)
7+
## Building
118

12-
Once installed the `EMSDK_PATH` environment variable needs to be set:
13-
14-
On Linux and macOS:
15-
16-
```bash
17-
export EMSDK_PATH=<FULL_PATH_TO_SDK_INSTALL>/emsdk
18-
```
19-
20-
## Building everything
21-
22-
At this time no other build dependencies are necessary to start building for WebAssembly.
9+
At this time no other build dependencies are necessary to start building for WebAssembly. Emscripten will be downloaded and installed automatically in the build process. To read how to build on specific platforms, see [Building](../../../../src/mono/wasm/README.md#building).
2310

2411
This document explains how to work on the runtime or libraries. If you haven't already done so, please read [this document](../../README.md#Configurations) to understand configurations.
2512

26-
For Linux and macOS:
27-
28-
```bash
29-
./build.sh -os browser -configuration Release
30-
```
31-
32-
Artifacts will be placed in `artifacts/bin/microsoft.netcore.app.runtime.browser-wasm/Release/`. When rebuilding with `build.sh` after a code change, you need to ensure that the `mono.wasmruntime` and `libs.pretest` subsets are included even for a Mono-only change or this directory will not be updated (details below).
13+
When rebuilding with `build.sh` after a code change, you need to ensure that the `mono.wasmruntime` and `libs.pretest` subsets are included even for a Mono-only change or this directory will not be updated (details below).
3314

3415
### Note: do not mix runtime and library configurations
3516

36-
At this time, it is not possible to specify different configurations for the runtime and libraries. That is mixing a Release `-runtimeConfiguration` with a Debug `-libraryConfiguration` (or `-configuration`), or vice versa will not work.
17+
At this time, it is not possible to specify different configurations for the runtime and libraries. That is mixing a Release `-runtimeConfiguration` with a Debug `-libraryConfiguration` (or `-configuration`), or vice versa will not work. The same applies to single and multithreaded configurations.
3718

3819
Please only use the `-configuration` option with `Debug` or `Release`, and do not specify a `-runtimeConfiguration` and `-libraryConfiguration`.
3920

@@ -68,7 +49,7 @@ Building both Mono/System.Private.CoreLib and the managed libraries:
6849

6950
## Building the WebAssembly runtime files
7051

71-
The WebAssembly implementation files are built after the libraries source build and made available in the artifacts folder. If you are working on the code base and need to compile just these modules then building the `Mono.WasmRuntime` subset will allow one to do that:
52+
The WebAssembly implementation files are built after the libraries source build and made available in the artifacts folder. If you are working on the code base and need to compile just these modules then building the `Mono.WasmRuntime` subset will allow one to do that:
7253

7354
```bash
7455
./build.sh mono.wasmruntime -os browser -c Debug|Release
@@ -174,3 +155,7 @@ container:
174155
```
175156

176157
Open a PR request with the new image.
158+
159+
# Test libraries
160+
161+
You can read about running library tests in [Libraries tests](../../../../src/mono/wasm/README.md#libraries-tests).

docs/workflow/building/mono/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The build has a number of options that you can learn about using build -?.
7272

7373
### WebAssembly
7474

75-
See the instructions for [Building WebAssembly](../../building/libraries/webassembly-instructions.md).
75+
See the instructions for [Building WebAssembly](../../../../src/mono/wasm/README.md).
7676

7777
### Android
7878

docs/workflow/debugging/mono/wasm-debugging.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,87 @@ C @ blazor.webassembly.js:1
257257
dispatchGlobalEventToAllElements @ blazor.webassembly.js:1
258258
onGlobalEvent @ blazor.webassembly.js:1
259259
```
260+
261+
# Enabling additional logging in Blazor
262+
263+
In .NET 8+, Blazor startup can be controlled by setting the `autostart="false"` attribute on the
264+
`<script>` tag that loads the blazor webassembly framework. After that, a call to the
265+
`globalThis.Blazor.start()` JavaScript function can be passed additional configuration options,
266+
including setting mono environment variables, or additional command line arguments.
267+
268+
The name of the script and the location of the `<script>` tag depends on whether the project was a
269+
Blazor WebAssembly project (template `blazorwasm`) or a Blazor project (template `blazor`).
270+
271+
See the runtime `DotnetHostBuilder` interface in
272+
[dotnet.d.ts](../../../../src/mono/wasm/runtime/dotnet.d.ts) for additional configuration functions.
273+
274+
## Blazor WebAssembly
275+
276+
In a `blazorwasm` project, the script is `_framework/blazor.webassembly.js` and it is loaded in `wwwroot/index.html`:
277+
278+
```html
279+
<body>
280+
<div id="app">
281+
...
282+
</div>
283+
284+
<div id="blazor-error-ui">
285+
...
286+
</div>
287+
<script src="_framework/blazor.webassembly.js"></script>
288+
</body>
289+
```
290+
291+
Replace it with this:
292+
293+
```html
294+
<body>
295+
<div id="app">
296+
...
297+
</div>
298+
299+
<div id="blazor-error-ui">
300+
...
301+
</div>
302+
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
303+
304+
<script>
305+
Blazor.start({
306+
configureRuntime: dotnet => {
307+
dotnet.withEnvironmentVariable("MONO_LOG_LEVEL", "debug");
308+
dotnet.withEnvironmentVariable("MONO_LOG_MASK", "all");
309+
}
310+
});
311+
</script></body>
312+
```
313+
314+
## Blazor
315+
316+
In a `blazor` project, the script is `_framework/blazor.web.js` and it is loaded by `Components/App.razor` in the server-side project:
317+
318+
```html
319+
<body>
320+
<Routes />
321+
<script src="_framework/blazor.web.js"></script>
322+
</body>
323+
```
324+
325+
Replace it with this (note that for a `blazor` project, `Blazor.start` needs an extra dictionary with a `webAssembly` key):
326+
327+
```html
328+
<body>
329+
<Routes />
330+
<script src="_framework/blazor.web.js" autostart="false"></script>
331+
<script>
332+
Blazor.start({
333+
webAssembly: {
334+
configureRuntime: dotnet => {
335+
console.log("in configureRuntime");
336+
dotnet.withEnvironmentVariable("MONO_LOG_LEVEL", "debug");
337+
dotnet.withEnvironmentVariable("MONO_LOG_MASK", "all");
338+
}
339+
}
340+
});
341+
</script>
342+
</body>
343+
```

eng/testing/performance/performance-setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ if [[ "$physicalpromotion" == "true" ]]; then
371371
configurations="$configurations PhysicalPromotionType=physicalpromotion"
372372
fi
373373

374-
if [[ "${hybridglobalization,,}" == "true" ]]; then # convert to lowercase to test
374+
if [[ "$(echo "$hybridglobalization" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then # convert to lowercase to test
375375
configurations="$configurations HybridGlobalization=True" # Force True for consistency
376376
fi
377377

@@ -421,7 +421,7 @@ if [[ -n "$wasm_bundle_directory" ]]; then
421421
using_wasm=true
422422
wasm_bundle_directory_path=$payload_directory
423423
mv $wasm_bundle_directory/* $wasm_bundle_directory_path
424-
wasm_args="--experimental-wasm-eh --expose_wasm"
424+
wasm_args="--expose_wasm"
425425
if [ "$javascript_engine" == "v8" ]; then
426426
# for es6 module support
427427
wasm_args="$wasm_args --module"

src/coreclr/jit/block.cpp

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,6 @@ void BasicBlock::dspFlags()
399399
{
400400
printf("failV ");
401401
}
402-
if (bbFlags & BBF_TRY_BEG)
403-
{
404-
printf("try ");
405-
}
406402
if (bbFlags & BBF_RUN_RARELY)
407403
{
408404
printf("rare ");
@@ -613,15 +609,35 @@ void BasicBlock::dspJumpKind()
613609
switch (bbJumpKind)
614610
{
615611
case BBJ_EHFINALLYRET:
612+
{
613+
printf(" ->");
614+
615+
// Early in compilation, we display the jump kind before the BBJ_EHFINALLYRET successors have been set.
616+
if (bbJumpEhf == nullptr)
617+
{
618+
printf(" ????");
619+
}
620+
else
621+
{
622+
const unsigned jumpCnt = bbJumpEhf->bbeCount;
623+
BasicBlock** const jumpTab = bbJumpEhf->bbeSuccs;
624+
625+
for (unsigned i = 0; i < jumpCnt; i++)
626+
{
627+
printf("%c" FMT_BB, (i == 0) ? ' ' : ',', jumpTab[i]->bbNum);
628+
}
629+
}
630+
616631
printf(" (finret)");
617632
break;
633+
}
618634

619635
case BBJ_EHFAULTRET:
620636
printf(" (falret)");
621637
break;
622638

623639
case BBJ_EHFILTERRET:
624-
printf(" (fltret)");
640+
printf(" -> " FMT_BB " (fltret)", bbJumpDest->bbNum);
625641
break;
626642

627643
case BBJ_EHCATCHRET:
@@ -1065,14 +1081,13 @@ unsigned BasicBlock::NumSucc() const
10651081
{
10661082
case BBJ_THROW:
10671083
case BBJ_RETURN:
1068-
case BBJ_EHFINALLYRET:
10691084
case BBJ_EHFAULTRET:
1070-
case BBJ_EHFILTERRET:
10711085
return 0;
10721086

10731087
case BBJ_CALLFINALLY:
10741088
case BBJ_ALWAYS:
10751089
case BBJ_EHCATCHRET:
1090+
case BBJ_EHFILTERRET:
10761091
case BBJ_LEAVE:
10771092
case BBJ_NONE:
10781093
return 1;
@@ -1087,6 +1102,23 @@ unsigned BasicBlock::NumSucc() const
10871102
return 2;
10881103
}
10891104

1105+
case BBJ_EHFINALLYRET:
1106+
// We may call this method before we realize we have invalid IL. Tolerate.
1107+
//
1108+
if (!hasHndIndex())
1109+
{
1110+
return 0;
1111+
}
1112+
1113+
// We may call this before we've computed the BBJ_EHFINALLYRET successors in the importer. Tolerate.
1114+
//
1115+
if (bbJumpEhf == nullptr)
1116+
{
1117+
return 0;
1118+
}
1119+
1120+
return bbJumpEhf->bbeCount;
1121+
10901122
case BBJ_SWITCH:
10911123
return bbJumpSwt->bbsCount;
10921124

@@ -1112,6 +1144,7 @@ BasicBlock* BasicBlock::GetSucc(unsigned i) const
11121144
case BBJ_CALLFINALLY:
11131145
case BBJ_ALWAYS:
11141146
case BBJ_EHCATCHRET:
1147+
case BBJ_EHFILTERRET:
11151148
case BBJ_LEAVE:
11161149
return bbJumpDest;
11171150

@@ -1126,9 +1159,13 @@ BasicBlock* BasicBlock::GetSucc(unsigned i) const
11261159
else
11271160
{
11281161
assert(i == 1);
1162+
assert(bbNext != bbJumpDest);
11291163
return bbJumpDest;
11301164
}
11311165

1166+
case BBJ_EHFINALLYRET:
1167+
return bbJumpEhf->bbeSuccs[i];
1168+
11321169
case BBJ_SWITCH:
11331170
return bbJumpSwt->bbsDstTab[i];
11341171

@@ -1164,7 +1201,15 @@ unsigned BasicBlock::NumSucc(Compiler* comp)
11641201
{
11651202
return 0;
11661203
}
1167-
return comp->fgNSuccsOfFinallyRet(this);
1204+
1205+
// We may call this before we've computed the BBJ_EHFINALLYRET successors in the importer. Tolerate.
1206+
//
1207+
if (bbJumpEhf == nullptr)
1208+
{
1209+
return 0;
1210+
}
1211+
1212+
return bbJumpEhf->bbeCount;
11681213

11691214
case BBJ_CALLFINALLY:
11701215
case BBJ_ALWAYS:
@@ -1213,15 +1258,14 @@ BasicBlock* BasicBlock::GetSucc(unsigned i, Compiler* comp)
12131258
switch (bbJumpKind)
12141259
{
12151260
case BBJ_EHFILTERRET:
1216-
{
12171261
// Handler is the (sole) normal successor of the filter.
12181262
assert(comp->fgFirstBlockOfHandler(this) == bbJumpDest);
12191263
return bbJumpDest;
1220-
}
12211264

12221265
case BBJ_EHFINALLYRET:
1223-
// Note: the following call is expensive.
1224-
return comp->fgSuccOfFinallyRet(this, i);
1266+
assert(bbJumpEhf != nullptr);
1267+
assert(i < bbJumpEhf->bbeCount);
1268+
return bbJumpEhf->bbeSuccs[i];
12251269

12261270
case BBJ_CALLFINALLY:
12271271
case BBJ_ALWAYS:
@@ -1240,6 +1284,7 @@ BasicBlock* BasicBlock::GetSucc(unsigned i, Compiler* comp)
12401284
else
12411285
{
12421286
assert(i == 1);
1287+
assert(bbNext != bbJumpDest);
12431288
return bbJumpDest;
12441289
}
12451290

@@ -1645,6 +1690,24 @@ BBswtDesc::BBswtDesc(Compiler* comp, const BBswtDesc* other)
16451690
}
16461691
}
16471692

1693+
//------------------------------------------------------------------------
1694+
// BBehfDesc copy ctor: copy a EHFINALLYRET descriptor
1695+
//
1696+
// Arguments:
1697+
// comp - compiler instance
1698+
// other - existing descriptor to copy
1699+
//
1700+
BBehfDesc::BBehfDesc(Compiler* comp, const BBehfDesc* other) : bbeCount(other->bbeCount)
1701+
{
1702+
// Allocate and fill in a new dst tab
1703+
//
1704+
bbeSuccs = new (comp, CMK_BasicBlock) BasicBlock*[bbeCount];
1705+
for (unsigned i = 0; i < bbeCount; i++)
1706+
{
1707+
bbeSuccs[i] = other->bbeSuccs[i];
1708+
}
1709+
}
1710+
16481711
//------------------------------------------------------------------------
16491712
// unmarkLoopAlign: Unmarks the LOOP_ALIGN flag from the block and reduce the
16501713
// loop alignment count.

0 commit comments

Comments
 (0)