Hi,
I am writing a mixed mode application, I have a mixed mode Assembly manipulating a managed byte[] array, to access this array in unmanaged code I '__pin' the array, As I understand, pining an object guarantee that it will not be collected by the GC ( by increasing it's refcount or so ), Taking that in mind, looking at the code generated by the compiler I can't see anything taking care of the GC refcount... following is the pinned variable with the corresponding dis-assembly section:
*************** *** Mixed mode C++ code line *************** ***
BYTE __pin *pbtArray = &btArray[0];
*************** ***** The dis-assembly *************** ********
00000019 cmp dword ptr [esi+4],0 // makes sure that NULL != &btArray[0]
0000001d ja 00000026 // if it is not NULL go three lines bellow
0000001f xor ecx,ecx
00000021 call 7227F90B // call some exception handling procedure...
00000026 lea eax,[esi+8] // get the address of &btArray[0] to eax
00000029 mov dword ptr [ebp-14h],eax // pbtArray = content of eax
*************** *************** *************** ***********
Why there is no GC manipulation code? isn't it needed?
The original code:
*************** *************** *************** ***********
virtual int NotArray(System ::Byte btArray __gc[])
{
int i = 0;
BYTE __pin *pbtArray = &btArray[0];
for(i; i < btArray->Length; i++)
pbtArray[i] <<= 1;
return 0;
}
Nadav http://www.ddevel.com 3 1076
Look at the IL/meta data generated. It will have a pinned modifier on the
storage location. That is sufficient for the GC to know how to handle this.
Ronald Laeremans
Visual C++ team
"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message
news:A2******** *************** ***********@mic rosoft.com... Hi,
I am writing a mixed mode application, I have a mixed mode Assembly manipulating a managed byte[] array, to access this array in unmanaged code I '__pin' the array, As I understand, pining an object guarantee that it will not be collected by the GC ( by increasing it's refcount or so ), Taking that in mind, looking at the code generated by the compiler I can't see anything taking care of the GC refcount... following is the pinned variable with the corresponding dis-assembly section:
*************** *** Mixed mode C++ code line *************** *** BYTE __pin *pbtArray = &btArray[0];
*************** ***** The dis-assembly *************** ******** 00000019 cmp dword ptr [esi+4],0 // makes sure that NULL != &btArray[0] 0000001d ja 00000026 // if it is not NULL go three lines bellow 0000001f xor ecx,ecx 00000021 call 7227F90B // call some exception handling procedure... 00000026 lea eax,[esi+8] // get the address of &btArray[0] to eax 00000029 mov dword ptr [ebp-14h],eax // pbtArray = content of eax *************** *************** *************** *********** Why there is no GC manipulation code? isn't it needed?
The original code: *************** *************** *************** *********** virtual int NotArray(System ::Byte btArray __gc[]) { int i = 0; BYTE __pin *pbtArray = &btArray[0]; for(i; i < btArray->Length; i++) pbtArray[i] <<= 1; return 0; }
Nadav http://www.ddevel.com
Hi Ronald, Thanks for your immediate responce, Taking in mind what you have said, Still there should be some code that 'tells' the GC to 'read' this meta-data, where is this code? how does the GC know to use the pinned variable meta-data? any pointers, samples or any useful information would be appriciated...
Nadav http://www.ddevel.com
"Ronald Laeremans [MSFT]" wrote: Look at the IL/meta data generated. It will have a pinned modifier on the storage location. That is sufficient for the GC to know how to handle this.
Ronald Laeremans Visual C++ team
"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com... Hi,
I am writing a mixed mode application, I have a mixed mode Assembly manipulating a managed byte[] array, to access this array in unmanaged code I '__pin' the array, As I understand, pining an object guarantee that it will not be collected by the GC ( by increasing it's refcount or so ), Taking that in mind, looking at the code generated by the compiler I can't see anything taking care of the GC refcount... following is the pinned variable with the corresponding dis-assembly section:
*************** *** Mixed mode C++ code line *************** *** BYTE __pin *pbtArray = &btArray[0];
*************** ***** The dis-assembly *************** ******** 00000019 cmp dword ptr [esi+4],0 // makes sure that NULL != &btArray[0] 0000001d ja 00000026 // if it is not NULL go three lines bellow 0000001f xor ecx,ecx 00000021 call 7227F90B // call some exception handling procedure... 00000026 lea eax,[esi+8] // get the address of &btArray[0] to eax 00000029 mov dword ptr [ebp-14h],eax // pbtArray = content of eax *************** *************** *************** *********** Why there is no GC manipulation code? isn't it needed?
The original code: *************** *************** *************** *********** virtual int NotArray(System ::Byte btArray __gc[]) { int i = 0; BYTE __pin *pbtArray = &btArray[0]; for(i; i < btArray->Length; i++) pbtArray[i] <<= 1; return 0; }
Nadav http://www.ddevel.com
It is in the runtime code for the garbage collector itself. It doesn't need
to be in the generated assembly for your program. The code to do the garbage
collection itself likewise isn't emitted as part of your program. The GC
code uses the meta data directly.
Ronald
"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message
news:90******** *************** ***********@mic rosoft.com... Hi Ronald, Thanks for your immediate responce, Taking in mind what you have said, Still there should be some code that 'tells' the GC to 'read' this meta-data, where is this code? how does the GC know to use the pinned variable meta-data? any pointers, samples or any useful information would be appriciated...
Nadav http://www.ddevel.com
"Ronald Laeremans [MSFT]" wrote:
Look at the IL/meta data generated. It will have a pinned modifier on the storage location. That is sufficient for the GC to know how to handle this.
Ronald Laeremans Visual C++ team
"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message news:A2******** *************** ***********@mic rosoft.com... > Hi, > > I am writing a mixed mode application, I have a mixed mode Assembly > manipulating a managed byte[] array, to access this array in unmanaged > code I '__pin' the array, As I understand, pining an object guarantee > that > it will not be collected by the GC ( by increasing it's refcount or > so ), > Taking that in mind, looking at the code generated by the compiler I > can't > see anything taking care of the GC refcount... following is the pinned > variable with the corresponding dis-assembly section: > > *************** *** Mixed mode C++ code line *************** *** > BYTE __pin *pbtArray = &btArray[0]; > > *************** ***** The dis-assembly *************** ******** > 00000019 cmp dword ptr [esi+4],0 // makes sure that NULL != > &btArray[0] > 0000001d ja 00000026 // if it is not NULL go > three > lines bellow > 0000001f xor ecx,ecx > 00000021 call 7227F90B // call some exception > handling procedure... > 00000026 lea eax,[esi+8] // get the address of > &btArray[0] to eax > 00000029 mov dword ptr [ebp-14h],eax // pbtArray = content of > eax > *************** *************** *************** *********** > Why there is no GC manipulation code? isn't it needed? > > The original code: > *************** *************** *************** *********** > virtual int NotArray(System ::Byte btArray __gc[]) > { > int i = 0; > BYTE __pin *pbtArray = &btArray[0]; > for(i; i < btArray->Length; i++) > pbtArray[i] <<= 1; > return 0; > } > > Nadav > http://www.ddevel.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mytfein |
last post by:
Hi Everyone,
Background:
Another department intends to ftp a .txt file from the mainframe, for me
to process.
The objective is to write a vb script that would be scheduled to run
daily to process this .txt file.
Goal:
I am working on a vba script to:
|
by: Sai Kit Tong |
last post by:
I have to interface managed application with my legacy dll. I have employed
the wrapper approach but I have to deal with the asynchronous callback from
the legacy dll, which likely goes through a thread other than the initial
calling thread. I got the idea from MSDN and other responses from this group
by using the delegate. However, for garabage collection issue, I need to pin
the delegate. Since my callback is asynchronous, I have been...
|
by: Nadav |
last post by:
Hi,
I am writing a mixed mode application, I have a mixed mode Assembly manipulating a managed byte array, to access this array in unmanaged code I '__pin' the array, As I understand, pining an object guarantee that it will not be collected by the GC ( by increasing it's refcount or so ), Taking that in mind, looking at the code generated by the compiler I can't see anything taking care of the GC refcount... following is the pinned variable...
|
by: Hexar Anderson |
last post by:
I have two questions:
a) From documentation located at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcManagedExtensionsSpec_7_7.asp,
it says, "Pinning a sub-object defined in a managed object has the effect of
pinning the entire object. For example, if any element of an array is pinned,
then the whole array is also pinned. There are no extensions to the language
for declaring a pinned array. To pin an...
|
by: Avlan |
last post by:
Hi,
I'm pretty new with ASP-coding, but I got a simple login working. I let
the user enter a username and password and through a SQL-statement I
check if there is a corresponding password in the database (Yes I know,
not very good security but for the moment it's enough). Problem is that
when I enter a false user/password, I want the code to redirect to
another .asp-page which states the user is not valid. Problem lies
within the...
| |
by: rob |
last post by:
I have the following code:
int Function(short buffer __gc) {
....
short __pin* inPinned = & buffer;
DoSomethingUnsafe(inPinned)
...
}
&buffer shows a valid address but when I pin it down inPinned is 0.
|
by: Luke - eat.lemons |
last post by:
Sorry for the post in this NG but im short on time to get this working
and i haven't seem to of got a response anywhere else.
Im pretty new to asp so all light on this question would be great.
Basically i need to test to see what value is set (where to retrieve the
data from) so ive done it like this:
If Request.Querystring("id") = "" then
TidF=Request.Form("TidF")
|
by: majestic12 |
last post by:
This is the first time I've tried to use mysql/phpmyadmin and I'm having trouble. I'm using a geocites pro account and I got both installed and it set up a database call mysql and the user yroot. It asked me to make my own user name, which I did, and had me create a password as well. When I went into phpMyadmin I was able to create a new database but I cant really do anything with it. When I go into privileges I get this warning:
Warning:...
|
by: recurr |
last post by:
How to get what a variable is dimmed as? How to get what an object is
declared as? If variable or object is Nothing?
I want to do something like the following, but TypeOf and GetType
doesn't seem to work when a variable is Nothing. The watch window is
able to find the type, so why can't I with TypeOf or GetType()?
Public something as SomeClass
Public Sub SomeSub() as Boolean
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |