This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to insert dynamic code? (continued)


On Jul 13, 2006, at 8:48 AM, jacob navia wrote:
1) I generate exactly the same code now as gcc:

You don't want to generate exactly the same code as gcc, unless it is exactly the same case; you want to generate the correct code.


Divide and concur.

Do simple things work? For example, do:

routine() {
	throw 1;
}

loadme() {
	try {
		routine();
	} catch (...) {
		printf("Hello\n");
	}
	_exit (42);
}

in your JIT language and then compile it, load it and dispatch it. You can then know if you got there, and if it printed hello and exited with 42. I'd work on that problem first, if it doesn't work.

Once that works, you know that the right things are registered and that the information is approximately correct. Repeat the same with 2 layers of functions.

Then you can move onto JITing:

routine() {
	throw 1;
}

and call from

void base() {
	try {
		jit_routine();
	} catch (...) {
		print("Hello");
	}
	_exit(42);
}

in normal C++. This checks that yet another part of the problem. Does that work?

Then, you can add local variables, and print the addresses of the local variables across throws and ensure that the variable is at the address you expect after a throw.

void foo() {
	int bar [200];
	printf("%p\n", bar);
	try {...}
	catch(...) {
		printf("%p\n", bar);	
	}
}

if they don't have the right values, the frame information isn't yet correct. Does that work?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]