Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-10-01 00:47:24 +0300
committerScott Mosier <smosier@microsoft.com>2015-10-01 00:47:24 +0300
commitad0323ab91a7b1469b42ca5457ddd631b94294fe (patch)
tree88fae57e1ec3aae90288463dc07e58f7aebc1de8 /src/Native/Runtime/ObjectLayout.cpp
parent6763d16387778f126ec510c0421783952602f8f7 (diff)
Initial population of CoreRT Runtime files.
Diffstat (limited to 'src/Native/Runtime/ObjectLayout.cpp')
-rw-r--r--src/Native/Runtime/ObjectLayout.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/Native/Runtime/ObjectLayout.cpp b/src/Native/Runtime/ObjectLayout.cpp
new file mode 100644
index 000000000..d2e988ed2
--- /dev/null
+++ b/src/Native/Runtime/ObjectLayout.cpp
@@ -0,0 +1,78 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+//
+// Implementations of functions dealing with object layout related types.
+//
+#include "common.h"
+#ifdef DACCESS_COMPILE
+#include "gcrhenv.h"
+#endif // DACCESS_COMPILE
+
+#ifndef DACCESS_COMPILE
+#include "commontypes.h"
+#include "daccess.h"
+#include "commonmacros.h"
+#include "assert.h"
+#include "redhawkwarnings.h"
+#include "palredhawkcommon.h"
+#include "palredhawk.h"
+#include "targetptrs.h"
+#include "eetype.h"
+#include "objectlayout.h"
+#endif // !DACCESS_COMPILE
+
+#ifndef DACCESS_COMPILE
+void Object::InitEEType(EEType * pEEType)
+{
+ ASSERT(NULL == m_pEEType);
+ m_pEEType = pEEType;
+}
+#endif
+
+UInt32 Array::GetArrayLength()
+{
+ return m_Length;
+}
+
+void* Array::GetArrayData()
+{
+ UInt8* pData = (UInt8*)this;
+ pData += (get_EEType()->get_BaseSize() - sizeof(ObjHeader));
+ return pData;
+}
+
+#ifndef DACCESS_COMPILE
+void Array::InitArrayLength(UInt32 length)
+{
+ ASSERT(NULL == m_Length);
+ m_Length = length;
+}
+
+void ObjHeader::SetBit(UInt32 uBit)
+{
+ PalInterlockedOr(&m_uSyncBlockValue, uBit);
+}
+
+void ObjHeader::ClrBit(UInt32 uBit)
+{
+ PalInterlockedAnd(&m_uSyncBlockValue, ~uBit);
+}
+
+size_t Object::GetSize()
+{
+ EEType * pEEType = get_EEType();
+
+ // strings have component size2, all other non-arrays should have 0
+ ASSERT(( pEEType->get_ComponentSize() <= 2) || pEEType->IsArray());
+
+ size_t s = pEEType->get_BaseSize();
+ UInt16 componentSize = pEEType->get_ComponentSize();
+ if (componentSize > 0)
+ s += ((Array*)this)->GetArrayLength() * componentSize;
+ return s;
+}
+
+#endif