473,396 Members | 1,884 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,396 software developers and data experts.

Threaded interpreter with aggressige tail-call optimization of virtual calls

I just wonder if this is possible with C++/clr.

I'm trying to .NET-enable an interpreter for a Lisp flavoured
language, the interpreter written in NASM which I have
managed to port to MASM. However the VS2005 debugger
is giving me a really hard time - seems it doesn't cope well
with mixing MASM with C++/clr, so I am considering a
rewrite of the interpreter kernel in C++/clr.

The control flow of the language doesn't really map into
..net method calls, so I will need to implement it otherwise.

I'd prefer to do it by represent the execution state as a chain
of C++ objects that is operated on by virtual methods, so
that each state transition is represented by a virtual method
call, which calls the next etc. in a tail recursive manner.
This is how the assembler program works, except that
the objects are stacked on the processor stack rather than
chained - and it works nice.

To use it in a C++ implementation, I need tail optimized
virtual calls. When performing a complex computation,
the interpreter will do millions of chained calls before
it finally return to the event handler that started the
computation.

I know the IL has provisions for tail call optimization´
but the docs I've seen didn't state clearly how well this
works - it just states that the jit will sometimes do it.

I also don't know if the C++/clr compiler will emit the
tail-optimized call instructions (the C# compiler doesn't
but C# is unsuitable for this task anyway).

When asked about this, C++ or C# programmers tend
to argue that relying on tail call optimization is bad
style, which may be true for most tasks, but a threaded
interpreter would really gain from being able to use it.

So, does anyone know how the compiler and jit
handles this? Is it possible to set up a set of premises
and tell that the tail call optimization works on these
premises?

Mar 29 '06 #1
0 1074

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

Similar topics

5
by: Paul Moore | last post by:
I can't find anything which spells this out in the manuals. I guess that, at some level, the answer is "a single bytecode operation", but I'm not sure that explains it for me. This thought was...
0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
8
by: Matthew Bell | last post by:
Hi, I've got a question about whether there are any issues with directly calling attributes and/or methods of a threaded class instance. I wonder if someone could give me some advice on this. ...
10
by: Mel | last post by:
i need to create a unix like "tail" function on my site. the question: the text is displayed in a scrolled area and a new line is added at the end and the entire text is scrolled down so that...
12
by: s99999999s2003 | last post by:
hi I have a file which is very large eg over 200Mb , and i am going to use python to code a "tail" command to get the last few lines of the file. What is a good algorithm for this type of task...
19
by: Kay Schluehr | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691
30
by: Chas Emerick | last post by:
I looked around for an ElementTree-specific mailing list, but found none -- my apologies if this is too broad a forum for this question. I've been using the lxml variant of the ElementTree API,...
12
by: John | last post by:
I want to do something like this: for i = 1 in range(0,N): for j = 1 in range(0,N): D = calculate(i,j) I would like to now do this using a fixed number of threads, say 10 threads. What is...
6
by: lak | last post by:
i want to write a program that implement tail and tail -f command in unix. can any one help me in this?
35
by: Muzammil | last post by:
int harmonic(int n) { if (n=1) { return 1; } else { return harmonic(n-1)+1/n; } } can any help me ??
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
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: 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
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...

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.