Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
101 lines (93 loc) · 3.06 KB

File metadata and controls

101 lines (93 loc) · 3.06 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* @license
* Copyright 2010 The Emscripten Authors
* SPDX-License-Identifier: MIT
*/
// Takes a pair of return values, stashes one in tempRet0 and returns the other.
// Should probably be renamed to `makeReturn64` but keeping this old name in
// case external JS library code uses this name.
function makeStructuralReturn(values) {
assert(values.length == 2);
return 'setTempRet0(' + values[1] + '); return ' + asmCoercion(values[0], 'i32');
}
// Replaced (at least internally) with receiveI64ParamAsI53 that does
// bounds checking.
function receiveI64ParamAsDouble(name) {
if (WASM_BIGINT) {
// Just convert the bigint into a double.
return `${name} = Number(${name});`;
}
// Combine the i32 params. Use an unsigned operator on low and shift high by
// 32 bits.
return `var ${name} = ${name}_high * 0x100000000 + (${name}_low >>> 0);`;
}
function stripCorrections(param) {
let m;
while (true) {
if (m = /^\((.*)\)$/.exec(param)) {
param = m[1];
continue;
}
if (m = /^\(([$_\w]+)\)&\d+$/.exec(param)) {
param = m[1];
continue;
}
if (m = /^\(([$_\w()]+)\)\|0$/.exec(param)) {
param = m[1];
continue;
}
if (m = /^\(([$_\w()]+)\)\>>>0$/.exec(param)) {
param = m[1];
continue;
}
if (m = /CHECK_OVERFLOW\(([^,)]*),.*/.exec(param)) {
param = m[1];
continue;
}
break;
}
return param;
}
const UNROLL_LOOP_MAX = 8;
function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') {
assert(typeof align === 'undefined');
function unroll(type, num, jump = 1) {
const setValues = range(num).map((i) => makeSetValue(dest, i * jump, makeGetValue(src, i * jump, type), type));
return setValues.join(sep);
}
// If we don't know how to handle this at compile-time, or handling it is best
// done in a large amount of code, call memcpy
if (!isNumber(num)) num = stripCorrections(num);
if (!isNumber(align)) align = stripCorrections(align);
if (!isNumber(num) || (parseInt(num) / align >= UNROLL_LOOP_MAX)) {
return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)';
}
num = parseInt(num);
// remove corrections, since we will be correcting after we add anyhow,
dest = stripCorrections(dest);
src = stripCorrections(src);
// and in the heap assignment expression
const ret = [];
[4, 2, 1].forEach((possibleAlign) => {
if (num == 0) return;
if (align >= possibleAlign) {
ret.push(unroll('i' + (possibleAlign * 8), Math.floor(num / possibleAlign), possibleAlign));
src = getFastValue(src, '+', Math.floor(num / possibleAlign) * possibleAlign);
dest = getFastValue(dest, '+', Math.floor(num / possibleAlign) * possibleAlign);
num %= possibleAlign;
}
});
return ret.join(sep);
}
function makeMalloc(source, param) {
return `_malloc(${param})`;
}
function getNativeFieldSize(type) {
return Math.max(getNativeTypeSize(type), POINTER_SIZE);
}
global.Runtime = {
getNativeTypeSize: getNativeTypeSize,
getNativeFieldSize: getNativeFieldSize,
POINTER_SIZE: POINTER_SIZE,
QUANTUM_SIZE: POINTER_SIZE,
};
Morty Proxy This is a proxified and sanitized view of the page, visit original site.