Commit 565bf130 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[heap] Address left-over comments on CL

Bug: v8:8557
Change-Id: If6e70c30c0553f8742980590875c4892535e5863
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559749Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60741}
parent f7e95058
......@@ -2553,6 +2553,7 @@ bool JSObject::IsUnmodifiedApiObject(FullObjectSlot o) {
if (!maybe_constructor->IsJSFunction()) return false;
JSFunction constructor = JSFunction::cast(maybe_constructor);
if (js_object->elements()->length() != 0) return false;
// Check that the object is not a key in a WeakMap (over-approximation).
if (!js_object->GetIdentityHash()->IsUndefined()) return false;
return constructor->initial_map() == heap_object->map();
......
......@@ -312,14 +312,19 @@ TEST(WeakHandleToUnmodifiedJSApiObjectDiesOnScavenge) {
TEST(WeakHandleToJSApiObjectWithIdentityHashSurvivesScavenge) {
CcTest::InitializeVM();
Isolate* i_isolate = CcTest::i_isolate();
HandleScope scope(i_isolate);
Handle<JSWeakMap> weakmap = i_isolate->factory()->NewJSWeakMap();
WeakHandleTest(
CcTest::isolate(), &ConstructJSApiObject,
[](FlagAndPersistent* fp) {
[&weakmap, i_isolate](FlagAndPersistent* fp) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Object> handle =
v8::Local<v8::Object>::New(CcTest::isolate(), fp->handle);
handle->GetIdentityHash();
handle.Clear();
Handle<JSReceiver> key =
Utils::OpenHandle(*fp->handle.Get(CcTest::isolate()));
Handle<Smi> smi(Smi::FromInt(23), i_isolate);
int32_t hash = key->GetOrCreateHash(i_isolate)->value();
JSWeakCollection::Set(weakmap, key, smi, hash);
},
[]() { InvokeScavenge(); }, SurvivalMode::kSurvives);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment