|
10 | 10 |
|
11 | 11 | #include <v8-context.h> |
12 | 12 | #include <v8-object.h> |
| 13 | +#include <v8-version.h> |
13 | 14 |
|
14 | 15 | #include <kj/common.h> |
15 | 16 | #include <kj/debug.h> |
@@ -55,7 +56,13 @@ template <typename T> |
55 | 56 | kj::Maybe<T&> getAlignedPointerFromEmbedderData( |
56 | 57 | v8::Local<v8::Context> context, ContextPointerSlot slot) { |
57 | 58 | KJ_DASSERT(slot != ContextPointerSlot::RESERVED, "Attempt to use reserved embedder data slot."); |
| 59 | + // TODO(cleanup): Remove this #if when workerd's V8 version is updated to 14.2. |
| 60 | +#if V8_MAJOR_VERSION < 14 || V8_MINOR_VERSION < 2 |
58 | 61 | void* ptr = context->GetAlignedPointerFromEmbedderData(static_cast<int>(slot)); |
| 62 | +#else |
| 63 | + void* ptr = context->GetAlignedPointerFromEmbedderData( |
| 64 | + static_cast<int>(slot), static_cast<v8::EmbedderDataTypeTag>(slot)); |
| 65 | +#endif |
59 | 66 | if (ptr == nullptr) return kj::none; |
60 | 67 | return *reinterpret_cast<T*>(ptr); |
61 | 68 | } |
@@ -109,8 +116,15 @@ class Wrappable: public kj::Refcounted { |
109 | 116 | static constexpr uint16_t WORKERD_WRAPPABLE_TAG = 0xeb04; |
110 | 117 |
|
111 | 118 | static bool isWorkerdApiObject(v8::Local<v8::Object> object) { |
| 119 | + // TODO(cleanup): Remove this #if when workerd's V8 version is updated to 14.2. |
| 120 | +#if V8_MAJOR_VERSION < 14 || V8_MINOR_VERSION < 2 |
112 | 121 | return object->GetAlignedPointerFromInternalField(WRAPPABLE_TAG_FIELD_INDEX) == |
113 | 122 | &WORKERD_WRAPPABLE_TAG; |
| 123 | +#else |
| 124 | + return object->GetAlignedPointerFromInternalField(WRAPPABLE_TAG_FIELD_INDEX, |
| 125 | + static_cast<v8::EmbedderDataTypeTag>(WRAPPABLE_TAG_FIELD_INDEX)) == |
| 126 | + &WORKERD_WRAPPABLE_TAG; |
| 127 | +#endif |
114 | 128 | } |
115 | 129 |
|
116 | 130 | void addStrongRef(); |
@@ -315,8 +329,15 @@ T& extractInternalPointer( |
315 | 329 | getAlignedPointerFromEmbedderData<T>(context, ContextPointerSlot::GLOBAL_WRAPPER)); |
316 | 330 | } else { |
317 | 331 | KJ_ASSERT(object->InternalFieldCount() == Wrappable::INTERNAL_FIELD_COUNT); |
| 332 | + // TODO(cleanup): Remove this #if when workerd's V8 version is updated to 14.2. |
| 333 | +#if V8_MAJOR_VERSION < 14 || V8_MINOR_VERSION < 2 |
318 | 334 | return *reinterpret_cast<T*>( |
319 | 335 | object->GetAlignedPointerFromInternalField(Wrappable::WRAPPED_OBJECT_FIELD_INDEX)); |
| 336 | +#else |
| 337 | + return *reinterpret_cast<T*>( |
| 338 | + object->GetAlignedPointerFromInternalField(Wrappable::WRAPPED_OBJECT_FIELD_INDEX, |
| 339 | + static_cast<v8::EmbedderDataTypeTag>(Wrappable::WRAPPED_OBJECT_FIELD_INDEX))); |
| 340 | +#endif |
320 | 341 | } |
321 | 342 | } |
322 | 343 |
|
|
0 commit comments