OLD | NEW |
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 12024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12035 | 12035 |
12036 | 12036 |
12037 Script::Iterator::Iterator(Isolate* isolate) | 12037 Script::Iterator::Iterator(Isolate* isolate) |
12038 : iterator_(isolate->heap()->script_list()) {} | 12038 : iterator_(isolate->heap()->script_list()) {} |
12039 | 12039 |
12040 | 12040 |
12041 Script* Script::Iterator::Next() { return iterator_.Next<Script>(); } | 12041 Script* Script::Iterator::Next() { return iterator_.Next<Script>(); } |
12042 | 12042 |
12043 | 12043 |
12044 SharedFunctionInfo::Iterator::Iterator(Isolate* isolate) | 12044 SharedFunctionInfo::Iterator::Iterator(Isolate* isolate) |
12045 : script_iterator_(isolate), sfi_iterator_(NULL) { | 12045 : script_iterator_(isolate), |
12046 NextScript(); | 12046 sfi_iterator_(isolate->heap()->noscript_shared_function_infos()) {} |
12047 } | |
12048 | 12047 |
12049 | 12048 |
12050 bool SharedFunctionInfo::Iterator::NextScript() { | 12049 bool SharedFunctionInfo::Iterator::NextScript() { |
12051 Script* script = script_iterator_.Next(); | 12050 Script* script = script_iterator_.Next(); |
12052 if (script == NULL) return false; | 12051 if (script == NULL) return false; |
12053 sfi_iterator_.Reset(script->shared_function_infos()); | 12052 sfi_iterator_.Reset(script->shared_function_infos()); |
12054 return true; | 12053 return true; |
12055 } | 12054 } |
12056 | 12055 |
12057 | 12056 |
12058 SharedFunctionInfo* SharedFunctionInfo::Iterator::Next() { | 12057 SharedFunctionInfo* SharedFunctionInfo::Iterator::Next() { |
12059 do { | 12058 do { |
12060 SharedFunctionInfo* next = sfi_iterator_.Next<SharedFunctionInfo>(); | 12059 SharedFunctionInfo* next = sfi_iterator_.Next<SharedFunctionInfo>(); |
12061 if (next != NULL) return next; | 12060 if (next != NULL) return next; |
12062 } while (NextScript()); | 12061 } while (NextScript()); |
12063 return NULL; | 12062 return NULL; |
12064 } | 12063 } |
12065 | 12064 |
12066 | 12065 |
12067 void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, | 12066 void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, |
12068 Handle<Object> script_object) { | 12067 Handle<Object> script_object) { |
12069 if (shared->script() == *script_object) return; | 12068 if (shared->script() == *script_object) return; |
| 12069 Isolate* isolate = shared->GetIsolate(); |
| 12070 |
| 12071 // Add shared function info to new script's list. If a collection occurs, |
| 12072 // the shared function info may be temporarily in two lists. |
| 12073 // This is okay because the gc-time processing of these lists can tolerate |
| 12074 // duplicates. |
| 12075 Handle<Object> list; |
| 12076 if (script_object->IsScript()) { |
| 12077 Handle<Script> script = Handle<Script>::cast(script_object); |
| 12078 list = handle(script->shared_function_infos(), isolate); |
| 12079 } else { |
| 12080 list = isolate->factory()->noscript_shared_function_infos(); |
| 12081 } |
| 12082 |
| 12083 #ifdef DEBUG |
| 12084 { |
| 12085 WeakFixedArray::Iterator iterator(*list); |
| 12086 SharedFunctionInfo* next; |
| 12087 while ((next = iterator.Next<SharedFunctionInfo>())) { |
| 12088 DCHECK_NE(next, *shared); |
| 12089 } |
| 12090 } |
| 12091 #endif // DEBUG |
| 12092 list = WeakFixedArray::Add(list, shared); |
| 12093 |
| 12094 if (script_object->IsScript()) { |
| 12095 Handle<Script> script = Handle<Script>::cast(script_object); |
| 12096 script->set_shared_function_infos(*list); |
| 12097 } else { |
| 12098 isolate->heap()->UpdateNoScriptSharedFunctionInfos(*list); |
| 12099 } |
| 12100 |
12070 // Remove shared function info from old script's list. | 12101 // Remove shared function info from old script's list. |
12071 if (shared->script()->IsScript()) { | 12102 if (shared->script()->IsScript()) { |
12072 Script* old_script = Script::cast(shared->script()); | 12103 Script* old_script = Script::cast(shared->script()); |
12073 if (old_script->shared_function_infos()->IsWeakFixedArray()) { | 12104 if (old_script->shared_function_infos()->IsWeakFixedArray()) { |
12074 WeakFixedArray* list = | 12105 WeakFixedArray* list = |
12075 WeakFixedArray::cast(old_script->shared_function_infos()); | 12106 WeakFixedArray::cast(old_script->shared_function_infos()); |
12076 list->Remove(shared); | 12107 list->Remove(shared); |
12077 } | 12108 } |
| 12109 } else { |
| 12110 // Remove shared function info from root array. |
| 12111 Object* list = isolate->heap()->noscript_shared_function_infos(); |
| 12112 CHECK(WeakFixedArray::cast(list)->Remove(shared)); |
12078 } | 12113 } |
12079 // Add shared function info to new script's list. | 12114 |
12080 if (script_object->IsScript()) { | |
12081 Handle<Script> script = Handle<Script>::cast(script_object); | |
12082 Handle<Object> list(script->shared_function_infos(), shared->GetIsolate()); | |
12083 #ifdef DEBUG | |
12084 { | |
12085 WeakFixedArray::Iterator iterator(*list); | |
12086 SharedFunctionInfo* next; | |
12087 while ((next = iterator.Next<SharedFunctionInfo>())) { | |
12088 DCHECK_NE(next, *shared); | |
12089 } | |
12090 } | |
12091 #endif // DEBUG | |
12092 list = WeakFixedArray::Add(list, shared); | |
12093 script->set_shared_function_infos(*list); | |
12094 } | |
12095 // Finally set new script. | 12115 // Finally set new script. |
12096 shared->set_script(*script_object); | 12116 shared->set_script(*script_object); |
12097 } | 12117 } |
12098 | 12118 |
12099 | 12119 |
12100 String* SharedFunctionInfo::DebugName() { | 12120 String* SharedFunctionInfo::DebugName() { |
12101 Object* n = name(); | 12121 Object* n = name(); |
12102 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name(); | 12122 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name(); |
12103 return String::cast(n); | 12123 return String::cast(n); |
12104 } | 12124 } |
(...skipping 5727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17832 if (cell->value() != *new_value) { | 17852 if (cell->value() != *new_value) { |
17833 cell->set_value(*new_value); | 17853 cell->set_value(*new_value); |
17834 Isolate* isolate = cell->GetIsolate(); | 17854 Isolate* isolate = cell->GetIsolate(); |
17835 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17855 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17836 isolate, DependentCode::kPropertyCellChangedGroup); | 17856 isolate, DependentCode::kPropertyCellChangedGroup); |
17837 } | 17857 } |
17838 } | 17858 } |
17839 | 17859 |
17840 } // namespace internal | 17860 } // namespace internal |
17841 } // namespace v8 | 17861 } // namespace v8 |
OLD | NEW |