Rotor实现中用到的Macro(摘自Shared Source CLI Essentials)

本文详细介绍了CLR中的各种宏定义,包括用于断言、日志记录、内存操作等的通用宏,以及针对执行引擎和JIT编译器特性的专用宏。此外还探讨了平台相关的宏定义,帮助开发者更好地理解CLR内部工作原理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

General Macros

ASSERTE

, this is used to define facilities called out for individual configurability when tracing.

, these macros dereference a pointer and fetch a value, even if the pointer is not a naturally-aligned pointer. Natural alignment is defined as ((UINT_PTR)p & (sizeof(p)-1)) == 0.

, this is used in debug-enabled builds to issue a logging message. See also DEFINE_LOG_FACILITY.

libfoo.dylib on Mac OS X, libfoo.so on FreeBSD, and foo.dll contains all opcode definitions for Rotor, and is shared by the C# compiler, the assembler and disassembler, and the execution engine.

should be changed to a matching ASSERT. To find regions of code that are platform-specific, use your favorite search or indexing utility to find these macros .

, these store a value into a pointer, even if the pointer is not naturally aligned. For platforms that automatically handle mis-aligned memory references, these macros expand to a simple dereferenced assignment. See also GET_UNALIGNED.

, these are used to simplify writing code to run on both big-endian and little-endian processors. They are no-ops on little-endian platforms, but byte-swapped on big-endian platforms. Given a value composed of 16, 32, or 64 bits in little-endian format, they return the value in the native format.

 

Execution Engine Macros

, these macros bracket code in which garbage collection is forbidden. They are activated in debug-enabled builds only.

code.

family of macros with additional code that maintains internal execution engine data structures. In particular, these protect the integrity of the frame chain. They are defined in clr/src/vm/exceptmacros.h.

supports both catch and finally clauses.) It is defined in clr/src/vm/exceptmacros.h.

, are used to declare and implement FCalls. Platform-to-platform differences in FCall calling conventions are encapsulated inside these macros.

would be used to throw exceptions if a helper frame were erected.) It is defined in clr/src/vm/frames.h.

are visible to the garbage collector, and the objects that they reference can be promoted safely. These macros are defined in clr/src/vm/frames.h.

are used to erect a helper frame within an FCall implementation. These helper frames must exist when an FCall wishes to call other parts of the execution engine that might trigger garbage collection or cause nonlocal changes. Simple FCalls do not need helper frames. Some flavors of HELPER_METHOD_FRAME expose a simplified version of GC_PROTECT, to reduce the number of frames pushed in the FCall.

, is used to mark code blocks that can throw exceptions. This is used only in debug-enabled builds.

 

JIT Compiler Macros

and is augmented by platform-specific redefinition files that can be found in subdirectories named after their processor targets:

also contains macros used to emit code for manipulating the stack and calling helper functions:

, saves the a map of the evaluation stack and associates it with the current IL offset so that the garbage collector will be able to find roots on the stack. This macro is used before calls to JIT helper functions that may trigger garbage collection.

 

PAL & Platform Macros

contains the API definitions for the PAL, as well as these macros, which result in calls against the PAL's exception-handling mechanism.

macros in that it doesn't take an expression as an argument. It is a printf-style logger plus an optional debug breakpoint. This is a no-op in the "free" build.



Trackback: http://tb.blog.youkuaiyun.com/TrackBack.aspx?PostId=1531737


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值