cppgc-js: Set stack start

Set stack start as otherwise TracedReference from stack would not be
kept alive.

Bug: chromium:1220744, chromium:1056170
Change-Id: I99d54ac44b3f7cb4aa9732eb9260b918193a68e2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2972728
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75249}
This commit is contained in:
Michael Lippautz 2021-06-18 14:43:14 +02:00 committed by V8 LUCI CQ
parent 35931e83bd
commit 3a01e05d3b
2 changed files with 18 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "include/v8.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/execution/isolate-inl.h"
#include "src/flags/flags.h"
@ -323,6 +324,7 @@ void CppHeap::AttachIsolate(Isolate* isolate) {
isolate_->heap()->local_embedder_heap_tracer()->SetWrapperDescriptor(
wrapper_descriptor_);
SetMetricRecorder(std::make_unique<MetricRecorderAdapter>(*this));
SetStackStart(base::Stack::GetStackStart());
no_gc_scope_--;
}

View File

@ -132,6 +132,22 @@ TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) {
wrappable->wrapper()->GetAlignedPointerFromInternalField(1));
}
TEST_F(UnifiedHeapTest, TracedReferenceRetainsFromStack) {
v8::HandleScope scope(v8_isolate());
v8::Local<v8::Context> context = v8::Context::New(v8_isolate());
v8::Context::Scope context_scope(context);
TracedReference<v8::Object> holder;
{
v8::HandleScope scope(v8_isolate());
auto local = v8::Object::New(v8_isolate());
EXPECT_TRUE(local->IsObject());
holder.Reset(v8_isolate(), local);
}
CollectGarbageWithEmbedderStack(cppgc::Heap::SweepingType::kAtomic);
auto local = holder.Get(v8_isolate());
EXPECT_TRUE(local->IsObject());
}
TEST_F(UnifiedHeapDetachedTest, AllocationBeforeConfigureHeap) {
auto heap = v8::CppHeap::Create(
V8::GetCurrentPlatform(),