1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5
6#ifndef _ARRAY_H_
7#define _ARRAY_H_
8
9#define MAX_RANK 32 // If you make this bigger, you need to make MAX_CLASSNAME_LENGTH bigger too.
10 // if you have an 32 dim array with at least 2 elements in each dim that
11 // takes up 4Gig!!! Thus this is a reasonable maximum.
12// (Note: at the time of the above comment, the rank was 32, and
13// MAX_CLASSNAME_LENGTH was 256. I'm now changing MAX_CLASSNAME_LENGTH
14// to 1024, but not changing MAX_RANK.)
15
16class MethodTable;
17
18
19#ifndef FEATURE_ARRAYSTUB_AS_IL
20
21//======================================================================
22// The following structures double as hash keys for the ArrayStubCache.
23// Thus, it's imperative that there be no
24// unused "pad" fields that contain unstable values.
25#include <pshpack1.h>
26
27
28// Specifies one index spec. This is used mostly to get the argument
29// location done early when we still have a signature to work with.
30struct ArrayOpIndexSpec
31{
32 UINT32 m_idxloc; //if (m_fref) offset in ArgumentReg else base-frame offset into stack.
33 UINT32 m_lboundofs; //offset within array of lowerbound
34 UINT32 m_lengthofs; //offset within array of lengths
35};
36
37
38struct ArrayOpScript
39{
40 enum
41 {
42 LOAD = 0,
43 STORE = 1,
44 LOADADDR = 2,
45 };
46
47
48 // FLAGS
49 enum
50 {
51 ISFPUTYPE = 0x01,
52 NEEDSWRITEBARRIER = 0x02,
53 HASRETVALBUFFER = 0x04,
54 NEEDSTYPECHECK = 0x10,
55 };
56
57 //
58 // these args have been reordered for better packing..
59 //
60
61 BYTE m_rank; // # of ArrayOpIndexSpec's
62 BYTE m_fHasLowerBounds; // if FALSE, all lowerbounds are 0
63 BYTE m_flags;
64 BYTE m_signed; // whether to sign-extend or zero-extend (for short types)
65
66 BYTE m_op; // STORE/LOAD/LOADADDR
67 BYTE m_pad1;
68
69 UINT16 m_fRetBufLoc; // if HASRETVALBUFFER, stack offset or argreg offset of retbuf ptr
70 UINT16 m_fValLoc; // for STORES, stack offset or argreg offset of value
71
72 UINT16 m_cbretpop; // how much to pop
73
74 UINT32 m_elemsize; // size in bytes of element.
75 UINT m_ofsoffirst; // offset of first element
76 INT m_typeParamOffs; // offset of type param
77 CGCDesc* m_gcDesc; // layout of GC stuff (0 if not needed)
78
79 // Array of ArrayOpIndexSpec's follow (one for each dimension).
80
81 const ArrayOpIndexSpec *GetArrayOpIndexSpecs() const
82 {
83 LIMITED_METHOD_CONTRACT;
84
85 return (const ArrayOpIndexSpec *)(1+ this);
86 }
87
88 UINT Length() const
89 {
90 LIMITED_METHOD_CONTRACT;
91
92 return sizeof(*this) + m_rank * sizeof(ArrayOpIndexSpec);
93 }
94
95};
96
97#include <poppack.h>
98//======================================================================
99
100#endif // FEATURE_ARRAYSTUB_AS_IL
101
102
103Stub *GenerateArrayOpStub(ArrayMethodDesc* pMD);
104
105
106
107BOOL IsImplicitInterfaceOfSZArray(MethodTable *pIntfMT);
108BOOL ArraySupportsBizarreInterface(ArrayTypeDesc *pArrayTypeDesc, MethodTable *pInterfaceMT);
109
110MethodDesc* GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod(MethodDesc *pItfcMeth, TypeHandle theT);
111
112#endif// _ARRAY_H_
113
114