Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
compiler_layering_check.LayeringChecker Class Reference
Inheritance diagram for compiler_layering_check.LayeringChecker:

Public Member Functions

def __init__ (self, root)
 
def Check (self)
 
def CheckNotInRuntime (self, files)
 
def BuildIncludesGraph (self)
 
def PropagateLayers (self)
 
def AddAllSourcesToWorklist (self, dir)
 
def ExtractIncludes (self, file)
 

Public Attributes

 root
 
 worklist
 
 included_into
 
 loaded
 
 file_layers
 

Detailed Description

Definition at line 32 of file compiler_layering_check.py.

Constructor & Destructor Documentation

◆ __init__()

def compiler_layering_check.LayeringChecker.__init__ (   self,
  root 
)

Definition at line 34 of file compiler_layering_check.py.

34 def __init__(self, root):
35 self.root = root
36 self.worklist = set()
37 # Mapping from header to a set of files it is included into.
38 self.included_into = dict()
39 # Set of files that were parsed to avoid double parsing.
40 self.loaded = set()
41 # Mapping from headers to their layer.
42 self.file_layers = {file: 'runtime' for file in RUNTIME_LAYER_HEADERS}
43
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

Member Function Documentation

◆ AddAllSourcesToWorklist()

def compiler_layering_check.LayeringChecker.AddAllSourcesToWorklist (   self,
  dir 
)
Add all *.cc and *.h files from dir recursively into worklist.

Definition at line 97 of file compiler_layering_check.py.

97 def AddAllSourcesToWorklist(self, dir):
98 """Add all *.cc and *.h files from dir recursively into worklist."""
99 for file in os.listdir(dir):
100 path = os.path.join(dir, file)
101 if os.path.isdir(path):
102 self.AddAllSourcesToWorklist(path)
103 elif path.endswith('.cc') or path.endswith('.h'):
104 self.worklist.add(os.path.relpath(path, self.root))
105

◆ BuildIncludesGraph()

def compiler_layering_check.LayeringChecker.BuildIncludesGraph (   self)

Definition at line 63 of file compiler_layering_check.py.

63 def BuildIncludesGraph(self):
64 while self.worklist:
65 file = self.worklist.pop()
66 deps = self.ExtractIncludes(file)
67 self.loaded.add(file)
68 for d in deps:
69 if d not in self.included_into:
70 self.included_into[d] = set()
71 self.included_into[d].add(file)
72 if d not in self.loaded:
73 self.worklist.add(d)
74
static std::function< void(void)> pop(std::deque< std::function< void(void)> > *list)
Definition: SkExecutor.cpp:62

◆ Check()

def compiler_layering_check.LayeringChecker.Check (   self)

Definition at line 44 of file compiler_layering_check.py.

44 def Check(self):
45 self.AddAllSourcesToWorklist(os.path.join(self.root, 'runtime/vm'))
46 self.BuildIncludesGraph()
47 errors = self.PropagateLayers()
48 errors += self.CheckNotInRuntime(SHOULD_NOT_DEPEND_ON_RUNTIME)
49 return errors
50
def Check(request)
Definition: tester.py:24

◆ CheckNotInRuntime()

def compiler_layering_check.LayeringChecker.CheckNotInRuntime (   self,
  files 
)
Check that given files do not depend on runtime layer.

Definition at line 51 of file compiler_layering_check.py.

51 def CheckNotInRuntime(self, files):
52 """Check that given files do not depend on runtime layer."""
53 errors = []
54 for file in files:
55 if not os.path.exists(os.path.join(self.root, file)):
56 errors.append('File %s does not exist.' % (file))
57 if self.file_layers.get(file) is not None:
58 errors.append(
59 'LAYERING ERROR: %s includes object.h or raw_object.h' %
60 (file))
61 return errors
62
const myers::Point & get(const myers::Segment &)

◆ ExtractIncludes()

def compiler_layering_check.LayeringChecker.ExtractIncludes (   self,
  file 
)
Extract the list of includes from the given file.

Definition at line 106 of file compiler_layering_check.py.

106 def ExtractIncludes(self, file):
107 """Extract the list of includes from the given file."""
108 deps = set()
109 with open(os.path.join(self.root, file), encoding='utf-8') as file:
110 for line in file:
111 if line.startswith('namespace dart {'):
112 break
113
114 m = INCLUDE_DIRECTIVE_RE.match(line)
115 if m is not None:
116 header = os.path.join('runtime', m.group(1))
117 if os.path.isfile(os.path.join(self.root, header)):
118 deps.add(header)
119 return deps
120
121

◆ PropagateLayers()

def compiler_layering_check.LayeringChecker.PropagateLayers (   self)
Propagate layering information through include graph.

If A is in layer L and A is included into B then B is in layer L.

Definition at line 75 of file compiler_layering_check.py.

75 def PropagateLayers(self):
76 """Propagate layering information through include graph.
77
78 If A is in layer L and A is included into B then B is in layer L.
79 """
80 errors = []
81 self.worklist = set(self.file_layers.keys())
82 while self.worklist:
83 file = self.worklist.pop()
84 if file not in self.included_into:
85 continue
86 file_layer = self.file_layers[file]
87 for tgt in self.included_into[file]:
88 if tgt in self.file_layers:
89 if self.file_layers[tgt] != file_layer:
90 errors.add(
91 'Layer mismatch: %s (%s) is included into %s (%s)' %
92 (file, file_layer, tgt, self.file_layers[tgt]))
93 self.file_layers[tgt] = file_layer
94 self.worklist.add(tgt)
95 return errors
96

Member Data Documentation

◆ file_layers

compiler_layering_check.LayeringChecker.file_layers

Definition at line 42 of file compiler_layering_check.py.

◆ included_into

compiler_layering_check.LayeringChecker.included_into

Definition at line 38 of file compiler_layering_check.py.

◆ loaded

compiler_layering_check.LayeringChecker.loaded

Definition at line 40 of file compiler_layering_check.py.

◆ root

compiler_layering_check.LayeringChecker.root

Definition at line 35 of file compiler_layering_check.py.

◆ worklist

compiler_layering_check.LayeringChecker.worklist

Definition at line 36 of file compiler_layering_check.py.


The documentation for this class was generated from the following file: