Reference Counting PIMPL Idiom

The pointer to implementation or PIMPL idiom is a popular C++ idiom for decoupling the representation and implementation of a class. It reduces compilation times and enables a stable API while allowing the internals to change. Reference counting is another ubiquitous programming technique, used to manage an object’s lifetime by keeping track of the number of references held to it. C++’s std::shared_ptr uses this technique to provide shared ownership of an object through a pointer....

<span title='2017-08-08 18:00:00 +0000 UTC'>August 8, 2017</span>

Exposing Containers of Unique Pointers

The std::unique_ptr is probably one of my favorite and most used features in modern C++. The unique pointer is as powerful as it is simple, and assuming you’ve used it before, you surely know how awesome it is. There are many great articles written about unique pointers, so I won’t go into detail. What I will mention though is that unique pointers provide ownership semantics. What this means is that the unique pointer follows a well defined set of rules regarding the lifetime of its allocated resource....

<span title='2017-04-17 10:00:00 +0000 UTC'>April 17, 2017</span>

One Year At GuardSquare

Today marks my one year anniversary at GuardSquare. On the one hand it feels like yesterday (as cliché as that might sound) but on the other hand it feels like ages ago, considering how much we have been able to do in just one year’s time. For those that don’t know GuardSquare yet, allow me to quickly introduce our company. If you have ever used Java, you probably know ProGuard, our open source optimizer for Java bytecode....

<span title='2017-03-07 00:00:00 +0000 UTC'>March 7, 2017</span>

Building a Workstation

January 2017 marks the sixth birthday of my desktop computer. When I purchased my trusty Intel Core i5-2500K, I would’ve never guessed that I’d use it for that long. However, rather than jumping to the recently released Kaby Lake CPUs, I’m building my new workstation around two Intel Xeon E5-2670s. Why Xeon? There’s several reasons I went with a dual Xeon setup rather than a flagship i5 or i7. The first reason is that I’m not building a gaming rig but a workstation....

<span title='2017-01-13 21:44:45 +0000 UTC'>January 13, 2017</span>

Escape Analysis & Capture Tracking in LLVM

Pointer analysis is an important topic in compiler optimization. One interesting aspect is the dynamic scope of pointers. LLVM differentiates between two situations: Pointer Capture: A pointer value is captured if the function makes a copy of any part of the pointer that outlives the call. Pointer Escape: A pointer value escapes if it is is accessible from outside the current function or thread. The latter case is sometimes considered separate and called thread-escape....

<span title='2017-01-08 19:00:00 +0000 UTC'>January 8, 2017</span>

Order Your Members

The C++ standard guarantees that the members of a class or struct appear in memory in the same order as they are declared. Nonstatic data members of a (non-union) class with the same access control are allocated so that later members have higher addresses within a class object. The order of allocation of non-static data members with different access control is unspecified. Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions and virtual base classes....

<span title='2017-01-04 21:00:00 +0000 UTC'>January 4, 2017</span>

Guaranteed Copy Elision

The new C++17 standard brings many exciting new features. A smaller, more subtle improvement it brings is guaranteed copy elision. The keyword is guaranteed, as copy elision itself has always been part of the standard. Although it might not be a change as radical as, say, structured bindings, I’m very happy to see it made it into the standard. Table of Content Copy Elision Return Value Optimization Passing a Temporary by Value Throwing and Catching Exceptions by Value Guaranteed Copy Elision Value Categories Addendum: Translation Units Addendum: Copy-List-Initialization Copy Elision Before discussing what changed in the latest version of the standard, it might be useful to revisit the basics of copy elision as they are currently defined by the C++14 standard....

<span title='2016-11-21 21:00:00 +0000 UTC'>November 21, 2016</span>

LibEBC & ebcutil

In a previous blog post I wrote about bitcode. Embedding it was already possible for quite some time with Apple’s fork of LLVM that ships with Xcode. Recently, Apple upstreamed (parts of) their implementation making it possible to do the same with the open source clang compiler. However, there are some differences between the two implementations. Bitcode embedded with Apple’s version of clang is bundled into a xar-archive. Metadata such as compiler commands used to create the binary and dylibs which the code linked against, are kept in the archive’s table of content....

<span title='2016-10-13 21:34:44 +0000 UTC'>October 13, 2016</span>

Public Key

-----BEGIN PGP PUBLIC KEY BLOCK----- Version: SKS 1.1.5 mQINBFdy74MBEAC75SzUR+ibt50wrTmQ2Exi/E2Oqrson4a1+C3y2KfTngfPU1pcHweHuqGl Fi0Qx5wPmj9vWeGAX5n/MLO4NTRlwPYS2pp8khk/0JQI39F7z/gjJatWmtWjNtDBkifXQfzL EO8Yd6kN3eFRCSgYZ2r/rzFj1rtrqgZJZY8ANgPciytJeNQSKvr2DtkKPXUY72Vn8Y2Rn2jo /KwxRagLh8I1+8djv0M/84DFTmTGNMqaG+cBWXRmWYeEpxiLgXX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8LztULoOr1gGGJ79Jr+CzEhX3sCTBIFm1cQa a9KQ8PUS2wubyPeHo3VuLmb88PMwduwjz7mE9g6sQz1j0aEJJpZB0Pbx/C0ZIa8G8yZdwASP UhgQ0tnbTeawmv1u7f8qAkYOrkI/vydNLrNpFP0y4M1IEkRk70qzVO/9iCPrgU7x6Qbkc/0k EB+jECWQmyxWfj4lPYE8Kcj//zVPi2ZcauiWs8JhR6qs4TO46jFjqvqB17SDIZf+84wmG4Up Z1eXCrrSP6BF0BYAMaV6pbKpIg1I9wKsR9QVx5xnyAjtfy+Hz0QR5Vy3EYUFt+eHAITQkFvF VazlwC3vscOqhHsjY7ksFAINlRlsCmQKkjgmgH4djWxtcZBWqIaqZLhShojI9OdQixTPUeM7 8kjVxc/vGDPG7X/vRJAE8t+sp9OIrmlpihW/jLlVtTLA2v3lbree4C3JAbFrUBHNQrZH7jZR kxBq8IFVWABmiydtnaJtiXqLez64xRxqfpr1aZNjtuZ7CuNoGow1g9NTxVvatp/h1NmX+on2 PdQ= =fXbQ -----END PGP PUBLIC KEY BLOCK-----

<span title='2016-08-17 06:35:00 +0000 UTC'>August 17, 2016</span>

Embedded Bitcode

Little over a year ago, Apple announced at WWDC 2015 the ability to embed bitcode in Mach-O files. Bitcode is the intermediate representation used by the LLVM compiler and contains all the information required to recompile an application. Having the bitcode present, in addition to machine code, Apple can further optimize applications by compiling and linking specifically for the user’s target device. This is one approach to app thinning, which aims to achieve smaller binaries and therefore more free space on your iDevice....

<span title='2016-06-21 20:26:35 +0000 UTC'>June 21, 2016</span>