Changeset e8bad5c8 for doc/theses
- Timestamp:
- Aug 25, 2021, 2:31:27 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- cfbab07
- Parents:
- ba2e8f0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/implement.tex
rba2e8f0 re8bad5c8 14 14 \label{s:VirtualSystem} 15 15 % Virtual table rules. Virtual tables, the pointer to them and the cast. 16 While the \CFA virtual system currently has only one public feature, virtual 17 cast (see the virtual cast feature \vpageref{p:VirtualCast}), 18 substantial structure is required to support it, 16 While the \CFA virtual system currently has only one public features, virtual 17 cast and virtual tables, 18 % ??? refs (see the virtual cast feature \vpageref{p:VirtualCast}), 19 substantial structure is required to support them, 19 20 and provide features for exception handling and the standard library. 20 21 … … 215 216 type's alignment, is set using an @alignof@ expression. 216 217 218 Most of these tools are already inside the compiler. Using the is a simple 219 code transformation early on in compilation allows most of that work to be 220 handed off to the existing tools. \autoref{f:VirtualTableTransformation} 221 shows an example transformation, this example shows an exception virtual table. 222 It also shows the transformation on the full declaration, 223 for a forward declaration the @extern@ keyword is preserved and the 224 initializer is not added. 225 226 \begin{figure}[htb] 227 \begin{cfa} 228 vtable(example_type) example_name; 229 \end{cfa} 230 \transformline 231 % Check mangling. 232 \begin{cfa} 233 const struct example_type_vtable example_name = { 234 .__cfavir_typeid : &__cfatid_example_type, 235 .size : sizeof(example_type), 236 .copy : copy, 237 .^?{} : ^?{}, 238 .msg : msg, 239 }; 240 \end{cfa} 241 \caption{Virtual Table Transformation} 242 \label{f:VirtualTableTransformation} 243 \end{figure} 244 217 245 \subsection{Concurrency Integration} 218 246 Coroutines and threads need instances of @CoroutineCancelled@ and … … 251 279 \end{figure} 252 280 253 \begin{figure} 281 \begin{figure}[htb] 254 282 \begin{cfa} 255 283 void main(Example & this) { … … 300 328 301 329 \section{Exceptions} 302 \todo{The entire exceptions section.} 330 % The implementation of exception types. 331 332 Creating exceptions can roughly divided into two parts, 333 the exceptions themselves and the virtual system interactions. 334 335 Creating an exception type is just a matter of preppending the field 336 with the virtual table pointer to the list of the fields 337 (see \autoref{f:ExceptionTypeTransformation}). 338 339 \begin{figure}[htb] 340 \begin{cfa} 341 exception new_exception { 342 // EXISTING FIELDS 343 }; 344 \end{cfa} 345 \transformline 346 \begin{cfa} 347 struct new_exception { 348 struct new_exception_vtable const * virtual_table; 349 // EXISTING FIELDS 350 }; 351 \end{cfa} 352 \caption{Exception Type Transformation} 353 \label{f:ExceptionTypeTransformation} 354 \end{figure} 355 356 The integration between exceptions and the virtual system is a bit more 357 complex simply because of the nature of the virtual system prototype. 358 The primary issue is that the virtual system has no way to detect when it 359 should generate any of its internal types and data. This is handled by 360 the exception code, which tells the virtual system when to generate 361 its components. 362 363 All types associated with a virtual type, 364 the types of the virtual table and the type id, 365 are generated when the virtual type (the exception) is first found. 366 The type id (the instance) is generated with the exception if it is 367 a monomorphic type. 368 However if the exception is polymorphic then a different type id has to 369 be generated for every instance. In this case generation is delayed 370 until a virtual table is created. 371 % There are actually some problems with this, which is why it is not used 372 % for monomorphic types. 373 When a virtual table is created and initialized two functions are created 374 to fill in the list of virtual members. 375 The first is a copy function which adapts the exception's copy constructor 376 to work with pointers, avoiding some issues with the current copy constructor 377 interface. 378 Second is the msg function, which returns a C-string with the type's name, 379 including any polymorphic parameters. 303 380 304 381 \section{Unwinding}
Note: See TracChangeset
for help on using the changeset viewer.