<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Be careful.  When I revamped label handling (admittedly, early in the process), performance was very sensitive to the approach.  I tried half a dozen approaches.  Having multiple subtypes of labels definitely had a cost.  
<div class=""><br class="">
</div>
<div class="">The main case we probably want to avoid regressing on is the mostly-no-op-adapataion case.  <br class="">
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jan 15, 2024, at 9:30 AM, Adam Sotona <<a href="mailto:adam.sotona@oracle.com" class="">adam.sotona@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Hi,<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">ClassFile API Labels are always strictly linked with the source CodeModel or with the target CodeBuilder.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Only Labels coming from an existing CodeModel can be applied multiple times in various target CodeBuilders. Labels created by one CodeBuilder cannot be (re-)used in another CodeBuilder.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">All these restrictions serve to the purpose of maximum performance.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">However, this strict approach prevents to address not-yet existing code blocks or instructions outside of (or better say before the existence of) the CodeBuilder.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">As an example, let’s say we plan to build a complex code structure from a custom abstract model.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Each of the addressable instruction or code block will be addressed by a Label at the build time, however that Label could not exist outside of the CodeBuilder.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Current workaround is to provide an extra mapping layer (a “CodeBuilderContext”) to translate from custom addressable elements to Labels (a unique new mapping for each CodeBuilder).<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">I would like to simplify this situation and here are some alternatives:<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class=""><o:p class=""> </o:p></span></div>
<ol start="1" type="1" style="margin-bottom: 0cm; margin-top: 0cm;" class="">
<li class="MsoListParagraph" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" class="">Introduce new Proto/Global/Unbound/UnresolvedLabel  (unsealed) interface.<span class="Apple-converted-space"> </span><br class="">
And add CodeBuilder::resolve(ProtoLabel) method, which will identity-map it to a local Label during the build process.<br class="">
<br class="">
or<br class="">
<br class="">
<o:p class=""></o:p></span></li><li class="MsoListParagraph" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" class="">Allow to statically create global Labels and make them reusable, it means to add static Label::newLabel() and fix current implementation.<o:p class=""></o:p></span></li></ol>
<div style="margin: 0cm 0cm 0cm 36pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">I expect the static factory Label::newLabel() may attract users more than CodeBuilder::newLabel(), so the implementation should keep performance of the existing use cases.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Any comment and suggestions are welcome.<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Thanks,<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span lang="EN-US" class="">Adam</span></div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>