64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER...
Transcript of 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER...
![Page 1: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/1.jpg)
1
David Intersimone “David I”VP of Developer Relations and Chief Evangelist
[email protected]://blogs.embarcadero.com/davidi
Twitter: davidi99Skype: davidi99
64 Bit DelphiWhat does it all mean?
![Page 2: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/2.jpg)
2
Agenda
• RAD Studio Product Family Overview
• 64bit computing – What’s the same? Different?– Data types
• The CPU - Instructions, Addresses• What this means for Delphi• What can I do today?
• Q&A
![Page 3: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/3.jpg)
3
Product Editions
Delphi Prism XE
• Professional • Enterprise
RadPHP XEC++Builder XE
• Starter• Professional • Enterprise• Architect
Delphi XE
• Starter• Professional • Enterprise• Architect
RAD Studio XE
• Professional• Enterprise• Architect
Included all IDE’s
InterBase Developer Edition FREEfor development
ER Studio Developer EditionIncluded on Architect edition
![Page 4: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/4.jpg)
4
Delphi XE and C++Builder XE Starter Edition
• Low cost solution for hobbyists, students, and independent developers to be able to get started building and distributing apps
• VCL Form Designer to visually build native Windows applications
• Full-featured debugger with color syntax highlighting• Hundreds of included components
– Touch and Gesture support– Ribbon Controls– IBX for database development– Allow third party components
![Page 5: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/5.jpg)
5
Recent investments in RAD Studio
• Acquisitions
• Strategic acquisitions
• Investing in new and future technologies for software development
![Page 6: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/6.jpg)
6
RAD Studio Future
6464
![Page 7: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/7.jpg)
7
Bit Computing
![Page 8: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/8.jpg)
8
What’s the same?
• Integer, Longint, Cardinal – still 32bits• Int64, UInt64 – still 64bits• UnicodeString, AnsiString, WideString• Exceptions• Runtime Library (RTL)• SysUtils, Classes, etc…
![Page 9: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/9.jpg)
9
Delphi 32 and 64-bit Type Sizes
Signed types Delphi/32 Delphi/64ShortInt 1 byte
SmallInt 2 bytes
LongInt 4 bytes
Integer 4 bytes
Int64 8 bytes
Unsigned types Delphi/32 Delphi/64 Byte 1 byte
Word 2 bytes
LongWord 4 bytes
Cardinal 4 bytes
UInt64 8 bytes
![Page 10: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/10.jpg)
10
What’s different?
• NativeInt, NativeUint – 64bits• Pointer (all pointers) – 64bits• Dynamic Arrays – 64bit indexing• Floating point math - Double
![Page 11: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/11.jpg)
11
Delphi 32 and 64-bit Type Sizes
Signed types Delphi/32 Delphi/64NativeInt 4 bytes 8 bytes
Unsigned types Delphi/32 Delphi/64 NativeUInt 4 bytes 8 bytes
![Page 12: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/12.jpg)
12
Delphi 32 and 64-bit Pointer Types
Pointer types Delphi/32 Delphi/64Pointer StringClass instance Class reference Interface AnsiString 4 bytes 8 bytesWideString UnicodeString Procedure pointer Dynamic array PAnsiChar PWideChar PChar
![Page 13: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/13.jpg)
13
The CPU – Programming model
![Page 14: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/14.jpg)
14
Instructions and Addresses
• 64 bit address space• Limited by physical hardware• Same core Intel instruction set• New REX prefix for 64bit instructions• RIP-relative addressing• Jumps – relative +/- 2GB• 16 byte stack alignments
• Online resources• http://msdn.microsoft.com/en-us/magazine/cc300794.aspx• http://msdn.microsoft.com/en-us/library/7kcdt6fy.aspx
![Page 15: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/15.jpg)
15
What does this mean for Delphi?
![Page 16: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/16.jpg)
16
Don’t panic!
![Page 17: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/17.jpg)
17
Delphi 64-bit on Windows
• Same Windows API– CreateWindowEx, PeekMessage, etc..
• Same Delphi RTL– SysUtils, Classes, Generics.Collections, etc…
• Same VCL– Forms, Graphics, Controls, Menus, etc..
![Page 18: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/18.jpg)
18
• Category Identifier dcc32 dcc64 • Compiler DCC defined defined
VER230 defined defined • Platform MSWINDOWS defined defined
WIN32 defined not defined WIN64 not defined defined
• CPU CPU386 defined not defined CPUX86 defined not defined CPUX64 not defined defined
• Availability ASSEMBLER defined defined UNICODE defined defined
Pre-Defined Conditionals
![Page 19: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/19.jpg)
19
Delphi 64-bit on Windows – some gotcha’s
• SizeOf(Pointer) <> SizeOf(Integer)– Integer<->Pointer casts will break in 64bit– SizeOf(THandle) = SizeOf(Pointer)– All Handles = SizeOf(Pointer) (HWND, HDC, etc..).
• All code in process must be 64bit – Must have 64bit versions of external non-Delphi libraries
(DLLs)
• One, and only one, calling convention– register,pascal,cdecl,stdcall ignored.
• safecall is still “special”• Old “pointer math” code may break
– Works in 32 and 64bit: MyPtr := PByte(P) + 10;
![Page 20: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/20.jpg)
20
Delphi 64-bit on Windows – some gotcha’s
• Inline Assembly– Cannot mix asm blocks with Pascal code– Only procedural level asm blocks supported– Stack must be 16-byte aligned at each call instruction– Define locals for temp storage– Do not modify the RSP stack pointer– New unified calling convention. First 4 parameters in registers,
RCX, RDX, R8, R9 (or XMM0-XMM3)
• Exception unwinding– No change for pure Delphi code. Exceptions function
identically.– Inline Assembly can cause exception unwinding to fail if not
properly written.
![Page 21: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/21.jpg)
21
Windows API gotcha’s
• SetWindowLong / GetWindowLog should be replaced by SetWindowLongPtr / GetWindowLongPtr for GWLP_HINSTANCE, GWLP_WNDPROC, etc… as they return pointers and handles.
– Pointers passed to SetWindowLongPtr should be type-casted to LONG_PTR and not to Integer / Longint.
• SetWindowLong mapped to SetWindowLongPtr in Windows.pas.
– Calls to our declaration of SetWindowLong are safe, as long as they are cast correctly.
![Page 22: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/22.jpg)
22
Windows API gotcha’s (con’t)
• Use explicit casts to WPARAM and LPARAM where appropriate.
– Example: Passing pointers through SendMessage SendMessage(hWnd, WM_SETTEXT, 0, LPARAM(@MyCharArray));
• Use LRESULT to cast message results
– Example: Message.Result := LRESULT(Self);
• Message cracker records (TWMxxx) changed
– Alignment changes and field-size changes
![Page 23: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/23.jpg)
23
What can I do today?
• Find all Integer<->Pointer casts, including Integer<->instance casts.
– Check for Pointer size assumptions
• Ensure external dependencies are also 64bit
– Image/bitmap libraries– Hardware interfaces libraries– ActiveX controls
• Consider rewriting Assembler in pure-Pascal
– Better future portability (think ARM CPUs…)– Rely more on algorithmic performance rather than raw
assembly performance.
![Page 24: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/24.jpg)
24
Delphi 64-bit Demonstration
![Page 25: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/25.jpg)
25
Rich Client Application
RAD Studio Client Vision
KeyboardKeyboard
MouseMouseTouchTouch VoiceVoice
BiometricsBiometrics
LocationLocation
InterBaseInterBase
RESTREST
COMCOM
CloudCloud
SOAPSOAP
.NET.NET
SocialSocial
![Page 26: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/26.jpg)
26
DataSnapServer Methods
dbExpress
RAD Studio Server Vision
InterBaseInterBase
RESTREST
COMCOM
CloudCloud
SOAPSOAP
.NET.NET
SocialSocial
![Page 27: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/27.jpg)
27
Q & A
![Page 28: 64 Bit Delphi What does it all mean? - Embarcadero … Developer Edition FREE for development ER Studio Developer Edition Included on Architect edition 4 Delphi XE and C++Builder XE](https://reader030.fdocuments.in/reader030/viewer/2022013110/5ace86c27f8b9a71028b8157/html5/thumbnails/28.jpg)
28
Thank You
David Intersimone “David I”VP of Developer Relations and Chief Evangelist
[email protected]://blogs.embarcadero.com/davidi
Twitter: davidi99Skype: davidi99