Commit 35391e43 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Refactor JSFunction body descriptor.

Since code flushing is gone, we treat the code entry as a strong field.

Change-Id: Idfcaf6fbfd84f7e4435b81d30a2a0e1be71ec89d
Reviewed-on: https://chromium-review.googlesource.com/531285
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45894}
parent 28810a2a
......@@ -5031,7 +5031,7 @@ void Heap::IterateAndScavengePromotedObject(HeapObject* target, int size) {
if (target->IsJSFunction()) {
// JSFunctions reachable through kNextFunctionLinkOffset are weak. Slots for
// this links are recorded during processing of weak lists.
JSFunction::BodyDescriptorWeakCode::IterateBody(target, size, &visitor);
JSFunction::BodyDescriptorWeak::IterateBody(target, size, &visitor);
} else {
target->IterateBody(target->map()->instance_type(), size, &visitor);
}
......
......@@ -2231,13 +2231,17 @@ class YoungGenerationMarkingVisitor final
}
}
void VisitCodeEntry(JSFunction* host, Address code_entry) final {
// Code is not in new space.
}
// Special cases for young generation. Also see StaticNewSpaceVisitor.
int VisitJSFunction(Map* map, JSFunction* object) final {
if (!ShouldVisit(object)) return 0;
int size = JSFunction::BodyDescriptorWeakCode::SizeOf(map, object);
int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object);
VisitMapPointer(object, object->map_slot());
JSFunction::BodyDescriptorWeakCode::IterateBody(object, size, this);
JSFunction::BodyDescriptorWeak::IterateBody(object, size, this);
return size;
}
......
......@@ -78,7 +78,7 @@ void StaticNewSpaceVisitor<StaticVisitor>::Initialize() {
// Don't visit code entry. We are using this visitor only during scavenges.
table_.Register(
kVisitJSFunction,
&FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode,
&FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeak,
int>::Visit);
table_.Register(
......@@ -440,7 +440,7 @@ void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo(
template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction(Map* map,
HeapObject* object) {
FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorStrongCode,
FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeak,
void>::Visit(map, object);
}
......
......@@ -174,12 +174,9 @@ class StaticNewSpaceVisitor : public StaticVisitorBase {
}
}
// Although we are using the JSFunction body descriptor which does not
// visit the code entry, compiler wants it to be accessible.
// See JSFunction::BodyDescriptorImpl.
inline static void VisitCodeEntry(Heap* heap, HeapObject* object,
Address entry_address) {
UNREACHABLE();
// Code is not in new space.
}
private:
......
......@@ -174,13 +174,8 @@ class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase {
static inline void IterateBody(HeapObject* obj, int object_size,
ObjectVisitor* v) {
IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v);
if (body_visiting_policy & kVisitCodeEntry) {
v->VisitCodeEntry(JSFunction::cast(obj),
obj->address() + kCodeEntryOffset);
}
if (body_visiting_policy & kVisitNextFunction) {
v->VisitCodeEntry(JSFunction::cast(obj), obj->address() + kCodeEntryOffset);
if (body_visiting_policy == kIgnoreWeakness) {
IteratePointers(obj, kNextFunctionLinkOffset, kSize, v);
}
IterateBodyImpl(obj, kSize, object_size, v);
......@@ -192,12 +187,9 @@ class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase {
IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset,
kNonWeakFieldsEndOffset);
if (body_visiting_policy & kVisitCodeEntry) {
StaticVisitor::VisitCodeEntry(heap, obj,
obj->address() + kCodeEntryOffset);
}
StaticVisitor::VisitCodeEntry(heap, obj, obj->address() + kCodeEntryOffset);
if (body_visiting_policy & kVisitNextFunction) {
if (body_visiting_policy == kIgnoreWeakness) {
IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize);
}
IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size);
......
......@@ -5150,26 +5150,13 @@ class JSFunction: public JSObject {
int requested_in_object_properties,
int* instance_size,
int* in_object_properties);
// Visiting policy flags define whether the code entry or next function
// should be visited or not.
enum BodyVisitingPolicy {
kVisitCodeEntry = 1 << 0,
kVisitNextFunction = 1 << 1,
kSkipCodeEntryAndNextFunction = 0,
kVisitCodeEntryAndNextFunction = kVisitCodeEntry | kVisitNextFunction
};
enum BodyVisitingPolicy { kIgnoreWeakness, kRespectWeakness };
// Iterates the function object according to the visiting policy.
template <BodyVisitingPolicy>
class BodyDescriptorImpl;
// Visit the whole object.
typedef BodyDescriptorImpl<kVisitCodeEntryAndNextFunction> BodyDescriptor;
// Don't visit next function.
typedef BodyDescriptorImpl<kVisitCodeEntry> BodyDescriptorStrongCode;
typedef BodyDescriptorImpl<kSkipCodeEntryAndNextFunction>
BodyDescriptorWeakCode;
typedef BodyDescriptorImpl<kIgnoreWeakness> BodyDescriptor;
typedef BodyDescriptorImpl<kRespectWeakness> BodyDescriptorWeak;
// Dispatched behavior.
DECLARE_PRINTER(JSFunction)
......
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