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
파일 보기 프로젝트 열기: tgiphil/MOSA-Project

공개 메소드들

메소드 설명
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