Hello,
I tried to confirm that two different heap allocation calls were being made,
i.e., one for __gc and one for __nogc. However, the addresses of the calls
(as seen in disassembly) are not what I expected. As you can see the four
calls in tmain are all to the same routine, while the one in the class
constructor is different. Does anybody know what's going on here?
Thanks
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
__value class VClass
{
public:
VClass()
: p(new int(0)) // call F9BB56E3
{ }
int* p;
};
int _tmain()
{
int* p1 = new int(0); // call dword ptr ds:[00965A00h]
int __nogc* p2 = __nogc new int(0); // call dword ptr ds:[00965A00h]
Int32* p3 = new Int32(0); // call dword ptr ds:[00965A00h]
Int32 __gc* p4 = new Int32(0); // call dword ptr ds:[00965A00h]
VClass v;
return 0;
} 1 1717
"Ian Lazarus" <no****@nowhere.com> wrote in message
news:Sa*******************@bgtnsc05-news.ops.worldnet.att.net... Hello,
I tried to confirm that two different heap allocation calls were being
made, i.e., one for __gc and one for __nogc. However, the addresses of the calls (as seen in disassembly) are not what I expected. As you can see the four calls in tmain are all to the same routine, while the one in the class constructor is different. Does anybody know what's going on here?
This is a guess, and I'd be interested to hear a more definitive answer.
First I used Reflector to have a look at what's going on:
public static unsafe int modopt(CallConvCdecl) main()
{
VClass class1;
int num4 = <Module>.new(4);
int* numPtr2 = (num4 == 0) ? null : ((int*) num4);
int num3 = <Module>.new(4);
int* numPtr1 = (num3 == 0) ? null : ((int*) num3);
int num2 = <Module>.new(4);
ref int numRef2 = (num2 == 0) ? 0 : num2;
int num1 = <Module>.new(4);
ref int numRef1 = (num1 == 0) ? 0 : num1;
class1 = new VClass();
class1 = new VClass();
return 0;
}
[PreserveSig, MethodImpl(MethodImplOptions.Unmanaged,
MethodCodeType=MethodCodeType.Native), SuppressUnmanagedCodeSecurity]
public static unsafe void* modopt(CallConvCdecl) @new(uint);
[StructLayout(LayoutKind.Sequential)]
internal struct VClass
{
public unsafe int* p;
public VClass();
}
public unsafe VClass()
{
int num2;
int num1 = <Module>.new(4);
if (num1 != 0)
{
num1[0] = 0;
num2 = num1;
}
else
{
num2 = 0;
}
this.p = (int*) num2;
}
I think therefore that because main() and new() have the same calling
convention (cdecl), the call can be made directly. However, when calling
from VClass (which presumably uses something different, stdcall maybe?), a
thunk has to be used to change between the calling conventions.
Stu Thanks
#include "stdafx.h" #using <mscorlib.dll> using namespace System; __value class VClass { public: VClass() : p(new int(0)) // call F9BB56E3 { } int* p; };
int _tmain() { int* p1 = new int(0); // call dword ptr ds:[00965A00h] int __nogc* p2 = __nogc new int(0); // call dword ptr ds:[00965A00h] Int32* p3 = new Int32(0); // call dword ptr ds:[00965A00h] Int32 __gc* p4 = new Int32(0); // call dword ptr ds:[00965A00h] VClass v;
return 0; }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: NigelW |
last post by:
Clarification needed please.
If I compile a C++ program with the /clr option inpsection
of the resulting assembly with ILDASM shows MSIL even for
methods in classes for which I have not...
|
by: Edward Diener |
last post by:
Why is it impossible to have a __value class instance variable in a __nogc
class when it is possible to have a built-in type instance variable in a
__nogc class ?
__value class X { int a; };...
|
by: Edward Diener |
last post by:
I want to share a __nogc classes between different assemblies. For __gc
classes, one only needs to declare the class public in order to be able to
do this. Is there a way to share a __nogc class so...
|
by: Gueverson |
last post by:
Hello, I am new in programming smart cards and I got an error in compiling that I cannnot manage to get rid of.
There is a function in the PCSC that is called "ScardEstablishContext"
I am calling...
|
by: Bern McCarty |
last post by:
I am using MEC++ in VC 7.1. I had a method on a __gc object that looked
like this:
__property System::UInt32 get_MyProperty(void)
{
System::Byte __pin * pinBytes = &m_byteArray; // entire...
|
by: Lupina |
last post by:
#pragma once
using namespace System;
__gc class CWords
{
public:
|
by: Chris |
last post by:
Hi,
if have a __gc class with a datamember of type : a pointer to a DateTime,
but I get a compiler error :
__gc class Employee
{
public:
DateTime * m_hiringDate; ==> error : cannot...
|
by: Bae,Hyun-jik |
last post by:
Is member variable alignment in __gc class same to that of __nogc class?
For example, does this code below make problems?(Please ignore other errors
such as wrong grammar ,etc.)
Please reply....
|
by: Achim Domma (Procoders) |
last post by:
Hi,
I still try to implement a .Net wrapper to handel AVI Files. I'm unsing
managed C++ with VStudio 2003. The structure of my classes looks like this:
class AudioStream {
...
}
class...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |