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