Commit b5984e9e authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Simplify IsWeakObjectInOptimizedCode for concurrent marking.

It removes special handling for Cells and PropertyCells. That handling
was required before when new space objects were embedded in code objects
via Cells. Since code objects support direct embedding now, the handling
can be removed.

The patch also makes sure to load the map of the object once using
the synchronized accessor, which will be needed for concurrent visiting
of code object.

Bug: v8:8459
Change-Id: I83833e19ad1da4a92e1a9be60b7c1dcd05c2b2be
Reviewed-on: https://chromium-review.googlesource.com/c/1337745Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57616}
parent 603bab1e
......@@ -591,23 +591,19 @@ bool Code::CanContainWeakObjects() {
return is_optimized_code() && can_have_weak_objects();
}
bool Code::IsWeakObject(Object* object) {
bool Code::IsWeakObject(HeapObject* object) {
return (CanContainWeakObjects() && IsWeakObjectInOptimizedCode(object));
}
bool Code::IsWeakObjectInOptimizedCode(Object* object) {
if (object->IsMap()) {
bool Code::IsWeakObjectInOptimizedCode(HeapObject* object) {
Map map = object->synchronized_map();
InstanceType instance_type = map->instance_type();
if (InstanceTypeChecker::IsMap(instance_type)) {
return Map::cast(object)->CanTransition();
}
if (object->IsCell()) {
object = Cell::cast(object)->value();
} else if (object->IsPropertyCell()) {
object = PropertyCell::cast(object)->value();
}
if (object->IsJSReceiver() || object->IsContext()) {
return true;
}
return false;
return InstanceTypeChecker::IsPropertyCell(instance_type) ||
InstanceTypeChecker::IsJSReceiver(instance_type) ||
InstanceTypeChecker::IsContext(instance_type);
}
INT_ACCESSORS(CodeDataContainer, kind_specific_flags, kKindSpecificFlagsOffset)
......
......@@ -362,9 +362,9 @@ class Code : public HeapObjectPtr {
inline bool CanContainWeakObjects();
inline bool IsWeakObject(Object* object);
inline bool IsWeakObject(HeapObject* object);
static inline bool IsWeakObjectInOptimizedCode(Object* object);
static inline bool IsWeakObjectInOptimizedCode(HeapObject* object);
// Return true if the function is inlined in the code.
bool Inlines(SharedFunctionInfo* sfi);
......
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