Commit 8fcf7cb0 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[compiler] Test kWeakRef to kFullTransitionArray insertions

If we insert a second SIMPLE_PROPERTY_ARRAY we move from kWeakRef
encoding to kFullTransitionArray encoding. As always, we are searching
in the meantime in a background thread.

Bug: v8:7790
Change-Id: I5e3d85657dda4c199e50b9c35e7f617f1821a8f0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2243218Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68980}
parent 2d428a61
......@@ -153,6 +153,68 @@ TEST(FullFieldTransitions) {
thread->Join();
}
// Search and insert on the main thread which changes the encoding from kWeakRef
// to kFullTransitionArray, while the background thread searches at the same
// time.
TEST(WeakRefToFullFieldTransitions) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate();
Handle<String> name1 = CcTest::MakeString("name1");
Handle<String> name2 = CcTest::MakeString("name2");
const PropertyAttributes attributes = NONE;
const PropertyKind kind = kData;
// Set map0 to be a simple transition array with transition 'name1' to map1.
Handle<Map> map0 = Map::Create(isolate, 0);
Handle<Map> map1 =
Map::CopyWithField(isolate, map0, name1, FieldType::Any(isolate),
attributes, PropertyConstness::kMutable,
Representation::Tagged(), OMIT_TRANSITION)
.ToHandleChecked();
Handle<Map> map2 =
Map::CopyWithField(isolate, map0, name2, FieldType::Any(isolate),
attributes, PropertyConstness::kMutable,
Representation::Tagged(), OMIT_TRANSITION)
.ToHandleChecked();
TransitionsAccessor(isolate, map0)
.Insert(name1, map1, SIMPLE_PROPERTY_TRANSITION);
{
TestTransitionsAccessor transitions(isolate, map0);
CHECK(transitions.IsWeakRefEncoding());
}
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
Handle<Name> persistent_name = ph->NewHandle(name1);
Handle<Map> persistent_map = ph->NewHandle(map0);
Handle<Map> persistent_result_map = ph->NewHandle(map1);
base::Semaphore sema_started(0);
// Pass persistent handles to background thread.
std::unique_ptr<ConcurrentSearchThread> thread(new ConcurrentSearchThread(
isolate->heap(), &sema_started, std::move(ph), persistent_name,
persistent_map, persistent_result_map));
CHECK(thread->Start());
sema_started.Wait();
CHECK_EQ(*map1, TransitionsAccessor(isolate, map0)
.SearchTransition(*name1, kind, attributes));
TransitionsAccessor(isolate, map0)
.Insert(name2, map2, SIMPLE_PROPERTY_TRANSITION);
{
TestTransitionsAccessor transitions(isolate, map0);
CHECK(transitions.IsFullTransitionArrayEncoding());
}
CHECK_EQ(*map2, TransitionsAccessor(isolate, map0)
.SearchTransition(*name2, kind, attributes));
thread->Join();
}
} // anonymous namespace
} // namespace internal
......
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