Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e1887d2

Browse filesBrowse files
jasnellRafaelGSS
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 f185e8a commit e1887d2
Copy full SHA for e1887d2

File tree

Expand file treeCollapse file tree

3 files changed

+15
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+15
-8
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_util.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_util.h
+3-2Lines 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

Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+2-5Lines 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) {
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,16 @@ 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 should be kept on the stack. Here, the entries
407+
// in this object grows and shrinks with the C stack, and entries
408+
// will be in the right handle scopes, but v8::Locals are supposed
409+
// to remain on the stack and not the heap. For general purposes
410+
// this *should* be ok but may need to be looked at further should
411+
// v8 become stricter in the future about v8::Locals being held in
412+
// the stack.
413+
v8::LocalVector<v8::Object> native_execution_async_resources_;
405414

406415
// Non-empty during deserialization
407416
const SerializeInfo* info_ = nullptr;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.