Content-Length: 362797 | pFad | https://github.com/nodejs/node/commit/48493e9fd5

1B src: use LocalVector in more places · nodejs/node@48493e9 · GitHub
Skip to content

Commit 48493e9

Browse files
jasnelladuh95
authored andcommitted
src: use LocalVector in more places
PR-URL: #56457 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 2c6124c commit 48493e9

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
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]] {
@@ -1705,6 +1701,7 @@ AsyncHooks::AsyncHooks(Isolate* isolate, const SerializeInfo* info)
17051701
fields_(isolate, kFieldsCount, MAYBE_FIELD_PTR(info, fields)),
17061702
async_id_fields_(
17071703
isolate, kUidFieldsCount, MAYBE_FIELD_PTR(info, async_id_fields)),
1704+
native_execution_async_resources_(isolate),
17081705
info_(info) {
17091706
HandleScope handle_scope(isolate);
17101707
if (info == nullptr) {

src/env.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,16 @@ class AsyncHooks : public MemoryRetainer {
405405
void grow_async_ids_stack();
406406

407407
v8::Global<v8::Array> js_execution_async_resources_;
408-
std::vector<v8::Local<v8::Object>> native_execution_async_resources_;
408+
409+
// TODO(@jasnell): Note that this is technically illegal use of
410+
// v8::Locals which should be kept on the stack. Here, the entries
411+
// in this object grows and shrinks with the C stack, and entries
412+
// will be in the right handle scopes, but v8::Locals are supposed
413+
// to remain on the stack and not the heap. For general purposes
414+
// this *should* be ok but may need to be looked at further should
415+
// v8 become stricter in the future about v8::Locals being held in
416+
// the stack.
417+
v8::LocalVector<v8::Object> native_execution_async_resources_;
409418

410419
// Non-empty during deserialization
411420
const SerializeInfo* info_ = nullptr;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/nodejs/node/commit/48493e9fd5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy