diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93da70b0e..249db3fe0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,4 +25,9 @@ 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 c3e7097d4..3f4ef8f0f 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) @@ -164,7 +169,7 @@ file(GLOB extensions-sources CONFIGURE_DEPENDS v8/src/extensions/*.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) @@ -450,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..7c4b651a8 --- /dev/null +++ b/patches/0002-Patch-v8-src-heap-third-party.patch @@ -0,0 +1,77 @@ +From 7491dcc78090a1f022481eadbbda754719bb2962 Mon Sep 17 00:00:00 2001 +From: Ben Noordhuis +Date: Tue, 21 Apr 2020 18:15:06 +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 | 54 ++++++++++++++++++++++++ + 1 file changed, 54 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..9d71468 +--- /dev/null ++++ b/v8/src/heap/third-party/heap-api-stub.cc +@@ -0,0 +1,54 @@ ++// 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::Isolate*) { return nullptr; } ++ ++// static ++v8::Isolate* Heap::GetIsolate(Address) { return nullptr; } ++ ++AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) { ++ return AllocationResult(); ++} ++ ++Address Heap::GetObjectFromInnerPointer(Address) { return 0; } ++ ++// 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) +-- +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..9d71468a8 --- /dev/null +++ b/v8/src/heap/third-party/heap-api-stub.cc @@ -0,0 +1,54 @@ +// 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::Isolate*) { return nullptr; } + +// static +v8::Isolate* Heap::GetIsolate(Address) { return nullptr; } + +AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) { + return AllocationResult(); +} + +Address Heap::GetObjectFromInnerPointer(Address) { return 0; } + +// 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)