Implement ShadowRealm constructor and prototype.evaluate method

This commit is contained in:
kwonjeomsim 2025-08-12 15:57:24 +09:00 committed by Hyukwoo Park
commit 25a5bf17c3
9 changed files with 314 additions and 53 deletions

View file

@ -38,7 +38,7 @@ jobs:
brew install ninja icu4c
- name: Build x64
env:
BUILD_OPTIONS: -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
# check cpu
sysctl -a | grep machdep.cpu
@ -65,7 +65,7 @@ jobs:
brew install ninja icu4c
- name: Build arm64
env:
BUILD_OPTIONS: -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
# check cpu
sysctl -a | grep machdep.cpu
@ -122,13 +122,13 @@ jobs:
sudo apt-get install -y ninja-build gcc-multilib g++-multilib libicu-dev
- name: Build x86
env:
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
CC=clang CXX=clang++ cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/clang/x86 $BUILD_OPTIONS
ninja -Cout/clang/x86
- name: Build x64
env:
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
CC=clang CXX=clang++ cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/clang/x64 $BUILD_OPTIONS
ninja -Cout/clang/x64
@ -180,7 +180,7 @@ jobs:
platform: ${{ matrix.arch.cpu }}
- name: Build ${{ matrix.arch.cpu }} Release
run: |
CMake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch.cpu }} -Bout/ -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -G Ninja -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=release -DCMAKE_C_FLAGS="${{ matrix.arch.flag }}" -DCMAKE_CXX_FLAGS="${{ matrix.arch.flag }}"
CMake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch.cpu }} -Bout/ -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -G Ninja -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=release -DCMAKE_C_FLAGS="${{ matrix.arch.flag }}" -DCMAKE_CXX_FLAGS="${{ matrix.arch.flag }}"
CMake --build out/ --config Release
- name: Run octane
run: |
@ -233,7 +233,7 @@ jobs:
sdk: "10.0.26100.0"
- name: Build ${{ matrix.arch }} Release
run: |
CMake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} -DESCARGOT_ARCH=${{ matrix.arch }} -Bout/ -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_WASM=ON -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=release
CMake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} -DESCARGOT_ARCH=${{ matrix.arch }} -Bout/ -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_WASM=ON -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=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)
@ -275,7 +275,7 @@ jobs:
uwp: true
- name: Build x64 UWP Release
run: |
CMake -G "Visual Studio 17 2022" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=x64 -Bout/win64_release_uwp/ -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_TEST=ON
CMake -G "Visual Studio 17 2022" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=x64 -Bout/win64_release_uwp/ -DESCARGOT_OUTPUT=shell -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON
CMake --build out\win64_release_uwp --config Release
shell: cmd
- uses: ilammy/msvc-dev-cmd@v1.13.0
@ -284,7 +284,7 @@ jobs:
sdk: "10.0.26100.0"
- name: Build x86 DLL Release
run: |
CMake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=x86 -Bout/win32_release_shared/ -DESCARGOT_OUTPUT=shared_lib -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=release
CMake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION:STRING="10.0" -DCMAKE_SYSTEM_PROCESSOR=x86 -Bout/win32_release_shared/ -DESCARGOT_OUTPUT=shared_lib -DESCARGOT_LIBICU_SUPPORT=ON -DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=release
CMake --build out/win32_release_shared --config Release
shell: cmd
- if: ${{ failure() }}
@ -314,7 +314,7 @@ jobs:
dpkg -X libicu70_70.1-2ubuntu1_i386.deb $GITHUB_WORKSPACE/icu32
- name: Build x86
env:
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
export CXXFLAGS="-I$GITHUB_WORKSPACE/icu32/usr/include"
export LDFLAGS="-L$GITHUB_WORKSPACE/icu32/usr/lib/i386-linux-gnu -Wl,-rpath=$GITHUB_WORKSPACE/icu32/usr/lib/i386-linux-gnu"
@ -350,7 +350,7 @@ jobs:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
- name: Build x64
env:
BUILD_OPTIONS: -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/release/x64 $BUILD_OPTIONS ${{ matrix.build_opt }}
ninja -Cout/release/x64
@ -382,8 +382,8 @@ jobs:
sudo apt-get install -y libicu-dev:i386 # install i386 ICU
- name: Build x86/x64
env:
BUILD_OPTIONS_X86: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS_X64: -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS_X86: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS_X64: -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/debug/x86 $BUILD_OPTIONS_X86
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/debug/x64 $BUILD_OPTIONS_X64
@ -403,7 +403,7 @@ jobs:
submodules: true
- name: Build
env:
BUILD_OPTIONS: -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
LDFLAGS=" -L/usr/icu77-32/lib/ -Wl,-rpath=/usr/icu77-32/lib/" PKG_CONFIG_PATH="/usr/icu77-32/lib/pkgconfig/" cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bbuild/out_linux -DESCARGOT_ARCH=x86 -DESCARGOT_MODE=debug -DESCARGOT_TCO_DEBUG=ON $BUILD_OPTIONS
LDFLAGS=" -L/usr/icu77-32/lib/ -Wl,-rpath=/usr/icu77-32/lib/" PKG_CONFIG_PATH="/usr/icu77-32/lib/pkgconfig/" cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bbuild/out_linux_release -DESCARGOT_ARCH=x86 $BUILD_OPTIONS
@ -430,7 +430,7 @@ jobs:
submodules: true
- name: Build
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bout -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=arm32 -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bout -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=arm32 -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
cmake --build ./out/
- name: Test
run: |
@ -445,7 +445,7 @@ jobs:
submodules: true
- name: Build
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bout -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bout -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
cmake --build ./out/
- name: Test
run: |
@ -471,7 +471,7 @@ jobs:
apt-get update
apt-get install -y cmake build-essential ninja-build pkg-config python3 git libicu-dev
run: |
cmake -H. -Bout/riscv64 -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
cmake -H. -Bout/riscv64 -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
ninja -Cout/riscv64
python3 ./tools/run-tests.py --engine="./out/riscv64/escargot" regression-tests new-es intl sunspider-js
@ -487,7 +487,7 @@ jobs:
sudo apt-get install -y ninja-build
- name: Build
env:
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_DEBUGGER=1 -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_DEBUGGER=1 -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/debugger $BUILD_OPTIONS
ninja -Cout/debugger
@ -508,8 +508,8 @@ jobs:
sudo apt-get install -y ninja-build gcc-multilib g++-multilib
- name: Build x86/x64
env:
BUILD_OPTIONS_X86: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_THREADING=ON -DESCARGOT_DEBUGGER=1 -DESCARGOT_USE_EXTENDED_API=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=cctest -GNinja
BUILD_OPTIONS_X64: -DESCARGOT_MODE=debug -DESCARGOT_THREADING=1 -DESCARGOT_DEBUGGER=1 -DESCARGOT_USE_EXTENDED_API=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=cctest -GNinja
BUILD_OPTIONS_X86: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_THREADING=ON -DESCARGOT_DEBUGGER=1 -DESCARGOT_USE_EXTENDED_API=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=cctest -GNinja
BUILD_OPTIONS_X64: -DESCARGOT_MODE=debug -DESCARGOT_THREADING=1 -DESCARGOT_DEBUGGER=1 -DESCARGOT_USE_EXTENDED_API=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=cctest -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/cctest/x86 $BUILD_OPTIONS_X86
ninja -Cout/cctest/x86
@ -535,19 +535,19 @@ jobs:
sudo apt-get install -y libicu-dev:i386 # install i386 ICU
- name: Build x86
env:
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_CODE_CACHE=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_CODE_CACHE=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/codecache/x86 $BUILD_OPTIONS
ninja -Cout/codecache/x86
- name: Build x64
env:
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_CODE_CACHE=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_CODE_CACHE=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/codecache/x64 $BUILD_OPTIONS
ninja -Cout/codecache/x64
- name: Build x64 Release Mode
env:
BUILD_OPTIONS: -DESCARGOT_MODE=release -DESCARGOT_CODE_CACHE=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_MODE=release -DESCARGOT_CODE_CACHE=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/codecache/release/x64 $BUILD_OPTIONS
ninja -Cout/codecache/release/x64
@ -598,13 +598,13 @@ jobs:
sudo apt-get install -y ninja-build gcc-multilib g++-multilib
- name: Build x86
env:
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/wasm/x86 $BUILD_OPTIONS
ninja -Cout/wasm/x86
- name: Build x64
env:
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_ENABLE_SHADOWREALM=ON -DESCARGOT_OUTPUT=shell -GNinja
run: |
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/wasm/x64 $BUILD_OPTIONS
ninja -Cout/wasm/x64

View file

@ -72,6 +72,10 @@ IF (ESCARGOT_SMALL_CONFIG)
SET (ESCARGOT_DEFINITIONS ${ESCARGOT_DEFINITIONS} -DESCARGOT_SMALL_CONFIG)
ENDIF()
IF (ESCARGOT_ENABLE_SHADOWREALM)
SET (ESCARGOT_DEFINITIONS ${ESCARGOT_DEFINITIONS} -DESCARGOT_ENABLE_SHADOWREALM)
ENDIF()
IF (NOT DEFINED ESCARGOT_LIBICU_SUPPORT)
SET (ESCARGOT_LIBICU_SUPPORT ON)
ENDIF()

View file

@ -0,0 +1,204 @@
#include "Escargot.h"
#include "interpreter/ByteCode.h"
#include "interpreter/ByteCodeGenerator.h"
#include "interpreter/ByteCodeInterpreter.h"
#include "runtime/Global.h"
#include "runtime/GlobalObject.h"
#include "runtime/Context.h"
#include "runtime/Environment.h"
#include "runtime/EnvironmentRecord.h"
#include "runtime/ExtendedNativeFunctionObject.h"
#include "runtime/VMInstance.h"
#include "runtime/ShadowRealmObject.h"
#include "runtime/NativeFunctionObject.h"
#include "runtime/ScriptFunctionObject.h"
#include "parser/Script.h"
#include "parser/ScriptParser.h"
namespace Escargot {
#if defined(ESCARGOT_ENABLE_SHADOWREALM)
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealm
static Value builtinShadowRealmConstructor(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
{
// If NewTarget is undefined, throw a TypeError exception.
if (!newTarget) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ErrorObject::Messages::GlobalObject_ConstructorRequiresNew);
}
// Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%ShadowRealm.prototype%", « [[ShadowRealm]] »).
Object* proto = Object::getPrototypeFromConstructor(state, newTarget.value(), [](ExecutionState& state, Context* constructorRealm) -> Object* {
return constructorRealm->globalObject()->shadowRealmPrototype();
});
ShadowRealmObject* O = new ShadowRealmObject(state, proto);
// Let callerContext be the running execution context.
// Perform ? InitializeHostDefinedRealm().
// Let innerContext be the running execution context.
Context* innerContext = new Context(state.context()->vmInstance());
// Remove innerContext from the execution context stack and restore callerContext as the running execution context.
// Let realmRec be the Realm of innerContext.
// Set O.[[ShadowRealm]] to realmRec.
O->setRealmContext(innerContext);
// Perform ? HostInitializeShadowRealm(realmRec, innerContext, O).
// Assert: realmRec.[[GlobalObject]] is an ordinary object.
ASSERT(innerContext->globalObject()->isOrdinary());
// Return O.
return O;
}
static Value execute(ExecutionState& state, Script* script, bool isExecuteOnEvalFunction, bool inStrictMode, Context* callerContext, Context* evalContext)
{
InterpretedCodeBlock* topCodeBlock = script->topCodeBlock();
ByteCodeBlock* byteCodeBlock = topCodeBlock->byteCodeBlock();
ExecutionState* newState;
if (byteCodeBlock->needsExtendedExecutionState()) {
newState = new (alloca(sizeof(ExtendedExecutionState))) ExtendedExecutionState(evalContext);
} else {
newState = new (alloca(sizeof(ExecutionState))) ExecutionState(evalContext);
}
ExecutionState* codeExecutionState = newState;
EnvironmentRecord* globalRecord = new GlobalEnvironmentRecord(state, topCodeBlock, evalContext->globalObject(), evalContext->globalDeclarativeRecord(), evalContext->globalDeclarativeStorage());
LexicalEnvironment* globalLexicalEnvironment = new LexicalEnvironment(globalRecord, nullptr);
newState->setLexicalEnvironment(globalLexicalEnvironment, topCodeBlock->isStrict());
EnvironmentRecord* globalVariableRecord = globalRecord;
if (isExecuteOnEvalFunction) {
EnvironmentRecord* newVariableRecord = new DeclarativeEnvironmentRecordNotIndexed(state, true);
ExecutionState* newVariableState = new ExtendedExecutionState(evalContext);
newVariableState->setLexicalEnvironment(new LexicalEnvironment(newVariableRecord, globalLexicalEnvironment), topCodeBlock->isStrict());
newVariableState->setParent(newState);
codeExecutionState = newVariableState;
}
const InterpretedCodeBlock::IdentifierInfoVector& identifierVector = topCodeBlock->identifierInfos();
size_t identifierVectorLen = identifierVector.size();
const auto& globalLexicalVector = topCodeBlock->blockInfo(0)->identifiers();
size_t globalLexicalVectorLen = globalLexicalVector.size();
{
VirtualIdDisabler d(evalContext); // we should create binding even there is virtual ID
for (size_t i = 0; i < globalLexicalVectorLen; i++) {
codeExecutionState->lexicalEnvironment()->record()->createBinding(*codeExecutionState, globalLexicalVector[i].m_name, false, globalLexicalVector[i].m_isMutable, false);
}
for (size_t i = 0; i < identifierVectorLen; i++) {
// https://www.ecma-international.org/ecma-262/5.1/#sec-10.5
// Step 2. If code is eval code, then let configurableBindings be true.
if (identifierVector[i].m_isVarDeclaration) {
globalVariableRecord->createBinding(*codeExecutionState, identifierVector[i].m_name, isExecuteOnEvalFunction, identifierVector[i].m_isMutable, true, topCodeBlock);
}
}
}
Value thisValue(evalContext->globalObjectProxy());
const size_t literalStorageSize = byteCodeBlock->m_numeralLiteralData.size();
const size_t registerFileSize = byteCodeBlock->m_requiredTotalRegisterNumber;
ASSERT(registerFileSize == byteCodeBlock->m_requiredOperandRegisterNumber + topCodeBlock->totalStackAllocatedVariableSize() + literalStorageSize);
Value* registerFile;
registerFile = CustomAllocator<Value>().allocate(registerFileSize);
// we need to reset allocated memory because customAllocator read it
memset(static_cast<void*>(registerFile), 0, sizeof(Value) * registerFileSize);
registerFile[0] = Value();
Value* stackStorage = registerFile + byteCodeBlock->m_requiredOperandRegisterNumber;
stackStorage[0] = thisValue;
Value* literalStorage = stackStorage + topCodeBlock->totalStackAllocatedVariableSize();
Value* src = byteCodeBlock->m_numeralLiteralData.data();
for (size_t i = 0; i < literalStorageSize; i++) {
literalStorage[i] = src[i];
}
Value resultValue;
#ifdef ESCARGOT_DEBUGGER
// set the next(first) breakpoint to be stopped in a newer script execution
evalContext->setAsAlwaysStopState();
#endif
resultValue = Interpreter::interpret(codeExecutionState, byteCodeBlock, reinterpret_cast<size_t>(byteCodeBlock->m_code.data()), registerFile);
clearStack<512>();
// we give up program bytecodeblock after first excution for reducing memory usage
topCodeBlock->setByteCodeBlock(nullptr);
return resultValue;
}
static Value performShadowRealmEval(ExecutionState& state, Value& sourceText, Context* callerRealm, Context* evalRealm)
{
ScriptParser parser(evalRealm);
bool strictFromOutside = false;
Script* script = parser.initializeScript(nullptr, 0, sourceText.asString(), evalRealm->staticStrings().lazyEvalCode().string(), nullptr, false, true, false, false, strictFromOutside, false, false, false, true).scriptThrowsExceptionIfParseError(state);
ExtendedExecutionState stateForNewGlobal(evalRealm);
Value result;
try {
result = execute(stateForNewGlobal, script, true, script->topCodeBlock()->isStrict(), callerRealm, evalRealm);
} catch (const Value& e) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, "ShadowRealm.evaluate failed");
}
// https://tc39.es/proposal-shadowrealm/#sec-getwrappedvalue
if (result.isObject()) {
if (!result.isCallable()) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, "The result of ShadowRealm.evaluate must be a callable function");
}
}
return result;
}
static Value builtinShadowRealmEvaluate(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
{
// Let O be the this value.
const Value& O = thisValue;
// Perform ? ValidateShadowRealmObject(O).
if (!O.asObject()->isShadowRealmObject()) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, "this value must be a ShadowRealm object");
}
// If sourceText is not a String, throw a TypeError exception.
if (!argv[0].isString()) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, "sourceText must be a String");
}
// Let callerRealm be the current Realm Record.
Context* callerRealm = state.context();
// Let evalRealm be O.[[ShadowRealm]].
Context* evalRealm = O.asObject()->asShadowRealmObject()->realmContext();
// Return ? PerformShadowRealmEval(sourceText, callerRealm, evalRealm).
return performShadowRealmEval(state, argv[0], callerRealm, evalRealm);
}
#endif
void GlobalObject::initializeShadowRealm(ExecutionState& state)
{
installShadowRealm(state);
}
void GlobalObject::installShadowRealm(ExecutionState& state)
{
#if defined(ESCARGOT_ENABLE_SHADOWREALM)
const StaticStrings* strings = &state.context()->staticStrings();
m_shadowRealm = new NativeFunctionObject(state, NativeFunctionInfo(strings->ShadowRealm, builtinShadowRealmConstructor, 0), NativeFunctionObject::__ForBuiltinConstructor__);
m_shadowRealm->setGlobalIntrinsicObject(state);
m_shadowRealmPrototype = new PrototypeObject(state);
m_shadowRealmPrototype->setGlobalIntrinsicObject(state, true);
m_shadowRealm->setFunctionPrototype(state, m_shadowRealmPrototype);
m_shadowRealmPrototype->directDefineOwnProperty(state, ObjectPropertyName(state.context()->vmInstance()->globalSymbols().toStringTag),
ObjectPropertyDescriptor(String::fromASCII("ShadowRealm"), ObjectPropertyDescriptor::ConfigurablePresent));
m_shadowRealmPrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->evaluate),
ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings->evaluate, builtinShadowRealmEvaluate, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
directDefineOwnProperty(state, ObjectPropertyName(strings->ShadowRealm),
ObjectPropertyDescriptor(m_shadowRealm, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
#endif
}
} // namespace Escargot

View file

@ -213,6 +213,15 @@ class FunctionObject;
F(set, FunctionObject, objName) \
F(setPrototypeObject, Object, objName) \
F(setIteratorPrototype, Object, objName)
#if defined(ESCARGOT_ENABLE_SHADOWREALM)
#define GLOBALOBJECT_BUILTIN_SHADOWREALM(F, objName) \
F(shadowRealm, FunctionObject, objName) \
F(shadowRealmPrototype, Object, objName)
#else
#define GLOBALOBJECT_BUILTIN_SHADOWREALM(F, objName)
#endif
#define GLOBALOBJECT_BUILTIN_STRING(F, objName) \
F(string, FunctionObject, objName) \
F(stringPrototype, Object, objName) \
@ -335,6 +344,7 @@ class FunctionObject;
F(REFLECT, Reflect, ARG) \
F(REGEXP, RegExp, ARG) \
F(SET, Set, ARG) \
F(SHADOWREALM, ShadowRealm, ARG) \
F(SHAREDARRAYBUFFER, SharedArrayBuffer, ARG) \
F(STRING, String, ARG) \
F(SYMBOL, Symbol, ARG) \
@ -346,7 +356,6 @@ class FunctionObject;
F(WEAKREF, WeakRef, ARG) \
F(WASM, WebAssembly, ARG)
#define DECLARE_BUILTIN_ALL_LIST(OBJNAME, objName, ARG) \
GLOBALOBJECT_BUILTIN_##OBJNAME(ARG, objName)

View file

@ -91,6 +91,7 @@ class TemporalTimeZoneObject;
class TypedArrayObject;
class ModuleNamespaceObject;
class SharedArrayBufferObject;
class ShadowRealmObject;
#if defined(ENABLE_INTL)
class IntlLocaleObject;
class IntlPluralRulesObject;
@ -277,6 +278,11 @@ public:
return false;
}
virtual bool isShadowRealmObject() const
{
return false;
}
virtual bool isStringObject() const
{
return false;
@ -745,6 +751,13 @@ public:
return (ScriptClassConstructorPrototypeObject*)this;
}
#if defined(ESCARGOT_ENABLE_SHADOWREALM)
ShadowRealmObject* asShadowRealmObject()
{
ASSERT(isShadowRealmObject());
return (ShadowRealmObject*)this;
}
#endif
StringObject* asStringObject()
{
ASSERT(isStringObject());

View file

@ -0,0 +1,20 @@
#include "Escargot.h"
#include "runtime/Context.h"
#include "runtime/ExecutionState.h"
#include "runtime/ShadowRealmObject.h"
#if defined(ESCARGOT_ENABLE_SHADOWREALM)
namespace Escargot {
ShadowRealmObject::ShadowRealmObject(ExecutionState& state)
: DerivedObject(state)
{
}
ShadowRealmObject::ShadowRealmObject(ExecutionState& state, Object* proto)
: DerivedObject(state, proto)
{
}
} // namespace Escargot
#endif

View file

@ -0,0 +1,36 @@
#ifndef __EscargotShadowRealmObject__
#define __EscargotShadowRealmObject__
#include "runtime/Object.h"
#include "runtime/Context.h"
#include "runtime/ExecutionState.h"
#if defined(ESCARGOT_ENABLE_SHADOWREALM)
namespace Escargot {
class ShadowRealmObject : public DerivedObject {
public:
explicit ShadowRealmObject(ExecutionState& state);
explicit ShadowRealmObject(ExecutionState& state, Object* proto);
Context* realmContext()
{
return m_realmContext;
}
void setRealmContext(Context* context)
{
m_realmContext = context;
}
virtual bool isShadowRealmObject() const override
{
return true;
}
private:
Context* m_realmContext;
};
} // namespace Escargot
#endif // defined(ESCARGOT_ENABLE_SHADOWREALM)
#endif

View file

@ -99,6 +99,7 @@ namespace Escargot {
F(SQRT1_2) \
F(SQRT2) \
F(Set) \
F(ShadowRealm) \
F(SetIterator) \
F(String) \
F(StringIterator) \
@ -207,6 +208,7 @@ namespace Escargot {
F(error) \
F(escape) \
F(eval) \
F(evaluate) \
F(every) \
F(exec) \
F(exp) \
@ -290,6 +292,7 @@ namespace Escargot {
F(hypot) \
F(ignoreCase) \
F(implements) \
F(importValue) \
F(imul) \
F(includes) \
F(indices) \

View file

@ -103,35 +103,8 @@
<test id="built-ins/ShadowRealm/WrappedFunction/name"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/WrappedFunction/name-throws-typeerror"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/WrappedFunction/throws-typeerror-on-revoked-proxy"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/constructor"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/descriptor"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/extensibility"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/instance"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/instance-extensibility"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/length"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/name"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/proto"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/Symbol.toStringTag"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/descriptor"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/errors-from-the-other-realm-is-wrapped-into-a-typeerror"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/globalthis-available-properties"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/globalthis-config-only-properties"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/globalthis-ordinary-object"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/length"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/name"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/nested-realms"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/no-conditional-strict-mode"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/not-constructor"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/proto"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/returns-primitive-values"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/returns-proxy-callable-object"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/returns-symbol-values"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/throws-error-from-ctor-realm"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/throws-syntaxerror-on-bad-syntax"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/throws-typeerror-if-evaluation-resolves-to-non-primitive"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/throws-typeerror-wrap-throwing"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/throws-when-argument-is-not-a-string"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/validates-realm-object"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/wrapped-function-arguments-are-wrapped-into-the-inner-realm"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/wrapped-function-arguments-are-wrapped-into-the-inner-realm-extended"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/evaluate/wrapped-function-from-return-values-share-no-identity"><reason>TODO</reason></test>
@ -161,7 +134,6 @@
<test id="built-ins/ShadowRealm/prototype/importValue/throws-typeerror-import-syntax-error"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/importValue/throws-typeerror-import-throws"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/importValue/validates-realm-object"><reason>TODO</reason></test>
<test id="built-ins/ShadowRealm/prototype/proto"><reason>TODO</reason></test>
<test id="built-ins/String/prototype/match/cstm-matcher-on-bigint-primitive"><reason>TODO</reason></test>
<test id="built-ins/String/prototype/match/cstm-matcher-on-boolean-primitive"><reason>TODO</reason></test>
<test id="built-ins/String/prototype/match/cstm-matcher-on-number-primitive"><reason>TODO</reason></test>