Skip to content

Commit

Permalink
Update V8 to 8.9.255.20 (#87)
Browse files Browse the repository at this point in the history
* Update V8 to 8.9.255.20

* c fmt

* Update V8 static library for ubuntu-latest (#88)

Co-authored-by: rogchap <[email protected]>

* Update V8 static library for macos-latest (#89)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: rogchap <[email protected]>
Co-authored-by: Zhao Wang <[email protected]>
  • Loading branch information
4 people authored Mar 10, 2021
1 parent 387e66e commit a487634
Show file tree
Hide file tree
Showing 30 changed files with 1,193 additions and 498 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Promise resolver and promise result

### Changed
- Upgrade to V8 8.9.255.20

### 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 @@ -137,7 +137,7 @@ V8 requires 64-bit on Windows, therefore will not work on 32-bit systems.

## V8 dependency

V8 version: **8.8.278.14** (January 2021)
V8 version: **8.9.255.20** (March 2021)

In order to make `v8go` usable as a standard Go package, prebuilt static libraries of V8
are included for Linux and macOS ie. you *should not* require to build V8 yourself.
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 07bd25 to d071f2
3 changes: 3 additions & 0 deletions deps/include/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ include_rules = [
# v8-inspector-protocol.h depends on generated files under include/inspector.
"+inspector",
"+cppgc/common.h",
# Used by v8-cppgc.h to bridge to cppgc.
"+cppgc/custom-space.h",
"+cppgc/internal/write-barrier.h",
"+cppgc/visitor.h",
]
29 changes: 23 additions & 6 deletions deps/include/cppgc/allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ class V8_EXPORT MakeGarbageCollectedTraitInternal {
const_cast<uint16_t*>(reinterpret_cast<const uint16_t*>(
reinterpret_cast<const uint8_t*>(payload) -
api_constants::kFullyConstructedBitFieldOffsetFromPayload)));
uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed);
value = value | api_constants::kFullyConstructedBitMask;
atomic_mutable_bitfield->store(value, std::memory_order_release);
atomic_mutable_bitfield->fetch_or(api_constants::kFullyConstructedBitMask,
std::memory_order_release);
}

static void* Allocate(cppgc::AllocationHandle& handle, size_t size,
Expand Down Expand Up @@ -113,11 +112,29 @@ class MakeGarbageCollectedTraitBase
};

/**
* struct used specify to MakeGarbageCollected how many bytes should be
* appended to the allocated object.
* Passed to MakeGarbageCollected to specify how many bytes should be appended
* to the allocated object.
*
* Example:
* \code
* class InlinedArray final : public GarbageCollected<InlinedArray> {
* public:
* explicit InlinedArray(size_t bytes) : size(bytes), byte_array(this + 1) {}
* void Trace(Visitor*) const {}
* size_t size;
* char* byte_array;
* };
*
* auto* inlined_array = MakeGarbageCollected<InlinedArray(
* GetAllocationHandle(), AdditionalBytes(4), 4);
* for (size_t i = 0; i < 4; i++) {
* Process(inlined_array->byte_array[i]);
* }
* \endcode
*/
struct AdditionalBytes {
explicit AdditionalBytes(size_t bytes) : value(bytes) {}
constexpr explicit AdditionalBytes(size_t bytes) : value(bytes) {}
const size_t value;
};

Expand Down
6 changes: 3 additions & 3 deletions deps/include/cppgc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace cppgc {
enum class EmbedderStackState {
kMayContainHeapPointers,
kNoHeapPointers,
kUnknown V8_ENUM_DEPRECATE_SOON("Use kMayContainHeapPointers") =
kUnknown V8_ENUM_DEPRECATED("Use kMayContainHeapPointers") =
kMayContainHeapPointers,
kNonEmpty V8_ENUM_DEPRECATE_SOON("Use kMayContainHeapPointers") =
kNonEmpty V8_ENUM_DEPRECATED("Use kMayContainHeapPointers") =
kMayContainHeapPointers,
kEmpty V8_ENUM_DEPRECATE_SOON("Use kNoHeapPointers") = kNoHeapPointers,
kEmpty V8_ENUM_DEPRECATED("Use kNoHeapPointers") = kNoHeapPointers,
};

} // namespace cppgc
Expand Down
22 changes: 19 additions & 3 deletions deps/include/cppgc/default-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ namespace cppgc {
*/
class V8_EXPORT DefaultPlatform : public Platform {
public:
/**
* Use this method instead of 'cppgc::InitializeProcess' when using
* 'cppgc::DefaultPlatform'. 'cppgc::DefaultPlatform::InitializeProcess'
* will initialize cppgc and v8 if needed (for non-standalone builds).
*
* \param platform DefaultPlatform instance used to initialize cppgc/v8.
*/
static void InitializeProcess(DefaultPlatform* platform);

using IdleTaskSupport = v8::platform::IdleTaskSupport;
explicit DefaultPlatform(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled)
: v8_platform_(v8::platform::NewDefaultPlatform(thread_pool_size,
idle_task_support)) {}
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
std::unique_ptr<TracingController> tracing_controller = {})
: v8_platform_(v8::platform::NewDefaultPlatform(
thread_pool_size, idle_task_support,
v8::platform::InProcessStackDumping::kDisabled,
std::move(tracing_controller))) {}

cppgc::PageAllocator* GetPageAllocator() override {
return v8_platform_->GetPageAllocator();
Expand All @@ -48,6 +60,10 @@ class V8_EXPORT DefaultPlatform : public Platform {
return v8_platform_->PostJob(priority, std::move(job_task));
}

TracingController* GetTracingController() override {
return v8_platform_->GetTracingController();
}

protected:
static constexpr v8::Isolate* kNoIsolate = nullptr;

Expand Down
137 changes: 137 additions & 0 deletions deps/include/cppgc/heap-consistency.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// 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.

#ifndef INCLUDE_CPPGC_HEAP_CONSISTENCY_H_
#define INCLUDE_CPPGC_HEAP_CONSISTENCY_H_

#include <cstddef>

#include "cppgc/internal/write-barrier.h"
#include "cppgc/trace-trait.h"
#include "v8config.h" // NOLINT(build/include_directory)

namespace cppgc {

class HeapHandle;

namespace subtle {

/**
* **DO NOT USE: Use the appropriate managed types.**
*
* Consistency helpers that aid in maintaining a consistent internal state of
* the garbage collector.
*/
class HeapConsistency final {
public:
using WriteBarrierParams = internal::WriteBarrier::Params;
using WriteBarrierType = internal::WriteBarrier::Type;

/**
* Gets the required write barrier type for a specific write.
*
* \param slot Slot containing the pointer to the object. The slot itself
* must reside in an object that has been allocated using
* `MakeGarbageCollected()`.
* \param value The pointer to the object. May be an interior pointer to an
* interface of the actual object.
* \param params Parameters that may be used for actual write barrier calls.
* Only filled if return value indicates that a write barrier is needed. The
* contents of the `params` are an implementation detail.
* \returns whether a write barrier is needed and which barrier to invoke.
*/
static V8_INLINE WriteBarrierType GetWriteBarrierType(
const void* slot, const void* value, WriteBarrierParams& params) {
return internal::WriteBarrier::GetWriteBarrierType(slot, value, params);
}

/**
* Gets the required write barrier type for a specific write.
*
* \param slot Slot containing the pointer to some part of an object object
* that has been allocated using `MakeGarbageCollected()`. Does not consider
* the value of `slot`.
* \param params Parameters that may be used for actual write barrier calls.
* Only filled if return value indicates that a write barrier is needed. The
* contents of the `params` are an implementation detail.
* \returns whether a write barrier is needed and which barrier to invoke.
*/
static V8_INLINE WriteBarrierType
GetWriteBarrierType(const void* slot, WriteBarrierParams& params) {
return internal::WriteBarrier::GetWriteBarrierType(slot, params);
}

/**
* Conservative Dijkstra-style write barrier that processes an object if it
* has not yet been processed.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param object The pointer to the object. May be an interior pointer to a
* an interface of the actual object.
*/
static V8_INLINE void DijkstraWriteBarrier(const WriteBarrierParams& params,
const void* object) {
internal::WriteBarrier::DijkstraMarkingBarrier(params, object);
}

/**
* Conservative Dijkstra-style write barrier that processes a range of
* elements if they have not yet been processed.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param heap The corresponding heap.
* \param first_element Pointer to the first element that should be processed.
* The slot itself must reside in an object that has been allocated using
* `MakeGarbageCollected()`.
* \param element_size Size of the element in bytes.
* \param number_of_elements Number of elements that should be processed,
* starting with `first_element`.
* \param trace_callback The trace callback that should be invoked for each
* element if necessary.
*/
static V8_INLINE void DijkstraWriteBarrierRange(
const WriteBarrierParams& params, HeapHandle& heap,
const void* first_element, size_t element_size, size_t number_of_elements,
TraceCallback trace_callback) {
internal::WriteBarrier::DijkstraMarkingBarrierRange(
params, heap, first_element, element_size, number_of_elements,
trace_callback);
}

/**
* Steele-style write barrier that re-processes an object if it has already
* been processed.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param object The pointer to the object which must point to an object that
* has been allocated using `MakeGarbageCollected()`. Interior pointers are
* not supported.
*/
static V8_INLINE void SteeleWriteBarrier(const WriteBarrierParams& params,
const void* object) {
internal::WriteBarrier::SteeleMarkingBarrier(params, object);
}

/**
* Generational barrier for maintaining consistency when running with multiple
* generations.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param slot Slot containing the pointer to the object. The slot itself
* must reside in an object that has been allocated using
* `MakeGarbageCollected()`.
*/
static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
const void* slot) {
internal::WriteBarrier::GenerationalBarrier(params, slot);
}

private:
HeapConsistency() = delete;
};

} // namespace subtle
} // namespace cppgc

#endif // INCLUDE_CPPGC_HEAP_CONSISTENCY_H_
56 changes: 56 additions & 0 deletions deps/include/cppgc/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ namespace internal {
class Heap;
} // namespace internal

/**
* Used for additional heap APIs.
*/
class HeapHandle;

class V8_EXPORT Heap {
public:
/**
Expand All @@ -51,6 +56,41 @@ class V8_EXPORT Heap {
kNoConservativeStackScan,
};

/**
* Specifies supported marking types
*/
enum class MarkingType : uint8_t {
/**
* Atomic stop-the-world marking. This option does not require any write
* barriers but is the most intrusive in terms of jank.
*/
kAtomic,
/**
* Incremental marking, i.e. interleave marking is the rest of the
* application on the same thread.
*/
kIncremental,
/**
* Incremental and concurrent marking.
*/
kIncrementalAndConcurrent
};

/**
* Specifies supported sweeping types
*/
enum class SweepingType : uint8_t {
/**
* Atomic stop-the-world sweeping. All of sweeping is performed at once.
*/
kAtomic,
/**
* Incremental and concurrent sweeping. Sweeping is split and interleaved
* with the rest of the application.
*/
kIncrementalAndConcurrent
};

/**
* Constraints for a Heap setup.
*/
Expand Down Expand Up @@ -93,6 +133,16 @@ class V8_EXPORT Heap {
*/
StackSupport stack_support = StackSupport::kSupportsConservativeStackScan;

/**
* Specifies which types of marking are supported by the heap.
*/
MarkingType marking_support = MarkingType::kIncrementalAndConcurrent;

/**
* Specifies which types of sweeping are supported by the heap.
*/
SweepingType sweeping_support = SweepingType::kIncrementalAndConcurrent;

/**
* Resource constraints specifying various properties that the internal
* GC scheduler follows.
Expand Down Expand Up @@ -132,6 +182,12 @@ class V8_EXPORT Heap {
*/
AllocationHandle& GetAllocationHandle();

/**
* \returns the opaque heap handle which may be used to refer to this heap in
* other APIs. Valid as long as the underlying `Heap` is alive.
*/
HeapHandle& GetHeapHandle();

private:
Heap() = default;

Expand Down
2 changes: 1 addition & 1 deletion deps/include/cppgc/internal/api-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ constexpr size_t kGB = kMB * 1024;
static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
2 * sizeof(uint16_t);
// Mask for in-construction bit.
static constexpr size_t kFullyConstructedBitMask = size_t{1};
static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};

static constexpr size_t kPageSize = size_t{1} << 17;

Expand Down
12 changes: 11 additions & 1 deletion deps/include/cppgc/internal/pointer-policies.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ struct DijkstraWriteBarrierPolicy {
// barrier doesn't break the tri-color invariant.
}
static void AssigningBarrier(const void* slot, const void* value) {
WriteBarrier::MarkingBarrier(slot, value);
WriteBarrier::Params params;
switch (WriteBarrier::GetWriteBarrierType(slot, value, params)) {
case WriteBarrier::Type::kGenerational:
WriteBarrier::GenerationalBarrier(params, slot);
break;
case WriteBarrier::Type::kMarking:
WriteBarrier::DijkstraMarkingBarrier(params, value);
break;
case WriteBarrier::Type::kNone:
break;
}
}
};

Expand Down
Loading

0 comments on commit a487634

Please sign in to comment.