C# Class 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.
Inheritance: InvokeInstruction
Afficher le fichier Open project: tgiphil/MOSA-Project

Méthodes publiques

Méthode Description
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.

Method Details

Decode() public méthode

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.
Résultat void

NewobjInstruction() public méthode

Initializes a new instance of the NewobjInstruction class.
public NewobjInstruction ( OpCode opcode ) : System.Diagnostics
opcode OpCode The opcode.
Résultat System.Diagnostics

Resolve() public méthode

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.
Résultat void