Skip to content
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

src: use LocalVector in more places #56457

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/crypto/crypto_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ void ThrowCryptoError(Environment* env,

class CipherPushContext {
public:
inline explicit CipherPushContext(Environment* env) : env_(env) {}
inline explicit CipherPushContext(Environment* env)
: list_(env->isolate()), env_(env) {}

inline void push_back(const char* str) {
list_.emplace_back(OneByteString(env_->isolate(), str));
Expand All @@ -558,7 +559,7 @@ class CipherPushContext {
}

private:
std::vector<v8::Local<v8::Value>> list_;
v8::LocalVector<v8::Value> list_;
Environment* env_;
};

Expand Down
7 changes: 2 additions & 5 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ bool AsyncHooks::pop_async_context(double async_id) {
}
#endif
native_execution_async_resources_.resize(offset);
if (native_execution_async_resources_.size() <
native_execution_async_resources_.capacity() / 2 &&
native_execution_async_resources_.size() > 16) {
native_execution_async_resources_.shrink_to_fit();
}
native_execution_async_resources_.shrink_to_fit();
}

if (js_execution_async_resources()->Length() > offset) [[unlikely]] {
Expand Down Expand Up @@ -1694,6 +1690,7 @@ AsyncHooks::AsyncHooks(Isolate* isolate, const SerializeInfo* info)
fields_(isolate, kFieldsCount, MAYBE_FIELD_PTR(info, fields)),
async_id_fields_(
isolate, kUidFieldsCount, MAYBE_FIELD_PTR(info, async_id_fields)),
native_execution_async_resources_(isolate),
info_(info) {
HandleScope handle_scope(isolate);
if (info == nullptr) {
Expand Down
10 changes: 8 additions & 2 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "aliased_buffer.h"
#if HAVE_INSPECTOR
#include "inspector_agent.h"
#include "inspector_agent.h"f
jasnell marked this conversation as resolved.
Show resolved Hide resolved
#include "inspector_profiler.h"
#endif
#include "callback_queue.h"
Expand Down Expand Up @@ -401,7 +401,13 @@ class AsyncHooks : public MemoryRetainer {
void grow_async_ids_stack();

v8::Global<v8::Array> js_execution_async_resources_;
std::vector<v8::Local<v8::Object>> native_execution_async_resources_;

// TODO(@jasnell): Note that this is technically illegal use of
// v8::Locals, which aren't supposed to live beyond the handle
// scope in which they were created. This should likely be a
jasnell marked this conversation as resolved.
Show resolved Hide resolved
// std::vector<v8::Global<v8::Object>> but that's possibly a
// larger change that should be made separately.
jasnell marked this conversation as resolved.
Show resolved Hide resolved
v8::LocalVector<v8::Object> native_execution_async_resources_;

// Non-empty during deserialization
const SerializeInfo* info_ = nullptr;
Expand Down
Loading