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

Side by Side Diff: src/lithium-codegen.cc

Issue 866723002: Treat pointers in optimized code as strong before all weak dependencies are registered. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix check Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/lithium.cc ('k') | src/mips/lithium-codegen-mips.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/lithium-codegen.h" 5 #include "src/lithium-codegen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 int LCodeGenBase::GetNextEmittedBlock() const { 164 int LCodeGenBase::GetNextEmittedBlock() const {
165 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { 165 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
166 if (!graph()->blocks()->at(i)->IsReachable()) continue; 166 if (!graph()->blocks()->at(i)->IsReachable()) continue;
167 if (!chunk_->GetLabel(i)->HasReplacement()) return i; 167 if (!chunk_->GetLabel(i)->HasReplacement()) return i;
168 } 168 }
169 return -1; 169 return -1;
170 } 170 }
171 171
172 172
173 static void AddWeakObjectToCodeDependency(Isolate* isolate,
174 Handle<Object> object,
175 Handle<Code> code) {
176 Heap* heap = isolate->heap();
177 heap->EnsureWeakObjectToCodeTable();
178 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object));
179 dep = DependentCode::Insert(dep, DependentCode::kWeakCodeGroup, code);
180 heap->AddWeakObjectToCodeDependency(object, dep);
181 }
182
183
184 void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
185 DCHECK(code->is_optimized_code());
186 ZoneList<Handle<Map> > maps(1, zone());
187 ZoneList<Handle<JSObject> > objects(1, zone());
188 ZoneList<Handle<Cell> > cells(1, zone());
189 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
190 RelocInfo::ModeMask(RelocInfo::CELL);
191 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
192 RelocInfo::Mode mode = it.rinfo()->rmode();
193 if (mode == RelocInfo::CELL &&
194 code->IsWeakObjectInOptimizedCode(it.rinfo()->target_cell())) {
195 Handle<Cell> cell(it.rinfo()->target_cell());
196 cells.Add(cell, zone());
197 } else if (mode == RelocInfo::EMBEDDED_OBJECT &&
198 code->IsWeakObjectInOptimizedCode(it.rinfo()->target_object())) {
199 if (it.rinfo()->target_object()->IsMap()) {
200 Handle<Map> map(Map::cast(it.rinfo()->target_object()));
201 maps.Add(map, zone());
202 } else if (it.rinfo()->target_object()->IsJSObject()) {
203 Handle<JSObject> object(JSObject::cast(it.rinfo()->target_object()));
204 objects.Add(object, zone());
205 } else if (it.rinfo()->target_object()->IsCell()) {
206 Handle<Cell> cell(Cell::cast(it.rinfo()->target_object()));
207 cells.Add(cell, zone());
208 }
209 }
210 }
211 if (FLAG_enable_ool_constant_pool) {
212 code->constant_pool()->set_weak_object_state(
213 ConstantPoolArray::WEAK_OBJECTS_IN_OPTIMIZED_CODE);
214 }
215 #ifdef VERIFY_HEAP
216 // This disables verification of weak embedded objects after full GC.
217 // AddDependentCode can cause a GC, which would observe the state where
218 // this code is not yet in the depended code lists of the embedded maps.
219 NoWeakObjectVerificationScope disable_verification_of_embedded_objects;
220 #endif
221 for (int i = 0; i < maps.length(); i++) {
222 Map::AddDependentCode(maps.at(i), DependentCode::kWeakCodeGroup, code);
223 }
224 for (int i = 0; i < objects.length(); i++) {
225 AddWeakObjectToCodeDependency(isolate(), objects.at(i), code);
226 }
227 for (int i = 0; i < cells.length(); i++) {
228 AddWeakObjectToCodeDependency(isolate(), cells.at(i), code);
229 }
230 }
231
232
233 void LCodeGenBase::Abort(BailoutReason reason) { 173 void LCodeGenBase::Abort(BailoutReason reason) {
234 info()->AbortOptimization(reason); 174 info()->AbortOptimization(reason);
235 status_ = ABORTED; 175 status_ = ABORTED;
236 } 176 }
237 177
238 178
239 void LCodeGenBase::Retry(BailoutReason reason) { 179 void LCodeGenBase::Retry(BailoutReason reason) {
240 info()->RetryOptimization(reason); 180 info()->RetryOptimization(reason);
241 status_ = ABORTED; 181 status_ = ABORTED;
242 } 182 }
243 183
244 184
245 void LCodeGenBase::AddDeprecationDependency(Handle<Map> map) { 185 void LCodeGenBase::AddDeprecationDependency(Handle<Map> map) {
246 if (map->is_deprecated()) return Retry(kMapBecameDeprecated); 186 if (map->is_deprecated()) return Retry(kMapBecameDeprecated);
247 chunk_->AddDeprecationDependency(map); 187 chunk_->AddDeprecationDependency(map);
248 } 188 }
249 189
250 190
251 void LCodeGenBase::AddStabilityDependency(Handle<Map> map) { 191 void LCodeGenBase::AddStabilityDependency(Handle<Map> map) {
252 if (!map->is_stable()) return Retry(kMapBecameUnstable); 192 if (!map->is_stable()) return Retry(kMapBecameUnstable);
253 chunk_->AddStabilityDependency(map); 193 chunk_->AddStabilityDependency(map);
254 } 194 }
255 195
256 } } // namespace v8::internal 196 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium.cc ('k') | src/mips/lithium-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698