Skip to content

Commit a9de0b9

Browse files
committed
src: use LocalVector in more places
1 parent 01554f3 commit a9de0b9

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/crypto/crypto_util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ void ThrowCryptoError(Environment* env,
547547

548548
class CipherPushContext {
549549
public:
550-
inline explicit CipherPushContext(Environment* env) : env_(env) {}
550+
inline explicit CipherPushContext(Environment* env)
551+
: list_(env->isolate()), env_(env) {}
551552

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

560561
private:
561-
std::vector<v8::Local<v8::Value>> list_;
562+
v8::LocalVector<v8::Value> list_;
562563
Environment* env_;
563564
};
564565

src/env.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,7 @@ bool AsyncHooks::pop_async_context(double async_id) {
176176
}
177177
#endif
178178
native_execution_async_resources_.resize(offset);
179-
if (native_execution_async_resources_.size() <
180-
native_execution_async_resources_.capacity() / 2 &&
181-
native_execution_async_resources_.size() > 16) {
182-
native_execution_async_resources_.shrink_to_fit();
183-
}
179+
native_execution_async_resources_.shrink_to_fit();
184180
}
185181

186182
if (js_execution_async_resources()->Length() > offset) [[unlikely]] {
@@ -1694,6 +1690,7 @@ AsyncHooks::AsyncHooks(Isolate* isolate, const SerializeInfo* info)
16941690
fields_(isolate, kFieldsCount, MAYBE_FIELD_PTR(info, fields)),
16951691
async_id_fields_(
16961692
isolate, kUidFieldsCount, MAYBE_FIELD_PTR(info, async_id_fields)),
1693+
native_execution_async_resources_(isolate),
16971694
info_(info) {
16981695
HandleScope handle_scope(isolate);
16991696
if (info == nullptr) {

src/env.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "aliased_buffer.h"
2828
#if HAVE_INSPECTOR
29-
#include "inspector_agent.h"
29+
#include "inspector_agent.h"f
3030
#include "inspector_profiler.h"
3131
#endif
3232
#include "callback_queue.h"
@@ -401,7 +401,13 @@ class AsyncHooks : public MemoryRetainer {
401401
void grow_async_ids_stack();
402402

403403
v8::Global<v8::Array> js_execution_async_resources_;
404-
std::vector<v8::Local<v8::Object>> native_execution_async_resources_;
404+
405+
// TODO(@jasnell): Note that this is technically illegal use of
406+
// v8::Locals, which aren't supposed to live beyond the handle
407+
// scope in which they were created. This should likely be a
408+
// std::vector<v8::Global<v8::Object>> but that's possibly a
409+
// larger change that should be made separately.
410+
v8::LocalVector<v8::Object> native_execution_async_resources_;
405411

406412
// Non-empty during deserialization
407413
const SerializeInfo* info_ = nullptr;

0 commit comments

Comments
 (0)