Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: src/objects.cc

Issue 1410223007: Add non-script SharedFunctionInfos to the Iterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 0c317eb386b859fa379d78717c610093e9367119..a75dfc1e8413ba6ed079ecf7b51cfe187bcb811f 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12102,9 +12102,8 @@ Script* Script::Iterator::Next() { return iterator_.Next<Script>(); }
SharedFunctionInfo::Iterator::Iterator(Isolate* isolate)
- : script_iterator_(isolate), sfi_iterator_(NULL) {
- NextScript();
-}
+ : script_iterator_(isolate),
+ sfi_iterator_(isolate->heap()->noscript_shared_function_infos()) {}
bool SharedFunctionInfo::Iterator::NextScript() {
@@ -12127,6 +12126,38 @@ SharedFunctionInfo* SharedFunctionInfo::Iterator::Next() {
void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
Handle<Object> script_object) {
if (shared->script() == *script_object) return;
+ Isolate* isolate = shared->GetIsolate();
+
+ // Add shared function info to new script's list. If a collection occurs,
+ // the shared function info may be temporarily in two lists.
+ // This is okay because the gc-time processing of these lists can tolerate
+ // duplicates.
+ Handle<Object> list;
+ if (script_object->IsScript()) {
+ Handle<Script> script = Handle<Script>::cast(script_object);
+ list = handle(script->shared_function_infos(), isolate);
+ } else {
+ list = isolate->factory()->noscript_shared_function_infos();
+ }
+
+#ifdef DEBUG
+ {
+ WeakFixedArray::Iterator iterator(*list);
+ SharedFunctionInfo* next;
+ while ((next = iterator.Next<SharedFunctionInfo>())) {
+ DCHECK_NE(next, *shared);
+ }
+ }
+#endif // DEBUG
+ list = WeakFixedArray::Add(list, shared);
+
+ if (script_object->IsScript()) {
+ Handle<Script> script = Handle<Script>::cast(script_object);
+ script->set_shared_function_infos(*list);
+ } else {
+ isolate->heap()->SetRootNoScriptSharedFunctionInfos(*list);
+ }
+
// Remove shared function info from old script's list.
if (shared->script()->IsScript()) {
Script* old_script = Script::cast(shared->script());
@@ -12135,23 +12166,12 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
WeakFixedArray::cast(old_script->shared_function_infos());
list->Remove(shared);
}
+ } else {
+ // Remove shared function info from root array.
+ Object* list = isolate->heap()->noscript_shared_function_infos();
+ CHECK(WeakFixedArray::cast(list)->Remove(shared));
}
- // Add shared function info to new script's list.
- if (script_object->IsScript()) {
- Handle<Script> script = Handle<Script>::cast(script_object);
- Handle<Object> list(script->shared_function_infos(), shared->GetIsolate());
-#ifdef DEBUG
- {
- WeakFixedArray::Iterator iterator(*list);
- SharedFunctionInfo* next;
- while ((next = iterator.Next<SharedFunctionInfo>())) {
- DCHECK_NE(next, *shared);
- }
- }
-#endif // DEBUG
- list = WeakFixedArray::Add(list, shared);
- script->set_shared_function_infos(*list);
- }
+
// Finally set new script.
shared->set_script(*script_object);
}
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698