Skip to content

Commit

Permalink
Update source and test driver for running test262 on windows
Browse files Browse the repository at this point in the history
* Update test262 driver for python3 and windows
* Update DateFormat for windows
* Fix compiler warnings on Win64

Signed-off-by: Seonghyun Kim <[email protected]>
  • Loading branch information
ksh8281 authored and clover2123 committed Jul 7, 2023
1 parent 1353d2e commit a2886b8
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 199 deletions.
90 changes: 51 additions & 39 deletions .github/workflows/es-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,45 +43,6 @@ jobs:
ninja -Cout/mac/x64
./tools/run-tests.py --engine="./out/mac/x64/escargot" new-es
build-on-windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: lukka/get-cmake@latest
- uses: GuillaumeFalourd/[email protected]
with:
sdk-version: 20348
- uses: ilammy/[email protected]
with:
arch: x86
sdk: "10.0.20348.0"
- name: Install msvc redist package
run: |
(new-object System.Net.WebClient).DownloadFile('https://github.com/abbodi1406/vcredist/releases/download/v0.73.0/VisualCppRedist_AIO_x86_x64.exe','VisualCppRedist_AIO_x86_x64.exe')
.\VisualCppRedist_AIO_x86_x64.exe /y
- name: Copy octane
run: |
copy test\octane\*.js
dir
- name: Build Win32 Release
run: |
CMake -G "Visual Studio 16 2019" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_ARCH=x86 -DESCARGOT_MODE=release -Bout/win32_release_ninja/ -DESCARGOT_HOST=windows -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_TEST=ON -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=release
CMake --build out/win32_release_ninja/ --config Release
.\out\win32_release_ninja\escargot.exe run.js
- uses: ilammy/[email protected]
with:
arch: x64
sdk: "10.0.20348.0"
- name: Build Win64 Release
run: |
CMake -G "Visual Studio 16 2019" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=x64 -DESCARGOT_ARCH=x64 -DESCARGOT_MODE=release -Bout/win64_release_ninja/ -DESCARGOT_HOST=windows -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_TEST=ON -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=release
CMake --build out/win64_release_ninja/ --config Release
.\out\win64_release_ninja\escargot.exe run.js
- if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
build-test-on-android:
runs-on: macos-12
strategy:
Expand Down Expand Up @@ -214,6 +175,57 @@ jobs:
ninja -Cout/release
python3 ./tools/run-tests.py --engine="./out/release/escargot" new-es
test-on-windows-x86-x64:
runs-on: windows-2022
strategy:
matrix:
arch: [x86, x64]
steps:
- name: Set git cllf config
run: |
git config --global core.autocrlf input
git config --global core.eol lf
- uses: actions/checkout@v3
with:
submodules: true
- uses: szenius/[email protected]
with:
timezoneWindows: "Pacific Standard Time"
- uses: lukka/get-cmake@latest
- uses: GuillaumeFalourd/[email protected]
with:
sdk-version: 20348
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install msvc redist package
run: |
(new-object System.Net.WebClient).DownloadFile('https://github.com/abbodi1406/vcredist/releases/download/v0.73.0/VisualCppRedist_AIO_x86_x64.exe','VisualCppRedist_AIO_x86_x64.exe')
.\VisualCppRedist_AIO_x86_x64.exe /y
- uses: ilammy/[email protected]
with:
arch: ${{ matrix.arch }}
sdk: "10.0.20348.0"
- name: Build ${{ matrix.arch }} Release
run: |
CMake -G "Visual Studio 16 2019" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} -DESCARGOT_ARCH=${{ matrix.arch }} -DESCARGOT_MODE=release -Bout/ -DESCARGOT_HOST=windows -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=release
CMake --build out/ --config Release
# windows internal ICU doesn't support Temporal and intl402 well
# github action windows runner only have 2 CPUs. that's why I disable Atomics(timeout occured with some tests)
- name: Run test262
run: |
set GC_FREE_SPACE_DIVISOR=1
pip install chardet
python tools\run-tests.py --engine=%cd%\out\escargot.exe test262 --extra-arg="--skip Temporal --skip intl402 --skip Atomics"
shell: cmd
- name: Run octane
run: |
copy test\octane\*.js
dir
.\out\escargot.exe run.js
- if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
build-test-on-x86-release:
runs-on: ubuntu-latest
strategy:
Expand Down
14 changes: 9 additions & 5 deletions src/interpreter/ByteCodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2988,9 +2988,13 @@ NEVER_INLINE Value InterpreterSlowPath::tryOperation(ExecutionState*& state, siz
char* codeBuffer = byteCodeBlock->m_code.data();
TryOperation* code = (TryOperation*)programCounter;

bool inPauserScope = state->inPauserScope();
bool inPauserResumeProcess = code->m_isTryResumeProcess || code->m_isCatchResumeProcess || code->m_isFinallyResumeProcess;
bool shouldUseHeapAllocatedState = inPauserScope && !inPauserResumeProcess;
const bool inPauserScope = state->inPauserScope();
const bool inPauserResumeProcess = code->m_isTryResumeProcess || code->m_isCatchResumeProcess || code->m_isFinallyResumeProcess;
// NOTE in msvc 2019, taking value of isTryResumeProcess is required by compiler bug
// the value of `code` is changed if programCounter is changed in release mode :(
const bool isTryResumeProcess = code->m_isTryResumeProcess;

const bool shouldUseHeapAllocatedState = inPauserScope && !inPauserResumeProcess;
ExecutionState* newState;

if (UNLIKELY(shouldUseHeapAllocatedState)) {
Expand Down Expand Up @@ -3025,11 +3029,11 @@ NEVER_INLINE Value InterpreterSlowPath::tryOperation(ExecutionState*& state, siz
if (newState->inExecutionStopState()) {
return Value();
}
if (UNLIKELY(code->m_isTryResumeProcess && newState->parent()->inExecutionStopState())) {
if (UNLIKELY(isTryResumeProcess && newState->parent()->inExecutionStopState())) {
return Value();
}
clearStack<512>();
if (UNLIKELY(code->m_isTryResumeProcess)) {
if (UNLIKELY(isTryResumeProcess)) {
#ifdef ESCARGOT_DEBUGGER
Debugger::updateStopState(state->context()->debugger(), newState, ESCARGOT_DEBUGGER_ALWAYS_STOP);
#endif /* ESCARGOT_DEBUGGER */
Expand Down
1 change: 1 addition & 0 deletions src/runtime/DateObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,7 @@ String* DateObject::toTimeString(ExecutionState& state)
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%s%04d", getHours(state), getMinutes(state), getSeconds(state), (tzOffsetAsMin < 0) ? "-" : "+", std::abs(tzOffsetHour + tzOffsetMin));
StringBuilder sb;
sb.appendString(buffer);
sb.appendChar(' ');
sb.appendChar('(');
sb.appendString(String::fromUTF8(timeZoneName.data(), timeZoneName.length()));
sb.appendChar(')');
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ template <typename ResultType, typename ResultBinder>
static ResultType objectOwnPropertyKeys(ExecutionState& state, Object* self)
{
// TODO turn-on gc if replace std::multiset to another gc-well-supported type
GC_disable();
GCDisabler disableGC;
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
struct Properties {
std::multiset<IndexItem, CompareIndexItem, GCUtil::gc_malloc_allocator<IndexItem>> indexes;
Expand Down Expand Up @@ -1029,7 +1029,6 @@ static ResultType objectOwnPropertyKeys(ExecutionState& state, Object* self)
return true;
},
&properties, false);
GC_enable();

ResultType result(properties.indexes.size() + properties.strings.size() + properties.symbols.size());

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/ObjectStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class ObjectStructureWithTransition : public ObjectStructure {
return 1;
}
size_t base = FAST_LOG2_UINT(newSize);
return 1 << (base + 1);
return size_t(1) << (base + 1);
}

ObjectStructureItemTightVector m_properties;
Expand Down
3 changes: 2 additions & 1 deletion src/util/SpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class SpinLock {

public:
SpinLock()
: m_locked(ATOMIC_FLAG_INIT)
: m_locked()
{
m_locked.clear();
}

void lock()
Expand Down
13 changes: 13 additions & 0 deletions src/util/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ class LongTaskFinder {
const char* m_msg;
};

class GCDisabler {
public:
GCDisabler()
{
GC_disable();
}
~GCDisabler()
{
GC_enable();
}
};


namespace detail {

template <typename T, typename Comparator>
Expand Down
2 changes: 1 addition & 1 deletion src/util/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct ComputeReservedCapacityFunctionWithLog2 {
return 0;
}
size_t base = FAST_LOG2_UINT(newSize);
size_t capacity = 1 << (base + 1);
size_t capacity = size_t(1) << (base + 1);
if (glowFactor > 100) {
return capacity * glowFactor / 100.f;
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/GCutil
2 changes: 1 addition & 1 deletion third_party/robin_map/include/tsl/robin_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class robin_vector {
return 0;
}
size_t base = log2l(newSize);
size_t capacity = 1 << (base + 1);
size_t capacity = size_t(1) << (base + 1);
return capacity;
}
};
Expand Down
Loading

0 comments on commit a2886b8

Please sign in to comment.