Skip to content

Revert V8 MSVC and deadlock workarounds #58187

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

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.10',
'v8_embedder_string': '-node.13',

##### V8 defaults for Node.js #####

Expand Down
16 changes: 2 additions & 14 deletions deps/v8/src/base/fpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,13 @@ void FPU::SetFlushDenormals(bool value) {
#elif defined(V8_HOST_ARCH_ARM64) || defined(V8_HOST_ARCH_ARM)

namespace {
#if defined(V8_HOST_ARCH_ARM64) && defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
#endif

// Bit 24 is the flush-to-zero mode control bit. Setting it to 1 flushes
// denormals to 0.
constexpr int kFlushDenormToZeroBit = (1 << 24);
int GetStatusWord() {
int result;
#if defined(V8_HOST_ARCH_ARM64)
# if defined(_MSC_VER) && !defined(__clang__)
result = _ReadStatusReg(ARM64_FPCR);
# else
asm volatile("mrs %x[result], FPCR" : [result] "=r"(result));
# endif
asm volatile("mrs %x[result], FPCR" : [result] "=r"(result));
#else
asm volatile("vmrs %[result], FPSCR" : [result] "=r"(result));
#endif
Expand All @@ -80,11 +72,7 @@ int GetStatusWord() {

void SetStatusWord(int a) {
#if defined(V8_HOST_ARCH_ARM64)
# if defined(_MSC_VER) && !defined(__clang__)
_WriteStatusReg(ARM64_FPCR, a);
# else
asm volatile("msr FPCR, %x[src]" : : [src] "r"(a));
# endif
asm volatile("msr FPCR, %x[src]" : : [src] "r"(a));
#else
asm volatile("vmsr FPSCR, %[src]" : : [src] "r"(a));
#endif
Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ bool is_inbounds(float_t v) {
// Setup for Windows shared library export.
#define V8_EXPORT_ENUM
#ifdef BUILDING_V8_SHARED_PRIVATE
#define V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE __declspec(dllexport)
#elif USING_V8_SHARED_PRIVATE
#define V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE __declspec(dllimport)
#else
#define V8_EXPORT_PRIVATE
#endif // BUILDING_V8_SHARED
Expand All @@ -454,7 +454,7 @@ bool is_inbounds(float_t v) {
// Setup for Linux shared library export.
#if V8_HAS_ATTRIBUTE_VISIBILITY && \
(defined(BUILDING_V8_SHARED_PRIVATE) || USING_V8_SHARED_PRIVATE)
#define V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE __attribute__((visibility("default")))
#define V8_EXPORT_ENUM V8_EXPORT_PRIVATE
#else
#define V8_EXPORT_PRIVATE
Expand Down
8 changes: 6 additions & 2 deletions deps/v8/src/codegen/arm64/assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ class AssemblerZone {
public:
explicit AssemblerZone(const MaybeAssemblerZone& zone)
// Create a fresh Zone unless one is already provided.
: maybe_local_zone_(),
: maybe_local_zone_(
std::holds_alternative<Zone*>(zone)
? std::nullopt
: std::make_optional<Zone>(std::get<AccountingAllocator*>(zone),
ZONE_NAME)),
zone_(std::holds_alternative<Zone*>(zone)
? std::get<Zone*>(zone)
: &maybe_local_zone_.emplace(std::get<AccountingAllocator*>(zone), ZONE_NAME)) {}
: &maybe_local_zone_.value()) {}

Zone* get() const { return zone_; }

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/compiler/js-heap-broker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ ElementAccessFeedback const& JSHeapBroker::ProcessFeedbackMapsForElementAccess(
Tagged<Map> transition_target;

// Don't generate elements kind transitions from stable maps.
if (!map.is_stable() && possible_transition_targets.begin() != possible_transition_targets.end()) {
if (!map.is_stable()) {
// The lock is needed for UnusedPropertyFields (called deep inside
// FindElementsKindTransitionedMap).
MapUpdaterGuardIfNeeded mumd_scope(this);
Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/execution/frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -1292,11 +1292,11 @@ class WasmFrame : public TypedFrame {
FrameSummaries Summarize() const override;

static WasmFrame* cast(StackFrame* frame) {
DCHECK(frame->is_wasm()
#ifdef V8_ENABLE_DRUMBRAKE
DCHECK(frame->is_wasm() && !frame->is_wasm_interpreter_entry());
#else
DCHECK(frame->is_wasm());
&& !frame->is_wasm_interpreter_entry()
#endif // V8_ENABLE_DRUMBRAKE
);
return static_cast<WasmFrame*>(frame);
}

Expand Down
4 changes: 0 additions & 4 deletions deps/v8/src/execution/isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,10 @@ using DebugObjectCache = std::vector<Handle<HeapObject>>;
#define THREAD_LOCAL_TOP_ADDRESS(type, name) \
inline type* name##_address() { return &thread_local_top()->name##_; }

#if defined(_MSC_VER)
extern thread_local Isolate* g_current_isolate_ V8_CONSTINIT;
#else
// Do not use this variable directly, use Isolate::Current() instead.
// Defined outside of Isolate because Isolate uses V8_EXPORT_PRIVATE.
__attribute__((tls_model(V8_TLS_MODEL))) extern thread_local Isolate*
g_current_isolate_ V8_CONSTINIT;
#endif // defined(_MSC_VER)

// HiddenFactory exists so Isolate can privately inherit from it without making
// Factory's members available to Isolate directly.
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/flags/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ DEFINE_BOOL(baseline_batch_compilation, true, "batch compile Sparkplug code")
DEFINE_BOOL_READONLY(concurrent_sparkplug, false,
"compile Sparkplug code in a background thread")
#else
DEFINE_BOOL(concurrent_sparkplug, false,
DEFINE_BOOL(concurrent_sparkplug, ENABLE_SPARKPLUG_BY_DEFAULT,
"compile Sparkplug code in a background thread")
DEFINE_WEAK_IMPLICATION(future, concurrent_sparkplug)
DEFINE_NEG_IMPLICATION(predictable, concurrent_sparkplug)
Expand Down
32 changes: 0 additions & 32 deletions deps/v8/src/heap/base/asm/arm64/push_registers_masm.S

This file was deleted.

4 changes: 0 additions & 4 deletions deps/v8/src/heap/local-heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ class MarkingBarrier;
class MutablePageMetadata;
class Safepoint;

#if defined(_MSC_VER)
extern thread_local LocalHeap* g_current_local_heap_ V8_CONSTINIT;
#else
// Do not use this variable directly, use LocalHeap::Current() instead.
// Defined outside of LocalHeap because LocalHeap uses V8_EXPORT_PRIVATE.
__attribute__((tls_model(V8_TLS_MODEL))) extern thread_local LocalHeap*
g_current_local_heap_ V8_CONSTINIT;
#endif // defined(_MSC_VER)

// LocalHeap is used by the GC to track all threads with heap access in order to
// stop them before performing a collection. LocalHeaps can be either Parked or
Expand Down
12 changes: 3 additions & 9 deletions deps/v8/src/maglev/maglev-graph-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11003,19 +11003,13 @@ MaybeReduceResult MaglevGraphBuilder::TryReduceCallForNewClosure(
return BuildCallRuntime(Runtime::kThrowConstructorNonCallableError,
{target_node});
}

#ifdef V8_ENABLE_LEAPTIERING
RETURN_IF_DONE(TryBuildCallKnownJSFunction(
target_context, target_node,
GetRootConstant(RootIndex::kUndefinedValue),
dispatch_handle,
shared, feedback_cell, args, feedback_source));
#else
RETURN_IF_DONE(TryBuildCallKnownJSFunction(
target_context, target_node,
GetRootConstant(RootIndex::kUndefinedValue),
shared, feedback_cell, args, feedback_source));
#ifdef V8_ENABLE_LEAPTIERING
dispatch_handle,
#endif
shared, feedback_cell, args, feedback_source));
}
return BuildGenericCall(target_node, Call::TargetType::kJSFunction, args);
}
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/objects/instance-type-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ HEAP_OBJECT_TYPE_LIST(DECL_TYPE)
// Instance types which are associated with one unique map.

template <class type>
V8_INLINE constexpr std::optional<RootIndex> UniqueMapOfInstanceTypeCheck() {
V8_INLINE consteval std::optional<RootIndex> UniqueMapOfInstanceTypeCheck() {
return {};
}

#define INSTANCE_TYPE_MAP(V, rootIndexName, rootAccessorName, class_name) \
template <> \
V8_INLINE constexpr std::optional<RootIndex> \
V8_INLINE consteval std::optional<RootIndex> \
UniqueMapOfInstanceTypeCheck<InstanceTypeTraits::class_name>() { \
return {RootIndex::k##rootIndexName}; \
}
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/objects/tagged-field.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ static_assert(sizeof(UnalignedDoubleMember) == sizeof(double));
#define FLEXIBLE_ARRAY_MEMBER(Type, name) \
using FlexibleDataReturnType = Type[0]; \
FlexibleDataReturnType& name() { \
static_assert(alignof(Type) <= alignof(decltype(*this))); \
using ReturnType = Type[0]; \
return reinterpret_cast<ReturnType&>(*(this + 1)); \
} \
const FlexibleDataReturnType& name() const { \
static_assert(alignof(Type) <= alignof(decltype(*this))); \
using ReturnType = Type[0]; \
return reinterpret_cast<const ReturnType&>(*(this + 1)); \
} \
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/runtime/runtime-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,8 @@ RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
namespace {

int FixedArrayLenFromSize(int size) {
return std::min<int>((size - OFFSET_OF_DATA_START(FixedArray)) / kTaggedSize,
static_cast<int>(FixedArray::kMaxRegularLength));
return std::min({(size - OFFSET_OF_DATA_START(FixedArray)) / kTaggedSize,
FixedArray::kMaxRegularLength});
}

void FillUpOneNewSpacePage(Isolate* isolate, Heap* heap,
Expand Down
10 changes: 2 additions & 8 deletions deps/v8/src/wasm/wasm-objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3009,21 +3009,15 @@ DirectHandle<WasmExportedFunction> WasmExportedFunction::New(
DirectHandle<WasmFuncRef> func_ref,
DirectHandle<WasmInternalFunction> internal_function, int arity,
DirectHandle<Code> export_wrapper) {
#if V8_ENABLE_DRUMBRAKE
DCHECK(CodeKind::JS_TO_WASM_FUNCTION == export_wrapper->kind() ||
(export_wrapper->is_builtin() &&
(export_wrapper->builtin_id() == Builtin::kJSToWasmWrapper ||
#if V8_ENABLE_DRUMBRAKE
export_wrapper->builtin_id() ==
Builtin::kGenericJSToWasmInterpreterWrapper ||
#endif // V8_ENABLE_DRUMBRAKE
export_wrapper->builtin_id() == Builtin::kWasmPromising ||
export_wrapper->builtin_id() == Builtin::kWasmStressSwitch)));
#else
DCHECK(CodeKind::JS_TO_WASM_FUNCTION == export_wrapper->kind() ||
(export_wrapper->is_builtin() &&
(export_wrapper->builtin_id() == Builtin::kJSToWasmWrapper ||
export_wrapper->builtin_id() == Builtin::kWasmPromising ||
export_wrapper->builtin_id() == Builtin::kWasmStressSwitch)));
#endif // V8_ENABLE_DRUMBRAKE
int func_index = internal_function->function_index();
Factory* factory = isolate->factory();
DirectHandle<Map> rtt;
Expand Down
9 changes: 2 additions & 7 deletions deps/v8/third_party/rapidhash-v8/rapidhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,8 @@ struct PlainHashReader {
/*
* Likely and unlikely macros.
*/
#if defined(_MSC_VER) && !defined(__clang__)
#define _likely_(x) (x)
#define _unlikely_(x) (x)
#else
#define _likely_(x) __builtin_expect(x, 1)
#define _unlikely_(x) __builtin_expect(x, 0)
#endif
#define _likely_(x) __builtin_expect(x, 1)
#define _unlikely_(x) __builtin_expect(x, 0)

/*
* Default seed.
Expand Down
Loading