C# Класс Mosa.Compiler.Framework.CIL.NewobjInstruction

Intermediate representation of the newobj IL instruction.
Actually this is a waste. Newobj is a compound of at least three instructions: - pop ctor-args - push type - push type-size - call allocator.new - dup - push ctor-args - call ctor Note that processing this instruction does require extensive call stack rewriting in order to insert the this reference in front of all other ctor arguments, even though it is pushed *after* calling allocator new as seen above. Additionally note that after executing the ctor call another reference to this is on the stack in order to be able to use the constructed object. Note that this is very similar to arrays (newarr), except there's no ctor to call. I don't want to have runtime helpers for newarr and newobj, so we unite both by using a common allocator, which receives the type and memory size as parameters. This also fixes string issues for us, which vary in size and thus can't be allocated by a plain newobj. These details are automatically processed by the Expand function, which expands this highlevel opcode into its parts as described above. The exception is that Expand is not stack based anymore and uses virtual registers to implement two calls: - this-vreg = allocator-new(type-vreg, type-size-vreg) - ctor(this-vreg[, args]) Those calls are ultimately processed by further expansion and inlining, except that allocator-new is a kernel call and can't be inlined - even by the jit. The expansion essentially adds a dependency to mosacor, which provides the allocator and gc.
Наследование: InvokeInstruction
Показать файл Открыть проект

Открытые методы

Метод Описание
Decode ( InstructionNode context, IInstructionDecoder decoder ) : void

Decodes the specified instruction.

NewobjInstruction ( OpCode opcode ) : System.Diagnostics

Initializes a new instance of the NewobjInstruction class.

Resolve ( Context ctx, BaseMethodCompiler compiler ) : void

Validates the instruction operands and creates a matching variable for the result.

Описание методов

Decode() публичный Метод

Decodes the specified instruction.
public Decode ( InstructionNode context, IInstructionDecoder decoder ) : void
context InstructionNode The context.
decoder IInstructionDecoder The instruction decoder, which holds the code stream.
Результат void

NewobjInstruction() публичный Метод

Initializes a new instance of the NewobjInstruction class.
public NewobjInstruction ( OpCode opcode ) : System.Diagnostics
opcode OpCode The opcode.
Результат System.Diagnostics

Resolve() публичный Метод

Validates the instruction operands and creates a matching variable for the result.
public Resolve ( Context ctx, BaseMethodCompiler compiler ) : void
ctx Context The context.
compiler BaseMethodCompiler The compiler.
Результат void