Protect the emptiness of Array prototype elements with a PropertyCell.
[platform/upstream/v8.git] / src / compilation-dependencies.h
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
3 // found in the LICENSE file.
4
5 #ifndef V8_DEPENDENCIES_H_
6 #define V8_DEPENDENCIES_H_
7
8 namespace v8 {
9 namespace internal {
10
11 // Collects dependencies for this compilation, e.g. assumptions about
12 // stable maps, constant globals, etc.
13 class CompilationDependencies {
14  public:
15   CompilationDependencies(Isolate* isolate, Zone* zone)
16       : isolate_(isolate),
17         zone_(zone),
18         object_wrapper_(Handle<Foreign>::null()),
19         aborted_(false) {
20     std::fill_n(groups_, DependentCode::kGroupCount, nullptr);
21   }
22
23   void Insert(DependentCode::DependencyGroup group, Handle<HeapObject> handle);
24
25   void AssumeInitialMapCantChange(Handle<Map> map) {
26     Insert(DependentCode::kInitialMapChangedGroup, map);
27   }
28   void AssumeFieldType(Handle<Map> map) {
29     Insert(DependentCode::kFieldTypeGroup, map);
30   }
31   void AssumePropertyCell(Handle<PropertyCell> cell) {
32     Insert(DependentCode::kPropertyCellChangedGroup, cell);
33   }
34   void AssumeTenuringDecision(Handle<AllocationSite> site) {
35     Insert(DependentCode::kAllocationSiteTenuringChangedGroup, site);
36   }
37   void AssumeTransitionStable(Handle<AllocationSite> site);
38
39   void Commit(Handle<Code> code);
40   void Rollback();
41   void Abort() { aborted_ = true; }
42   bool HasAborted() const { return aborted_; }
43
44   bool IsEmpty() const {
45     for (int i = 0; i < DependentCode::kGroupCount; i++) {
46       if (groups_[i]) return false;
47     }
48     return true;
49   }
50
51  private:
52   Isolate* isolate_;
53   Zone* zone_;
54   Handle<Foreign> object_wrapper_;
55   bool aborted_;
56   ZoneList<Handle<HeapObject> >* groups_[DependentCode::kGroupCount];
57
58   DependentCode* Get(Handle<Object> object);
59   void Set(Handle<Object> object, Handle<DependentCode> dep);
60 };
61 }
62 }  // namespace v8::internal
63
64 #endif  // V8_DEPENDENCIES_H_