Commit 21aedeb4 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Add local IsReadOnlyHeapObject helper

... and remove a related, unused function.

Bug: v8:7790
Change-Id: I803f4b747220a1722e096ef77fcc6c8a9e18fe1a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002534Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65805}
parent f9ad515a
...@@ -118,6 +118,15 @@ class AllowHeapAllocationIf { ...@@ -118,6 +118,15 @@ class AllowHeapAllocationIf {
base::Optional<AllowHeapAllocation> maybe_allow_handle_; base::Optional<AllowHeapAllocation> maybe_allow_handle_;
}; };
namespace {
bool IsReadOnlyHeapObject(Object object) {
DisallowHeapAllocation no_gc;
return (object.IsCode() && Code::cast(object).is_builtin()) ||
(object.IsHeapObject() &&
ReadOnlyHeap::Contains(HeapObject::cast(object)));
}
} // namespace
class ObjectData : public ZoneObject { class ObjectData : public ZoneObject {
public: public:
ObjectData(JSHeapBroker* broker, ObjectData** storage, Handle<Object> object, ObjectData(JSHeapBroker* broker, ObjectData** storage, Handle<Object> object,
...@@ -142,8 +151,7 @@ class ObjectData : public ZoneObject { ...@@ -142,8 +151,7 @@ class ObjectData : public ZoneObject {
broker->mode() == JSHeapBroker::kSerializing, broker->mode() == JSHeapBroker::kSerializing,
broker->isolate()->handle_scope_data()->canonical_scope != nullptr); broker->isolate()->handle_scope_data()->canonical_scope != nullptr);
CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized, CHECK_IMPLIES(broker->mode() == JSHeapBroker::kSerialized,
(broker->is_builtin_code(*object) || IsReadOnlyHeapObject(*object));
ReadOnlyHeap::Contains(HeapObject::cast(*object))));
} }
#define DECLARE_IS_AND_AS(Name) \ #define DECLARE_IS_AND_AS(Name) \
...@@ -2483,16 +2491,6 @@ void JSHeapBroker::SetTargetNativeContextRef( ...@@ -2483,16 +2491,6 @@ void JSHeapBroker::SetTargetNativeContextRef(
target_native_context_ = NativeContextRef(this, native_context); target_native_context_ = NativeContextRef(this, native_context);
} }
bool IsShareable(Handle<Object> object, Isolate* isolate) {
int index;
RootIndex root_index;
bool is_builtin_handle =
object->IsHeapObject() && isolate->builtins()->IsBuiltinHandle(
Handle<HeapObject>::cast(object), &index);
return is_builtin_handle ||
isolate->roots_table().IsRootHandle(object, &root_index);
}
void JSHeapBroker::CollectArrayAndObjectPrototypes() { void JSHeapBroker::CollectArrayAndObjectPrototypes() {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
CHECK_EQ(mode(), kSerializing); CHECK_EQ(mode(), kSerializing);
...@@ -2634,10 +2632,6 @@ void JSHeapBroker::InitializeAndStartSerializing( ...@@ -2634,10 +2632,6 @@ void JSHeapBroker::InitializeAndStartSerializing(
TRACE(this, "Finished serializing standard objects"); TRACE(this, "Finished serializing standard objects");
} }
bool JSHeapBroker::is_builtin_code(Object object) {
return (object.IsCode() && Code::cast(object).is_builtin());
}
// clang-format off // clang-format off
ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) { ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) {
RefsMap::Entry* entry = refs_->LookupOrInsert(object.address(), zone()); RefsMap::Entry* entry = refs_->LookupOrInsert(object.address(), zone());
...@@ -2647,10 +2641,7 @@ ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) { ...@@ -2647,10 +2641,7 @@ ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) {
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
if (object->IsSmi()) { if (object->IsSmi()) {
new (zone()) ObjectData(this, data_storage, object, kSmi); new (zone()) ObjectData(this, data_storage, object, kSmi);
} else if (is_builtin_code(*object)) { } else if (IsReadOnlyHeapObject(*object)) {
new (zone()) ObjectData(this, data_storage, object,
kUnserializedReadOnlyHeapObject);
} else if (ReadOnlyHeap::Contains(HeapObject::cast(*object))) {
new (zone()) ObjectData(this, data_storage, object, new (zone()) ObjectData(this, data_storage, object,
kUnserializedReadOnlyHeapObject); kUnserializedReadOnlyHeapObject);
#define CREATE_DATA_IF_MATCH(name) \ #define CREATE_DATA_IF_MATCH(name) \
......
...@@ -231,8 +231,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -231,8 +231,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
PerIsolateCompilerCache* compiler_cache() const { return compiler_cache_; } PerIsolateCompilerCache* compiler_cache() const { return compiler_cache_; }
bool is_builtin_code(Object object);
Isolate* const isolate_; Isolate* const isolate_;
Zone* const zone_ = nullptr; Zone* const zone_ = nullptr;
base::Optional<NativeContextRef> target_native_context_; base::Optional<NativeContextRef> target_native_context_;
......
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