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

Upgrade V8 to 9.0 #111

Merged
merged 7 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/v8build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Build V8 for ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
Expand All @@ -19,7 +19,7 @@ jobs:
run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
shell: bash
- name: Build V8 linux
if: matrix.platform == 'ubuntu-latest'
if: matrix.platform == 'ubuntu-18.04'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, nice. Thanks @kuoruan 👍

.... now going to update all my projects

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to change this before merge? if not, I can merge this PR now.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address this in another PR later, as we have already run the builds for this version

run: cd deps && ./build.py --no-clang
- name: Build V8 macOS
if: matrix.platform == 'macos-latest'
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Promise resolver and promise result
- Convert a Value to a Function and invoke it
- Convert a Value to a Function and invoke it. Thanks to [@robfig](https://github.com/robfig)
- Windows static binary. Thanks to [@cleiner](https://github.com/cleiner)
- Setting/unsetting of V8 feature flags

### Changed
- Upgrade to V8 8.9.255.20
- Upgrade to V8 9.0.257.18

### Fixed
- Go GC attempting to free C memory (via finalizer) of values after an Isolate is disposed causes a panic
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ V8 requires 64-bit on Windows, therefore it will not work on 32-bit systems.

## V8 dependency

V8 version: **8.9.255.20** (March 2021)
V8 version: **9.0.257.18** (April 2021)

In order to make `v8go` usable as a standard Go package, prebuilt static libraries of V8
are included for Linux, macOS and Windows ie. you *should not* require to build V8 yourself.
Expand Down
1 change: 0 additions & 1 deletion deps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def apply_mingw_patches():
v8_build_path = os.path.join(v8_path, "build")
apply_patch("0000-add-mingw-main-code-changes", v8_path)
apply_patch("0001-add-mingw-toolchain", v8_build_path)
apply_patch("0002-fix-mingw-unwind-tables", v8_build_path)
update_last_change()
zlib_path = os.path.join(v8_path, "third_party", "zlib")
zlib_src_gn = os.path.join(deps_path, os_arch(), "zlib.gn")
Expand Down
Binary file modified deps/darwin_x86_64/libv8.a
Binary file not shown.
2 changes: 1 addition & 1 deletion deps/depot_tools
Submodule depot_tools updated from da7687 to 1dbd65
1 change: 1 addition & 0 deletions deps/include/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include_rules = [
"+cppgc/common.h",
# Used by v8-cppgc.h to bridge to cppgc.
"+cppgc/custom-space.h",
"+cppgc/heap-statistics.h",
"+cppgc/internal/write-barrier.h",
"+cppgc/visitor.h",
]
1 change: 1 addition & 0 deletions deps/include/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ per-file v8-inspector-protocol.h=pfeldman@chromium.org
per-file v8-inspector-protocol.h=kozyatinskiy@chromium.org
per-file js_protocol.pdl=dgozman@chromium.org
per-file js_protocol.pdl=pfeldman@chromium.org
per-file js_protocol.pdl=bmeurer@chromium.org

# For branch updates:
per-file v8-version.h=file:../INFRA_OWNERS
Expand Down
19 changes: 7 additions & 12 deletions deps/include/cppgc/allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ template <typename T>
class MakeGarbageCollectedTraitBase
: private internal::MakeGarbageCollectedTraitInternal {
private:
static_assert(internal::IsGarbageCollectedType<T>::value,
"T needs to be a garbage collected object");
static_assert(!IsGarbageCollectedWithMixinTypeV<T> ||
sizeof(T) <=
internal::api_constants::kLargeObjectSizeThreshold,
"GarbageCollectedMixin may not be a large object");

template <typename U, typename CustomSpace>
struct SpacePolicy {
static void* Allocate(AllocationHandle& handle, size_t size) {
Expand Down Expand Up @@ -153,12 +160,6 @@ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
public:
template <typename... Args>
static T* Call(AllocationHandle& handle, Args&&... args) {
static_assert(internal::IsGarbageCollectedType<T>::value,
"T needs to be a garbage collected object");
static_assert(
!internal::IsGarbageCollectedMixinType<T>::value ||
sizeof(T) <= internal::api_constants::kLargeObjectSizeThreshold,
"GarbageCollectedMixin may not be a large object");
void* memory =
MakeGarbageCollectedTraitBase<T>::Allocate(handle, sizeof(T));
T* object = ::new (memory) T(std::forward<Args>(args)...);
Expand All @@ -169,12 +170,6 @@ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
template <typename... Args>
static T* Call(AllocationHandle& handle, AdditionalBytes additional_bytes,
Args&&... args) {
static_assert(internal::IsGarbageCollectedType<T>::value,
"T needs to be a garbage collected object");
static_assert(
!internal::IsGarbageCollectedMixinType<T>::value ||
sizeof(T) <= internal::api_constants::kLargeObjectSizeThreshold,
"GarbageCollectedMixin may not be a large object");
void* memory = MakeGarbageCollectedTraitBase<T>::Allocate(
handle, sizeof(T) + additional_bytes.value);
T* object = ::new (memory) T(std::forward<Args>(args)...);
Expand Down
15 changes: 9 additions & 6 deletions deps/include/cppgc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@

namespace cppgc {

// Indicator for the stack state of the embedder.
/**
* Indicator for the stack state of the embedder.
*/
enum class EmbedderStackState {
/**
* Stack may contain interesting heap pointers.
*/
kMayContainHeapPointers,
/**
* Stack does not contain any interesting heap pointers.
*/
kNoHeapPointers,
kUnknown V8_ENUM_DEPRECATED("Use kMayContainHeapPointers") =
kMayContainHeapPointers,
kNonEmpty V8_ENUM_DEPRECATED("Use kMayContainHeapPointers") =
kMayContainHeapPointers,
kEmpty V8_ENUM_DEPRECATED("Use kNoHeapPointers") = kNoHeapPointers,
};

} // namespace cppgc
Expand Down
46 changes: 40 additions & 6 deletions deps/include/cppgc/cross-thread-persistent.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class BasicCrossThreadPersistent final : public PersistentBase,
T* raw, const SourceLocation& loc = SourceLocation::Current())
: PersistentBase(raw), LocationPolicy(loc) {
if (!IsValid(raw)) return;
PersistentRegionLock guard;
PersistentRegion& region = this->GetPersistentRegion(raw);
SetNode(region.AllocateNode(this, &Trace));
this->CheckPointer(raw);
Expand Down Expand Up @@ -162,13 +161,24 @@ class BasicCrossThreadPersistent final : public PersistentBase,
// heterogeneous assignments between different Member and Persistent handles
// based on their actual types.
V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
return static_cast<T*>(GetValue());
return static_cast<T*>(const_cast<void*>(GetValue()));
}

/**
* Clears the stored object.
*/
void Clear() { Assign(nullptr); }
void Clear() {
// Simplified version of `Assign()` to allow calling without a complete type
// `T`.
const void* old_value = GetValue();
if (IsValid(old_value)) {
PersistentRegionLock guard;
PersistentRegion& region = this->GetPersistentRegion(old_value);
region.FreeNode(GetNode());
SetNode(nullptr);
}
SetValue(nullptr);
}

/**
* Returns a pointer to the stored object and releases it.
Expand Down Expand Up @@ -209,16 +219,39 @@ class BasicCrossThreadPersistent final : public PersistentBase,
T* operator->() const { return Get(); }
T& operator*() const { return *Get(); }

template <typename U, typename OtherWeaknessPolicy = WeaknessPolicy,
typename OtherLocationPolicy = LocationPolicy,
typename OtherCheckingPolicy = CheckingPolicy>
BasicCrossThreadPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
OtherCheckingPolicy>
To() const {
PersistentRegionLock guard;
return BasicCrossThreadPersistent<U, OtherWeaknessPolicy,
OtherLocationPolicy, OtherCheckingPolicy>(
static_cast<U*>(Get()));
}

template <typename U = T,
typename = typename std::enable_if<!BasicCrossThreadPersistent<
U, WeaknessPolicy>::IsStrongPersistent::value>::type>
BasicCrossThreadPersistent<U, internal::StrongCrossThreadPersistentPolicy>
Lock() const {
return BasicCrossThreadPersistent<
U, internal::StrongCrossThreadPersistentPolicy>(*this);
}

private:
static bool IsValid(void* ptr) { return ptr && ptr != kSentinelPointer; }
static bool IsValid(const void* ptr) {
return ptr && ptr != kSentinelPointer;
}

static void Trace(Visitor* v, const void* ptr) {
const auto* handle = static_cast<const BasicCrossThreadPersistent*>(ptr);
v->TraceRoot(*handle, handle->Location());
}

void Assign(T* ptr) {
void* old_value = GetValue();
const void* old_value = GetValue();
if (IsValid(old_value)) {
PersistentRegionLock guard;
PersistentRegion& region = this->GetPersistentRegion(old_value);
Expand All @@ -238,7 +271,8 @@ class BasicCrossThreadPersistent final : public PersistentBase,
}

void AssignUnsafe(T* ptr) {
void* old_value = GetValue();
PersistentRegionLock::AssertLocked();
const void* old_value = GetValue();
if (IsValid(old_value)) {
PersistentRegion& region = this->GetPersistentRegion(old_value);
if (IsValid(ptr) && (&region == &this->GetPersistentRegion(ptr))) {
Expand Down
14 changes: 10 additions & 4 deletions deps/include/cppgc/custom-space.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

namespace cppgc {

/**
* Index identifying a custom space.
*/
struct CustomSpaceIndex {
CustomSpaceIndex(size_t value) : value(value) {} // NOLINT
constexpr CustomSpaceIndex(size_t value) : value(value) {} // NOLINT
size_t value;
};

Expand Down Expand Up @@ -45,15 +48,18 @@ class CustomSpaceBase {
template <typename ConcreteCustomSpace>
class CustomSpace : public CustomSpaceBase {
public:
/**
* Compaction is only supported on spaces that manually manage slots
* recording.
*/
static constexpr bool kSupportsCompaction = false;

CustomSpaceIndex GetCustomSpaceIndex() const final {
return ConcreteCustomSpace::kSpaceIndex;
}
bool IsCompactable() const final {
return ConcreteCustomSpace::kSupportsCompaction;
}

protected:
static constexpr bool kSupportsCompaction = false;
};

/**
Expand Down
5 changes: 5 additions & 0 deletions deps/include/cppgc/ephemeron-pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef INCLUDE_CPPGC_EPHEMERON_PAIR_H_
#define INCLUDE_CPPGC_EPHEMERON_PAIR_H_

#include "cppgc/liveness-broker.h"
#include "cppgc/member.h"

namespace cppgc {
Expand All @@ -18,6 +19,10 @@ struct EphemeronPair {
EphemeronPair(K* k, V* v) : key(k), value(v) {}
WeakMember<K> key;
Member<V> value;

void ClearValueIfKeyIsDead(const LivenessBroker& broker) {
if (!broker.IsHeapObjectAlive(key)) value = nullptr;
}
};

} // namespace cppgc
Expand Down
Loading