Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danlapid committed Nov 29, 2024
1 parent e78f54c commit 0ef2816
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 93 deletions.
5 changes: 0 additions & 5 deletions src/workerd/jsg/promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,6 @@ class PromiseWrapper {
// std::nullptr_t). The getConfig allows us to handle any case using reasonable defaults.
PromiseWrapper(const auto& config): config(getConfig(config)) {}

template <typename MetaConfiguration>
void updateConfiguration(MetaConfiguration&& configuration) {
config = getConfig(kj::fwd<MetaConfiguration>(configuration));
}

template <typename T>
static constexpr const char* getName(Promise<T>*) {
return "Promise";
Expand Down
5 changes: 0 additions & 5 deletions src/workerd/jsg/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -1349,11 +1349,6 @@ class ResourceWrapper {
ResourceWrapper(MetaConfiguration&& configuration)
: configuration(kj::fwd<MetaConfiguration>(configuration)) {}

template <typename MetaConfiguration>
void updateConfiguration(MetaConfiguration&& config) {
configuration = kj::fwd<MetaConfiguration>(config);
}

inline void initTypeWrapper() {
TypeWrapper& wrapper = static_cast<TypeWrapper&>(*this);
wrapper.resourceTypeMap.insert(typeid(T),
Expand Down
52 changes: 26 additions & 26 deletions src/workerd/jsg/setup.c++
Original file line number Diff line number Diff line change
Expand Up @@ -404,32 +404,32 @@ v8::Local<v8::FunctionTemplate> IsolateBase::getOpaqueTemplate(v8::Isolate* isol
return static_cast<IsolateBase*>(isolate->GetData(0))->opaqueTemplate.Get(isolate);
}

void IsolateBase::dropWrappers(kj::Own<void> typeWrapperInstance) {
// Delete all wrappers.
jsg::runInV8Stack([&](jsg::V8StackScope& stackScope) {
v8::Locker lock(ptr);
v8::Isolate::Scope isolateScope(ptr);

// Make sure everything in the deferred destruction queue is dropped.
clearDestructionQueue();
clearPendingExternalMemoryDecrement();

// We MUST call heapTracer.destroy(), but we can't do it yet because destroying other handles
// may call into the heap tracer.
KJ_DEFER(heapTracer.destroy());

// Make sure v8::Globals are destroyed under lock (but not until later).
KJ_DEFER(symbolAsyncDispose.Reset());
KJ_DEFER(opaqueTemplate.Reset());

// Make sure the TypeWrapper is destroyed under lock by declaring a new copy of the variable
// that is destroyed before the lock is released.
kj::Own<void> typeWrapperInstanceInner = kj::mv(typeWrapperInstance);

// Destroy all wrappers.
heapTracer.clearWrappers();
});
}
// void IsolateBase::dropWrappers(kj::Array<kj::Own<void>> typeWrapperInstance) {
// // Delete all wrappers.
// jsg::runInV8Stack([&](jsg::V8StackScope& stackScope) {
// v8::Locker lock(ptr);
// v8::Isolate::Scope isolateScope(ptr);

// // Make sure everything in the deferred destruction queue is dropped.
// clearDestructionQueue();
// clearPendingExternalMemoryDecrement();

// // We MUST call heapTracer.destroy(), but we can't do it yet because destroying other handles
// // may call into the heap tracer.
// KJ_DEFER(heapTracer.destroy());

// // Make sure v8::Globals are destroyed under lock (but not until later).
// KJ_DEFER(symbolAsyncDispose.Reset());
// KJ_DEFER(opaqueTemplate.Reset());

// // Make sure the TypeWrapper is destroyed under lock by declaring a new copy of the variable
// // that is destroyed before the lock is released.
// auto typeWrapperInstanceInner = kj::mv(typeWrapperInstance);

// // Destroy all wrappers.
// heapTracer.clearWrappers();
// });
// }

void IsolateBase::fatalError(const char* location, const char* message) {
reportV8FatalError(location, message);
Expand Down
Loading

0 comments on commit 0ef2816

Please sign in to comment.