473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

method inline optimization

anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.
Nov 17 '05 #1
5 4603
Daniel,

You can not force a method to be inlined by the JIT. You can only force
it to NOT be inlined, either through the function being declared as virtual,
or using the MethodImpl attribute set so that it is not inlined.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel Jin" <Da*******@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.

Nov 17 '05 #2
exactly what I figured. it's unfortunate that you can't force a method
to be inlined. back to my other question, anyone have any information
on what criteria a method must meet for it to even be considered for
inlining? I googled on that, and so far only found some information on
how the compact framework handles it.
Nicholas Paldino [.NET/C# MVP] wrote:
Daniel,

You can not force a method to be inlined by the JIT. You can only force
it to NOT be inlined, either through the function being declared as virtual,
or using the MethodImpl attribute set so that it is not inlined.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel Jin" <Da*******@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.


Nov 17 '05 #3
Daniel Jin <sh********@yahoo.com> wrote:
exactly what I figured. it's unfortunate that you can't force a method
to be inlined. back to my other question, anyone have any information
on what criteria a method must meet for it to even be considered for
inlining? I googled on that, and so far only found some information on
how the compact framework handles it.


http://blogs.msdn.com/davidnotario/a...01/250398.aspx has a
fair amount on it, in terms of size etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

"Daniel Jin" <Da*******@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
anyone know the criteria a method must meet in order for it to be inlined?
and is there a way to force a method to be inlined? it's not one of the
MethodImplOptions.


Not sure if this is still valid for v2.0 of the JIT, but AFAIK for v1.x the
following are not inlined:
- Methods wth > 32 bytes of IL.
- Virtual calls.
- Valuetypes, and MarshalByRef call targets.
- Complex flowgraphs like loops, methods with exception handling blocks.
- Security checks that need a method frame (compressed stack etc).
-????

Willy.


Nov 17 '05 #5
Thanks Jon for the link. MVP to the rescue.

"Jon Skeet [C# MVP]" wrote:
Daniel Jin <sh********@yahoo.com> wrote:
exactly what I figured. it's unfortunate that you can't force a method
to be inlined. back to my other question, anyone have any information
on what criteria a method must meet for it to even be considered for
inlining? I googled on that, and so far only found some information on
how the compact framework handles it.


http://blogs.msdn.com/davidnotario/a...01/250398.aspx has a
fair amount on it, in terms of size etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Balbir Singh | last post by:
I was wondering if a function pointer pointing to an inline function, will actually expand "inline" when the function pointer is invoked. #include <iostream> #include <vector> using...
7
by: Aloo | last post by:
Dear friends, If we declare a recursive function as 'inline' then does it actually convert to an iterative form during compilation ( the executable code is iterative)? Is it possible ? ...
5
by: Bert Jansen | last post by:
There seems to be a bug in de VS .net C++ compiler (optimization) when using inline functions that return static data. The following code demonstrates this (Win32 console app with ATL support): ...
7
by: Wu Shaohua | last post by:
Hi Guys, 1. As we know usually we should not define a constructor as inline. I also learned if we define a member function inside the class this member function will be automatically be...
9
by: chinu | last post by:
hi all, i did a small experiment to grasp the advantages of declaring a function as inline. inline int fun1(); int main(){ unsigned int start=0,end=0; asm("rdtsc\n\t"
15
by: niklaus | last post by:
Hi, I have a doubt regarding inline functions. 1) When does the inline of function happen. During the preprocessing stage or just before the object code is produced. Can we see the source code...
25
by: toton | last post by:
Hi, As inline is not mandetory, it depends on compiler to inline certain function (or using switch like fior GCC), my question is there any scope for inlining when it is not declared as inline...
14
by: jg | last post by:
Does C++ standard require an inline function be generated all the time ? For example, #include <iostream> using namespace std; inline int foo() {
3
by: az.anonymous | last post by:
As far as I know, csc does not support inline IL. I was wondering: is there any C# compiler that allows inline IL????
32
by: Immortal Nephi | last post by:
I want to know if the practice is the best. Do I need to place inline keyword inside class definition or outside member function definition. For example class A { public: A(); ~A();
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.