diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93da70b0e..2857a41fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: v8-cmake on: + push: pull_request: paths: - 'CMakeLists.txt' @@ -25,4 +26,10 @@ jobs: - name: build run: cmake --build ${{runner.workspace}}/build -j 2 - name: test + if: matrix.os != 'windows-latest' run: ${{runner.workspace}}/build/d8 -e 42 + - name: test-windows + if: matrix.os == 'windows-latest' + run: | + ${{runner.workspace}}/build/Debug/d8 -e 42 + shell: powershell diff --git a/CMakeLists.txt b/CMakeLists.txt index e88b0a2c0..540e2b32a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,11 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MSVC.cmake set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) project(V8 LANGUAGES CXX C ASM) +if(MSVC) + enable_language(ASM_MASM) + set_property(SOURCE ${PROJECT_BINARY_DIR}/embedded.S PROPERTY LANGUAGE ASM_MASM) +endif() + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -54,7 +59,6 @@ string(CONCAT is-x64 $) option(V8_ENABLE_CONCURRENT_MARKING "Enable concurrent marking" ON) -option(V8_ENABLE_THIRD_PARTY_HEAP "Enable third party HEAP library" OFF) option(V8_ENABLE_I18N "Enable Internationalization support") set( @@ -69,7 +73,6 @@ set( $<${is-win}:NOMINMAX> $<$:V8_OS_WINX64> $<$:V8_CONCURRENT_MARKING> - $<$:V8_ENABLE_THIRD_PARTY_HEAP> $<${is-win}:V8_OS_WIN32> ) @@ -165,7 +168,7 @@ file(GLOB handles-sources CONFIGURE_DEPENDS v8/src/handles/*.cc) file(GLOB interpreter-sources CONFIGURE_DEPENDS v8/src/interpreter/*.cc) file(GLOB json-sources CONFIGURE_DEPENDS v8/src/json/*.cc) file(GLOB logging-sources CONFIGURE_DEPENDS v8/src/logging/*.cc) -file(GLOB heap-sources CONFIGURE_DEPENDS v8/src/heap/*.cc) +file(GLOB heap-sources CONFIGURE_DEPENDS v8/src/heap/*.cc v8/src/heap/third-party/*.cc) file(GLOB numbers-sources CONFIGURE_DEPENDS v8/src/numbers/*.cc) file(GLOB object-sources CONFIGURE_DEPENDS v8/src/objects/*.cc) file(GLOB parsing-sources CONFIGURE_DEPENDS v8/src/parsing/*.cc) @@ -452,6 +455,7 @@ add_custom_command( $<${is-x64}:--target_arch=x64> $<$:--target_os=mac> $<$:--target_os=linux> + $<$:--target_os=win> --turbo_instruction_scheduling DEPENDS mksnapshot diff --git a/patches/0002-Patch-v8-src-heap-third-party.patch b/patches/0002-Patch-v8-src-heap-third-party.patch new file mode 100644 index 000000000..d0dd9eb2f --- /dev/null +++ b/patches/0002-Patch-v8-src-heap-third-party.patch @@ -0,0 +1,70 @@ +From eba7aae41a74bab1aba7e26effbebf4c3e297c0d Mon Sep 17 00:00:00 2001 +From: Ben Noordhuis +Date: Wed, 15 Apr 2020 11:11:44 +0200 +Subject: [PATCH] Patch v8/src/heap/third-party + +Provide a stub `third_party_heap::Heap` implementation to work around +linker erors with Visual Studio. + +Refs: https://github.com/bnoordhuis/v8-cmake/issues/10 +--- + v8/src/heap/third-party/heap-api-stub.cc | 47 ++++++++++++++++++++++++ + 1 file changed, 47 insertions(+) + create mode 100644 v8/src/heap/third-party/heap-api-stub.cc + +diff --git a/v8/src/heap/third-party/heap-api-stub.cc b/v8/src/heap/third-party/heap-api-stub.cc +new file mode 100644 +index 0000000..3135aca +--- /dev/null ++++ b/v8/src/heap/third-party/heap-api-stub.cc +@@ -0,0 +1,47 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/heap/third-party/heap-api.h" ++ ++namespace v8 { ++namespace internal { ++namespace third_party_heap { ++ ++// Work around Visual Studio linker errors when V8_ENABLE_THIRD_PARTY_HEAP ++// is disabled. ++#ifndef V8_ENABLE_THIRD_PARTY_HEAP ++ ++// static ++std::unique_ptr Heap::New(v8::internal::Isolate*) { return nullptr; } ++ ++// static ++v8::internal::Isolate* Heap::GetIsolate(Address) { return nullptr; } ++ ++AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) { ++ return AllocationResult(); ++} ++ ++Address Heap::GetObjectFromInnerPointer(Address) { return 0; } ++ ++const base::AddressRegion& Heap::GetCodeRange() { ++ static const base::AddressRegion no_region(0, 0); ++ return no_region; ++} ++ ++// static ++bool Heap::InCodeSpace(Address) { return false; } ++ ++// static ++bool Heap::InReadOnlySpace(Address) { return false; } ++ ++// static ++bool Heap::IsValidHeapObject(HeapObject) { return false; } ++ ++bool Heap::CollectGarbage() { return false; } ++ ++#endif // !defined(V8_ENABLE_THIRD_PARTY_HEAP) ++ ++} // namespace third_party_heap ++} // namespace internal ++} // namespace v8 +-- +2.20.1 + diff --git a/v8/src/heap/third-party/heap-api-stub.cc b/v8/src/heap/third-party/heap-api-stub.cc new file mode 100644 index 000000000..8eb7e716a --- /dev/null +++ b/v8/src/heap/third-party/heap-api-stub.cc @@ -0,0 +1,59 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/heap/third-party/heap-api.h" +#include "src/execution/isolate-utils-inl.h" +#include "src/heap/heap-inl.h" + +// Work around Visual Studio linker errors when V8_ENABLE_THIRD_PARTY_HEAP +// is disabled. +#ifndef V8_ENABLE_THIRD_PARTY_HEAP + +namespace v8 { +namespace internal { + +Isolate* Heap::GetIsolateFromWritableObject(HeapObject object) { + return GetHeapFromWritableObject(object)->isolate(); +} + +} // namespace internal +} // namespace v8 + +namespace v8 { +namespace internal { +namespace third_party_heap { + +// static +std::unique_ptr Heap::New(v8::internal::Isolate*) { return nullptr; } + +// static +v8::internal::Isolate* Heap::GetIsolate(Address) { return nullptr; } + +AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) { + return AllocationResult(); +} + +Address Heap::GetObjectFromInnerPointer(Address) { return 0; } + +const base::AddressRegion& Heap::GetCodeRange() { + static const base::AddressRegion no_region(0, 0); + return no_region; +} + +// static +bool Heap::InCodeSpace(Address) { return false; } + +// static +bool Heap::InReadOnlySpace(Address) { return false; } + +// static +bool Heap::IsValidHeapObject(HeapObject) { return false; } + +bool Heap::CollectGarbage() { return false; } + +} // namespace third_party_heap +} // namespace internal +} // namespace v8 + +#endif // !defined(V8_ENABLE_THIRD_PARTY_HEAP)