public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ReadyToRunCodegenNodeFactory r2rFactory  = (ReadyToRunCodegenNodeFactory)factory;
            ObjectDataSignatureBuilder   dataBuilder = new ObjectDataSignatureBuilder();

            if (!relocsOnly)
            {
                dataBuilder.AddSymbol(this);

                switch (_runtimeLookupKind)
                {
                case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_CLASSPARAM:
                    dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_TypeDictionaryLookup);
                    break;

                case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_METHODPARAM:
                    dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_MethodDictionaryLookup);
                    break;

                case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_THISOBJ:
                    dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_ThisObjDictionaryLookup);
                    dataBuilder.EmitTypeSignature(_methodContext.ContextType, _signatureContext);
                    break;

                default:
                    throw new NotImplementedException();
                }

                dataBuilder.EmitByte((byte)_fixupKind);
                if (_typeArgument != null)
                {
                    dataBuilder.EmitTypeSignature(_typeArgument, _signatureContext);
                }
                else if (_methodArgument != null)
                {
                    dataBuilder.EmitMethodSignature(
                        method: _methodArgument.Method,
                        constrainedType: null,
                        methodToken: _methodArgument.Token,
                        enforceDefEncoding: false,
                        context: _signatureContext,
                        isUnboxingStub: false,
                        isInstantiatingStub: true);
                }
                else if (_fieldArgument != null)
                {
                    dataBuilder.EmitFieldSignature(_fieldArgument, _signatureContext);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(dataBuilder.ToObjectData());
        }
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ObjectDataSignatureBuilder builder = new ObjectDataSignatureBuilder();

            builder.AddSymbol(this);

            string[] supportedAndUnsupportedSplit = _instructionSetsSupport.Split(',');

            string[] instructionSetsSupported             = supportedAndUnsupportedSplit[0] == "" ? Array.Empty <string>() : supportedAndUnsupportedSplit[0].Split('+');
            string[] instructionSetsExplicitlyUnsupported = supportedAndUnsupportedSplit[1] == "" ? Array.Empty <string>() : supportedAndUnsupportedSplit[1].Split('-');

            // This type of fixup is not dependent on module
            builder.EmitByte(checked ((byte)ReadyToRunFixupKind.Check_InstructionSetSupport));

            builder.EmitUInt((uint)(instructionSetsSupported.Length + instructionSetsExplicitlyUnsupported.Length));

            foreach (string instructionSetString in instructionSetsSupported)
            {
                uint valueToEmit = (((uint)InstructionSetFromString(instructionSetString)) << 1) | 1;
                builder.EmitUInt(valueToEmit);
            }

            foreach (string instructionSetString in instructionSetsExplicitlyUnsupported)
            {
                uint valueToEmit = (((uint)InstructionSetFromString(instructionSetString)) << 1) | 0;
                builder.EmitUInt(valueToEmit);
            }

            return(builder.ToObjectData());
        }
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ObjectDataSignatureBuilder builder = new ObjectDataSignatureBuilder();

            builder.AddSymbol(this);
            builder.EmitByte((byte)ReadyToRunFixupKind.Helper);
            builder.EmitUInt((uint)_helperID);
            return(builder.ToObjectData());
        }
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ReadyToRunCodegenNodeFactory r2rFactory  = (ReadyToRunCodegenNodeFactory)factory;
            ObjectDataSignatureBuilder   dataBuilder = new ObjectDataSignatureBuilder();

            dataBuilder.AddSymbol(this);

            dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_NewArray);
            dataBuilder.EmitTypeSignature(_arrayType, _signatureContext);

            return(dataBuilder.ToObjectData());
        }
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ReadyToRunCodegenNodeFactory r2rFactory  = (ReadyToRunCodegenNodeFactory)factory;
            ObjectDataSignatureBuilder   dataBuilder = new ObjectDataSignatureBuilder();

            dataBuilder.AddSymbol(this);

            // TODO: module override for external module strings
            dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_StringHandle);
            dataBuilder.EmitUInt(_token.TokenRid);

            return(dataBuilder.ToObjectData());
        }
Exemple #6
0
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ReadyToRunCodegenNodeFactory r2rFactory  = (ReadyToRunCodegenNodeFactory)factory;
            ObjectDataSignatureBuilder   dataBuilder = new ObjectDataSignatureBuilder();

            if (!relocsOnly)
            {
                dataBuilder.AddSymbol(this);

                dataBuilder.EmitByte((byte)_fixupKind);
                dataBuilder.EmitFieldSignature(_fieldDesc, _signatureContext);
            }

            return(dataBuilder.ToObjectData());
        }
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            if (relocsOnly)
            {
                // Method fixup signature doesn't contain any direct relocs
                return(new ObjectData(data: Array.Empty <byte>(), relocs: null, alignment: 0, definedSymbols: null));
            }

            ReadyToRunCodegenNodeFactory r2rFactory  = (ReadyToRunCodegenNodeFactory)factory;
            ObjectDataSignatureBuilder   dataBuilder = new ObjectDataSignatureBuilder();

            dataBuilder.AddSymbol(this);

            dataBuilder.EmitByte((byte)_fixupKind);
            dataBuilder.EmitMethodSignature(_methodDesc, _constrainedType, _methodToken, enforceDefEncoding: false,
                                            _signatureContext, _isUnboxingStub, _isInstantiatingStub);

            return(dataBuilder.ToObjectData());
        }
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            ObjectDataSignatureBuilder builder = new ObjectDataSignatureBuilder();

            builder.AddSymbol(this);

            if (!relocsOnly)
            {
                builder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_DelegateCtor);
                builder.EmitMethodSignature(
                    _targetMethod.Method,
                    constrainedType: null,
                    methodToken: _methodToken,
                    enforceDefEncoding: false,
                    _signatureContext,
                    isUnboxingStub: false,
                    isInstantiatingStub: false);
                builder.EmitTypeSignature(_delegateType, _signatureContext);
            }

            return(builder.ToObjectData());
        }
Exemple #9
0
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            if (relocsOnly)
            {
                return(new ObjectData(Array.Empty <byte>(), null, 1, null));
            }

            ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory;

            // Determine the need for module override
            EcmaModule targetModule;

            if (_methodArgument != null)
            {
                targetModule = _methodArgument.Token.Module;
            }
            else if (_typeArgument != null)
            {
                targetModule = _signatureContext.GetTargetModule(_typeArgument);
            }
            else if (_fieldArgument != null)
            {
                targetModule = _signatureContext.GetTargetModule(_fieldArgument);
            }
            else
            {
                throw new NotImplementedException();
            }

            ReadyToRunFixupKind fixupToEmit;
            TypeDesc            contextTypeToEmit = null;

            switch (_runtimeLookupKind)
            {
            case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_CLASSPARAM:
                fixupToEmit = ReadyToRunFixupKind.READYTORUN_FIXUP_TypeDictionaryLookup;
                break;

            case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_METHODPARAM:
                fixupToEmit = ReadyToRunFixupKind.READYTORUN_FIXUP_MethodDictionaryLookup;
                break;

            case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_THISOBJ:
                fixupToEmit       = ReadyToRunFixupKind.READYTORUN_FIXUP_ThisObjDictionaryLookup;
                contextTypeToEmit = _methodContext.ContextType;
                break;

            default:
                throw new NotImplementedException();
            }

            ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder();

            dataBuilder.AddSymbol(this);

            SignatureContext innerContext = dataBuilder.EmitFixup(r2rFactory, fixupToEmit, targetModule, _signatureContext);

            if (contextTypeToEmit != null)
            {
                dataBuilder.EmitTypeSignature(contextTypeToEmit, innerContext);
            }

            dataBuilder.EmitByte((byte)_fixupKind);
            if (_methodArgument != null)
            {
                dataBuilder.EmitMethodSignature(
                    method: _methodArgument.Method,
                    constrainedType: _typeArgument,
                    methodToken: _methodArgument.Token,
                    enforceDefEncoding: false,
                    context: innerContext,
                    isUnboxingStub: false,
                    isInstantiatingStub: true);
            }
            else if (_typeArgument != null)
            {
                dataBuilder.EmitTypeSignature(_typeArgument, innerContext);
            }
            else if (_fieldArgument != null)
            {
                dataBuilder.EmitFieldSignature(_fieldArgument, innerContext);
            }
            else
            {
                throw new NotImplementedException();
            }

            return(dataBuilder.ToObjectData());
        }