Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the emscripten version to 2.0.23 #681

Merged
merged 26 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ac1df54
updated the emsdk version and other minor fix
Devika-Tantry Jun 9, 2021
cae6de8
minor revert
Devika-Tantry Jun 9, 2021
daec43a
space fix and install number fix
Devika-Tantry Jun 9, 2021
e14cc3f
updated dependency version
Devika-Tantry Jun 9, 2021
6ed6c37
test changes will revert it
Devika-Tantry Jun 9, 2021
0f7c84e
updated hash content and updated to 2.023
Devika-Tantry Jun 9, 2021
6dbda06
updated hash content and updated to 2.023
Devika-Tantry Jun 9, 2021
4b959ec
updated commit id to pint to correct value
Devika-Tantry Jun 9, 2021
338a30e
test changes
Devika-Tantry Jun 14, 2021
33207e2
conver of double to int INT as JS clamp
Devika-Tantry Jun 14, 2021
b80bf11
added .vs file to git ignore
Devika-Tantry Jun 14, 2021
fd75eaf
reverted changes in yml file and minor other fix
Devika-Tantry Jun 14, 2021
62260d5
build fail fix
Devika-Tantry Jun 16, 2021
233c79b
build fail fix
Devika-Tantry Jun 16, 2021
71c2cb3
added new line
Devika-Tantry Jun 16, 2021
70ee2f4
node version update
Devika-Tantry Jun 16, 2021
ed04573
python update
Devika-Tantry Jun 16, 2021
943a2ad
added const to variabale as per comment
Devika-Tantry Jun 17, 2021
5e2867f
changes to look exactly like emcc alogorithm
Devika-Tantry Jun 17, 2021
2162727
Reverted cpp and changes and changed tests
Devika-Tantry Jun 21, 2021
29a495d
lint error fix and test fix
Devika-Tantry Jun 21, 2021
5f3ef20
minor comment update and reverted python update
Devika-Tantry Jun 22, 2021
71aa65f
lint fix
Devika-Tantry Jun 22, 2021
91b56d4
node verision revert
Devika-Tantry Jun 22, 2021
eaa80fc
python revert
Devika-Tantry Jun 22, 2021
edce41a
Added author
Devika-Tantry Jun 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# Install lint dependencies
- uses: actions/setup-python@v2
with:
python-version: '3.5'
python-version: '3.7'
- uses: actions/setup-node@v1
with:
node-version: '12'
Expand All @@ -42,7 +42,7 @@ jobs:
# Install web dependencies
- uses: actions/setup-python@v2
with:
python-version: '3.5'
python-version: '3.7'
- run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
Expand All @@ -55,10 +55,10 @@ jobs:
- run: |
git clone https://github.com/juj/emsdk.git
cd emsdk
git checkout 369013943283939412fb2807bb0d2ded8ebd5a9e
git checkout tags/2.0.23
- run: |
emsdk/emsdk install 1.39.5-fastcomp
emsdk/emsdk activate 1.39.5-fastcomp
emsdk/emsdk install 2.0.23
emsdk/emsdk activate 2.0.23
- run: . emsdk/emsdk_env.sh && emcc -v

# Build web
Expand Down Expand Up @@ -110,18 +110,18 @@ jobs:
- run: chocolatey install gnuwin32-coreutils.portable -y
- uses: actions/setup-python@v2
with:
python-version: '3.5'
python-version: '3.7'
- run: |
python -m pip install --upgrade pip
pip install tox
- run: Start-Process npm "run httpbin" -PassThru
- run: |
git clone https://github.com/juj/emsdk.git
cd emsdk
git checkout 369013943283939412fb2807bb0d2ded8ebd5a9e
git checkout tags/2.0.23
- run: |
emsdk\emsdk install 1.39.5-fastcomp
emsdk\emsdk activate 1.39.5-fastcomp
emsdk\emsdk install 2.0.23
emsdk\emsdk activate 2.0.23
- run: emsdk\emsdk_env.ps1 && emcc -v

# Build web-windows
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Vireo_VS/VireoCommandLine.sln.DotSettings.user
**.opendb
**.suo
.vscode/
.vs/*

# Other
c_cpp_properties.json
Expand Down
4 changes: 2 additions & 2 deletions docs/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ The emsdk toolchain is used to cross-compile Vireo to Vireo.js to run in Node.js
3. From the cloned emsdk repository run the following commands:

```console
emsdk install 1.39.5-fastcomp
emsdk activate 1.39.5-fastcomp
emsdk install 2.0.23
emsdk activate 2.0.23
emcc -v # should match the sdk version
```

Expand Down
8 changes: 4 additions & 4 deletions make-it/EmMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ EMCC= emcc
EM_OPTFLAG = -O3

ifeq ($(BUILD), debug)
EM_OPTFLAG = -g4 -s ASSERTIONS=2 -s SAFE_HEAP=1
EM_OPTFLAG = -g -s ASSERTIONS=2 -s SAFE_HEAP=1
rajsite marked this conversation as resolved.
Show resolved Hide resolved
endif

ifeq ($(BUILD), profile)
Expand All @@ -92,11 +92,11 @@ ifeq ($(TARGET), asmjs-unknown-emscripten)
endif

ifeq ($(TARGET), wasm32-unknown-emscripten)
TARGET_FLAG = -s WASM=1 -s BINARYEN_TRAP_MODE=js -s ALLOW_MEMORY_GROWTH=1
rajsite marked this conversation as resolved.
Show resolved Hide resolved
TARGET_FLAG = -s WASM=1 -s ALLOW_MEMORY_GROWTH=1
endif

# NO_DYNAMIC_EXECUTION=1 Allows Vireo to be used in CSP environments where eval() is forbidden: https://github.com/kripken/emscripten/blob/master/src/settings.js#L563
EM_OPT = $(EM_OPTFLAGS) $(TARGET_FLAG) -s NO_EXIT_RUNTIME=1 -std=c++14 -fno-exceptions -Werror --memory-init-file 0 -s NO_DYNAMIC_EXECUTION=1 -s MODULARIZE=1 -s EXPORT_NAME=VireoCreateCoreModule -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 --minify 0 -s NO_FILESYSTEM=1 -s ABORTING_MALLOC=0
rajsite marked this conversation as resolved.
Show resolved Hide resolved
EM_OPT = $(EM_OPTFLAGS) $(TARGET_FLAG) -std=c++14 -fno-exceptions -Werror --memory-init-file 0 -s NO_DYNAMIC_EXECUTION=1 -s MODULARIZE=1 -s EXPORT_NAME=VireoCreateCoreModule -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 --minify 0 -s NO_FILESYSTEM=1 -s ABORTING_MALLOC=0
EMFLAGS = -I$(INCDIR) -DkVireoOS_emscripten $(EM_OPT)
EMLIBRARY = --js-library $(CORESOURCEDIR)/library_coreHelpers.js \
--js-library $(CORESOURCEDIR)/library_eventHelpers.js \
Expand All @@ -111,7 +111,7 @@ EM_EXPORTS = -s EXPORTED_FUNCTIONS="[\
'_free' \
]"

EM_RUNTIME_EXPORTS = -s EXTRA_EXPORTED_RUNTIME_METHODS="[\
rajsite marked this conversation as resolved.
Show resolved Hide resolved
EM_RUNTIME_EXPORTS = -s EXPORTED_RUNTIME_METHODS="[\
'lengthBytesUTF8', \
'stackAlloc', \
'stackSave', \
Expand Down
4 changes: 2 additions & 2 deletions make-it/EmMakefile-AAL
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ifeq (,$(wildcard $(ANALYSIS_WRAPPERS_SOURCE_DIRECTORY)/AnalysisWrapper*.cpp))
ANALYSIS_LIBRARY = $(OBJS)/NoAnalysisLibrary.bc
$(OBJS)/NoAnalysisLibrary.bc: | no-analysis
touch $(OBJS)/NoAnalysis.cpp
$(EMCC) $(EM_ANALYSIS_FLAGS) -o $@ $(OBJS)/NoAnalysis.cpp
$(EMCC) $(EM_ANALYSIS_FLAGS) -o $@ $(OBJS)/NoAnalysis.cpp -c
rajsite marked this conversation as resolved.
Show resolved Hide resolved
rm $(OBJS)/NoAnalysis.cpp

no-analysis::
Expand Down Expand Up @@ -94,7 +94,7 @@ help:

EMCC= emcc
EM_OPTFLAG = -Os
EM_OPT= $(EM_OPT_FLAG) -s NO_EXIT_RUNTIME=1 -fno-exceptions --memory-init-file 0
EM_OPT= $(EM_OPT_FLAG) -s -fno-exceptions --memory-init-file 0
EMFLAGS= -I$(INCDIR) -DkVireoOS_emscripten -DVIREO_LEAN $(EM_OPT)
EMLIBRARY= --js-library $(IOSOURCEDIR)/library_canvas2d.js --js-library $(IOSOURCEDIR)/library_httpClient.js
EM_WRAP= --pre-js $(CORESOURCEDIR)/vireo.preamble.js --post-js $(CORESOURCEDIR)/vireo.postamble.js
Expand Down
22 changes: 12 additions & 10 deletions source/core/TypeAndDataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,8 @@ IntMax ReadIntFromMemory(TypeRef type, void* pData)
case 0: value = 0; break;
case 4: {
Single singleVal = RoundToEven(*(Single*)pData);
if (singleVal >= std::numeric_limits<IntMax>::max())
const Single intMax = static_cast<Single>(std::numeric_limits<IntMax>::max());
if (singleVal >= intMax)
// >= is actually correct here because Int64 max isn't representable as a single and rounds up.
value = std::numeric_limits<IntMax>::max();
else if (singleVal <= std::numeric_limits<IntMax>::min())
Expand All @@ -2648,7 +2649,8 @@ IntMax ReadIntFromMemory(TypeRef type, void* pData)
}
case 8: {
Double doubleVal = RoundToEven(*(Double*)pData);
if (doubleVal >= std::numeric_limits<IntMax>::max())
const Double intMax = static_cast<Double>(std::numeric_limits<IntMax>::max());
if (doubleVal >= intMax)
// >= is actually correct here because Int64 max isn't representable as a double and rounds up.
value = std::numeric_limits<IntMax>::max();
else if (doubleVal <= std::numeric_limits<IntMax>::min())
Expand Down Expand Up @@ -2845,10 +2847,10 @@ NIError WriteDoubleToMemory(TypeRef type, void* pData, const Double value)
case kEncoding_S2CInt:
case kEncoding_DimInt:
switch (aqSize) {
case 1: *(Int8*)pData = (Int8)value; break;
case 2: *(Int16*)pData = (Int16)value; break;
case 4: *(Int32*)pData = (Int32)value; break;
case 8: *(Int64*)pData = (Int64)value; break;
case 1: *(Int8*)pData = ConvertFloatToInt<Double, Int8>(value); break;
case 2: *(Int16*)pData = ConvertFloatToInt<Double, Int16>(value); break;
case 4: *(Int32*)pData = ConvertFloatToInt<Double, Int32>(value); break;
case 8: *(Int64*)pData = ConvertFloatToInt<Double, Int64>(value); break;
default: err = kNIError_kCantEncode; break;
}
break;
Expand All @@ -2861,10 +2863,10 @@ NIError WriteDoubleToMemory(TypeRef type, void* pData, const Double value)
case kEncoding_UInt:
case kEncoding_Enum:
switch (aqSize) {
case 1: *(UInt8*)pData = (Int8)value; break;
case 2: *(UInt16*)pData = (UInt16)value; break;
case 4: *(UInt32*)pData = (UInt32)value; break;
case 8: *(UInt64*)pData = (UInt64)value; break;
case 1: *(UInt8*)pData = ConvertFloatToInt<Double, UInt8>(value); break;
case 2: *(UInt16*)pData = ConvertFloatToInt<Double, UInt16>(value); break;
case 4: *(UInt32*)pData = ConvertFloatToInt<Double, UInt32>(value); break;
case 8: *(UInt64*)pData = ConvertFloatToInt<Double, UInt64>(value); break;
default: err = kNIError_kCantEncode; break;
}
break;
Expand Down
3 changes: 2 additions & 1 deletion source/include/TypeAndDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,14 @@ template <typename TSource, typename TDest>
TDest ConvertFloatToInt(TSource src)
{
TDest dest;
const TSource maxDestValue = static_cast<TSource>(std::numeric_limits<TDest>::max());
if (std::isnan(src)) {
dest = std::numeric_limits<TDest>::max();
} else if (std::isinf(src)) {
dest = src < 0 ? std::numeric_limits<TDest>::min() : std::numeric_limits<TDest>::max();
} else if (src < std::numeric_limits<TDest>::min()) {
dest = std::numeric_limits<TDest>::min();
} else if (src > std::numeric_limits<TDest>::max()) {
} else if (src > maxDestValue) {
dest = std::numeric_limits<TDest>::max();
} else {
dest = static_cast<TDest>(RoundToEven(src));
Expand Down
13 changes: 13 additions & 0 deletions source/io/module_eggShell.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ var assignEggShell;
return dimensions;
};

// Note: If you are directly writing JavaScript numbers (floating point doubles) to
// integer TypedArray views then be aware that integer TypedArray views will truncate
// overflowing values as specified in TypedArray conversion operations:
// https://tc39.es/ecma262/#table-the-typedarray-constructors
// Vireo requires that overflowing JavaScript numbers written to Vireo integers
// are saturated instead of truncated. Make sure to perform Vireo's float-to-int
// conversion algorithm in JavaScript before directly writing to integer TypeArray views.
Module.eggShell.readTypedArray = publicAPI.eggShell.readTypedArray = function (valueRef) {
var TypedArrayConstructor = findCompatibleTypedArrayConstructor(valueRef.typeRef);
if (TypedArrayConstructor === undefined) {
Expand All @@ -488,6 +495,12 @@ var assignEggShell;
return (TypedArrayConstructor !== undefined && typedArrayValue instanceof TypedArrayConstructor);
};

// Note: When creating integer TypedArrays views from JavaScript numbers to write to
// Vireo using writeTypedArray be aware that integer TypedArray views will truncate
// overflowing values as specified in TypedArray conversion operations:
// https://tc39.es/ecma262/#table-the-typedarray-constructors
// Make sure to perform Vireo's float-to-int conversion algorithm in JavaScript when creating
// integer TypedArray views from JavaScript numbers to write to Vireo memory.
Module.eggShell.writeTypedArray = publicAPI.eggShell.writeTypedArray = function (valueRef, typedArrayValue) {
var TypedArrayConstructor = findCompatibleTypedArrayConstructor(valueRef.typeRef);
if (TypedArrayConstructor === undefined || !(typedArrayValue instanceof TypedArrayConstructor)) {
Expand Down
59 changes: 17 additions & 42 deletions test-it/karma/publicapi/Double.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ describe('The Vireo EggShell Double api can', function () {
expect(readDouble(path)).toMatchIEEE754Number(initialValue);
};

// Expected coerced values of Doubles in Vireo should have the same behavior as assignment to typed arrays
// This is so a user assigning a double to a typedarray using getTypedArray will see the same effect as writing to a double using writeDouble
var expectedCoercedValue = function (TypedArrayConstructor, value) {
Devika-Tantry marked this conversation as resolved.
Show resolved Hide resolved
return (new TypedArrayConstructor([value])[0]);
};

beforeAll(function (done) {
fixtures.preloadAbsoluteUrls([
publicApiMultipleTypesViaUrl
Expand Down Expand Up @@ -138,45 +132,26 @@ describe('The Vireo EggShell Double api can', function () {
});

it('to write integer values to memory', function () {
testWriteDoubleCoerced('int8MinValue', -128, 812, expectedCoercedValue(Int8Array, 812));
testWriteDoubleCoerced('int8MinValue', -128, -812, expectedCoercedValue(Int8Array, -812));
testWriteDoubleCoerced('int16MinValue', -32768, 81234, expectedCoercedValue(Int16Array, 81234));
testWriteDoubleCoerced('int16MinValue', -32768, -81234, expectedCoercedValue(Int16Array, -81234));
testWriteDoubleCoerced('int32MinValue', -2147483648, 8123456789, expectedCoercedValue(Int32Array, 8123456789));
testWriteDoubleCoerced('int32MinValue', -2147483648, -8123456789, expectedCoercedValue(Int32Array, -8123456789));
testWriteDoubleCoerced('uInt8MinValue', 0, 812, expectedCoercedValue(Uint8Array, 812));
testWriteDoubleCoerced('uInt8MinValue', 0, -812, expectedCoercedValue(Uint8Array, -812));
testWriteDoubleCoerced('uInt16MinValue', 0, 81234, expectedCoercedValue(Uint16Array, 81234));
testWriteDoubleCoerced('uInt16MinValue', 0, -81234, expectedCoercedValue(Uint16Array, -81234));
testWriteDoubleCoerced('uInt32MinValue', 0, 8123456789, expectedCoercedValue(Uint32Array, 8123456789));
testWriteDoubleCoerced('uInt32MinValue', 0, -8123456789, expectedCoercedValue(Uint32Array, -8123456789));

expect(expectedCoercedValue(Int8Array, 812)).toBe(44);
expect(expectedCoercedValue(Int8Array, -812)).toBe(-44);
expect(expectedCoercedValue(Int16Array, 81234)).toBe(15698);
expect(expectedCoercedValue(Int16Array, -81234)).toBe(-15698);
expect(expectedCoercedValue(Int32Array, 8123456789)).toBe(-466477803);
expect(expectedCoercedValue(Int32Array, -8123456789)).toBe(466477803);
expect(expectedCoercedValue(Uint8Array, 812)).toBe(44);
expect(expectedCoercedValue(Uint8Array, -812)).toBe(212);
expect(expectedCoercedValue(Uint16Array, 81234)).toBe(15698);
expect(expectedCoercedValue(Uint16Array, -81234)).toBe(49838);
expect(expectedCoercedValue(Uint32Array, 8123456789)).toBe(3828489493);
expect(expectedCoercedValue(Uint32Array, -8123456789)).toBe(466477803);
testWriteDoubleCoerced('int8MinValue', -128, 812, 127);
testWriteDoubleCoerced('int8MinValue', -128, -812, -128);
testWriteDoubleCoerced('int16MinValue', -32768, 81234, 32767);
testWriteDoubleCoerced('int16MinValue', -32768, -81234, -32768);
testWriteDoubleCoerced('int32MinValue', -2147483648, 8123456789, 2147483647);
testWriteDoubleCoerced('int32MinValue', -2147483648, -8123456789, -2147483648);
testWriteDoubleCoerced('uInt8MinValue', 0, 812, 255);
testWriteDoubleCoerced('uInt8MinValue', 0, -812, 0);
testWriteDoubleCoerced('uInt16MinValue', 0, 81234, 65535);
testWriteDoubleCoerced('uInt16MinValue', 0, -81234, 0);
testWriteDoubleCoerced('uInt32MinValue', 0, 8123456789, 4294967295);
testWriteDoubleCoerced('uInt32MinValue', 0, -8123456789, 0);
});

it('to coerce iee754 special values to memory', function () {
testWriteDoubleCoerced('int8MinValue', -128, NaN, expectedCoercedValue(Int8Array, NaN));
testWriteDoubleCoerced('int8MinValue', -128, Infinity, expectedCoercedValue(Int8Array, Infinity));
testWriteDoubleCoerced('int8MinValue', -128, -Infinity, expectedCoercedValue(Int8Array, -Infinity));
testWriteDoubleCoerced('int8MinValue', -128, -0, expectedCoercedValue(Int8Array, -0));
testWriteDoubleCoerced('int8MinValue', -128, 0, expectedCoercedValue(Int8Array, 0));

expect(expectedCoercedValue(Int8Array, NaN)).toBe(0);
expect(expectedCoercedValue(Int8Array, Infinity)).toBe(0);
expect(expectedCoercedValue(Int8Array, -Infinity)).toBe(0);
expect(expectedCoercedValue(Int8Array, -0)).toBe(0);
expect(expectedCoercedValue(Int8Array, 0)).toBe(0);
testWriteDoubleCoerced('int8MinValue', -128, NaN, 127);
rajsite marked this conversation as resolved.
Show resolved Hide resolved
testWriteDoubleCoerced('int8MinValue', -128, Infinity, 127);
testWriteDoubleCoerced('int8MinValue', -128, -Infinity, -128);
testWriteDoubleCoerced('int8MinValue', -128, -0, 0);
testWriteDoubleCoerced('int8MinValue', -128, 0, 0);
});

it('to write different enum values to memory', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ describe('The Vireo EggShell executeSlicesUntilClumpsFinished api', function ()

it('reports error when the Vireo runtime stops execution', async function () {
const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, publicApiLargeAllocationUrl);

const {rawPrint, rawPrintError} = await runSlicesAsync();
expect(rawPrint).toMatch(/Failed to perform allocation/);
expect(rawPrintError).toBeEmptyString();
var exception;
try {
await runSlicesAsync();
} catch (ex) {
exception = ex;
}
expect(exception.rawPrint).toMatch(/Failed to perform allocation/);
expect(exception.rawPrintError).toBeEmptyString();
});
});