Skip to content

Commit

Permalink
2002-05-27 Dietmar Maurer <dietmar@ximian.com>
Browse files Browse the repository at this point in the history
	* 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
Dietmar Maurer committed May 27, 2002
1 parent 08303b8 commit fdeeca5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
6 changes: 6 additions & 0 deletions 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.

Expand Down
2 changes: 2 additions & 0 deletions mono/jit/exception.c
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion mono/jit/jit.c
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions mono/jit/x86.brg
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion mono/tests/Makefile.am
Expand Up @@ -107,7 +107,8 @@ TESTSRC= \
static-ctor.cs \
inctest.cs \
bound.cs \
array-invoke.cs
array-invoke.cs \
decimal.cs


TESTSI=$(TESTSRC:.cs=.exe)
Expand Down
17 changes: 17 additions & 0 deletions 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;
}
}
}

0 comments on commit fdeeca5

Please sign in to comment.