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

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

                EcmaModule       targetModule = factory.SignatureContext.GetTargetModule(_fieldDesc);
                SignatureContext innerContext = dataBuilder.EmitFixup(factory, _fixupKind, targetModule, factory.SignatureContext);

                if (_fixupKind == ReadyToRunFixupKind.Verify_FieldOffset)
                {
                    TypeDesc baseType = _fieldDesc.OwningType.BaseType;
                    if ((_fieldDesc.OwningType.BaseType != null) && !_fieldDesc.IsStatic && !_fieldDesc.OwningType.IsValueType)
                    {
                        dataBuilder.EmitUInt((uint)_fieldDesc.OwningType.FieldBaseOffset().AsInt);
                    }
                    else
                    {
                        dataBuilder.EmitUInt(0);
                    }
                }

                if ((_fixupKind == ReadyToRunFixupKind.Check_FieldOffset) ||
                    (_fixupKind == ReadyToRunFixupKind.Verify_FieldOffset))
                {
                    dataBuilder.EmitUInt((uint)_fieldDesc.Offset.AsInt);
                }

                dataBuilder.EmitFieldSignature(_fieldDesc, innerContext);
            }

            return(dataBuilder.ToObjectData());
        }
        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());
        }
Exemple #3
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)
        {
            ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder();

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

                EcmaModule       targetModule = _signatureContext.GetTargetModule(_fieldDesc);
                SignatureContext innerContext = dataBuilder.EmitFixup(factory, _fixupKind, targetModule, _signatureContext);

                dataBuilder.EmitFieldSignature(_fieldDesc, innerContext);
            }

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

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

                IEcmaModule      targetModule = _fieldWithToken.Token.Module;
                SignatureContext innerContext = dataBuilder.EmitFixup(factory, _fixupKind, targetModule, factory.SignatureContext);
                uint             baseOffset   = 0;
                uint             fieldOffset  = (uint)_fieldWithToken.Field.Offset.AsInt;

                if (_fixupKind == ReadyToRunFixupKind.Verify_FieldOffset)
                {
                    TypeDesc baseType = _fieldWithToken.Field.OwningType.BaseType;
                    if ((_fieldWithToken.Field.OwningType.BaseType != null) &&
                        !_fieldWithToken.Field.IsStatic &&
                        !_fieldWithToken.Field.OwningType.IsValueType)
                    {
                        MetadataType owningType = (MetadataType)_fieldWithToken.Field.OwningType;
                        baseOffset = (uint)owningType.FieldBaseOffset().AsInt;
                        if (factory.CompilationModuleGroup.NeedsAlignmentBetweenBaseTypeAndDerived((MetadataType)baseType, owningType))
                        {
                            fieldOffset -= baseOffset;
                            baseOffset   = 0;
                        }
                    }
                    dataBuilder.EmitUInt(baseOffset);
                }

                if ((_fixupKind == ReadyToRunFixupKind.Check_FieldOffset) ||
                    (_fixupKind == ReadyToRunFixupKind.Verify_FieldOffset))
                {
                    dataBuilder.EmitUInt(fieldOffset);
                }

                dataBuilder.EmitFieldSignature(_fieldWithToken, innerContext);
            }

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

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

                EcmaModule       targetModule = factory.SignatureContext.GetTargetModule(_fieldDesc);
                SignatureContext innerContext = dataBuilder.EmitFixup(factory, _fixupKind, targetModule, factory.SignatureContext);

                if (_fixupKind == ReadyToRunFixupKind.Check_FieldOffset)
                {
                    dataBuilder.EmitInt(_fieldDesc.Offset.AsInt);
                }

                dataBuilder.EmitFieldSignature(_fieldDesc, innerContext);
            }

            return(dataBuilder.ToObjectData());
        }
Exemple #7
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());
        }