Skip to content

Commit f780254

Browse files
author
Stephen Belanger
committed
deps: V8: backport 7857eb34db42
Original commit message: Reland^2 "Add ContinuationPreservedEmbedderData builtins to extras binding" This reverts commit cb1277e97a0ed32fd893be9f4e927f6e8b6c566c. > Original change's description: > > Add ContinuationPreservedEmbedderData builtins to extras binding > > > > Node.js and Deno wish to use CPED for AsyncLocalStorage and APM, which > > needs a high performance implementation. These builtins allow JavaScript > > to handle CPED performantly. > > > > Change-Id: I7577be80818524baa52791dfce57d442d7c0c933 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5638129 > > Commit-Queue: snek <[email protected]> > > Reviewed-by: Darius Mercadier <[email protected]> > > Reviewed-by: Leszek Swirski <[email protected]> > > Reviewed-by: Nico Hartmann <[email protected]> > > Cr-Commit-Position: refs/heads/main@{#94607} > > Change-Id: Ief390f0b99891c8de83b4c794180440f91cbaf1f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5649024 > Auto-Submit: Shu-yu Guo <[email protected]> > Bot-Commit: Rubber Stamper <[email protected]> > Commit-Queue: Rubber Stamper <[email protected]> > Cr-Commit-Position: refs/heads/main@{#94608} Change-Id: I4943071ffe192084e83bfe3113cfe9c92ef31465 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5677045 Reviewed-by: Darius Mercadier <[email protected]> Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: snek <[email protected]> Cr-Commit-Position: refs/heads/main@{#94866} Refs: v8/v8@7857eb3
1 parent ad1e561 commit f780254

29 files changed

+627
-63
lines changed

common.gypi

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

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.16',
39+
'v8_embedder_string': '-node.17',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/builtins/base.tq

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,6 @@ extern macro ChangeUint32ToWord(uint32): uintptr; // Doesn't sign-extend.
13131313
extern macro ChangeInt32ToInt64(int32): int64; // Sign-extends.
13141314
extern macro ChangeUint32ToUint64(uint32): uint64; // Doesn't sign-extend.
13151315
extern macro LoadNativeContext(Context): NativeContext;
1316-
extern macro GetContinuationPreservedEmbedderData(): Object;
13171316
extern macro TruncateFloat64ToFloat16(float64): float16;
13181317
extern macro TruncateFloat32ToFloat16(float32): float16;
13191318
extern macro TruncateFloat64ToFloat32(float64): float32;

deps/v8/src/builtins/promise-misc.tq

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ extern macro PromiseBuiltinsAssembler::IsIsolatePromiseHookEnabled(uint32):
3030

3131
extern macro PromiseBuiltinsAssembler::PromiseHookFlags(): uint32;
3232

33+
namespace macros {
34+
extern macro GetContinuationPreservedEmbedderData(): Object;
35+
extern macro SetContinuationPreservedEmbedderData(Object): void;
36+
}
37+
3338
namespace promise {
3439
extern macro IsFunctionWithPrototypeSlotMap(Map): bool;
3540

@@ -80,7 +85,7 @@ macro NewPromiseFulfillReactionJobTask(
8085
return new PromiseFulfillReactionJobTask{
8186
map: PromiseFulfillReactionJobTaskMapConstant(),
8287
continuation_preserved_embedder_data:
83-
GetContinuationPreservedEmbedderData(),
88+
macros::GetContinuationPreservedEmbedderData(),
8489
argument,
8590
context: handlerContext,
8691
handler,
@@ -108,7 +113,7 @@ macro NewPromiseRejectReactionJobTask(
108113
return new PromiseRejectReactionJobTask{
109114
map: PromiseRejectReactionJobTaskMapConstant(),
110115
continuation_preserved_embedder_data:
111-
GetContinuationPreservedEmbedderData(),
116+
macros::GetContinuationPreservedEmbedderData(),
112117
argument,
113118
context: handlerContext,
114119
handler,
@@ -303,7 +308,7 @@ macro NewPromiseReaction(
303308
return new PromiseReaction{
304309
map: PromiseReactionMapConstant(),
305310
continuation_preserved_embedder_data:
306-
GetContinuationPreservedEmbedderData(),
311+
macros::GetContinuationPreservedEmbedderData(),
307312
next: next,
308313
reject_handler: rejectHandler,
309314
fulfill_handler: fulfillHandler,
@@ -347,7 +352,7 @@ macro NewPromiseResolveThenableJobTask(
347352
return new PromiseResolveThenableJobTask{
348353
map: PromiseResolveThenableJobTaskMapConstant(),
349354
continuation_preserved_embedder_data:
350-
GetContinuationPreservedEmbedderData(),
355+
macros::GetContinuationPreservedEmbedderData(),
351356
context: nativeContext,
352357
promise_to_resolve: promiseToResolve,
353358
thenable,
@@ -452,4 +457,18 @@ transitioning macro BranchIfAccessCheckFailed(
452457
}
453458
} label HasAccess {}
454459
}
460+
461+
@if(V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA)
462+
transitioning javascript builtin GetContinuationPreservedEmbedderData(
463+
js-implicit context: Context, receiver: JSAny)(): JSAny {
464+
return UnsafeCast<JSAny>(macros::GetContinuationPreservedEmbedderData());
465+
}
466+
467+
@if(V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA)
468+
transitioning javascript builtin SetContinuationPreservedEmbedderData(
469+
js-implicit context: Context, receiver: JSAny)(data: Object): Undefined {
470+
macros::SetContinuationPreservedEmbedderData(data);
471+
return Undefined;
472+
}
473+
455474
}

deps/v8/src/compiler/js-call-reducer.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5108,6 +5108,12 @@ Reduction JSCallReducer::ReduceJSCall(Node* node,
51085108
case Builtin::kBigIntAsIntN:
51095109
case Builtin::kBigIntAsUintN:
51105110
return ReduceBigIntAsN(node, builtin);
5111+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
5112+
case Builtin::kGetContinuationPreservedEmbedderData:
5113+
return ReduceGetContinuationPreservedEmbedderData(node);
5114+
case Builtin::kSetContinuationPreservedEmbedderData:
5115+
return ReduceSetContinuationPreservedEmbedderData(node);
5116+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
51115117
default:
51125118
break;
51135119
}
@@ -8780,6 +8786,39 @@ Reduction JSCallReducer::ReduceJSCallMathMinMaxWithArrayLike(Node* node,
87808786
return ReplaceWithSubgraph(&a, subgraph);
87818787
}
87828788

8789+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
8790+
Reduction JSCallReducer::ReduceGetContinuationPreservedEmbedderData(
8791+
Node* node) {
8792+
JSCallNode n(node);
8793+
Effect effect = n.effect();
8794+
Control control = n.control();
8795+
8796+
Node* value = effect = graph()->NewNode(
8797+
simplified()->GetContinuationPreservedEmbedderData(), effect);
8798+
8799+
ReplaceWithValue(node, value, effect, control);
8800+
return Replace(node);
8801+
}
8802+
8803+
Reduction JSCallReducer::ReduceSetContinuationPreservedEmbedderData(
8804+
Node* node) {
8805+
JSCallNode n(node);
8806+
Effect effect = n.effect();
8807+
Control control = n.control();
8808+
8809+
if (n.ArgumentCount() == 0) return NoChange();
8810+
8811+
effect =
8812+
graph()->NewNode(simplified()->SetContinuationPreservedEmbedderData(),
8813+
n.Argument(0), effect);
8814+
8815+
Node* value = jsgraph()->UndefinedConstant();
8816+
8817+
ReplaceWithValue(node, value, effect, control);
8818+
return Replace(node);
8819+
}
8820+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
8821+
87838822
CompilationDependencies* JSCallReducer::dependencies() const {
87848823
return broker()->dependencies();
87858824
}

deps/v8/src/compiler/js-call-reducer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
239239
base::Optional<Reduction> TryReduceJSCallMathMinMaxWithArrayLike(Node* node);
240240
Reduction ReduceJSCallMathMinMaxWithArrayLike(Node* node, Builtin builtin);
241241

242+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
243+
Reduction ReduceGetContinuationPreservedEmbedderData(Node* node);
244+
Reduction ReduceSetContinuationPreservedEmbedderData(Node* node);
245+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
246+
242247
// The pendant to ReplaceWithValue when using GraphAssembler-based reductions.
243248
Reduction ReplaceWithSubgraph(JSCallReducerAssembler* gasm, Node* subgraph);
244249
std::pair<Node*, Node*> ReleaseEffectAndControlFromAssembler(

deps/v8/src/compiler/opcodes.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@
429429

430430
#define SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(V) V(SpeculativeToNumber)
431431

432+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
433+
#define SIMPLIFIED_CPED_OP_LIST(V) \
434+
V(GetContinuationPreservedEmbedderData) \
435+
V(SetContinuationPreservedEmbedderData)
436+
#else
437+
#define SIMPLIFIED_CPED_OP_LIST(V)
438+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
439+
432440
#define SIMPLIFIED_OTHER_OP_LIST(V) \
433441
V(Allocate) \
434442
V(AllocateRaw) \
@@ -534,7 +542,8 @@
534542
V(TransitionElementsKind) \
535543
V(TypeOf) \
536544
V(Unsigned32Divide) \
537-
V(VerifyType)
545+
V(VerifyType) \
546+
SIMPLIFIED_CPED_OP_LIST(V)
538547

539548
#define SIMPLIFIED_SPECULATIVE_BIGINT_BINOP_LIST(V) \
540549
V(SpeculativeBigIntAdd) \

deps/v8/src/compiler/simplified-lowering.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4635,6 +4635,17 @@ class RepresentationSelector {
46354635
SetOutput<T>(node, LoadRepresentationOf(node->op()).representation());
46364636
return;
46374637

4638+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
4639+
case IrOpcode::kGetContinuationPreservedEmbedderData:
4640+
SetOutput<T>(node, MachineRepresentation::kTagged);
4641+
return;
4642+
4643+
case IrOpcode::kSetContinuationPreservedEmbedderData:
4644+
ProcessInput<T>(node, 0, UseInfo::AnyTagged());
4645+
SetOutput<T>(node, MachineRepresentation::kNone);
4646+
return;
4647+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
4648+
46384649
default:
46394650
FATAL(
46404651
"Representation inference: unsupported opcode %i (%s), node #%i\n.",

deps/v8/src/compiler/simplified-operator.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,26 @@ struct SimplifiedOperatorGlobalCache final {
13391339
kSpeculativeToBigIntBigInt64Operator;
13401340
SpeculativeToBigIntOperator<BigIntOperationHint::kBigInt>
13411341
kSpeculativeToBigIntBigIntOperator;
1342+
1343+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
1344+
struct GetContinuationPreservedEmbedderDataOperator : public Operator {
1345+
GetContinuationPreservedEmbedderDataOperator()
1346+
: Operator(IrOpcode::kGetContinuationPreservedEmbedderData,
1347+
Operator::kNoThrow | Operator::kNoDeopt | Operator::kNoWrite,
1348+
"GetContinuationPreservedEmbedderData", 0, 1, 0, 1, 1, 0) {}
1349+
};
1350+
GetContinuationPreservedEmbedderDataOperator
1351+
kGetContinuationPreservedEmbedderData;
1352+
1353+
struct SetContinuationPreservedEmbedderDataOperator : public Operator {
1354+
SetContinuationPreservedEmbedderDataOperator()
1355+
: Operator(IrOpcode::kSetContinuationPreservedEmbedderData,
1356+
Operator::kNoThrow | Operator::kNoDeopt | Operator::kNoRead,
1357+
"SetContinuationPreservedEmbedderData", 1, 1, 0, 0, 1, 0) {}
1358+
};
1359+
SetContinuationPreservedEmbedderDataOperator
1360+
kSetContinuationPreservedEmbedderData;
1361+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
13421362
};
13431363

13441364
namespace {
@@ -2198,6 +2218,18 @@ const Operator* SimplifiedOperatorBuilder::StoreField(
21982218
2, 1, 1, 0, 1, 0, store_access);
21992219
}
22002220

2221+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
2222+
const Operator*
2223+
SimplifiedOperatorBuilder::GetContinuationPreservedEmbedderData() {
2224+
return &cache_.kGetContinuationPreservedEmbedderData;
2225+
}
2226+
2227+
const Operator*
2228+
SimplifiedOperatorBuilder::SetContinuationPreservedEmbedderData() {
2229+
return &cache_.kSetContinuationPreservedEmbedderData;
2230+
}
2231+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
2232+
22012233
const Operator* SimplifiedOperatorBuilder::LoadMessage() {
22022234
return zone()->New<Operator>(IrOpcode::kLoadMessage, Operator::kEliminatable,
22032235
"LoadMessage", 1, 1, 1, 1, 1, 0);

deps/v8/src/compiler/simplified-operator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,11 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
12181218
const FastApiCallFunctionVector& c_candidate_functions,
12191219
FeedbackSource const& feedback, CallDescriptor* descriptor);
12201220

1221+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
1222+
const Operator* GetContinuationPreservedEmbedderData();
1223+
const Operator* SetContinuationPreservedEmbedderData();
1224+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
1225+
12211226
private:
12221227
Zone* zone() const { return zone_; }
12231228

deps/v8/src/compiler/turboshaft/assembler.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,6 +3855,16 @@ class TurboshaftAssemblerOpInterface
38553855
}
38563856
#endif // V8_ENABLE_WEBASSEMBLY
38573857

3858+
#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
3859+
V<Object> GetContinuationPreservedEmbedderData() {
3860+
return ReduceIfReachableGetContinuationPreservedEmbedderData();
3861+
}
3862+
3863+
void SetContinuationPreservedEmbedderData(V<Object> data) {
3864+
ReduceIfReachableSetContinuationPreservedEmbedderData(data);
3865+
}
3866+
#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
3867+
38583868
template <typename Rep>
38593869
V<Rep> resolve(const V<Rep>& v) {
38603870
return v;

0 commit comments

Comments
 (0)