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

Side by Side 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, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 12084 matching lines...) Expand 10 before | Expand all | Expand 10 after
12095 12095
12096 12096
12097 Script::Iterator::Iterator(Isolate* isolate) 12097 Script::Iterator::Iterator(Isolate* isolate)
12098 : iterator_(isolate->heap()->script_list()) {} 12098 : iterator_(isolate->heap()->script_list()) {}
12099 12099
12100 12100
12101 Script* Script::Iterator::Next() { return iterator_.Next<Script>(); } 12101 Script* Script::Iterator::Next() { return iterator_.Next<Script>(); }
12102 12102
12103 12103
12104 SharedFunctionInfo::Iterator::Iterator(Isolate* isolate) 12104 SharedFunctionInfo::Iterator::Iterator(Isolate* isolate)
12105 : script_iterator_(isolate), sfi_iterator_(NULL) { 12105 : script_iterator_(isolate),
12106 NextScript(); 12106 sfi_iterator_(isolate->heap()->noscript_shared_function_infos()) {}
12107 }
12108 12107
12109 12108
12110 bool SharedFunctionInfo::Iterator::NextScript() { 12109 bool SharedFunctionInfo::Iterator::NextScript() {
12111 Script* script = script_iterator_.Next(); 12110 Script* script = script_iterator_.Next();
12112 if (script == NULL) return false; 12111 if (script == NULL) return false;
12113 sfi_iterator_.Reset(script->shared_function_infos()); 12112 sfi_iterator_.Reset(script->shared_function_infos());
12114 return true; 12113 return true;
12115 } 12114 }
12116 12115
12117 12116
12118 SharedFunctionInfo* SharedFunctionInfo::Iterator::Next() { 12117 SharedFunctionInfo* SharedFunctionInfo::Iterator::Next() {
12119 do { 12118 do {
12120 SharedFunctionInfo* next = sfi_iterator_.Next<SharedFunctionInfo>(); 12119 SharedFunctionInfo* next = sfi_iterator_.Next<SharedFunctionInfo>();
12121 if (next != NULL) return next; 12120 if (next != NULL) return next;
12122 } while (NextScript()); 12121 } while (NextScript());
12123 return NULL; 12122 return NULL;
12124 } 12123 }
12125 12124
12126 12125
12127 void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, 12126 void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
12128 Handle<Object> script_object) { 12127 Handle<Object> script_object) {
12129 if (shared->script() == *script_object) return; 12128 if (shared->script() == *script_object) return;
12129 Isolate* isolate = shared->GetIsolate();
12130
12131 // Add shared function info to new script's list. If a collection occurs,
12132 // the shared function info may be temporarily in two lists.
12133 // This is okay because the gc-time processing of these lists can tolerate
12134 // duplicates.
12135 Handle<Object> list;
12136 if (script_object->IsScript()) {
12137 Handle<Script> script = Handle<Script>::cast(script_object);
12138 list = handle(script->shared_function_infos(), isolate);
12139 } else {
12140 list = isolate->factory()->noscript_shared_function_infos();
12141 }
12142
12143 #ifdef DEBUG
12144 {
12145 WeakFixedArray::Iterator iterator(*list);
12146 SharedFunctionInfo* next;
12147 while ((next = iterator.Next<SharedFunctionInfo>())) {
12148 DCHECK_NE(next, *shared);
12149 }
12150 }
12151 #endif // DEBUG
12152 list = WeakFixedArray::Add(list, shared);
12153
12154 if (script_object->IsScript()) {
12155 Handle<Script> script = Handle<Script>::cast(script_object);
12156 script->set_shared_function_infos(*list);
12157 } else {
12158 isolate->heap()->SetRootNoScriptSharedFunctionInfos(*list);
12159 }
12160
12130 // Remove shared function info from old script's list. 12161 // Remove shared function info from old script's list.
12131 if (shared->script()->IsScript()) { 12162 if (shared->script()->IsScript()) {
12132 Script* old_script = Script::cast(shared->script()); 12163 Script* old_script = Script::cast(shared->script());
12133 if (old_script->shared_function_infos()->IsWeakFixedArray()) { 12164 if (old_script->shared_function_infos()->IsWeakFixedArray()) {
12134 WeakFixedArray* list = 12165 WeakFixedArray* list =
12135 WeakFixedArray::cast(old_script->shared_function_infos()); 12166 WeakFixedArray::cast(old_script->shared_function_infos());
12136 list->Remove(shared); 12167 list->Remove(shared);
12137 } 12168 }
12169 } else {
12170 // Remove shared function info from root array.
12171 Object* list = isolate->heap()->noscript_shared_function_infos();
12172 CHECK(WeakFixedArray::cast(list)->Remove(shared));
12138 } 12173 }
12139 // Add shared function info to new script's list. 12174
12140 if (script_object->IsScript()) {
12141 Handle<Script> script = Handle<Script>::cast(script_object);
12142 Handle<Object> list(script->shared_function_infos(), shared->GetIsolate());
12143 #ifdef DEBUG
12144 {
12145 WeakFixedArray::Iterator iterator(*list);
12146 SharedFunctionInfo* next;
12147 while ((next = iterator.Next<SharedFunctionInfo>())) {
12148 DCHECK_NE(next, *shared);
12149 }
12150 }
12151 #endif // DEBUG
12152 list = WeakFixedArray::Add(list, shared);
12153 script->set_shared_function_infos(*list);
12154 }
12155 // Finally set new script. 12175 // Finally set new script.
12156 shared->set_script(*script_object); 12176 shared->set_script(*script_object);
12157 } 12177 }
12158 12178
12159 12179
12160 String* SharedFunctionInfo::DebugName() { 12180 String* SharedFunctionInfo::DebugName() {
12161 Object* n = name(); 12181 Object* n = name();
12162 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name(); 12182 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name();
12163 return String::cast(n); 12183 return String::cast(n);
12164 } 12184 }
(...skipping 5730 matching lines...) Expand 10 before | Expand all | Expand 10 after
17895 if (cell->value() != *new_value) { 17915 if (cell->value() != *new_value) {
17896 cell->set_value(*new_value); 17916 cell->set_value(*new_value);
17897 Isolate* isolate = cell->GetIsolate(); 17917 Isolate* isolate = cell->GetIsolate();
17898 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17918 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17899 isolate, DependentCode::kPropertyCellChangedGroup); 17919 isolate, DependentCode::kPropertyCellChangedGroup);
17900 } 17920 }
17901 } 17921 }
17902 17922
17903 } // namespace internal 17923 } // namespace internal
17904 } // namespace v8 17924 } // namespace v8
OLDNEW
« 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