Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2002-05-27 Dietmar Maurer <dietmar@ximian.com>

	* jit.c (mono_cfg_new): reserve additional space to store ESP when
	calling finally handlers.

	* exception.c (arch_get_call_finally): save ESP before calling
	finally handler.

svn path=/trunk/mono/; revision=4964
  • Loading branch information...
commit fdeeca53db1b1433dc4be2da52ae4bcc4b058d66 1 parent 08303b8
Dietmar Maurer authored
View
6 mono/jit/ChangeLog
@@ -1,5 +1,11 @@
2002-05-27 Dietmar Maurer <dietmar@ximian.com>
+ * jit.c (mono_cfg_new): reserve additional space to store ESP when
+ calling finally handlers.
+
+ * exception.c (arch_get_call_finally): save ESP before calling
+ finally handler.
+
* helpers.c (map_arg_type): move some generic helper function into
this file.
View
2  mono/jit/exception.c
@@ -118,6 +118,8 @@ arch_get_call_finally (void)
x86_push_reg (code, X86_EBP);
/* set new EBP */
x86_mov_reg_membase (code, X86_EBP, X86_EAX, G_STRUCT_OFFSET (struct sigcontext, SC_EBP), 4);
+ /* save the ESP - this is used by endfinally */
+ x86_mov_membase_reg (code, X86_EBP, -16, X86_ESP, 4);
/* call the handler */
x86_call_reg (code, X86_ECX);
/* restore EBP */
View
3  mono/jit/jit.c
@@ -3211,7 +3211,8 @@ mono_cfg_new (MonoMethod *method)
/* reserve space for caller saved registers */
/* fixme: this is arch dependent */
- cfg->locals_size = 12;
+ /* we save EAX, EDX, ECX - and ESP if we call finally handlers */
+ cfg->locals_size = 16;
/* fixme: we should also consider loader optimisation attributes */
cfg->share_code = mono_jit_share_code;
View
6 mono/jit/x86.brg
@@ -372,11 +372,17 @@ stmt: RETHROW {
}
stmt: HANDLER {
+ /* save ESP (used by ENDFINALLY) */
+ x86_mov_membase_reg (s->code, X86_EBP, -16, X86_ESP, 4);
mono_add_jump_info (s, s->code, MONO_JUMP_INFO_BB, tree->data.bb);
x86_call_imm (s->code, 0);
}
stmt: ENDFINALLY {
+ /* restore ESP - which an be modified when we allocate value types
+ * in the finally handler */
+ x86_mov_reg_membase (s->code, X86_ESP, X86_EBP, -16, 4);
+ x86_alu_reg_imm (s->code, X86_SUB, X86_ESP, 4);
x86_ret (s->code);
}
View
3  mono/tests/Makefile.am
@@ -107,7 +107,8 @@ TESTSRC= \
static-ctor.cs \
inctest.cs \
bound.cs \
- array-invoke.cs
+ array-invoke.cs \
+ decimal.cs
TESTSI=$(TESTSRC:.cs=.exe)
View
17 mono/tests/decimal.cs
@@ -0,0 +1,17 @@
+using System;
+
+class Class1
+{
+ static void Main(string[] args)
+ {
+ Class1 o = new Class1();
+ try {
+ }
+ finally {
+ // this allocates space on the stack and
+ // thus modifies the stack pointer
+ decimal x = 7.7m;
+ }
+ }
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.