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

Side by Side Diff: src/compiler/escape-analysis.cc

Issue 2694723002: [turbofan] attempt to fix OOM caused by escape analysis (Closed)
Patch Set: fixed mistake Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/escape-analysis.h" 5 #include "src/compiler/escape-analysis.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/flags.h" 9 #include "src/base/flags.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 changed = true; 246 changed = true;
247 fields_[i] = other.fields_[i]; 247 fields_[i] = other.fields_[i];
248 } 248 }
249 } 249 }
250 return changed; 250 return changed;
251 } 251 }
252 252
253 class VirtualState : public ZoneObject { 253 class VirtualState : public ZoneObject {
254 public: 254 public:
255 VirtualState(Node* owner, Zone* zone, size_t size) 255 VirtualState(Node* owner, Zone* zone, size_t size)
256 : info_(size, nullptr, zone), owner_(owner) {} 256 : info_(size, nullptr, zone),
257 initialized_(static_cast<int>(size), zone),
258 owner_(owner) {}
257 259
258 VirtualState(Node* owner, const VirtualState& state) 260 VirtualState(Node* owner, const VirtualState& state)
259 : info_(state.info_.size(), nullptr, state.info_.get_allocator().zone()), 261 : info_(state.info_.size(), nullptr, state.info_.get_allocator().zone()),
262 initialized_(state.initialized_.length(),
263 state.info_.get_allocator().zone()),
260 owner_(owner) { 264 owner_(owner) {
261 for (size_t i = 0; i < info_.size(); ++i) { 265 for (size_t i = 0; i < info_.size(); ++i) {
262 if (state.info_[i]) { 266 if (state.info_[i]) {
263 info_[i] = state.info_[i]; 267 info_[i] = state.info_[i];
264 } 268 }
265 } 269 }
266 } 270 }
267 271
268 VirtualObject* VirtualObjectFromAlias(size_t alias); 272 VirtualObject* VirtualObjectFromAlias(size_t alias);
269 void SetVirtualObject(Alias alias, VirtualObject* state); 273 void SetVirtualObject(Alias alias, VirtualObject* state);
270 bool UpdateFrom(VirtualState* state, Zone* zone); 274 bool UpdateFrom(VirtualState* state, Zone* zone);
271 bool MergeFrom(MergeCache* cache, Zone* zone, Graph* graph, 275 bool MergeFrom(MergeCache* cache, Zone* zone, Graph* graph,
272 CommonOperatorBuilder* common, Node* at); 276 CommonOperatorBuilder* common, Node* at);
273 size_t size() const { return info_.size(); } 277 size_t size() const { return info_.size(); }
274 Node* owner() const { return owner_; } 278 Node* owner() const { return owner_; }
275 VirtualObject* Copy(VirtualObject* obj, Alias alias); 279 VirtualObject* Copy(VirtualObject* obj, Alias alias);
276 void SetCopyRequired() { 280 void SetCopyRequired() {
277 for (VirtualObject* obj : info_) { 281 for (VirtualObject* obj : info_) {
278 if (obj) obj->SetCopyRequired(); 282 if (obj) obj->SetCopyRequired();
279 } 283 }
280 } 284 }
281 285
282 private: 286 private:
283 ZoneVector<VirtualObject*> info_; 287 ZoneVector<VirtualObject*> info_;
288 BitVector initialized_;
284 Node* owner_; 289 Node* owner_;
285 290
286 DISALLOW_COPY_AND_ASSIGN(VirtualState); 291 DISALLOW_COPY_AND_ASSIGN(VirtualState);
287 }; 292 };
288 293
289 class MergeCache : public ZoneObject { 294 class MergeCache : public ZoneObject {
290 public: 295 public:
291 explicit MergeCache(Zone* zone) 296 explicit MergeCache(Zone* zone)
292 : states_(zone), objects_(zone), fields_(zone) { 297 : states_(zone), objects_(zone), fields_(zone) {
293 states_.reserve(5); 298 states_.reserve(5);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 info_[alias] = new_obj; 374 info_[alias] = new_obj;
370 return new_obj; 375 return new_obj;
371 } 376 }
372 377
373 VirtualObject* VirtualState::VirtualObjectFromAlias(size_t alias) { 378 VirtualObject* VirtualState::VirtualObjectFromAlias(size_t alias) {
374 return info_[alias]; 379 return info_[alias];
375 } 380 }
376 381
377 void VirtualState::SetVirtualObject(Alias alias, VirtualObject* obj) { 382 void VirtualState::SetVirtualObject(Alias alias, VirtualObject* obj) {
378 info_[alias] = obj; 383 info_[alias] = obj;
384 if (obj) initialized_.Add(alias);
379 } 385 }
380 386
381 bool VirtualState::UpdateFrom(VirtualState* from, Zone* zone) { 387 bool VirtualState::UpdateFrom(VirtualState* from, Zone* zone) {
382 if (from == this) return false; 388 if (from == this) return false;
383 bool changed = false; 389 bool changed = false;
384 for (Alias alias = 0; alias < size(); ++alias) { 390 for (Alias alias = 0; alias < size(); ++alias) {
385 VirtualObject* ls = VirtualObjectFromAlias(alias); 391 VirtualObject* ls = VirtualObjectFromAlias(alias);
386 VirtualObject* rs = from->VirtualObjectFromAlias(alias); 392 VirtualObject* rs = from->VirtualObjectFromAlias(alias);
387 393
388 if (ls == rs || rs == nullptr) continue; 394 if (ls == rs || rs == nullptr) continue;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 size_t fields = std::numeric_limits<size_t>::max(); 527 size_t fields = std::numeric_limits<size_t>::max();
522 for (VirtualState* state : cache->states()) { 528 for (VirtualState* state : cache->states()) {
523 if (VirtualObject* obj = state->VirtualObjectFromAlias(alias)) { 529 if (VirtualObject* obj = state->VirtualObjectFromAlias(alias)) {
524 cache->objects().push_back(obj); 530 cache->objects().push_back(obj);
525 if (mergeObject == obj) { 531 if (mergeObject == obj) {
526 copy_merge_object = true; 532 copy_merge_object = true;
527 } 533 }
528 fields = std::min(obj->field_count(), fields); 534 fields = std::min(obj->field_count(), fields);
529 } 535 }
530 } 536 }
531 if (cache->objects().size() == cache->states().size()) { 537 if (cache->objects().size() == cache->states().size() &&
538 (mergeObject || !initialized_.Contains(alias))) {
532 bool initialMerge = false; 539 bool initialMerge = false;
533 if (!mergeObject) { 540 if (!mergeObject) {
534 initialMerge = true; 541 initialMerge = true;
535 VirtualObject* obj = new (zone) 542 VirtualObject* obj = new (zone)
536 VirtualObject(cache->objects().front()->id(), this, zone, fields, 543 VirtualObject(cache->objects().front()->id(), this, zone, fields,
537 cache->objects().front()->IsInitialized()); 544 cache->objects().front()->IsInitialized());
538 SetVirtualObject(alias, obj); 545 SetVirtualObject(alias, obj);
539 mergeObject = obj; 546 mergeObject = obj;
540 changed = true; 547 changed = true;
541 } else if (copy_merge_object) { 548 } else if (copy_merge_object) {
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 } 1736 }
1730 } 1737 }
1731 return false; 1738 return false;
1732 } 1739 }
1733 1740
1734 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); } 1741 Graph* EscapeAnalysis::graph() const { return status_analysis_->graph(); }
1735 1742
1736 } // namespace compiler 1743 } // namespace compiler
1737 } // namespace internal 1744 } // namespace internal
1738 } // namespace v8 1745 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698