GeezerVison is showing github.com — deps: V8: cherry-pick 0fd478bcdabd · nodejs/node@8da9d96
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: common.gypi +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 36 | 36 |
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | 39 | | - 'v8_embedder_string': '-node.17', | | 39 | + 'v8_embedder_string': '-node.18', | 40 | 40 |
| 41 | 41 | ##### V8 defaults for Node.js ##### | 42 | 42 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/include/v8-profiler.h +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -921,12 +921,22 @@ class V8_EXPORT EmbedderGraph { | 921 | 921 | virtual ~EmbedderGraph() = default; | 922 | 922 | }; | 923 | 923 |
| | 924 | +class QueryObjectPredicate { | | 925 | + public: | | 926 | + virtual ~QueryObjectPredicate() = default; | | 927 | + virtual bool Filter(v8::Local<v8::Object> object) = 0; | | 928 | +}; | | 929 | + | 924 | 930 | /** | 925 | 931 | * Interface for controlling heap profiling. Instance of the | 926 | 932 | * profiler can be retrieved using v8::Isolate::GetHeapProfiler. | 927 | 933 | */ | 928 | 934 | class V8_EXPORT HeapProfiler { | 929 | 935 | public: | | 936 | + void QueryObjects(v8::Local<v8::Context> context, | | 937 | + QueryObjectPredicate* predicate, | | 938 | + std::vector<v8::Global<v8::Object>>* objects); | | 939 | + | 930 | 940 | enum SamplingFlags { | 931 | 941 | kSamplingNoFlags = 0, | 932 | 942 | kSamplingForceGC = 1 << 0, | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/api/api.cc +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10917,6 +10917,16 @@ int HeapProfiler::GetSnapshotCount() { | 10917 | 10917 | return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); | 10918 | 10918 | } | 10919 | 10919 |
| | 10920 | +void HeapProfiler::QueryObjects(Local<Context> v8_context, | | 10921 | + QueryObjectPredicate* predicate, | | 10922 | + std::vector<Global<Object>>* objects) { | | 10923 | + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_context->GetIsolate()); | | 10924 | + i::HeapProfiler* profiler = reinterpret_cast<i::HeapProfiler*>(this); | | 10925 | + DCHECK_EQ(isolate, profiler->isolate()); | | 10926 | + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | | 10927 | + profiler->QueryObjects(Utils::OpenHandle(*v8_context), predicate, objects); | | 10928 | +} | | 10929 | + | 10920 | 10930 | const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) { | 10921 | 10931 | return reinterpret_cast<const HeapSnapshot*>( | 10922 | 10932 | reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index)); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/debug/debug-interface.cc -9Lines changed: 0 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1211,15 +1211,6 @@ v8::MaybeLocal<v8::Value> EvaluateGlobalForTesting( | 1211 | 1211 | RETURN_ESCAPED(result); | 1212 | 1212 | } | 1213 | 1213 |
| 1214 | | -void QueryObjects(v8::Local<v8::Context> v8_context, | 1215 | | - QueryObjectPredicate* predicate, | 1216 | | - std::vector<v8::Global<v8::Object>>* objects) { | 1217 | | - i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_context->GetIsolate()); | 1218 | | - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | 1219 | | - isolate->heap_profiler()->QueryObjects(Utils::OpenHandle(*v8_context), | 1220 | | - predicate, objects); | 1221 | | -} | 1222 | | - | 1223 | 1214 | void GlobalLexicalScopeNames(v8::Local<v8::Context> v8_context, | 1224 | 1215 | std::vector<v8::Global<v8::String>>* names) { | 1225 | 1216 | i::Handle<i::Context> context = Utils::OpenHandle(*v8_context); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/debug/debug-interface.h -10Lines changed: 0 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -530,16 +530,6 @@ class V8_EXPORT_PRIVATE StackTraceIterator { | 530 | 530 | bool throw_on_side_effect) = 0; | 531 | 531 | }; | 532 | 532 |
| 533 | | -class QueryObjectPredicate { | 534 | | - public: | 535 | | - virtual ~QueryObjectPredicate() = default; | 536 | | - virtual bool Filter(v8::Local<v8::Object> object) = 0; | 537 | | -}; | 538 | | - | 539 | | -void QueryObjects(v8::Local<v8::Context> context, | 540 | | - QueryObjectPredicate* predicate, | 541 | | - std::vector<v8::Global<v8::Object>>* objects); | 542 | | - | 543 | 533 | void GlobalLexicalScopeNames(v8::Local<v8::Context> context, | 544 | 534 | std::vector<v8::Global<v8::String>>* names); | 545 | 535 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger.cc +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | #include "include/v8-context.h" | 9 | 9 | #include "include/v8-function.h" | 10 | 10 | #include "include/v8-microtask-queue.h" | | 11 | +#include "include/v8-profiler.h" | 11 | 12 | #include "include/v8-util.h" | 12 | 13 | #include "src/inspector/inspected-context.h" | 13 | 14 | #include "src/inspector/protocol/Protocol.h" | @@ -38,7 +39,7 @@ void cleanupExpiredWeakPointers(Map& map) { | 38 | 39 | } | 39 | 40 | } | 40 | 41 |
| 41 | | -class MatchPrototypePredicate : public v8::debug::QueryObjectPredicate { | | 42 | +class MatchPrototypePredicate : public v8::QueryObjectPredicate { | 42 | 43 | public: | 43 | 44 | MatchPrototypePredicate(V8InspectorImpl* inspector, | 44 | 45 | v8::Local<v8::Context> context, | @@ -994,7 +995,7 @@ v8::Local<v8::Array> V8Debugger::queryObjects(v8::Local<v8::Context> context, | 994 | 995 | v8::Isolate* isolate = context->GetIsolate(); | 995 | 996 | std::vector<v8::Global<v8::Object>> v8_objects; | 996 | 997 | MatchPrototypePredicate predicate(m_inspector, context, prototype); | 997 | | - v8::debug::QueryObjects(context, &predicate, &v8_objects); | | 998 | + isolate->GetHeapProfiler()->QueryObjects(context, &predicate, &v8_objects); | 998 | 999 |
| 999 | 1000 | v8::MicrotasksScope microtasksScope(context, | 1000 | 1001 | v8::MicrotasksScope::kDoNotRunMicrotasks); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/profiler/heap-profiler.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -247,7 +247,7 @@ Heap* HeapProfiler::heap() const { return ids_->heap(); } | 247 | 247 | Isolate* HeapProfiler::isolate() const { return heap()->isolate(); } | 248 | 248 |
| 249 | 249 | void HeapProfiler::QueryObjects(Handle<Context> context, | 250 | | - debug::QueryObjectPredicate* predicate, | | 250 | + v8::QueryObjectPredicate* predicate, | 251 | 251 | std::vector<v8::Global<v8::Object>>* objects) { | 252 | 252 | // We need a stack marker here to allow deterministic passes over the stack. | 253 | 253 | // The garbage collection and the two object heap iterators should scan the | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/profiler/heap-profiler.h +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,7 +30,7 @@ class StringsStorage; | 30 | 30 | // generate consistent IDs for moved objects. | 31 | 31 | class HeapProfilerNativeMoveListener { | 32 | 32 | public: | 33 | | - HeapProfilerNativeMoveListener(HeapProfiler* profiler) | | 33 | + explicit HeapProfilerNativeMoveListener(HeapProfiler* profiler) | 34 | 34 | : profiler_(profiler) {} | 35 | 35 | HeapProfilerNativeMoveListener(const HeapProfilerNativeMoveListener& other) = | 36 | 36 | delete; | @@ -116,8 +116,7 @@ class HeapProfiler : public HeapObjectAllocationTracker { | 116 | 116 |
| 117 | 117 | Isolate* isolate() const; | 118 | 118 |
| 119 | | - void QueryObjects(Handle<Context> context, | 120 | | - debug::QueryObjectPredicate* predicate, | | 119 | + void QueryObjects(Handle<Context> context, QueryObjectPredicate* predicate, | 121 | 120 | std::vector<v8::Global<v8::Object>>* objects); | 122 | 121 | void set_native_move_listener( | 123 | 122 | std::unique_ptr<HeapProfilerNativeMoveListener> listener) { | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-heap-profiler.cc +62Lines changed: 62 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | #include <ctype.h> | 31 | 31 |
| 32 | 32 | #include <memory> | | 33 | +#include <vector> | 33 | 34 |
| 34 | 35 | #include "include/v8-function.h" | 35 | 36 | #include "include/v8-json.h" | @@ -4064,6 +4065,67 @@ TEST(SamplingHeapProfilerSampleDuringDeopt) { | 4064 | 4065 | heap_profiler->StopSamplingHeapProfiler(); | 4065 | 4066 | } | 4066 | 4067 |
| | 4068 | +namespace { | | 4069 | +class TestQueryObjectPredicate : public v8::QueryObjectPredicate { | | 4070 | + public: | | 4071 | + TestQueryObjectPredicate(v8::Local<v8::Context> context, | | 4072 | + v8::Local<v8::Symbol> symbol) | | 4073 | + : context_(context), symbol_(symbol) {} | | 4074 | + | | 4075 | + bool Filter(v8::Local<v8::Object> object) override { | | 4076 | + return object->HasOwnProperty(context_, symbol_).FromMaybe(false); | | 4077 | + } | | 4078 | + | | 4079 | + private: | | 4080 | + v8::Local<v8::Context> context_; | | 4081 | + v8::Local<v8::Symbol> symbol_; | | 4082 | +}; | | 4083 | + | | 4084 | +class IncludeAllQueryObjectPredicate : public v8::QueryObjectPredicate { | | 4085 | + public: | | 4086 | + IncludeAllQueryObjectPredicate() {} | | 4087 | + bool Filter(v8::Local<v8::Object> object) override { return true; } | | 4088 | +}; | | 4089 | +} // anonymous namespace | | 4090 | + | | 4091 | +TEST(QueryObjects) { | | 4092 | + LocalContext env; | | 4093 | + v8::Isolate* isolate = env->GetIsolate(); | | 4094 | + v8::HandleScope scope(isolate); | | 4095 | + v8::Local<v8::Context> context = env.local(); | | 4096 | + | | 4097 | + v8::Local<v8::Symbol> sym = | | 4098 | + v8::Symbol::New(isolate, v8_str("query_object_test")); | | 4099 | + context->Global()->Set(context, v8_str("test_symbol"), sym).Check(); | | 4100 | + v8::Local<v8::Value> arr = CompileRun(R"( | | 4101 | + const arr = []; | | 4102 | + for (let i = 0; i < 10; ++i) { | | 4103 | + arr.push({[test_symbol]: true}); | | 4104 | + } | | 4105 | + arr; | | 4106 | + )"); | | 4107 | + context->Global()->Set(context, v8_str("arr"), arr).Check(); | | 4108 | + v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); | | 4109 | + | | 4110 | + { | | 4111 | + TestQueryObjectPredicate predicate(context, sym); | | 4112 | + std::vector<v8::Global<v8::Object>> out; | | 4113 | + heap_profiler->QueryObjects(context, &predicate, &out); | | 4114 | + | | 4115 | + CHECK_EQ(out.size(), 10); | | 4116 | + for (size_t i = 0; i < out.size(); ++i) { | | 4117 | + CHECK(out[i].Get(isolate)->HasOwnProperty(context, sym).FromMaybe(false)); | | 4118 | + } | | 4119 | + } | | 4120 | + | | 4121 | + { | | 4122 | + IncludeAllQueryObjectPredicate predicate; | | 4123 | + std::vector<v8::Global<v8::Object>> out; | | 4124 | + heap_profiler->QueryObjects(context, &predicate, &out); | | 4125 | + CHECK_GE(out.size(), 10); | | 4126 | + } | | 4127 | +} | | 4128 | + | 4067 | 4129 | TEST(WeakReference) { | 4068 | 4130 | v8::Isolate* isolate = CcTest::isolate(); | 4069 | 4131 | i::Isolate* i_isolate = CcTest::i_isolate(); | |
|