Cargando…

Relaxing the one definition rule in interpreted C++

Most implementations of the C++ programming language generate binary executable code. However, interpreted execution of C++ sources has its own use cases as the Cling interpreter from CERN’s ROOT project has shown. Some limitations are derived from the ODR (One Definition Rule) that rules out multip...

Descripción completa

Detalles Bibliográficos
Autores principales: López-Gómez, Javier, Fernández, Javier, Astorga, David del Rio, Vassilev, Vassil, Naumann, Axel, García, J Daniel
Lenguaje:eng
Publicado: 2020
Materias:
Acceso en línea:https://dx.doi.org/10.1145/3377555.3377901
http://cds.cern.ch/record/2807614
_version_ 1780973059536060416
author López-Gómez, Javier
Fernández, Javier
Astorga, David del Rio
Vassilev, Vassil
Naumann, Axel
García, J Daniel
author_facet López-Gómez, Javier
Fernández, Javier
Astorga, David del Rio
Vassilev, Vassil
Naumann, Axel
García, J Daniel
author_sort López-Gómez, Javier
collection CERN
description Most implementations of the C++ programming language generate binary executable code. However, interpreted execution of C++ sources has its own use cases as the Cling interpreter from CERN’s ROOT project has shown. Some limitations are derived from the ODR (One Definition Rule) that rules out multiple definitions of entities within a single translation unit (TU). ODR is there to ensure uniform view of a given C++ entity across translation units. Ensuring uniform view of C++ entities helps when producing ABI compatible binaries. Interpreting C++ presumes a single evergrowing translation unit that define away some of the ODR use-cases. Therefore, it may well be desirable to relax the ODR and, consequently, to support the ability of developers to override any existing definition for a given declaration. This approach is especially well-suited for iterative prototyping. In this paper, we extend Cling, a Clang/LLVM-based C++ interpreter, to enable redefinitions of C++ entities at the prompt. To achieve this, top-level declarations are nested into inline namespaces and the translation unit lookup table is adjusted to invalidate previous definitions that would otherwise result in ambiguities. Formally, this technique refactors the code to an equivalent that does not violate the ODR, as each definition is nested in a different namespace. Furthermore, any previous definition that has been shadowed is still accessible by means of its fully-qualified name. A prototype implementation of the presented technique has been integrated into the Cling C++ interpreter, showing that our technique is feasible and usable.
id cern-2807614
institution Organización Europea para la Investigación Nuclear
language eng
publishDate 2020
record_format invenio
spelling cern-28076142022-04-26T18:30:03Zdoi:10.1145/3377555.3377901http://cds.cern.ch/record/2807614engLópez-Gómez, JavierFernández, JavierAstorga, David del RioVassilev, VassilNaumann, AxelGarcía, J DanielRelaxing the one definition rule in interpreted C++Computing and ComputersMost implementations of the C++ programming language generate binary executable code. However, interpreted execution of C++ sources has its own use cases as the Cling interpreter from CERN’s ROOT project has shown. Some limitations are derived from the ODR (One Definition Rule) that rules out multiple definitions of entities within a single translation unit (TU). ODR is there to ensure uniform view of a given C++ entity across translation units. Ensuring uniform view of C++ entities helps when producing ABI compatible binaries. Interpreting C++ presumes a single evergrowing translation unit that define away some of the ODR use-cases. Therefore, it may well be desirable to relax the ODR and, consequently, to support the ability of developers to override any existing definition for a given declaration. This approach is especially well-suited for iterative prototyping. In this paper, we extend Cling, a Clang/LLVM-based C++ interpreter, to enable redefinitions of C++ entities at the prompt. To achieve this, top-level declarations are nested into inline namespaces and the translation unit lookup table is adjusted to invalidate previous definitions that would otherwise result in ambiguities. Formally, this technique refactors the code to an equivalent that does not violate the ODR, as each definition is nested in a different namespace. Furthermore, any previous definition that has been shadowed is still accessible by means of its fully-qualified name. A prototype implementation of the presented technique has been integrated into the Cling C++ interpreter, showing that our technique is feasible and usable.oai:cds.cern.ch:28076142020
spellingShingle Computing and Computers
López-Gómez, Javier
Fernández, Javier
Astorga, David del Rio
Vassilev, Vassil
Naumann, Axel
García, J Daniel
Relaxing the one definition rule in interpreted C++
title Relaxing the one definition rule in interpreted C++
title_full Relaxing the one definition rule in interpreted C++
title_fullStr Relaxing the one definition rule in interpreted C++
title_full_unstemmed Relaxing the one definition rule in interpreted C++
title_short Relaxing the one definition rule in interpreted C++
title_sort relaxing the one definition rule in interpreted c++
topic Computing and Computers
url https://dx.doi.org/10.1145/3377555.3377901
http://cds.cern.ch/record/2807614
work_keys_str_mv AT lopezgomezjavier relaxingtheonedefinitionruleininterpretedc
AT fernandezjavier relaxingtheonedefinitionruleininterpretedc
AT astorgadaviddelrio relaxingtheonedefinitionruleininterpretedc
AT vassilevvassil relaxingtheonedefinitionruleininterpretedc
AT naumannaxel relaxingtheonedefinitionruleininterpretedc
AT garciajdaniel relaxingtheonedefinitionruleininterpretedc