OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 extension_ = NULL; | 100 extension_ = NULL; |
101 pre_parse_data_ = NULL; | 101 pre_parse_data_ = NULL; |
102 zone_ = zone; | 102 zone_ = zone; |
103 deferred_handles_ = NULL; | 103 deferred_handles_ = NULL; |
104 code_stub_ = NULL; | 104 code_stub_ = NULL; |
105 prologue_offset_ = kPrologueOffsetNotSet; | 105 prologue_offset_ = kPrologueOffsetNotSet; |
106 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 106 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
107 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 107 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
108 ? new List<OffsetRange>(2) : NULL; | 108 ? new List<OffsetRange>(2) : NULL; |
109 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 109 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
110 dependent_maps_[i] = NULL; | 110 dependencies_[i] = NULL; |
111 } | 111 } |
112 if (mode == STUB) { | 112 if (mode == STUB) { |
113 mode_ = STUB; | 113 mode_ = STUB; |
114 return; | 114 return; |
115 } | 115 } |
116 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 116 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
117 if (script_->type()->value() == Script::TYPE_NATIVE) { | 117 if (script_->type()->value() == Script::TYPE_NATIVE) { |
118 MarkAsNative(); | 118 MarkAsNative(); |
119 } | 119 } |
120 if (!shared_info_.is_null()) { | 120 if (!shared_info_.is_null()) { |
121 ASSERT(language_mode() == CLASSIC_MODE); | 121 ASSERT(language_mode() == CLASSIC_MODE); |
122 SetLanguageMode(shared_info_->language_mode()); | 122 SetLanguageMode(shared_info_->language_mode()); |
123 } | 123 } |
124 set_bailout_reason("unknown"); | 124 set_bailout_reason("unknown"); |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 CompilationInfo::~CompilationInfo() { | 128 CompilationInfo::~CompilationInfo() { |
129 delete deferred_handles_; | 129 delete deferred_handles_; |
130 delete no_frame_ranges_; | 130 delete no_frame_ranges_; |
131 #ifdef DEBUG | 131 #ifdef DEBUG |
132 // Check that no dependent maps have been added or added dependent maps have | 132 // Check that no dependent maps have been added or added dependent maps have |
133 // been rolled back or committed. | 133 // been rolled back or committed. |
134 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 134 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
135 ASSERT_EQ(NULL, dependent_maps_[i]); | 135 ASSERT_EQ(NULL, dependencies_[i]); |
136 } | 136 } |
137 #endif // DEBUG | 137 #endif // DEBUG |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 void CompilationInfo::CommitDependentMaps(Handle<Code> code) { | 141 void CompilationInfo::CommitDependencies(Handle<Code> code) { |
142 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 142 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
143 ZoneList<Handle<Map> >* group_maps = dependent_maps_[i]; | 143 ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i]; |
144 if (group_maps == NULL) continue; | 144 if (group_objects == NULL) continue; |
145 ASSERT(!object_wrapper_.is_null()); | 145 ASSERT(!object_wrapper_.is_null()); |
146 for (int j = 0; j < group_maps->length(); j++) { | 146 for (int j = 0; j < group_objects->length(); j++) { |
147 group_maps->at(j)->dependent_code()->UpdateToFinishedCode( | 147 DependentCode::DependencyGroup group = |
148 static_cast<DependentCode::DependencyGroup>(i), this, *code); | 148 static_cast<DependentCode::DependencyGroup>(i); |
| 149 DependentCode* dependent_code = |
| 150 DependentCode::ForObject(group_objects->at(j), group); |
| 151 dependent_code->UpdateToFinishedCode(group, this, *code); |
149 } | 152 } |
150 dependent_maps_[i] = NULL; // Zone-allocated, no need to delete. | 153 dependencies_[i] = NULL; // Zone-allocated, no need to delete. |
151 } | 154 } |
152 } | 155 } |
153 | 156 |
154 | 157 |
155 void CompilationInfo::RollbackDependentMaps() { | 158 void CompilationInfo::RollbackDependencies() { |
156 // Unregister from all dependent maps if not yet committed. | 159 // Unregister from all dependent maps if not yet committed. |
157 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 160 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
158 ZoneList<Handle<Map> >* group_maps = dependent_maps_[i]; | 161 ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i]; |
159 if (group_maps == NULL) continue; | 162 if (group_objects == NULL) continue; |
160 for (int j = 0; j < group_maps->length(); j++) { | 163 for (int j = 0; j < group_objects->length(); j++) { |
161 group_maps->at(j)->dependent_code()->RemoveCompilationInfo( | 164 DependentCode::DependencyGroup group = |
162 static_cast<DependentCode::DependencyGroup>(i), this); | 165 static_cast<DependentCode::DependencyGroup>(i); |
| 166 DependentCode* dependent_code = |
| 167 DependentCode::ForObject(group_objects->at(j), group); |
| 168 dependent_code->RemoveCompilationInfo(group, this); |
163 } | 169 } |
164 dependent_maps_[i] = NULL; // Zone-allocated, no need to delete. | 170 dependencies_[i] = NULL; // Zone-allocated, no need to delete. |
165 } | 171 } |
166 } | 172 } |
167 | 173 |
168 | 174 |
169 int CompilationInfo::num_parameters() const { | 175 int CompilationInfo::num_parameters() const { |
170 ASSERT(!IsStub()); | 176 ASSERT(!IsStub()); |
171 return scope()->num_parameters(); | 177 return scope()->num_parameters(); |
172 } | 178 } |
173 | 179 |
174 | 180 |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 return; | 1036 return; |
1031 } | 1037 } |
1032 | 1038 |
1033 Isolate* isolate = info->isolate(); | 1039 Isolate* isolate = info->isolate(); |
1034 VMState<COMPILER> state(isolate); | 1040 VMState<COMPILER> state(isolate); |
1035 Logger::TimerEventScope timer( | 1041 Logger::TimerEventScope timer( |
1036 isolate, Logger::TimerEventScope::v8_recompile_synchronous); | 1042 isolate, Logger::TimerEventScope::v8_recompile_synchronous); |
1037 // If crankshaft succeeded, install the optimized code else install | 1043 // If crankshaft succeeded, install the optimized code else install |
1038 // the unoptimized code. | 1044 // the unoptimized code. |
1039 OptimizingCompiler::Status status = optimizing_compiler->last_status(); | 1045 OptimizingCompiler::Status status = optimizing_compiler->last_status(); |
1040 if (info->HasAbortedDueToDependentMap()) { | 1046 if (info->HasAbortedDueToDependencyChange()) { |
1041 info->set_bailout_reason("bailed out due to dependent map"); | 1047 info->set_bailout_reason("bailed out due to dependent map"); |
1042 status = optimizing_compiler->AbortOptimization(); | 1048 status = optimizing_compiler->AbortOptimization(); |
1043 } else if (status != OptimizingCompiler::SUCCEEDED) { | 1049 } else if (status != OptimizingCompiler::SUCCEEDED) { |
1044 info->set_bailout_reason("failed/bailed out last time"); | 1050 info->set_bailout_reason("failed/bailed out last time"); |
1045 status = optimizing_compiler->AbortOptimization(); | 1051 status = optimizing_compiler->AbortOptimization(); |
1046 } else { | 1052 } else { |
1047 status = optimizing_compiler->GenerateAndInstallCode(); | 1053 status = optimizing_compiler->GenerateAndInstallCode(); |
1048 ASSERT(status == OptimizingCompiler::SUCCEEDED || | 1054 ASSERT(status == OptimizingCompiler::SUCCEEDED || |
1049 status == OptimizingCompiler::BAILED_OUT); | 1055 status == OptimizingCompiler::BAILED_OUT); |
1050 } | 1056 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 } | 1206 } |
1201 } | 1207 } |
1202 | 1208 |
1203 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1209 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1204 Handle<Script>(info->script()), | 1210 Handle<Script>(info->script()), |
1205 Handle<Code>(info->code()), | 1211 Handle<Code>(info->code()), |
1206 info)); | 1212 info)); |
1207 } | 1213 } |
1208 | 1214 |
1209 } } // namespace v8::internal | 1215 } } // namespace v8::internal |
OLD | NEW |