Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
6 mono/jit/ChangeLog
... ... @@ -1,5 +1,11 @@
1 1 2002-05-27 Dietmar Maurer <dietmar@ximian.com>
2 2
  3 + * jit.c (mono_cfg_new): reserve additional space to store ESP when
  4 + calling finally handlers.
  5 +
  6 + * exception.c (arch_get_call_finally): save ESP before calling
  7 + finally handler.
  8 +
3 9 * helpers.c (map_arg_type): move some generic helper function into
4 10 this file.
5 11
2  mono/jit/exception.c
@@ -118,6 +118,8 @@ arch_get_call_finally (void)
118 118 x86_push_reg (code, X86_EBP);
119 119 /* set new EBP */
120 120 x86_mov_reg_membase (code, X86_EBP, X86_EAX, G_STRUCT_OFFSET (struct sigcontext, SC_EBP), 4);
  121 + /* save the ESP - this is used by endfinally */
  122 + x86_mov_membase_reg (code, X86_EBP, -16, X86_ESP, 4);
121 123 /* call the handler */
122 124 x86_call_reg (code, X86_ECX);
123 125 /* restore EBP */
3  mono/jit/jit.c
@@ -3211,7 +3211,8 @@ mono_cfg_new (MonoMethod *method)
3211 3211
3212 3212 /* reserve space for caller saved registers */
3213 3213 /* fixme: this is arch dependent */
3214   - cfg->locals_size = 12;
  3214 + /* we save EAX, EDX, ECX - and ESP if we call finally handlers */
  3215 + cfg->locals_size = 16;
3215 3216
3216 3217 /* fixme: we should also consider loader optimisation attributes */
3217 3218 cfg->share_code = mono_jit_share_code;
6 mono/jit/x86.brg
@@ -372,11 +372,17 @@ stmt: RETHROW {
372 372 }
373 373
374 374 stmt: HANDLER {
  375 + /* save ESP (used by ENDFINALLY) */
  376 + x86_mov_membase_reg (s->code, X86_EBP, -16, X86_ESP, 4);
375 377 mono_add_jump_info (s, s->code, MONO_JUMP_INFO_BB, tree->data.bb);
376 378 x86_call_imm (s->code, 0);
377 379 }
378 380
379 381 stmt: ENDFINALLY {
  382 + /* restore ESP - which an be modified when we allocate value types
  383 + * in the finally handler */
  384 + x86_mov_reg_membase (s->code, X86_ESP, X86_EBP, -16, 4);
  385 + x86_alu_reg_imm (s->code, X86_SUB, X86_ESP, 4);
380 386 x86_ret (s->code);
381 387 }
382 388
3  mono/tests/Makefile.am
@@ -107,7 +107,8 @@ TESTSRC= \
107 107 static-ctor.cs \
108 108 inctest.cs \
109 109 bound.cs \
110   - array-invoke.cs
  110 + array-invoke.cs \
  111 + decimal.cs
111 112
112 113
113 114 TESTSI=$(TESTSRC:.cs=.exe)
17 mono/tests/decimal.cs
... ... @@ -0,0 +1,17 @@
  1 +using System;
  2 +
  3 +class Class1
  4 +{
  5 + static void Main(string[] args)
  6 + {
  7 + Class1 o = new Class1();
  8 + try {
  9 + }
  10 + finally {
  11 + // this allocates space on the stack and
  12 + // thus modifies the stack pointer
  13 + decimal x = 7.7m;
  14 + }
  15 + }
  16 +}
  17 +

0 comments on commit fdeeca5

Please sign in to comment.
Something went wrong with that request. Please try again.