#ifdef __native_client_codegen__
-const guint kNaClAlignment = kNaClAlignmentX86;
-const guint kNaClAlignmentMask = kNaClAlignmentMaskX86;
/* Default alignment for Native Client is 32-byte. */
gint8 nacl_align_byte = -32; /* signed version of 0xe0 */
0x89, 0x02, /* mov %eax,(%edx) */
0x5b, /* pop %ebx */
0xc9, /* leave */
- 0x59, 0x83, 0xe1, 0xe0, 0xff, 0xe1 /* naclret */
+ 0x59, 0x83, 0xe1, 0xe0, 0xff, 0xe1, /* naclret */
+ 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, /* padding, to provide bundle aligned version */
+ 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4,
+ 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4,
+ 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4,
+ 0xf4
};
#endif
break;
case OP_IDIV:
case OP_IREM:
+#if defined( __native_client_codegen__ )
+ x86_alu_reg_imm (code, X86_CMP, ins->sreg2, 0);
+ EMIT_COND_SYSTEM_EXCEPTION (X86_CC_EQ, TRUE, "DivideByZeroException");
+#endif
/*
* The code is the same for div/rem, the allocator will allocate dreg
* to RAX/RDX as appropriate.
break;
case OP_IDIV_UN:
case OP_IREM_UN:
+#if defined( __native_client_codegen__ )
+ x86_alu_reg_imm (code, X86_CMP, ins->sreg2, 0);
+ EMIT_COND_SYSTEM_EXCEPTION (X86_CC_EQ, TRUE, "DivideByZeroException");
+#endif
if (ins->sreg2 == X86_EDX) {
x86_push_reg (code, ins->sreg2);
x86_alu_reg_reg (code, X86_XOR, X86_EDX, X86_EDX);
}
break;
case OP_DIV_IMM:
+#if defined( __native_client_codegen__ )
+ if (ins->inst_imm == 0) {
+ mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_EXC, "DivideByZeroException");
+ x86_jump32 (code, 0);
+ break;
+ }
+#endif
x86_mov_reg_imm (code, ins->sreg2, ins->inst_imm);
x86_cdq (code);
x86_div_reg (code, ins->sreg2, TRUE);
code = cfg->native_code = g_malloc (cfg->code_size);
#elif defined(__native_client_codegen__)
/* native_code_alloc is not 32-byte aligned, native_code is. */
+ cfg->code_size = NACL_BUNDLE_ALIGN_UP (cfg->code_size);
cfg->native_code_alloc = g_malloc (cfg->code_size + kNaClAlignment);
/* Align native_code to next nearest kNaclAlignment byte. */
#if defined(__native_client__) && defined(__native_client_codegen__)
/* In Native Client, we don't re-use thunks, allocate from the */
/* normal code manager paths. */
+ size = NACL_BUNDLE_ALIGN_UP (size);
code = mono_domain_code_reserve (domain, size);
#else
if (fail_tramp)