Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ to run a pre-compiled script in new contexts.
- Removed error return value from NewObjectTemplate and NewFunctionTemplate. Panic if given a nil argument.
- Function Call accepts receiver as first argument.
- Removed Windows support until its build issues are addressed.
- Upgrade to V8 9.6.180.12

### Fixed
- Add some missing error propagation
Expand Down
2 changes: 1 addition & 1 deletion cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package v8go
// #cgo LDFLAGS: -pthread -lv8
// #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/deps/darwin_x86_64
// #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/deps/darwin_arm64
// #cgo linux LDFLAGS: -L${SRCDIR}/deps/linux_x86_64
// #cgo linux LDFLAGS: -L${SRCDIR}/deps/linux_x86_64 -ldl
import "C"

// These imports forces `go mod vendor` to pull in all the folders that
Expand Down
Binary file modified deps/darwin_arm64/libv8.a
Binary file not shown.
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 2e486c to 85d7fe
18 changes: 7 additions & 11 deletions deps/include/OWNERS
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
[email protected]
[email protected]
danno@chromium.org
leszeks@chromium.org
[email protected]
[email protected]
[email protected]
[email protected]

per-file *DEPS=file:../COMMON_OWNERS
per-file v8-internal.h=file:../COMMON_OWNERS
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file [email protected]
per-file v8-inspector.h=file:../src/inspector/OWNERS
per-file v8-inspector-protocol.h=file:../src/inspector/OWNERS
per-file js_protocol.pdl=file:../src/inspector/OWNERS

# Needed by the auto_tag builder
per-file v8-version.h=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com

# For branch updates:
per-file v8-version.h=file:../INFRA_OWNERS
Expand Down
17 changes: 14 additions & 3 deletions deps/include/cppgc/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# C++ Garbage Collection
# Oilpan: C++ Garbage Collection

This directory provides an open-source garbage collection library for C++.
Oilpan is an open-source garbage collection library for C++ that can be used stand-alone or in collaboration with V8's JavaScript garbage collector.

The library is under construction, meaning that *all APIs in this directory are incomplete and considered unstable and should not be used*.
**Key properties**
- Trace-based garbage collection;
- Precise on-heap memory layout;
- Conservative on-stack memory layout;
- Allows for collection with and without considering stack;
- Incremental and concurrent marking;
- Incremental and concurrent sweeping;
- Non-incremental and non-concurrent compaction for selected spaces;

See the [Hello World](https://chromium.googlesource.com/v8/v8/+/main/samples/cppgc/hello-world.cc) example on how to get started using Oilpan to manage C++ code.

Oilpan follows V8's project organization, see e.g. on how we accept [contributions](https://v8.dev/docs/contribute) and [provide a stable API](https://v8.dev/docs/api).
90 changes: 50 additions & 40 deletions deps/include/cppgc/allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@
#ifndef INCLUDE_CPPGC_ALLOCATION_H_
#define INCLUDE_CPPGC_ALLOCATION_H_

#include <stdint.h>

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <new>
#include <type_traits>
#include <utility>

#include "cppgc/custom-space.h"
#include "cppgc/garbage-collected.h"
#include "cppgc/internal/api-constants.h"
#include "cppgc/internal/gc-info.h"
#include "cppgc/type-traits.h"
#include "v8config.h" // NOLINT(build/include_directory)

namespace cppgc {

template <typename T>
class MakeGarbageCollectedTraitBase;

namespace internal {
class ObjectAllocator;
} // namespace internal

/**
* AllocationHandle is used to allocate garbage-collected objects.
*/
Expand All @@ -39,10 +36,37 @@ class V8_EXPORT MakeGarbageCollectedTraitInternal {
const_cast<uint16_t*>(reinterpret_cast<const uint16_t*>(
reinterpret_cast<const uint8_t*>(payload) -
api_constants::kFullyConstructedBitFieldOffsetFromPayload)));
atomic_mutable_bitfield->fetch_or(api_constants::kFullyConstructedBitMask,
std::memory_order_release);
// It's safe to split use load+store here (instead of a read-modify-write
// operation), since it's guaranteed that this 16-bit bitfield is only
// modified by a single thread. This is cheaper in terms of code bloat (on
// ARM) and performance.
uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed);
value |= api_constants::kFullyConstructedBitMask;
atomic_mutable_bitfield->store(value, std::memory_order_release);
}

template <typename U, typename CustomSpace>
struct SpacePolicy {
static void* Allocate(AllocationHandle& handle, size_t size) {
// Custom space.
static_assert(std::is_base_of<CustomSpaceBase, CustomSpace>::value,
"Custom space must inherit from CustomSpaceBase.");
return MakeGarbageCollectedTraitInternal::Allocate(
handle, size, internal::GCInfoTrait<U>::Index(),
CustomSpace::kSpaceIndex);
}
};

template <typename U>
struct SpacePolicy<U, void> {
static void* Allocate(AllocationHandle& handle, size_t size) {
// Default space.
return MakeGarbageCollectedTraitInternal::Allocate(
handle, size, internal::GCInfoTrait<U>::Index());
}
};

private:
static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
GCInfoIndex index);
static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
Expand Down Expand Up @@ -71,27 +95,6 @@ class MakeGarbageCollectedTraitBase
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) {
// Custom space.
static_assert(std::is_base_of<CustomSpaceBase, CustomSpace>::value,
"Custom space must inherit from CustomSpaceBase.");
return internal::MakeGarbageCollectedTraitInternal::Allocate(
handle, size, internal::GCInfoTrait<T>::Index(),
CustomSpace::kSpaceIndex);
}
};

template <typename U>
struct SpacePolicy<U, void> {
static void* Allocate(AllocationHandle& handle, size_t size) {
// Default space.
return internal::MakeGarbageCollectedTraitInternal::Allocate(
handle, size, internal::GCInfoTrait<T>::Index());
}
};

protected:
/**
* Allocates memory for an object of type T.
Expand All @@ -101,9 +104,15 @@ class MakeGarbageCollectedTraitBase
* \param size The size that should be reserved for the object.
* \returns the memory to construct an object of type T on.
*/
static void* Allocate(AllocationHandle& handle, size_t size) {
return SpacePolicy<T, typename SpaceTrait<T>::Space>::Allocate(handle,
size);
V8_INLINE static void* Allocate(AllocationHandle& handle, size_t size) {
static_assert(
std::is_base_of<typename T::ParentMostGarbageCollectedType, T>::value,
"U of GarbageCollected<U> must be a base of T. Check "
"GarbageCollected<T> base class inheritance.");
return SpacePolicy<
typename internal::GCInfoFolding<
T, typename T::ParentMostGarbageCollectedType>::ResultType,
typename SpaceTrait<T>::Space>::Allocate(handle, size);
}

/**
Expand All @@ -112,7 +121,7 @@ class MakeGarbageCollectedTraitBase
*
* \param payload The base pointer the object is allocated at.
*/
static void MarkObjectAsFullyConstructed(const void* payload) {
V8_INLINE static void MarkObjectAsFullyConstructed(const void* payload) {
internal::MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed(
payload);
}
Expand Down Expand Up @@ -198,7 +207,7 @@ struct PostConstructionCallbackTrait {
* \returns an instance of type T.
*/
template <typename T, typename... Args>
T* MakeGarbageCollected(AllocationHandle& handle, Args&&... args) {
V8_INLINE T* MakeGarbageCollected(AllocationHandle& handle, Args&&... args) {
T* object =
MakeGarbageCollectedTrait<T>::Call(handle, std::forward<Args>(args)...);
PostConstructionCallbackTrait<T>::Call(object);
Expand All @@ -216,8 +225,9 @@ T* MakeGarbageCollected(AllocationHandle& handle, Args&&... args) {
* \returns an instance of type T.
*/
template <typename T, typename... Args>
T* MakeGarbageCollected(AllocationHandle& handle,
AdditionalBytes additional_bytes, Args&&... args) {
V8_INLINE T* MakeGarbageCollected(AllocationHandle& handle,
AdditionalBytes additional_bytes,
Args&&... args) {
T* object = MakeGarbageCollectedTrait<T>::Call(handle, additional_bytes,
std::forward<Args>(args)...);
PostConstructionCallbackTrait<T>::Call(object);
Expand Down
Loading