TMS FixInsight and the inline directive

Monday, April 24, 2017

The Delphi compiler allows functions and procedures to be tagged with the inline directive to improve performance. If the function or procedure meets certain criteria, the compiler will insert code directly, rather than generating a call. Embarcadero docwiki gives a list of conditions under which inlining does or does not occur.

One of basic conditions says: within a unit, the body for an inline function should be defined before calls to the function are made.

TMS FixInsight 2017.04 introduces rule O805 “Inline marked routine comes after its call in the same unit”. Let’s check FMX and VCL code to see if Embarcadero follows their own rules. Short answer: it doesn’t.

I will give a couple of examples from Delphi 10.1 Berlin (version 24.0.22858.6822).

Vcl.Controls.pas
//at line 8529 
procedure TWinControl.ReadState(Reader: TReader);
begin
  DisableAlign;
  try
    inherited ReadState(Reader);
  finally
    EnableAlign;
  end;
  FixupTabList;
  if FParent <> nil then Perform(CM_PARENTCTL3DCHANGED, 0, 0);
  UpdateControlState;
end;

Vcl.Controls.pas
//at line 9010
procedure TWinControl.AlignControl(AControl: TControl);
var
  Rect: TRect;
begin
  if not HandleAllocated or (csDestroying in ComponentState) then Exit;
  if FAlignLevel <> 0 then
    Include(FControlState, csAlignmentNeeded)
  else
  begin
    DisableAlign;
    try
      Rect := GetClientRect;
      AlignControls(AControl, Rect);
    finally
      Exclude(FControlState, csAlignmentNeeded);
      EnableAlign;
    end;
  end;
end;

Vcl.Controls.pas
//at line 9030 
procedure TWinControl.DisableAlign;
begin
  Inc(FAlignLevel);
end;
TWinControl.DisableAlign is an inline marked procedure. It is called at line 8531 and line 9019, but its body is defined after the calls – at line 9030. Obviously, this function will not be inlined.

One more example from another unit:

Fmx.ListView.pas
//at line 2430 
procedure TListViewBase.UpdateDeleteButtonLayout;
var
  RelRect: TRectF;
begin
  if (Adapter.Count < 1) or (FDeleteLayout = nil) or ((FDeleteButtonIndex = -1) and
    (FPrevDeleteButtonIndex = -1)) then
    Exit;
 
  if (FListingService <> nil) and (TListingTransitionFeature.DeleteButtonSlide in FListingService.GetTransitionFeatures) then
  begin
    FDeleteLayout.Width := DefaultDeleteButtonWidth * FDeleteModeTransitionAlpha;
    FDeleteButton.Opacity := 1;
  end
  else
  begin
    if FDeleteModeTransitionAlpha > 0 then
      FDeleteLayout.Width := DefaultDeleteButtonWidth
    else
      FDeleteLayout.Width := 0;
 
    FDeleteButton.Opacity := 0.5 + (FDeleteModeTransitionAlpha / 2);
  end;
 
  FDeleteLayout.Height := GetItemHeight(FDeleteButtonIndex);
  FDeleteLayout.Position.X := Width - FDeleteLayout.Width;
 
  if FDeleteButtonIndex = -1 then
    RelRect := GetItemRelRect(FPrevDeleteButtonIndex, LocalRect)
  else
    RelRect := GetItemRelRect(FDeleteButtonIndex, LocalRect);
 
  FDeleteLayout.Position.Y := (RelRect.Top + RelRect.Bottom - FDeleteLayout.Height) / 2;
end;
The method above contains two GetItemRelRect calls (lines 2457 and 2459), but both are before the actual GetItemRelRect body position in that unit (line 2868):

Fmx.ListView.pas
//at line 2868
function TListViewBase.GetItemRelRect(const Index: Integer; const LocRect: TRectF;
  const SideSpace: Integer = 0): TRectF;
begin
  Result := RectF(LocRect.Left + FSideSpace + SideSpace, LocRect.Top + FSideSpace + FHeightSums[Index] - FScrollViewPos,
    LocRect.Width - ((SideSpace + FSideSpace) * 2), GetItemHeight(Index));
 
  if (FScrollBar <> nil) and (not HasTouchTracking) and FScrollBar.Visible then
    Result.Right := Result.Right - FScrollBar.Width;
end;
Despite being declared as inline, this method will not be inlined.

It is not a critical issue, but this makes inline directive useless. There are more occurrences of this issue in Vcl.ExtActns.pas, FMX.ASE.Lexer.pas, FMX.Graphics.pas, FMX.Types.pas, FMX.Utils.pas and FMX.ZOrder.Win.pas.

This means that inlining conditions are not easy to follow, even though at first glance inline directive seems to be an easy way to slightly optimize your code. TMS FixInsight may help to make inlining more useful by avoiding such mistakes.

You can download TMS FixInsight trial and check your own code.

Nancy Lescouhier


Bookmarks: 

This blog post has not received any comments yet.



Add a new comment:
Author:
Email:
  You will receive a confirmation mail with a link to validate your comment, so please use a valid email address.
Comment:
 
Change Image
Fill in the characters from the image above:
 

All fields are required.
 



TMS hands-on training day in Kortrijk, Belgium on June 8th

Friday, April 07, 2017

TMS software organizes a new training day on Thursday June 8th in Kortrijk - Belgium.

All day, sessions will be spent on TMS VCL components, TMS FNC components and TMS Cloud components with also sufficient session time allocated to handle your specific questions on TMS components. The sessions will be given by Bruno Fierens, Embarcadero MVP in Belgium and CTO from tmssoftware.com and Bernard Roussely, product manager of TMS Cryptography Pack. All sessions will be in English.


In tentative program

9h00 - TMS FNC Controls architecture
Insight in the architecture of the TMS FNC controls and a brief introduction to using the TMS FNC library to write custom controls for VCL, FMX, LCL.

10h00 - TMS FNC Controls overview
Overview of TMS FNC UI Controls in the TMS FNC UI Pack, TMS FNC Chart, TMS FNC Blox

11h00 - TMS MQTT
Use the TMS messaging component for machine 2 machine messaging from Windows, iOS, Android, Linux.

12h00 - Lunch

13h00 - TMS Google Mapping components
Overview of features and advanced capabilities in the TMS Google Mapping components for VCL & FMX.

14h00 - TMS Cryptography components
Using the TMS Cryptography components in a client-server scenario with certificate generation

15h00 - TMS Cloud Components & myCloudData
Access popular cloud services from VCL and FMX applications. Use service agnostic cloud file storage access. Use cloud data storage with the myCloudData service.

16h00 - TMS PDF Library
Use the cross-platform PDF generation engine and applying the PDF lib for automatic PDF generation from several TMS components.

17h00 - Closing Q&A

Location

  • Hotel Ibis Styles Kortrijk Expo, Pres. Kennedypark 1, B-8500 Kortrijk
  • Free parking
  • Nearby highway (E17) exit
  • Facilities for hotel rooms at the event are available for international attendees


Registrations until May 31st

The cost of the TMS training day is 95 € exclusive VAT. This includes a full day access to the sessions and coffee/drinks during this day. A hot meal is served for lunch. Register now!

Nancy Lescouhier


Bookmarks: 

This blog post has not received any comments yet.



Add a new comment:
Author:
Email:
  You will receive a confirmation mail with a link to validate your comment, so please use a valid email address.
Comment:
 
Change Image
Fill in the characters from the image above:
 

All fields are required.
 



TMS Aurelius, the ORM for Delphi: For Linux. For Free.

Tuesday, April 04, 2017

Embarcadero has just released RAD Studio 10.2 Tokyo, the latest version of the great Delphi/C++Builder development tools. And the greatest feature of this release is the ability to compile for Linux!


After a few days following Tokyo release, we were glad to release a new version (3.7) of TMS Aurelius, our ORM framework, with Linux support. Yes, you can now build applications for Linux, using TMS Aurelius, with all the stability and robustness you are used to.

To celebrate this milestone in Delphi development, we are also announcing now that TMS Aurelius Free Edition is back. TMS Aurelius Free Edition has no license restrictions, you can build commercial applications with it, and it has all features of registered license, including Linux support. The promotion will run until April 30th, just visit the TMS Aurelius Free Edition page to register for it and receive a download link.

Finally, in case you have not seen it, the "My Top 10 Aurelius Features" series has finished. It's a great video-series for starters wanting to know more about TMS Aurelius and its capabilities.

"My Top 10 Aurelius Features" blog post
"My Top 10 Aurelius Features" playlist



Wagner R. Landgraf


Bookmarks: 

This blog post has received 4 comments.


1. Tuesday, April 04, 2017 at 11:26:36 AM

This is great offer, although I''m sceptical in using this kind of offers in my software. I like to use Aurelius for some non-profit projects but I don''t know if I can rely on this offer when a new version of Delphi comes out or serious bugs are found in Aurelius.
But it''s nice for learning and trying out this library.

Patrick


2. Tuesday, April 04, 2017 at 1:00:54 PM

This is the second offer. We had one for Berlin. Tokyo was released, and here is Aurelius Free for Tokyo again. TMS Aurelius is very stable and mature. And you will always have the option to purchase the registered license.

Wagner R. Landgraf


3. Tuesday, April 04, 2017 at 5:22:53 PM

gostaria de receber a versão free.

Adriano Galv


4. Tuesday, April 04, 2017 at 7:04:25 PM

É só se cadastrar no link mencionado neste post.

Wagner R. Landgraf




Add a new comment:
Author:
Email:
  You will receive a confirmation mail with a link to validate your comment, so please use a valid email address.
Comment:
 
Change Image
Fill in the characters from the image above:
 

All fields are required.
 



Upcoming event: TMS Day in Fredericia, Denmark on May 18th

Monday, March 27, 2017

We are excited to announce that Jens Fudge, Embarcadero MVP for Denmark, and TMS software are planning a TMS day in Denmark on May 18th.

All day, sessions will be spent on TMS VCL components, TMS FNC components and TMS Cloud components and with also sufficient session time allocated to handle your specific questions on TMS components. The sessions will be given by Bruno Fierens, Embarcadero MVP in Belgium and CTO from tmssoftware.com.

All sessions will be in English.

In tentative program

9h00
TMS FNC Controls architecture
Insight in the architecture of the TMS FNC controls and a brief introduction to using the TMS FNC library to write custom controls for VCL, FMX, LCL.

10h00
TMS FNC Controls overview
Overview of TMS FNC UI Controls in the TMS FNC UI Pack, TMS FNC Chart, TMS FNC Blox

11h00
TMS MQTT
Use the TMS messaging component for machine 2 machine messaging from Windows, iOS, Android, Android, Linux.

12h00
Lunch

13h00
TMS VCL Components tips & tricks
An overview of less known features in TMS VCL components

14h00
TMS Google Mapping components
Overview of features and advanced capabilities in the TMS Google Mapping components for VCL & FMX.

15h00
TMS Cloud Components & myCloudData
Access popular cloud services from VCL and FMX applications. Use service agnostic cloud file storage access. Use cloud data storage with the myCloudData service.

16h00
TMS PDF Library
Use the cross-platform PDF generation engine and applying the PDF lib for automatic PDF generation from several TMS components.

Location

Archersoft ApS
Vesterballevej 5
7000 Fredericia
Denmark



Register now!

Sign-up now for the TMS Day in Denmark in Fredericia, Denmark on May 18th, 2017. The cost of the TMS Day is only a small fee of 35 EUR (VAT exclusive) for the food and drinks during this day.

Don't delay your registration as the number of seats is limited.

Nancy Lescouhier


Bookmarks: 

This blog post has received 2 comments.


1. Wednesday, March 29, 2017 at 9:57:10 PM

Hi:
Would this be recorded and put online also?

Lewis Brian


2. Thursday, March 30, 2017 at 12:12:29 AM

Not sure, I''ll need to check with organizer Jens Fudge

Bruno Fierens




Add a new comment:
Author:
Email:
  You will receive a confirmation mail with a link to validate your comment, so please use a valid email address.
Comment:
 
Change Image
Fill in the characters from the image above:
 

All fields are required.
 



Boost your productivity with TMS components & RAD Studio 10.2 Tokyo

Thursday, March 23, 2017

Yesterday Embarcadero released Delphi, C++Builder and RAD Studio 10.2 Tokyo:
https://www.embarcadero.com/products/rad-studio/whats-new-in-10-2-tokyo

For our registered users, already several products are ready for this new RAD Studio version! So get started today with your Windows or cross-platform development in 10.2 Tokyo with TMS VCL, FMX and FNC components.

TMS rollout of components with RAD Studio 10.2 Tokyo support:

  VCL Windows application development
  FMX cross-platform application development
  FNC cross-platform & cross-framework application development
  Developer tools for Delphi developers
Our team is working hard to continue to add RAD Studio 10.2 Tokyo support to our other wide range of component products. You can track here the progress of our work to cover other products. For trial users, RAD Studio 10.2 Tokyo support will follow soon.

Nancy Lescouhier


Bookmarks: 

This blog post has not received any comments yet.



Add a new comment:
Author:
Email:
  You will receive a confirmation mail with a link to validate your comment, so please use a valid email address.
Comment:
 
Change Image
Fill in the characters from the image above:
 

All fields are required.
 




Previous  |  Next  |  Index