fun run_separate_compiler(mainmodule: MModule, runtime_type_analysis: RapidTypeAnalysis)
do
var time0 = get_time
- self.toolcontext.info("*** COMPILING TO C ***", 1)
+ self.toolcontext.info("*** GENERATING C ***", 1)
var compiler = new SeparateCompiler(mainmodule, self, runtime_type_analysis)
compiler.compile_header
# compile class structures
+ self.toolcontext.info("Property coloring", 2)
compiler.new_file("{mainmodule.name}.classes")
compiler.do_property_coloring
for m in mainmodule.in_importation.greaters do
for mclass in m.intro_mclasses do
+ if mclass.kind == abstract_kind or mclass.kind == interface_kind then continue
compiler.compile_class_to_c(mclass)
end
end
# compile methods
for m in mainmodule.in_importation.greaters do
+ self.toolcontext.info("Generate C for module {m}", 2)
compiler.new_file("{m.name}.sep")
compiler.compile_module_to_c(m)
end
# compile live & cast type structures
+ self.toolcontext.info("Type coloring", 2)
compiler.new_file("{mainmodule.name}.types")
var mtypes = compiler.do_type_coloring
for t in mtypes do
compiler.display_stats
+ var time1 = get_time
+ self.toolcontext.info("*** END GENERATING C: {time1-time0} ***", 2)
write_and_make(compiler)
end
end
# Layouts
var method_layout_builder: PropertyLayoutBuilder[MMethod]
var attribute_layout_builder: PropertyLayoutBuilder[MAttribute]
- if modelbuilder.toolcontext.opt_bm_typing.value then
- method_layout_builder = new MMethodBMizer(self.mainmodule)
- attribute_layout_builder = new MAttributeBMizer(self.mainmodule)
- else
- method_layout_builder = new MMethodColorer(self.mainmodule)
- attribute_layout_builder = new MAttributeColorer(self.mainmodule)
- end
+ #FIXME PH and BM layouts too slow for large programs
+ #if modelbuilder.toolcontext.opt_bm_typing.value then
+ # method_layout_builder = new MMethodBMizer(self.mainmodule)
+ # attribute_layout_builder = new MAttributeBMizer(self.mainmodule)
+ #else if modelbuilder.toolcontext.opt_phmod_typing.value then
+ # method_layout_builder = new MMethodHasher(new PHModOperator, self.mainmodule)
+ # attribute_layout_builder = new MAttributeHasher(new PHModOperator, self.mainmodule)
+ #else if modelbuilder.toolcontext.opt_phand_typing.value then
+ # method_layout_builder = new MMethodHasher(new PHAndOperator, self.mainmodule)
+ # attribute_layout_builder = new MAttributeHasher(new PHAndOperator, self.mainmodule)
+ #else
+ method_layout_builder = new MMethodColorer(self.mainmodule)
+ attribute_layout_builder = new MAttributeColorer(self.mainmodule)
+ #end
# methods coloration
var method_layout = method_layout_builder.build_layout(mclasses)
end
for mtype in mtypes do
- retieve_live_partial_types(mtype)
+ retrieve_partial_types(mtype)
end
mtypes.add_all(self.partial_types)
return tables
end
- fun retieve_live_partial_types(mtype: MType) do
+ fun retrieve_partial_types(mtype: MType) do
# add formal types arguments to mtypes
if mtype isa MGenericType then
for ft in mtype.arguments do
abort
end
self.partial_types.add(ft)
- retieve_live_partial_types(ft)
+ retrieve_partial_types(ft)
end
end
var mclass_type: MClassType
redef fun send(mmethod, arguments)
do
if arguments.first.mcasttype.ctype != "val*" then
- return self.monomorphic_send(mmethod, arguments.first.mcasttype, arguments)
+ # In order to shortcut the primitive, we need to find the most specific method
+ # Howverr, because of performance (no flattening), we always work on the realmainmodule
+ var m = self.compiler.mainmodule
+ self.compiler.mainmodule = self.compiler.realmainmodule
+ var res = self.monomorphic_send(mmethod, arguments.first.mcasttype, arguments)
+ self.compiler.mainmodule = m
+ return res
end
var res: nullable RuntimeVariable