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.
5 #ifndef V8_DEPENDENCIES_H_
6 #define V8_DEPENDENCIES_H_
11 // Collects dependencies for this compilation, e.g. assumptions about
12 // stable maps, constant globals, etc.
13 class CompilationDependencies {
15 CompilationDependencies(Isolate* isolate, Zone* zone)
18 object_wrapper_(Handle<Foreign>::null()),
20 std::fill_n(groups_, DependentCode::kGroupCount, nullptr);
23 void Insert(DependentCode::DependencyGroup group, Handle<HeapObject> handle);
25 void AssumeInitialMapCantChange(Handle<Map> map) {
26 Insert(DependentCode::kInitialMapChangedGroup, map);
28 void AssumeElementsCantBeAdded(Handle<Map> map) {
29 Insert(DependentCode::kElementsCantBeAddedGroup, map);
31 void AssumeFieldType(Handle<Map> map) {
32 Insert(DependentCode::kFieldTypeGroup, map);
34 void AssumePropertyCell(Handle<PropertyCell> cell) {
35 Insert(DependentCode::kPropertyCellChangedGroup, cell);
37 void AssumeTenuringDecision(Handle<AllocationSite> site) {
38 Insert(DependentCode::kAllocationSiteTenuringChangedGroup, site);
40 void AssumeTransitionStable(Handle<AllocationSite> site);
42 void Commit(Handle<Code> code);
44 void Abort() { aborted_ = true; }
45 bool HasAborted() const { return aborted_; }
47 bool IsEmpty() const {
48 for (int i = 0; i < DependentCode::kGroupCount; i++) {
49 if (groups_[i]) return false;
57 Handle<Foreign> object_wrapper_;
59 ZoneList<Handle<HeapObject> >* groups_[DependentCode::kGroupCount];
61 DependentCode* Get(Handle<Object> object);
62 void Set(Handle<Object> object, Handle<DependentCode> dep);
65 } // namespace v8::internal
67 #endif // V8_DEPENDENCIES_H_