blob: d1538a4a9d6b7f60795100e06d6a60a87305fc6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Internal.TypeSystem;
using Internal.Runtime;
namespace ILCompiler.DependencyAnalysis
{
internal sealed class CanonicalDefinitionEETypeNode : EETypeNode
{
public CanonicalDefinitionEETypeNode(NodeFactory factory, TypeDesc type) : base(factory, type)
{
Debug.Assert(type.IsCanonicalDefinitionType(CanonicalFormKind.Any));
}
public override bool ShouldSkipEmittingObjectNode(NodeFactory factory) => false;
public override bool StaticDependenciesAreComputed => true;
public override bool IsShareable => true;
protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFactory factory) => null;
protected override int GCDescSize => 0;
protected internal override void ComputeOptionalEETypeFields(NodeFactory factory, bool relocsOnly)
{
if (_type.IsCanonicalDefinitionType(CanonicalFormKind.Universal))
{
// Value types should have at least 1 byte of size to avoid zero-length structures
// Add pointer-size to the number of instance field bytes to consistently represents the boxed size.
uint numInstanceFieldBytes = 1 + (uint)factory.Target.PointerSize;
uint valueTypeFieldPadding = (uint)(MinimumObjectSize - factory.Target.PointerSize) - numInstanceFieldBytes;
uint valueTypeFieldPaddingEncoded = EETypeBuilderHelpers.ComputeValueTypeFieldPaddingFieldValue(valueTypeFieldPadding, 1, _type.Context.Target.PointerSize);
Debug.Assert(valueTypeFieldPaddingEncoded != 0);
_optionalFieldsBuilder.SetFieldValue(EETypeOptionalFieldTag.ValueTypeFieldPadding, valueTypeFieldPaddingEncoded);
}
}
// Canonical definition types will have their base size set to the minimum
protected override int BaseSize => MinimumObjectSize;
public override int ClassCode => -1851030036;
}
}
|