Commit 8d54fc2e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[heap] Limit friendship of the Heap class to essentials.

This makes it clear that only components within the "heap" directory
should be friends with the Heap class. The two notable exceptions are
Factory and Isolate which represent external interfaces into the heap.

R=mlippautz@chromium.org

Review URL: https://codereview.chromium.org/1320843002

Cr-Commit-Position: refs/heads/master@{#30408}
parent 147330f3
......@@ -344,13 +344,13 @@ bool Bootstrapper::CreateCodeStubContext(Isolate* isolate) {
Handle<Context> native_context = CreateEnvironment(
MaybeHandle<JSGlobalProxy>(), v8::Local<v8::ObjectTemplate>(),
&no_extensions, THIN_CONTEXT);
isolate->heap()->set_code_stub_context(*native_context);
isolate->heap()->SetRootCodeStubContext(*native_context);
isolate->set_context(*native_context);
Handle<JSObject> code_stub_exports =
isolate->factory()->NewJSObject(isolate->object_function());
JSObject::NormalizeProperties(code_stub_exports, CLEAR_INOBJECT_PROPERTIES, 2,
"container to export to extra natives");
isolate->heap()->set_code_stub_exports_object(*code_stub_exports);
isolate->heap()->SetRootCodeStubExportsObject(*code_stub_exports);
return InstallCodeStubNatives(isolate);
}
......@@ -2156,11 +2156,6 @@ bool Genesis::InstallNatives(ContextType context_type) {
script_is_embedder_debug_script, attribs);
script_map->AppendDescriptor(&d);
}
// Allocate the empty script.
Handle<Script> script = factory()->NewScript(factory()->empty_string());
script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
heap()->public_set_empty_script(*script);
}
{
// Builtin function for OpaqueReference -- a JSValue-based object,
......
......@@ -174,7 +174,7 @@ Handle<Code> CodeStub::GetCode() {
Handle<UnseededNumberDictionary>(heap->code_stubs()),
GetKey(),
new_object);
heap->public_set_code_stubs(*dict);
heap->SetRootCodeStubs(*dict);
}
code = *new_object;
}
......
......@@ -2252,7 +2252,7 @@ Handle<FixedArray> MaterializedObjectStore::EnsureStackEntries(int length) {
for (int i = array->length(); i < length; i++) {
new_array->set(i, isolate()->heap()->undefined_value());
}
isolate()->heap()->public_set_materialized_objects(*new_array);
isolate()->heap()->SetRootMaterializedObjects(*new_array);
return new_array;
}
......
......@@ -623,14 +623,6 @@ class Factory final {
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
inline void set_string_table(Handle<StringTable> table) {
isolate()->heap()->set_string_table(*table);
}
inline void set_weak_stack_trace_list(Handle<WeakFixedArray> list) {
isolate()->heap()->set_weak_stack_trace_list(*list);
}
// Allocates a new SharedFunctionInfo object.
Handle<SharedFunctionInfo> NewSharedFunctionInfo(
Handle<String> name, int number_of_literals, FunctionKind kind,
......
......@@ -3310,6 +3310,11 @@ void Heap::CreateInitialObjects() {
// Handling of script id generation is in Factory::NewScript.
set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId));
// Allocate the empty script.
Handle<Script> script = factory->NewScript(factory->empty_string());
script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
set_empty_script(*script);
Handle<PropertyCell> cell = factory->NewPropertyCell();
cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid));
set_array_protector(*cell);
......
......@@ -1215,21 +1215,33 @@ class Heap {
Object** roots_array_start() { return roots_; }
// Sets the stub_cache_ (only used when expanding the dictionary).
void public_set_code_stubs(UnseededNumberDictionary* value) {
void SetRootCodeStubs(UnseededNumberDictionary* value) {
roots_[kCodeStubsRootIndex] = value;
}
// Sets the non_monomorphic_cache_ (only used when expanding the dictionary).
void public_set_non_monomorphic_cache(UnseededNumberDictionary* value) {
void SetRootNonMonomorphicCache(UnseededNumberDictionary* value) {
roots_[kNonMonomorphicCacheRootIndex] = value;
}
void public_set_empty_script(Script* script) {
roots_[kEmptyScriptRootIndex] = script;
void SetRootMaterializedObjects(FixedArray* objects) {
roots_[kMaterializedObjectsRootIndex] = objects;
}
void public_set_materialized_objects(FixedArray* objects) {
roots_[kMaterializedObjectsRootIndex] = objects;
void SetRootCodeStubContext(Object* value) {
roots_[kCodeStubContextRootIndex] = value;
}
void SetRootCodeStubExportsObject(JSObject* value) {
roots_[kCodeStubExportsObjectRootIndex] = value;
}
void SetRootScriptList(Object* value) {
roots_[kScriptListRootIndex] = value;
}
void SetRootStringTable(StringTable* value) {
roots_[kStringTableRootIndex] = value;
}
// Set the stack limit in the roots_ array. Some architectures generate
......@@ -2408,21 +2420,23 @@ class Heap {
StrongRootsList* strong_roots_list_;
// Classes in "heap" can be friends.
friend class AlwaysAllocateScope;
friend class Bootstrapper;
friend class Deserializer;
friend class Factory;
friend class GCCallbacksScope;
friend class GCTracer;
friend class HeapIterator;
friend class IncrementalMarking;
friend class Isolate;
friend class MarkCompactCollector;
friend class MarkCompactMarkingVisitor;
friend class MapCompact;
friend class Page;
friend class StoreBuffer;
// The allocator interface.
friend class Factory;
// The Isolate constructs us.
friend class Isolate;
// Used in cctest.
friend class HeapTester;
......
......@@ -165,7 +165,7 @@ Code* PropertyICCompiler::FindPreMonomorphic(Isolate* isolate, Code::Kind kind,
static void FillCache(Isolate* isolate, Handle<Code> code) {
Handle<UnseededNumberDictionary> dictionary = UnseededNumberDictionary::Set(
isolate->factory()->non_monomorphic_cache(), code->flags(), code);
isolate->heap()->public_set_non_monomorphic_cache(*dictionary);
isolate->heap()->SetRootNonMonomorphicCache(*dictionary);
}
......
......@@ -14111,7 +14111,7 @@ void StringTable::EnsureCapacityForDeserialization(Isolate* isolate,
// We need a key instance for the virtual hash function.
InternalizedStringKey dummy_key(Handle<String>::null());
table = StringTable::EnsureCapacity(table, expected, &dummy_key);
isolate->factory()->set_string_table(table);
isolate->heap()->SetRootStringTable(*table);
}
......@@ -14145,7 +14145,7 @@ Handle<String> StringTable::LookupKey(Isolate* isolate, HashTableKey* key) {
table->set(EntryToIndex(entry), *string);
table->ElementAdded();
isolate->factory()->set_string_table(table);
isolate->heap()->SetRootStringTable(*table);
return Handle<String>::cast(string);
}
......
......@@ -776,7 +776,8 @@ void Deserializer::CommitPostProcessedObjects(Isolate* isolate) {
// Assign a new script id to avoid collision.
script->set_id(isolate_->heap()->NextScriptId());
// Add script to list.
heap->set_script_list(*WeakFixedArray::Add(factory->script_list(), script));
Handle<Object> list = WeakFixedArray::Add(factory->script_list(), script);
heap->SetRootScriptList(*list);
}
}
......
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