Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken authored Feb 13, 2024
2 parents 2675feb + 4b9a5f7 commit 1f5bf91
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 113 deletions.
16 changes: 3 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,19 +811,7 @@ jobs:
steps:
- run-tests-chrome:
title: "browser_2gb"
test_targets: "
browser_2gb.test_gles2_uniform_arrays
browser_2gb.test_fetch_to_memory
browser_2gb.test_emscripten_animate_canvas_element_size_manual_css
browser_2gb.test_fulles2_sdlproc
browser_2gb.test_cubegeom*
browser_2gb.test_html5_webgl_create_context*
browser_2gb.test_main_thread_async_em_asm
browser_2gb.test_webgl2_*
browser_2gb.test_webgl_*
browser_2gb.test_sdl_image
browser_2gb.test_wasm_worker*
"
test_targets: "browser_2gb"
test-browser-chrome-wasm64-4gb:
executor: bionic
steps:
Expand All @@ -841,6 +829,8 @@ jobs:
browser64_4gb.test_html5_webgl_create_context*
browser64_4gb.test_sdl_image
browser64_4gb.test_wasm_worker*
browser64_4gb.test_cube_explosion
browser64_4gb.test_cubegeom_*
"
test-browser-firefox:
executor: bionic
Expand Down
2 changes: 1 addition & 1 deletion src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ var LibraryDylink = {
}
#if DYLINK_DEBUG
else if (GOT[symName].value != value) {
dbg(`udateGOT: EXISTING SYMBOL: ${symName} : ${GOT[symName].value} (${value})`);
dbg(`updateGOT: EXISTING SYMBOL: ${symName} : ${GOT[symName].value} (${value})`);
}
#endif
}
Expand Down
4 changes: 3 additions & 1 deletion src/library_html5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ var LibraryHtml5WebGL = {
var len = arr.length;
var writeLength = dstLength < len ? dstLength : len;
var heap = heapType ? HEAPF32 : HEAP32;
// Works because HEAPF32 and HEAP32 have the same bytes-per-element
dst = {{{ getHeapOffset('dst', 'float') }}};
for (var i = 0; i < writeLength; ++i) {
heap[(dst >> 2) + i] = arr[i];
heap[dst + i] = arr[i];
}
return len;
},
Expand Down
11 changes: 10 additions & 1 deletion src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,16 @@ function makeSetValueImpl(ptr, pos, value, type) {
function makeHEAPView(which, start, end) {
const size = parseInt(which.replace('U', '').replace('F', '')) / 8;
const shift = Math.log2(size);
const mod = size == 1 ? '' : (CAN_ADDRESS_2GB || MEMORY64) ? ('>>>' + shift) : ('>>' + shift);
let mod = '';
if (size != 1) {
if (MEMORY64) {
mod = '/' + size;
} else if (CAN_ADDRESS_2GB) {
mod = '>>>' + shift;
} else {
mod = '>>' + shift;
}
}
return `HEAP${which}.subarray((${start})${mod}, (${end})${mod})`;
}

Expand Down
55 changes: 24 additions & 31 deletions test/browser/emmalloc_memgrowth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,30 @@
uint64_t nextAllocationSize = 16*1024*1024;
bool allocHasFailed = false;

void grow_memory()
{
uint8_t *ptr = (uint8_t*)malloc((size_t)nextAllocationSize);
EM_ASM({}, ptr); // Pass ptr out to confuse LLVM that it is used, so it won't optimize it away in -O1 and higher.
size_t heapSize = emscripten_get_heap_size();
printf("Allocated %zu: %d. Heap size: %zu\n", (size_t)nextAllocationSize, ptr ? 1 : 0, heapSize);
if (ptr)
{
if (!allocHasFailed)
{
nextAllocationSize *= 2;
// Make sure we don't overflow, and also exercise malloc(-1) to gracefully return 0 in ABORTING_MALLOC=0 mode.
if (nextAllocationSize > 0xFFFFFFFFULL)
nextAllocationSize = 0xFFFFFFFFULL;
}
}
else
{
nextAllocationSize /= 2;
allocHasFailed = true;
}
void grow_memory() {
uint8_t *ptr = (uint8_t*)malloc((size_t)nextAllocationSize);
EM_ASM({}, ptr); // Pass ptr out to confuse LLVM that it is used, so it won't optimize it away in -O1 and higher.
size_t heapSize = emscripten_get_heap_size();
printf("Allocated %zu: %d. Heap size: %zu\n", (size_t)nextAllocationSize, ptr ? 1 : 0, heapSize);
if (ptr) {
if (!allocHasFailed) {
nextAllocationSize *= 2;
// Make sure we don't overflow, and also exercise malloc(-1) to gracefully return 0 in ABORTING_MALLOC=0 mode.
if (nextAllocationSize > 0xFFFFFFFFULL)
nextAllocationSize = 0xFFFFFFFFULL;
}
} else {
nextAllocationSize /= 2;
allocHasFailed = true;
}
}

int main()
{
// Exhaust all available memory.
for(int i = 0; i < 50; ++i)
grow_memory();
// If we get this far without crashing on OOM, we are ok!
printf("Test finished!\n");
#ifdef REPORT_RESULT
REPORT_RESULT(0);
#endif
int main() {
// Exhaust all available memory.
for(int i = 0; i < 50; ++i) {
grow_memory();
}
// If we get this far without crashing on OOM, we are ok!
printf("Test finished!\n");
return 0;
}
47 changes: 18 additions & 29 deletions test/fs/test_idbfs_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@

int result = 1;

void success()
{
void success() {
REPORT_RESULT(result);
#ifdef FORCE_EXIT
emscripten_force_exit(0);
#endif
}

void test() {

int fd;
struct stat st;

#if FIRST

// for each file, we first make sure it doesn't currently exist
Expand All @@ -49,22 +47,20 @@ void test() {
fd = open("/working1/waka.txt", O_RDWR | O_CREAT, 0666);
if (fd == -1)
result = -5000 - errno;
else
{
else {
if (write(fd,"az",2) != 2)
result = -6000 - errno;
if (close(fd) != 0)
result = -7000 - errno;
}

// a file whose contents are random-ish string set by the test_browser.py file
if ((stat("/working1/moar.txt", &st) != -1) || (errno != ENOENT))
result = -8000 - errno;
fd = open("/working1/moar.txt", O_RDWR | O_CREAT, 0666);
if (fd == -1)
result = -9000 - errno;
else
{
else {
if (write(fd, SECRET, strlen(SECRET)) != strlen(SECRET))
result = -10000 - errno;
if (close(fd) != 0)
Expand Down Expand Up @@ -92,8 +88,7 @@ void test() {
fd = open("/working1/waka.txt", O_RDONLY);
if (fd == -1)
result = -17000 - errno;
else
{
else {
char bf[4];
int bytes_read = read(fd,&bf[0],sizeof(bf));
if (bytes_read != 2)
Expand All @@ -105,19 +100,17 @@ void test() {
if (unlink("/working1/waka.txt") != 0)
result = -21000 - errno;
}

// does the random-ish file exist and does it contain SECRET?
fd = open("/working1/moar.txt", O_RDONLY);
if (fd == -1)
if (fd == -1) {
result = -22000 - errno;
else
{
} else {
char bf[256];
int bytes_read = read(fd,&bf[0],sizeof(bf));
if (bytes_read != strlen(SECRET))
if (bytes_read != strlen(SECRET)) {
result = -23000;
else
{
} else {
bf[strlen(SECRET)] = 0;
if (strcmp(bf,SECRET) != 0)
result = -24000;
Expand All @@ -129,14 +122,13 @@ void test() {
}

// does the directory exist?
if (stat("/working1/dir", &st) != 0)
if (stat("/working1/dir", &st) != 0) {
result = -27000 - errno;
else
{
} else {
if (!S_ISDIR(st.st_mode))
result = -28000;
if (rmdir("/working1/dir") != 0)
result = -29000 - errno;
if (rmdir("/working1/dir") != 0)
result = -29000 - errno;
}

#endif
Expand Down Expand Up @@ -164,20 +156,18 @@ void test() {
ccall('success', 'v');
});
);

}

int main() {

EM_ASM(
FS.mkdir('/working1');
FS.mount(IDBFS, {}, '/working1');

#if !FIRST
// syncfs(true, f) should not break on already-existing directories:
FS.mkdir('/working1/dir');
// syncfs(true, f) should not break on already-existing directories:
FS.mkdir('/working1/dir');
#endif

// sync from persisted state into memory and then
// run the 'test' function
FS.syncfs(true, function (err) {
Expand All @@ -187,6 +177,5 @@ int main() {
);

emscripten_exit_with_live_runtime();

return 0;
}
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8348
8360
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22894
22922
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7169
7182
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19518
19546
16 changes: 8 additions & 8 deletions test/other/test_emsize.out
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
section size addr
TYPE 51 0
IMPORT 31 0
FUNCTION 14 0
GLOBAL 9 0
EXPORT 9 0
ELEM 9 0
CODE 1556 0
DATA 77 0
TYPE 51 10
IMPORT 31 63
FUNCTION 14 96
GLOBAL 9 112
EXPORT 9 123
ELEM 9 134
CODE 1556 146
DATA 77 1704
JS 6756 0
Total 8512
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58095
58128
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57006
57039
Loading

0 comments on commit 1f5bf91

Please sign in to comment.