+2011-09-02 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Do not create
+ TSS routine Finalize_Address when compiling in Alfa mode.
+ (Expand_Freeze_Record_Type): Do not create TSS routine
+ Finalize_Address when compiling in Alfa mode.
+ * exp_ch4.adb (Expand_Allocator_Expression): Do not produce a
+ call to Set_Finalize_Address in Alfa mode because Finalize_Address is
+ not built.
+ (Expand_N_Allocator): Do not produce a call to
+ Set_Finalize_Address in Alfa mode because Finalize_Address is not built.
+ * exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Do not
+ produce a call to primitive Set_Finalize_Address in Alfa mode because
+ Finalize_Address is not built.
+ * exp_ch7.adb (Build_Finalization_Master): Do not create
+ finalization masters in Afa mode since they are not needed.
+ (Build_Finalizer): Do not create scope and library-level
+ finalizers in Alfa mode since they are not needed.
+ * exp_util.adb (Build_Allocate_Deallocate_Proc): Do not expand
+ "new" and "free" when applied to controlled objects in Alfa mode since
+ this is not needed.
+
2011-09-02 Vincent Celier <celier@adacore.com>
* prj-nmsc.db: (Check_Stand_Alone_Library): For SALs, allow
elsif CodePeer_Mode then
return;
+
+ -- Do not create TSS routine Finalize_Address when compiling in Alfa
+ -- mode because it is not necessary and results in useless expansion.
+
+ elsif Alfa_Mode then
+ return;
end if;
-- Create the body of TSS primitive Finalize_Address. This automatically
-- Create the body of TSS primitive Finalize_Address. This must
-- be done before the bodies of all predefined primitives are
- -- created. If Def_Id is limited, Stream_Input and Streap_Read
- -- may produce build-in-place allocations and for that the
- -- expander needs Finalize_Address.
+ -- created. If Def_Id is limited, Stream_Input and Stream_Read
+ -- may produce build-in-place allocations and for those the
+ -- expander needs Finalize_Address. Do not create the body of
+ -- Finalize_Address in Alfa mode since it is not needed.
- Make_Finalize_Address_Body (Def_Id);
+ if not Alfa_Mode then
+ Make_Finalize_Address_Body (Def_Id);
+ end if;
Predef_List := Predefined_Primitive_Bodies (Def_Id, Renamed_Eq);
Append_Freeze_Actions (Def_Id, Predef_List);
-- Generate:
-- Set_Finalize_Address (<PtrT>FM, <T>FD'Unrestricted_Access);
- -- Since .NET/JVM compilers do not support address arithmetic,
- -- this call is skipped. The same is done for CodePeer because
- -- primitive Finalize_Address is never generated. Do not create
- -- this call if there is no allocator available any more.
+ -- Do not generate this call in the following cases:
+ --
+ -- * .NET/JVM - these targets do not support address arithmetic
+ -- and unchecked conversion, key elements of Finalize_Address.
+ --
+ -- * Alfa mode - the call is useless and results in unwanted
+ -- expansion.
+ --
+ -- * CodePeer mode - TSS primitive Finalize_Address is not
+ -- created in this mode.
if VM_Target = No_VM
+ and then not Alfa_Mode
and then not CodePeer_Mode
and then Present (Finalization_Master (PtrT))
and then Present (Temp_Decl)
end if;
-- The finalization master must be inserted and analyzed as part of
- -- the current semantic unit.
+ -- the current semantic unit. This form of expansion is not carried
+ -- out in Alfa mode because it is useless.
- if No (Finalization_Master (PtrT)) then
+ if No (Finalization_Master (PtrT))
+ and then not Alfa_Mode
+ then
Set_Finalization_Master (PtrT, Current_Anonymous_Master);
end if;
end if;
-- Set_Finalize_Address
-- (<PtrT>FM, <T>FD'Unrestricted_Access);
- -- Do not generate the above for CodePeer compilations
- -- because primitive Finalize_Address is never built.
+ -- Do not generate this call in the following cases:
+ --
+ -- * Alfa mode - the call is useless and results in
+ -- unwanted expansion.
+ --
+ -- * CodePeer mode - TSS primitive Finalize_Address is
+ -- not created in this mode.
- elsif not CodePeer_Mode then
+ elsif not Alfa_Mode
+ and then not CodePeer_Mode
+ then
Insert_Action (N,
Make_Set_Finalize_Address_Call
(Loc => Loc,
begin
-- Ada 2005 (AI-251): In class-wide interface objects we displace
- -- "this" to reference the base of the object --- required to get
+ -- "this" to reference the base of the object required to get
-- access to the TSD of the object.
if Is_Class_Wide_Type (Etype (Exp))
then
null;
- -- Do not generate the call to Make_Set_Finalize_Address for
- -- CodePeer compilations because Finalize_Address is never built.
+ -- Do not generate the call to Set_Finalize_Address in Alfa mode
+ -- because it is not necessary and results in unwanted expansion.
+ -- This expansion is also not carried out in CodePeer mode because
+ -- Finalize_Address is never built.
- elsif not CodePeer_Mode then
+ elsif not Alfa_Mode
+ and then not CodePeer_Mode
+ then
Insert_Action (Allocator,
Make_Set_Finalize_Address_Call (Loc,
Typ => Etype (Function_Id),
and then not Is_Controlled (Desig_Typ)
then
return;
+
+ -- Do not create finalization masters in Alfa mode because they result
+ -- in unwanted expansion.
+
+ elsif Alfa_Mode then
+ return;
end if;
declare
begin
Fin_Id := Empty;
+ -- Do not perform this expansion in Alfa mode because it is not
+ -- necessary.
+
+ if Alfa_Mode then
+ return;
+ end if;
+
-- Step 1: Extract all lists which may contain controlled objects or
-- library-level tagged types.
-- which belongs to a protected type.
begin
+ -- Do not perform this expansion in Alfa mode because we do not create
+ -- finalizers in the first place.
+
+ if Alfa_Mode then
+ return;
+ end if;
+
-- The At_End handler should have been assimilated by the finalizer
pragma Assert (No (At_End_Proc (HSS)));
-- Start of processing for Build_Allocate_Deallocate_Proc
begin
+ -- Do not perform this expansion in Alfa mode because it is not
+ -- necessary.
+
+ if Alfa_Mode then
+ return;
+ end if;
+
-- Obtain the attributes of the allocation / deallocation
if Nkind (N) = N_Free_Statement then