Skip to content

Commit a625a98

Browse files
StefanStojanovictargos
authored andcommitted
deps: patch V8 13.4 to support compilation with MSVC
1 parent 2025345 commit a625a98

File tree

16 files changed

+129
-52
lines changed

16 files changed

+129
-52
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

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

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/base/fpu.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@ void FPU::SetFlushDenormals(bool value) {
5757
#elif defined(V8_HOST_ARCH_ARM64) || defined(V8_HOST_ARCH_ARM)
5858

5959
namespace {
60+
#if defined(V8_HOST_ARCH_ARM64) && defined(_MSC_VER) && !defined(__clang__)
61+
#include <intrin.h>
62+
#endif
63+
6064
// Bit 24 is the flush-to-zero mode control bit. Setting it to 1 flushes
6165
// denormals to 0.
6266
constexpr int kFlushDenormToZeroBit = (1 << 24);
6367
int GetStatusWord() {
6468
int result;
6569
#if defined(V8_HOST_ARCH_ARM64)
66-
asm volatile("mrs %x[result], FPCR" : [result] "=r"(result));
70+
# if defined(_MSC_VER) && !defined(__clang__)
71+
result = _ReadStatusReg(ARM64_FPCR);
72+
# else
73+
asm volatile("mrs %x[result], FPCR" : [result] "=r"(result));
74+
# endif
6775
#else
6876
asm volatile("vmrs %[result], FPSCR" : [result] "=r"(result));
6977
#endif
@@ -72,7 +80,11 @@ int GetStatusWord() {
7280

7381
void SetStatusWord(int a) {
7482
#if defined(V8_HOST_ARCH_ARM64)
75-
asm volatile("msr FPCR, %x[src]" : : [src] "r"(a));
83+
# if defined(_MSC_VER) && !defined(__clang__)
84+
_WriteStatusReg(ARM64_FPCR, a);
85+
# else
86+
asm volatile("msr FPCR, %x[src]" : : [src] "r"(a));
87+
# endif
7688
#else
7789
asm volatile("vmsr FPSCR, %[src]" : : [src] "r"(a));
7890
#endif

deps/v8/src/codegen/arm64/assembler-arm64.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,10 @@ class AssemblerZone {
168168
public:
169169
explicit AssemblerZone(const MaybeAssemblerZone& zone)
170170
// Create a fresh Zone unless one is already provided.
171-
: maybe_local_zone_(
172-
std::holds_alternative<Zone*>(zone)
173-
? std::nullopt
174-
: std::make_optional<Zone>(std::get<AccountingAllocator*>(zone),
175-
ZONE_NAME)),
171+
: maybe_local_zone_(),
176172
zone_(std::holds_alternative<Zone*>(zone)
177173
? std::get<Zone*>(zone)
178-
: &maybe_local_zone_.value()) {}
174+
: &maybe_local_zone_.emplace(std::get<AccountingAllocator*>(zone), ZONE_NAME)) {}
179175

180176
Zone* get() const { return zone_; }
181177

deps/v8/src/compiler/backend/instruction-selector.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,8 @@ struct InstructionSelectorT<Adapter>::CachedStateValues : public ZoneObject {
10091009

10101010
template <>
10111011
class InstructionSelectorT<TurbofanAdapter>::CachedStateValuesBuilder {
1012+
using StateObjectDeduplicator = InstructionSelectorT<TurbofanAdapter>::StateObjectDeduplicator;
1013+
10121014
public:
10131015
explicit CachedStateValuesBuilder(StateValueList* values,
10141016
InstructionOperandVector* inputs,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; Copyright 2020 the V8 project authors. All rights reserved.
2+
; Use of this source code is governed by a BSD-style license that can be
3+
; found in the LICENSE file.
4+
5+
; This file is exactly the same as push_registers_asm.cc, just formatted for
6+
; the Microsoft Arm Assembler.
7+
8+
AREA |.text|, CODE, ALIGN=4, READONLY
9+
EXPORT PushAllRegistersAndIterateStack
10+
PushAllRegistersAndIterateStack
11+
; x19-x29 are callee-saved
12+
STP x19, x20, [sp, #-16]!
13+
STP x21, x22, [sp, #-16]!
14+
STP x23, x24, [sp, #-16]!
15+
STP x25, x26, [sp, #-16]!
16+
STP x27, x28, [sp, #-16]!
17+
STP fp, lr, [sp, #-16]!
18+
; Maintain frame pointer
19+
MOV fp, sp
20+
; Pass 1st parameter (x0) unchanged (Stack*).
21+
; Pass 2nd parameter (x1) unchanged (StackVisitor*).
22+
; Save 3rd parameter (x2; IterateStackCallback)
23+
MOV x7, x2
24+
; Pass 3rd parameter as sp (stack pointer)
25+
MOV x2, sp
26+
BLR x7
27+
; Load return address
28+
LDR lr, [sp, #8]
29+
; Restore frame pointer and pop all callee-saved registers.
30+
LDR fp, [sp], #96
31+
RET
32+
END

deps/v8/src/maglev/maglev-graph-builder.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10206,13 +10206,19 @@ MaybeReduceResult MaglevGraphBuilder::TryReduceCallForNewClosure(
1020610206
return BuildCallRuntime(Runtime::kThrowConstructorNonCallableError,
1020710207
{target_node});
1020810208
}
10209-
RETURN_IF_DONE(TryBuildCallKnownJSFunction(
10209+
10210+
#ifdef V8_ENABLE_LEAPTIERING
10211+
RETURN_IF_DONE(TryBuildCallKnownJSFunction(
1021010212
target_context, target_node,
1021110213
GetRootConstant(RootIndex::kUndefinedValue),
10212-
#ifdef V8_ENABLE_LEAPTIERING
1021310214
dispatch_handle,
10214-
#endif
1021510215
shared, feedback_vector, args, feedback_source));
10216+
#else
10217+
RETURN_IF_DONE(TryBuildCallKnownJSFunction(
10218+
target_context, target_node,
10219+
GetRootConstant(RootIndex::kUndefinedValue),
10220+
shared, feedback_vector, args, feedback_source));
10221+
#endif
1021610222
}
1021710223
return BuildGenericCall(target_node, Call::TargetType::kJSFunction, args);
1021810224
}

deps/v8/src/objects/instance-type-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ HEAP_OBJECT_TYPE_LIST(DECL_TYPE)
3939
// Instance types which are associated with one unique map.
4040

4141
template <class type>
42-
V8_INLINE consteval std::optional<RootIndex> UniqueMapOfInstanceTypeCheck() {
42+
V8_INLINE constexpr std::optional<RootIndex> UniqueMapOfInstanceTypeCheck() {
4343
return {};
4444
}
4545

4646
#define INSTANCE_TYPE_MAP(V, rootIndexName, rootAccessorName, class_name) \
4747
template <> \
48-
V8_INLINE consteval std::optional<RootIndex> \
48+
V8_INLINE constexpr std::optional<RootIndex> \
4949
UniqueMapOfInstanceTypeCheck<InstanceTypeTraits::class_name>() { \
5050
return {RootIndex::k##rootIndexName}; \
5151
}

deps/v8/src/runtime/runtime-test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,8 @@ RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
11971197
namespace {
11981198

11991199
int FixedArrayLenFromSize(int size) {
1200-
return std::min({(size - OFFSET_OF_DATA_START(FixedArray)) / kTaggedSize,
1201-
FixedArray::kMaxRegularLength});
1200+
return std::min<int>((size - OFFSET_OF_DATA_START(FixedArray)) / kTaggedSize,
1201+
static_cast<int>(FixedArray::kMaxRegularLength));
12021202
}
12031203

12041204
void FillUpOneNewSpacePage(Isolate* isolate, Heap* heap,

deps/v8/third_party/rapidhash-v8/rapidhash.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,13 @@ struct PlainHashReader {
153153
/*
154154
* Likely and unlikely macros.
155155
*/
156-
#define _likely_(x) __builtin_expect(x, 1)
157-
#define _unlikely_(x) __builtin_expect(x, 0)
156+
#if defined(_MSC_VER) && !defined(__clang__)
157+
#define _likely_(x) (x)
158+
#define _unlikely_(x) (x)
159+
#else
160+
#define _likely_(x) __builtin_expect(x, 1)
161+
#define _unlikely_(x) __builtin_expect(x, 0)
162+
#endif
158163

159164
/*
160165
* Default seed.

0 commit comments

Comments
 (0)