Compare commits

...
Author SHA1 Message Date
Wade Berrier b27152cb9d * TempFileCollection.cs: Bring in changes from HEAD for serialization
security fix:
       * r51229: Added a call to GC.SuppressFinalize in Dispose.
       * r52181: Changed BasePath property to use Path.
       GetTempPath (Environment check) and added the PathDiscovery check on
       the combined result. Fixed TempDir so it's value never change (i.e.
       imply that it doesn't need any permissions). Fixed SyncRoot to always
       return null.
       * r57836: Implement explicitly some interface methods to get rid of
       the "!" errors on CorCompare.
       * r60253: Make sure generated file names are unique. Fixes bug #76125
       and #78230.
       * r65441: Create files in a temporary subdirectory, for security reasons.


svn path=/branches/mono-1-1-4/mcs/; revision=66300
2006-10-05 18:10:24 +00:00
Miguel de Icaza 01df40f54f Backport from HEAD:
* Compile with older C compilers.
	* Remove the linear-scan hack for PPC.
	* Apply the DllImport patch from Paolo (fixes the PPC problem, makes workaround redundant).
	* Fixes S390 build from Neale.

Patches applied:

	r40214 - S390
	r40205 - PPC 
	r40162 - gcc 2.95 fixes
	r40163 - gcc 2.95 fixes


svn path=/branches/mono-1-1-4/mono/; revision=40246
2005-02-07 16:49:02 +00:00
Miguel de Icaza 0f15c90afc In Branch: Solaris terminal check; PPC workaround in linears from Geoff
svn path=/branches/mono-1-1-4/mono/; revision=40189
2005-02-05 20:21:22 +00:00
Miguel de Icaza 9d10e0c0d6 Revert the SSL code in the 1.1.4.1 branch
svn path=/branches/mono-1-1-4/mcs/; revision=40188
2005-02-05 20:20:37 +00:00
15 changed files with 288 additions and 235 deletions

No files matched your search

+7 -1
View File
@@ -1075,7 +1075,13 @@ if test x$platform_win32 = xno; then
dnl *********************************
dnl *** Check for Console 2.0 I/O ***
dnl *********************************
AC_CHECK_HEADERS([term.h termios.h])
AC_CHECK_HEADERS([curses.h])
AC_CHECK_HEADERS([term.h], [], [],
[#if HAVE_CURSES_H
#include <curses.h>
#endif
])
AC_CHECK_HEADERS([termios.h])
else
jdk_headers_found=no
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
@@ -24,11 +24,9 @@
using System;
using System.Collections;
using System.IO;
using System.Net.Sockets;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Security.Cryptography.X509Certificates;
using Mono.Security.Protocol.Tls.Handshake;
@@ -72,31 +70,7 @@ namespace Mono.Security.Protocol.Tls
#endregion
#region Reveive Record Methods
internal const int Timeout = 1000;
internal bool WaitForData ()
{
// problem: NetworkStream.ReadByte blocks until a byte is received
// and (maybe) no byte will ever be received
if (this.innerStream is NetworkStream)
{
NetworkStream ns = (this.innerStream as NetworkStream);
int delay = 10;
while (delay < Timeout)
{
if (ns.DataAvailable)
return true;
Thread.Sleep (delay);
delay *= 2;
}
// nothing to see, move along
return false;
}
// we assume other type of stream have their own timeout capabilities
return true;
}
#region Reveive Record Methods
public byte[] ReceiveRecord()
{
@@ -105,25 +79,20 @@ namespace Mono.Security.Protocol.Tls
throw new TlsException(
AlertDescription.InternalError,
"The session is finished and it's no longer valid.");
}
if (!WaitForData ())
{
return null;
}
// Try to read the Record Content Type
int type = this.innerStream.ReadByte ();
}
// Try to read the Record Content Type
int type = this.innerStream.ReadByte();
if (type == -1)
{
{
return null;
}
}
// Set last handshake message received to None
this.context.LastHandshakeMsg = HandshakeType.ClientHello;
ContentType contentType = (ContentType)type;
byte[] buffer = this.ReadRecordBuffer (type);
ContentType contentType = (ContentType)type;
byte[] buffer = this.ReadRecordBuffer(type);
TlsStream message = new TlsStream(buffer);
@@ -204,19 +173,13 @@ namespace Mono.Security.Protocol.Tls
}
private byte[] ReadClientHelloV2()
{
int msgType = -1;
byte[] message = null;
{
int msgLength = this.innerStream.ReadByte();
byte[] message = new byte [msgLength];
this.innerStream.Read (message, 0, msgLength);
int msgLength = this.innerStream.ReadByte();
if (msgLength > 0)
{
message = new byte [msgLength];
if (this.innerStream.Read (message, 0, msgLength) == msgLength)
msgType = message [0];
}
if ((msgType != 1) || (message.Length < 9))
int msgType = message [0];
if (msgType != 1)
{
throw new TlsException(AlertDescription.DecodeError);
}
@@ -255,30 +218,17 @@ namespace Mono.Security.Protocol.Tls
// Select the Cipher suite
this.ProcessCipherSpecV2Buffer(this.Context.SecurityProtocol, cipherSpecV2);
// Updated the Client Random
this.context.ClientRandom = new byte [32]; // Always 32
// 1. if challenge is bigger than 32 bytes only use the last 32 bytes
// 2. right justify (0) challenge in ClientRandom if less than 32
Buffer.BlockCopy (challenge, challenge.Length - length, this.context.ClientRandom, 32 - length, length);
// Updated the Client Random
this.context.ClientRandom = new byte [32]; // Always 32
// 1. if challenge is bigger than 32 bytes only use the last 32 bytes
// 2. right justify (0) challenge in ClientRandom if less than 32
Buffer.BlockCopy (challenge, challenge.Length - length, this.context.ClientRandom, 32 - length, length);
// Set
this.context.LastHandshakeMsg = HandshakeType.ClientHello;
this.context.ProtocolNegotiated = true;
return message;
}
private bool Wait (ref int delay)
{
if (delay < 10)
delay = 10;
if (delay >= Timeout)
return false;
Thread.Sleep (delay);
delay *= 2;
return true;
}
private byte[] ReadStandardRecordBuffer()
@@ -289,21 +239,9 @@ namespace Mono.Security.Protocol.Tls
// Read Record data
int received = 0;
byte[] buffer = new byte[length];
int n = 0;
while (received != length)
{
int incoming = this.innerStream.Read(buffer, received, buffer.Length - received);
// we risk an infinite loop is data isn't available
if (incoming == 0)
{
if (!Wait (ref n))
throw new TlsException (AlertLevel.Fatal, AlertDescription.CloseNotify);
}
else
{
n = 0; // reset
}
received += incoming;
received += this.innerStream.Read(buffer, received, buffer.Length - received);
}
// Check that the message has a valid protocol version
@@ -320,11 +258,8 @@ namespace Mono.Security.Protocol.Tls
private short ReadShort()
{
byte[] b = new byte[2];
if (this.innerStream.Read (b, 0, b.Length) != 2)
{
throw new TlsException (AlertLevel.Fatal, AlertDescription.DecodeError);
}
byte[] b = new byte[2];
this.innerStream.Read(b, 0, b.Length);
short val = BitConverter.ToInt16(b, 0);
@@ -688,7 +688,7 @@ namespace Mono.Security.Protocol.Tls
*/
internal void NegotiateHandshake()
{
{
lock (this)
{
try
@@ -707,11 +707,8 @@ namespace Mono.Security.Protocol.Tls
// Read server response
while (this.context.LastHandshakeMsg != HandshakeType.ServerHelloDone)
{
// Read next record
if (this.protocol.ReceiveRecord () == null)
{
throw new TlsException (AlertLevel.Fatal, AlertDescription.CloseNotify);
}
// Read next record
this.protocol.ReceiveRecord();
}
// Send client certificate if requested
@@ -740,12 +737,8 @@ namespace Mono.Security.Protocol.Tls
{
// If all goes well this will process messages:
// Change Cipher Spec
// Server finished
// Read next record
if (this.protocol.ReceiveRecord () == null)
{
throw new TlsException (AlertLevel.Fatal, AlertDescription.CloseNotify);
}
// Server finished
this.protocol.ReceiveRecord();
}
// Clear Key Info
@@ -1,3 +1,19 @@
2006-10-05 Wade Berrier <[email protected]>
* TempFileCollection.cs: Bring in changes from HEAD for serialization
security fix:
* r51229: Added a call to GC.SuppressFinalize in Dispose.
* r52181: Changed BasePath property to use Path.
GetTempPath (Environment check) and added the PathDiscovery check on
the combined result. Fixed TempDir so it's value never change (i.e.
imply that it doesn't need any permissions). Fixed SyncRoot to always
return null.
* r57836: Implement explicitly some interface methods to get rid of
the "!" errors on CorCompare.
* r60253: Make sure generated file names are unique. Fixes bug #76125
and #78230.
* r65441: Create files in a temporary subdirectory, for security reasons.
2005-01-27 LLuis Sanchez Gual <[email protected]>
* CodeGenerator.cs: Write 'f' suffix for float constants.
@@ -5,8 +5,7 @@
// Dick Porter ([email protected])
//
// (C) Copyright 2003 Ximian, Inc.
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,11 +27,18 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.IO;
using System.Collections;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
namespace System.CodeDom.Compiler
{
namespace System.CodeDom.Compiler {
#if NET_2_0
[Serializable]
#endif
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
public class TempFileCollection:ICollection, IEnumerable, IDisposable
{
Hashtable filehash;
@@ -40,19 +46,22 @@ namespace System.CodeDom.Compiler
bool keepfiles;
string basepath;
Random rnd;
string ownTempDir;
public TempFileCollection(): this(null, false)
public TempFileCollection ()
: this (String.Empty, false)
{
}
public TempFileCollection(string tempDir): this(tempDir, false)
public TempFileCollection(string tempDir)
: this (tempDir, false)
{
}
public TempFileCollection(string tempDir, bool keepFiles)
{
filehash=new Hashtable();
tempdir=tempDir;
tempdir = (tempDir == null) ? String.Empty : tempDir;
keepfiles=keepFiles;
}
@@ -60,22 +69,82 @@ namespace System.CodeDom.Compiler
{
get {
if(basepath==null) {
if (tempdir==null) {
/* Get the system temp dir */
MonoIO.GetTempPath(out tempdir);
}
if (rnd == null)
rnd = new Random ();
string random = rnd.Next (10000,99999).ToString ();
basepath = Path.Combine (tempdir, random);
// note: this property *cannot* change TempDir property
string temp = tempdir;
if (temp.Length == 0)
temp = GetOwnTempDir ();
// Create a temporary file at the target directory. This ensures
// that the generated file name is unique.
FileStream f = null;
do {
int num = rnd.Next ();
num++;
basepath = Path.Combine (temp, num.ToString("x"));
string path = basepath + ".tmp";
try {
f = new FileStream (path, FileMode.CreateNew);
}
catch (System.IO.IOException) {
f = null;
continue;
}
catch {
// avoid endless loop
throw;
}
} while (f == null);
f.Close ();
// and you must have discovery access to the combined path
// note: the cache behaviour is tested in the CAS tests
if (SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, basepath).Demand ();
}
}
return(basepath);
}
}
string GetOwnTempDir ()
{
if (ownTempDir != null)
return ownTempDir;
// this call ensure the Environment permissions check
string basedir = Path.GetTempPath ();
// Create a subdirectory with the correct user permissions
int res = -1;
do {
int num = rnd.Next ();
num++;
ownTempDir = Path.Combine (basedir, num.ToString("x"));
if (Directory.Exists (ownTempDir))
continue;
res = mkdir (ownTempDir, 0x1c0);
if (res != 0) {
if (!Directory.Exists (ownTempDir))
throw new IOException ();
// Somebody already created the dir, keep trying
}
} while (res != 0);
return ownTempDir;
}
int ICollection.Count {
get {
return filehash.Count;
}
}
public int Count
{
get {
@@ -96,11 +165,9 @@ namespace System.CodeDom.Compiler
public string TempDir
{
get {
if(tempdir==null) {
return(String.Empty);
} else {
return(tempdir);
}
// note: we only return what we were supplied so there
// is no permission protecting this information
return tempdir;
}
}
@@ -133,7 +200,7 @@ namespace System.CodeDom.Compiler
object ICollection.SyncRoot {
get {
return filehash.SyncRoot;
return null;
}
}
@@ -150,17 +217,33 @@ namespace System.CodeDom.Compiler
public void Delete()
{
string[] filenames=new string[filehash.Count];
filehash.Keys.CopyTo(filenames, 0);
bool allDeleted = true;
string[] filenames = new string[filehash.Count];
filehash.Keys.CopyTo (filenames, 0);
foreach(string file in filenames) {
if((bool)filehash[file]==false) {
File.Delete(file);
filehash.Remove(file);
}
} else
allDeleted = false;
}
if (basepath != null) {
string tmpFile = basepath + ".tmp";
File.Delete (tmpFile);
basepath = null;
}
if (allDeleted && ownTempDir != null) {
Directory.Delete (ownTempDir, true);
ownTempDir = null;
}
}
IEnumerator IEnumerable.GetEnumerator ()
{
return(filehash.Keys.GetEnumerator());
}
public IEnumerator GetEnumerator()
{
return(filehash.Keys.GetEnumerator());
@@ -169,6 +252,9 @@ namespace System.CodeDom.Compiler
protected virtual void Dispose(bool disposing)
{
Delete();
if (disposing) {
GC.SuppressFinalize (true);
}
}
~TempFileCollection()
@@ -176,5 +262,6 @@ namespace System.CodeDom.Compiler
Dispose(false);
}
[DllImport ("libc")] private static extern int mkdir (string olpath, uint mode);
}
}
+7
View File
@@ -14,12 +14,19 @@
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#ifdef HAVE_CURSES_H
#include <curses.h>
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#ifdef HAVE_TERM_H
#include <term.h>
#endif
/* Needed for FIONREAD under solaris */
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#ifndef PLATFORM_WIN32
#ifndef TIOCGWINSZ
#include <sys/ioctl.h>
+2 -1
View File
@@ -2776,8 +2776,9 @@ mono_marshal_get_xappdomain_invoke (MonoMethod *method)
j = 0;
for (i = 0; i < sig->param_count; i++) {
MonoClass *pclass;
if (marshal_types [i] != MONO_MARSHAL_SERIALIZE) continue;
MonoClass *pclass = mono_class_from_mono_type (sig->params[i]);
pclass = mono_class_from_mono_type (sig->params[i]);
mono_mb_emit_byte (mb, CEE_DUP);
mono_mb_emit_icon (mb, j);
mono_mb_emit_ldarg (mb, i + 1); /* 0=this */
+5 -2
View File
@@ -9131,10 +9131,12 @@ mono_declsec_get_demands (MonoMethod *method, MonoDeclSecurityActions* demands)
/* First we look for method-level attributes */
if (method->flags & METHOD_ATTRIBUTE_HAS_SECURITY) {
guint32 idx;
mono_class_init (method->klass);
memset (demands, 0, sizeof (MonoDeclSecurityActions));
guint32 idx = mono_method_get_index (method);
idx = mono_method_get_index (method);
idx <<= MONO_HAS_DECL_SECURITY_BITS;
idx |= MONO_HAS_DECL_SECURITY_METHODDEF;
result = fill_actions_from_index (image, idx, demands);
@@ -9144,11 +9146,12 @@ mono_declsec_get_demands (MonoMethod *method, MonoDeclSecurityActions* demands)
/* Here we use (or create) the class declarative cache to look for demands */
flags = mono_declsec_flags_from_class (method->klass);
if (flags & (MONO_DECLSEC_FLAG_DEMAND | MONO_DECLSEC_FLAG_NONCAS_DEMAND | MONO_DECLSEC_FLAG_DEMAND_CHOICE)) {
guint32 idx;
if (!result) {
mono_class_init (method->klass);
memset (demands, 0, sizeof (MonoDeclSecurityActions));
}
guint32 idx = mono_metadata_token_index (method->klass->type_token);
idx = mono_metadata_token_index (method->klass->type_token);
idx <<= MONO_HAS_DECL_SECURITY_BITS;
idx |= MONO_HAS_DECL_SECURITY_TYPEDEF;
result |= fill_actions_from_index (image, idx, demands);
+2 -1
View File
@@ -182,7 +182,6 @@ MonoString *
ves_icall_System_String_ctor_encoding (gpointer dummy, gint8 *value, gint32 sindex,
gint32 length, MonoObject *enc)
{
MONO_ARCH_SAVE_REGS;
MonoArray *arr;
MonoString *s;
MonoObject *exc;
@@ -190,6 +189,8 @@ ves_icall_System_String_ctor_encoding (gpointer dummy, gint8 *value, gint32 sind
MonoMethod *get_string;
gpointer args [1];
MONO_ARCH_SAVE_REGS;
if ((value == NULL) || (length == 0))
return mono_string_new_size (mono_domain_get (), 0);
if (enc == NULL)
+2 -1
View File
@@ -407,9 +407,10 @@ handle_load:
case CEE_AND: {
MonoSummarizedValue left_value;
MonoSummarizedValue right_value;
int constant_operand_value;
summarize_integer_value (area, value->inst_left, &left_value, result_value_kind);
summarize_integer_value (area, value->inst_right, &right_value, result_value_kind);
int constant_operand_value;
if (left_value.type == MONO_CONSTANT_SUMMARIZED_VALUE) {
constant_operand_value = left_value.value.constant.value;
+5 -3
View File
@@ -820,17 +820,19 @@ mono_aot_load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoMethod
for (i = 0; i < ji->data.table->table_size; i++)
table [i] = (gpointer)(gssize)decode_value (p, &p);
break;
case MONO_PATCH_INFO_R4:
ji->data.target = mono_mempool_alloc0 (mp, sizeof (float));
case MONO_PATCH_INFO_R4: {
guint32 val;
ji->data.target = mono_mempool_alloc0 (mp, sizeof (float));
val = decode_value (p, &p);
*(float*)ji->data.target = *(float*)&val;
break;
}
case MONO_PATCH_INFO_R8: {
ji->data.target = mono_mempool_alloc0 (mp, sizeof (double));
guint32 val [2];
ji->data.target = mono_mempool_alloc0 (mp, sizeof (double));
val [0] = decode_value (p, &p);
val [1] = decode_value (p, &p);
*(double*)ji->data.target = *(double*)val;
+5 -5
View File
@@ -47,14 +47,14 @@
#
adc: dest:i src1:i src2:i len:6
adc_imm: dest:i src1:i len:14
adc_imm: dest:i src1:i len:18
add.ovf.un: len: 8 dest:i src1:i src2:i
add.ovf: len: 24 dest:i src1:i src2:i
add: dest:i src1:i src2:i len:4 clob:1
add_imm: dest:i src1:i len:18
addcc_imm: dest:i src1:i len:18
add_ovf_carry: dest:i src1:1 src2:i len:28
add_ovf_un_carry: dest:i src1:1 src2:i len:12
add_ovf_un_carry: dest:i src1:1 src2:i len:28
addcc: dest:i src1:i src2:i len:6
and: dest:i src1:i src2:i len:6 clob:1
and_imm: dest:i src1:i len:16
@@ -453,8 +453,8 @@ retarg:
s390_move: len:48 dest:b src1:b
s390_setf4ret: dest:f src1:f len:4 clob:r
tls_get: dest:i len:44
sbb: dest:i src1:i src2:i len:6
sbb_imm: dest:i src1:i len:14
sbb: dest:i src1:i src2:i len:8
sbb_imm: dest:i src1:i len:16
setfreg: dest:f src1:f len:4 clob:r
setlret: src1:i src2:i len:12
setreg: dest:i src1:i len:4 clob:r
@@ -515,7 +515,7 @@ sub: dest:i src1:i src2:i len:4 clob:1
sub_imm: dest:i src1:i len:18
subcc_imm: dest:i src1:i len:18
sub_ovf_carry: dest:i src1:1 src2:i len:28
sub_ovf_un_carry: dest:i src1:1 src2:i len:12
sub_ovf_un_carry: dest:i src1:1 src2:i len:28
subcc: dest:i src1:i src2:i len:6
switch:
tail.:
+6
View File
@@ -669,6 +669,12 @@ mono_arch_allocate_vars (MonoCompile *m)
*/
if (m->flags & MONO_CFG_HAS_VARARGS)
m->param_area = MAX (m->param_area, sizeof (gpointer)*8);
/* gtk-sharp and other broken code will dllimport vararg functions even with
* non-varargs signatures. Since there is little hope people will get this right
* we assume they won't.
*/
if (m->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
m->param_area = MAX (m->param_area, sizeof (gpointer)*8);
header = mono_method_get_header (m->method);
+85 -92
View File
@@ -96,6 +96,38 @@ if (ins->flags & MONO_INST_BRLABEL) { \
s390_jcl (code, cond, 0); \
} while (0);
#define CHECK_SRCDST_COM \
if (ins->dreg == ins->sreg2) { \
src2 = ins->sreg1; \
} else { \
src2 = ins->sreg2; \
if (ins->dreg != ins->sreg1) { \
s390_lr (code, ins->dreg, ins->sreg1); \
} \
}
#define CHECK_SRCDST_NCOM \
if (ins->dreg == ins->sreg2) { \
src2 = s390_r13; \
s390_lr (code, s390_r13, ins->sreg2); \
} else { \
src2 = ins->sreg2; \
} \
if (ins->dreg != ins->sreg1) { \
s390_lr (code, ins->dreg, ins->sreg1); \
}
#define CHECK_SRCDST_NCOM_F \
if (ins->dreg == ins->sreg2) { \
src2 = s390_f15; \
s390_ldr (code, s390_r13, ins->sreg2); \
} else { \
src2 = ins->sreg2; \
} \
if (ins->dreg != ins->sreg1) { \
s390_ldr (code, ins->dreg, ins->sreg1); \
}
#undef DEBUG
#define DEBUG(a) if (cfg->verbose_level > 1) a
@@ -525,16 +557,16 @@ enum_parmtype:
printf ("[INT4:%d], ", *((int *) curParm));
break;
case MONO_TYPE_U1 :
printf ("[UINT1:%ud], ", *((unsigned int *) curParm));
printf ("[UINT1:%u], ", *((unsigned int *) curParm));
break;
case MONO_TYPE_U2 :
printf ("[UINT2:%ud], ", *((guint16 *) curParm));
printf ("[UINT2:%u], ", *((guint16 *) curParm));
break;
case MONO_TYPE_U4 :
printf ("[UINT4:%ud], ", *((guint32 *) curParm));
printf ("[UINT4:%u], ", *((guint32 *) curParm));
break;
case MONO_TYPE_U8 :
printf ("[UINT8:%ul], ", *((guint64 *) curParm));
printf ("[UINT8:%llu], ", *((guint64 *) curParm));
break;
case MONO_TYPE_STRING : {
MonoString *s = *((MonoString **) curParm);
@@ -863,6 +895,11 @@ handle_enum:
printf ("[LONG:%lld]", l);
break;
}
case MONO_TYPE_U8: {
guint64 l = va_arg (ap, guint64);
printf ("[ULONG:%llu]", l);
break;
}
case MONO_TYPE_R4: {
double f = va_arg (ap, double);
printf ("[FLOAT4:%f]\n", (float) f);
@@ -1038,9 +1075,11 @@ GList *
mono_arch_get_global_int_regs (MonoCompile *cfg)
{
GList *regs = NULL;
MonoMethodHeader *header;
int i, top = 13;
if (cfg->flags & MONO_CFG_HAS_ALLOCA)
header = mono_method_get_header (cfg->method);
if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
cfg->frame_reg = s390_r11;
for (i = 8; i < top; ++i) {
@@ -3124,8 +3163,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
guint8 *code = cfg->native_code + cfg->code_len;
MonoInst *last_ins = NULL;
guint last_offset = 0;
int max_len, cpos;
guint8 cond;
int max_len, cpos, src2;
if (cfg->opt & MONO_OPT_PEEPHOLE)
peephole_pass (cfg, bb);
@@ -3437,24 +3475,18 @@ guint8 cond;
}
break;
case OP_ADDCC: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_alr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_COM;
s390_alr (code, ins->dreg, src2);
}
break;
case CEE_ADD: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_ar (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_COM;
s390_ar (code, ins->dreg, src2);
}
break;
case OP_ADC: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_alcr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_COM;
s390_alcr (code, ins->dreg, src2);
}
break;
case OP_ADDCC_IMM:
@@ -3503,61 +3535,47 @@ guint8 cond;
}
break;
case CEE_ADD_OVF: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_ar (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_COM;
s390_ar (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
}
break;
case CEE_ADD_OVF_UN: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_alr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_COM;
s390_alr (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_CY, "OverflowException");
}
break;
case OP_ADD_OVF_CARRY: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
CHECK_SRCDST_COM;
s390_lhi (code, s390_r0, 0);
s390_lr (code, s390_r1, s390_r0);
s390_alcr (code, s390_r0, s390_r1);
s390_ar (code, ins->dreg, ins->sreg2);
s390_ar (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
s390_ar (code, ins->dreg, s390_r0);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
}
break;
case OP_ADD_OVF_UN_CARRY: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_alcr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_COM;
s390_alcr (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_CY, "OverflowException");
}
break;
case OP_SUBCC: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_slr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_NCOM;
s390_slr (code, ins->dreg, src2);
}
break;
case CEE_SUB: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_sr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_NCOM;
s390_sr (code, ins->dreg, src2);
}
break;
case OP_SBB: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_slbr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_NCOM;
s390_slbr (code, ins->dreg, src2);
}
break;
case OP_SUBCC_IMM: {
@@ -3610,39 +3628,31 @@ guint8 cond;
}
break;
case CEE_SUB_OVF: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_sr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_NCOM;
s390_sr (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
}
break;
case CEE_SUB_OVF_UN: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_slr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_NCOM;
s390_slr (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_NC, "OverflowException");
}
break;
case OP_SUB_OVF_CARRY: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
CHECK_SRCDST_NCOM;
s390_lhi (code, s390_r0, 0);
s390_lr (code, s390_r1, s390_r0);
s390_slbr (code, s390_r0, s390_r1);
s390_sr (code, ins->dreg, ins->sreg2);
s390_sr (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
s390_ar (code, ins->dreg, s390_r0);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_OV, "OverflowException");
}
break;
case OP_SUB_OVF_UN_CARRY: {
if (ins->dreg != ins->sreg1) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_slbr (code, ins->dreg, ins->sreg2);
CHECK_SRCDST_NCOM;
s390_slbr (code, ins->dreg, src2);
EMIT_COND_SYSTEM_EXCEPTION (S390_CC_NC, "OverflowException");
}
break;
@@ -3805,10 +3815,8 @@ guint8 cond;
}
break;
case CEE_SHL: {
if (ins->sreg1 != ins->dreg) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_sll (code, ins->dreg, ins->sreg2, 0);
CHECK_SRCDST_NCOM;
s390_sll (code, ins->dreg, src2, 0);
}
break;
case OP_SHL_IMM: {
@@ -3819,10 +3827,8 @@ guint8 cond;
}
break;
case CEE_SHR: {
if (ins->sreg1 != ins->dreg) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_sra (code, ins->dreg, ins->sreg2, 0);
CHECK_SRCDST_NCOM;
s390_sra (code, ins->dreg, src2, 0);
}
break;
case OP_SHR_IMM: {
@@ -3840,10 +3846,8 @@ guint8 cond;
}
break;
case CEE_SHR_UN: {
if (ins->sreg1 != ins->dreg) {
s390_lr (code, ins->dreg, ins->sreg1);
}
s390_srl (code, ins->dreg, ins->sreg2, 0);
CHECK_SRCDST_NCOM;
s390_srl (code, ins->dreg, src2, 0);
}
break;
case CEE_NOT: {
@@ -4475,12 +4479,8 @@ guint8 cond;
}
break;
case OP_FSUB: {
if (ins->dreg == ins->sreg1)
s390_sdbr (code, ins->dreg, ins->sreg2);
else {
s390_ldr (code, ins->dreg, ins->sreg1);
s390_sdbr (code, ins->dreg, ins->sreg2);
}
CHECK_SRCDST_NCOM_F;
s390_sdbr (code, ins->dreg, src2);
}
break;
case OP_FMUL: {
@@ -4497,12 +4497,8 @@ guint8 cond;
}
break;
case OP_FDIV: {
if (ins->dreg == ins->sreg1)
s390_ddbr (code, ins->dreg, ins->sreg2);
else {
s390_ldr (code, ins->dreg, ins->sreg1);
s390_ddbr (code, ins->dreg, ins->sreg2);
}
CHECK_SRCDST_NCOM_F;
s390_ddbr (code, ins->dreg, src2);
}
break;
case OP_FNEG: {
@@ -4510,9 +4506,7 @@ guint8 cond;
}
break;
case OP_FREM: {
if (ins->dreg != ins->sreg1) {
s390_ldr (code, ins->dreg, ins->sreg1);
}
CHECK_SRCDST_NCOM_F;
s390_didbr (code, ins->dreg, ins->sreg2, 5, s390_f15);
}
break;
@@ -5153,8 +5147,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_EXC: {
guint8 *ip = patch_info->ip.i + cfg->native_code,
*buf, buf2;
guint8 *ip = patch_info->ip.i + cfg->native_code;
MonoClass *exc_class;
guint32 throw_ip;
+4 -2
View File
@@ -472,10 +472,11 @@ cpuid (int id, int* p_eax, int* p_ebx, int* p_ecx, int* p_edx)
if (have_cpuid) {
/* Have to use the code manager to get around WinXP DEP */
MonoCodeManager *codeman = mono_code_manager_new_dynamic ();
CpuidFunc func;
void *ptr = mono_code_manager_reserve (codeman, sizeof (cpuid_impl));
memcpy (ptr, cpuid_impl, sizeof (cpuid_impl));
CpuidFunc func = (CpuidFunc)ptr;
func = (CpuidFunc)ptr;
func (id, p_eax, p_ebx, p_ecx, p_edx);
mono_code_manager_destroy (codeman);
@@ -2371,6 +2372,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
/* handle clobbering of sreg1 */
if ((spec [MONO_INST_CLOB] == '1' || spec [MONO_INST_CLOB] == 's') && ins->dreg != ins->sreg1) {
MonoInst *sreg2_copy = NULL;
MonoInst *copy = NULL;
if (ins->dreg == ins->sreg2) {
/*
@@ -2388,7 +2390,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
mono_regstate_free_int (rs, reg2);
}
MonoInst *copy = create_copy_ins (cfg, ins->dreg, ins->sreg1, NULL);
copy = create_copy_ins (cfg, ins->dreg, ins->sreg1, NULL);
DEBUG (g_print ("\tneed to copy sreg1 %s to dreg %s\n", mono_arch_regname (ins->sreg1), mono_arch_regname (ins->dreg)));
insert_before_ins (ins, tmp, copy);