Compare commits

...
Author SHA1 Message Date
Alexis Christoforides 633e444670 Trigger package build to bring in xamarin/bockbuild@99730f1980. Fixes #23553. 2014-10-02 17:25:23 -07:00
Marcos Henrich 47db8687f9 Fix Uri UserInfo parsing. Fixes 23246. 2014-09-29 18:59:42 +01:00
Zoltan Varga 53e316103e [llvm] Fix support for unaligned offsets in the store_membase_imm opcodes. Fixes #23267. 2014-09-22 18:53:10 -04:00
Zoltan Varga f28698eaf3 [runtime] Fix the lookup of nested types which have a namespace. Fixes #21653. 2014-09-22 16:28:43 -04:00
Marek Safar ac510020e7 [xbuild] Workaround for issues with CreateItem task where metadata are not generated due to up-to-data inputs. Fixes #23022 2014-09-17 20:20:35 +02:00
Zoltan Varga 491d1f508a [runtime] Make stack walks done by the sampling profiler async safe. 2014-09-16 16:57:12 -04:00
Zoltan Varga 97d0d52d75 [arm64] Increase some opcode sizes. Fixes #23026. 2014-09-15 20:52:26 -04:00
Marek Safar 13b06d2154 Update test verification data 2014-09-12 16:37:38 +02:00
Marek Safar 79d82d18d2 [mcs] Don't use `1 naming for compiler generated second level and deeper nested types. Fixes #22893 2014-09-12 16:25:23 +02:00
Zoltan Varga bf375c28e4 [jit] Always pass the imt arg to interface calls in gsharedvt methods. Fixes #22624. 2014-09-11 18:46:32 -04:00
Jo Shields b4dde7d30e Fix "make dist" error
ad8236ebb8 broke "make dist", by removing Makefile.am.in whilst leaving it in EXTRA_DIST
2014-09-11 14:09:58 -04:00
Zoltan Varga 19797cc6bb Fix the build. 2014-09-11 14:09:58 -04:00
Zoltan Varga 13c6efb7c6 [runtime] Get rid of the Makefile.am.in->Makefile.am change in metadata/, its not needed. 2014-09-11 14:09:58 -04:00
Rolf Bjarne Kvinge 8037a90611 Don't throw TimeZoneNotFoundExceptions when iOS gives us invalid data.
iOS 8 GM lists "Asia/Chita" among its time zones, but when requesting
the time zone data for that time zone, no data is returned.

With this change we ignore time zones without any data when fetching
all the timezones on the system.
2014-09-11 19:22:52 +02:00
Rodrigo Kumpera 9913521258 Revert "[mcs] Use closed delegate over static generated methods from anonymous methods"
This reverts commit 7edcd42a15.

Conflicts:
	mcs/tests/ver-il-net_4_5.xml
2014-09-10 11:46:00 -04:00
Zoltan Varga e9b744caef Fix the linux build. 2014-09-10 00:10:01 -04:00
Zoltan Varga 2342e18144 [runtime] Fix the linux build. 2014-09-09 11:48:04 -04:00
Zoltan Varga c8ef103f07 [jit] Store the epilog length in MonoArchEHJitInfo instead of encoding it in jinfo->unwind_desc, since the latter can overflow for methods with large epilogs. Fixes #22685. 2014-09-05 18:09:19 -04:00
Rodrigo Kumpera 9add1e0fc2 [utils] Add android extension point to threading. 2014-09-04 17:26:05 -04:00
Rodrigo Kumpera 32c8b7a212 [runtime] Cleanup the horrible ifdef hell that is the stack bounds discovery code.
This split a single chunk of intractable ifdef hell into a beautiful set of per-target
files.

This will allow us to actually figure out what's going on on each target.
2014-09-04 17:25:59 -04:00
Alexis Christoforides 292b18ead6 Bump Mono version -> 3.10.0 2014-09-04 00:13:32 -04:00
Zoltan Varga 39d843f11f [runtime] Load the runtime config file before initializing the runtime, so it can pick up the aot-cache configuration information. 2014-09-03 23:09:18 -04:00
Zoltan Varga 33ec8fd66b [sgen] Use mono_thread_info_get_stack_bounds () on win32 as well, the stack bottom value returned by it is correct, only the stack top value is unusable, since windows dynamically extends the stack. 2014-09-03 21:54:00 -04:00
Zoltan Varga 13dd8b3588 Fix a warning. 2014-09-03 00:56:27 -04:00
Zoltan Varga 47af9db998 [runtime] Add an 'app' attribute to the 'aotcache' config section to specify which apps should use the AOT cache. 2014-09-03 00:56:20 -04:00
Zoltan Varga d4d62e73c2 Disable a sys.data test which fails on wrench because of an old sqlite version. 2014-09-02 13:10:19 -04:00
Marek Safar 1ce0cbe0c8 [mcs] Remove wrong test 2014-09-01 13:29:18 +02:00
Marek Safar 5d73ab53fb [system.net.http] Update RequestMessage.RequestUri.AbsoluteUri after redirect. Fixes #22383 2014-09-01 10:11:23 +02:00
Zoltan Varga 085fa4ce86 [runtime] Fix the windows build. 2014-08-31 12:56:17 -04:00
Zoltan Varga cd4fa869d9 [jit] Avoid uninitialized fields in the MonoDelegateTrampInfo structure. 2014-08-31 12:56:08 -04:00
Zoltan Varga 174c85763f [aot] Fix full-aot support when the AOT cache is enabled. 2014-08-31 12:56:00 -04:00
Marek Safar 5ab589ace2 [xbuild] Fix InstalledAssemblyTables signature 2014-08-30 14:19:35 +02:00
Marek Safar 2eeebc9530 [mcs] Revert to broken native csc definite assignment for structs 2014-08-30 14:19:12 +02:00
Zoltan Varga c5a361b157 [sdb] Fix the checking of the handshake message. 2014-08-29 15:53:43 -04:00
Zoltan Varga fcb962d82f [runtime] Add functionality for AOTing assemblies on demand when they are first used. Configurable using a new "aotconfig" config element, i.e. <aotcache assemblies="mscorlib System"/>. 2014-08-29 15:53:16 -04:00
Zoltan Varga 5e200e65eb [runtime] Add Steve Reid's public domain SHA1 code. 2014-08-29 15:53:08 -04:00
54 changed files with 1858 additions and 1209 deletions

No files matched your search

-1
View File
@@ -123,7 +123,6 @@ if test x$has_ext_mod = xtrue; then
popd
else
cat mono/mini/Makefile.am.in > mono/mini/Makefile.am
cat mono/metadata/Makefile.am.in > mono/metadata/Makefile.am
fi
+1 -1
View File
@@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script.
#AC_PREREQ([2.62])
AC_INIT(mono, [3.8.1],
AC_INIT(mono, [3.10.0],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
+1 -1
@@ -99,8 +99,12 @@ namespace Microsoft.Build.BuildEngine {
try {
TaskExecutionMode taskExecutionMode;
string reason;
if (!BuildTargetNeeded (out reason)) {
bool skip_completely;
if (!BuildTargetNeeded (out reason, out skip_completely)) {
LogTargetSkipped (target, reason);
if (skip_completely)
return true;
taskExecutionMode = TaskExecutionMode.SkipAndSetOutput;
} else {
taskExecutionMode = TaskExecutionMode.Complete;
@@ -113,8 +117,27 @@ namespace Microsoft.Build.BuildEngine {
//FIXME: parsing attributes repeatedly
IBuildTask bt = target.BuildTasks [i];
// HACK: need some form of cross references checks
var tem = taskExecutionMode;
if (tem == TaskExecutionMode.SkipAndSetOutput) {
var bti = bt as BuildTask;
//
// BuildTargetNeeded checks only files timestamps but ignores any metadata dependencies
// that way we can end up in the situation when output metadata are populated but from
// incomplete dependencies.
//
// E.g.
// <CreateItem Include="$(IntermediateOutputPath)%(_PngImage.LogicalName)" AdditionalMetadata="LogicalName=%(_PngImage.LogicalName)">
// <Output TaskParameter="Include" />
// </CreateItem>
//
if (bti != null && bti.Name == "CreateItem")
tem = TaskExecutionMode.Complete;
}
TaskBatchingImpl batchingImpl = new TaskBatchingImpl (project);
bool task_result = batchingImpl.Build (bt, taskExecutionMode, out executeOnErrors);
bool task_result = batchingImpl.Build (bt, tem, out executeOnErrors);
if (task_result)
continue;
@@ -149,15 +172,17 @@ namespace Microsoft.Build.BuildEngine {
ParseAttribute (outputs);
}
bool BuildTargetNeeded (out string reason)
bool BuildTargetNeeded (out string reason, out bool skipCompletely)
{
reason = String.Empty;
ITaskItem [] inputFiles;
ITaskItem [] outputFiles;
DateTime youngestInput, oldestOutput;
skipCompletely = false;
if (String.IsNullOrEmpty (inputs.Trim ()))
if (String.IsNullOrEmpty (inputs.Trim ())) {
return true;
}
if (String.IsNullOrEmpty (outputs.Trim ())) {
project.ParentEngine.LogError ("Target {0} has inputs but no outputs specified.", name);
@@ -178,6 +203,7 @@ namespace Microsoft.Build.BuildEngine {
}
if (inputFiles == null || inputFiles.Length == 0) {
skipCompletely = true;
reason = String.Format ("No input files were specified for target {0}, skipping.", name);
return false;
}
@@ -53,7 +53,6 @@ namespace Microsoft.Build.Tasks {
bool findRelatedFiles;
bool findSatellites;
bool findSerializationAssemblies;
string[] installedAssemblyTables;
ITaskItem[] relatedFiles;
ITaskItem[] resolvedDependencyFiles;
ITaskItem[] resolvedFiles;
@@ -626,12 +625,15 @@ namespace Microsoft.Build.Tasks {
get { return findSerializationAssemblies; }
set { findSerializationAssemblies = value; }
}
/*
public string[] InstalledAssemblyTables {
get { return installedAssemblyTables; }
set { installedAssemblyTables = value; }
}
*/
public
#if NET_4_0
ITaskItem[]
#else
string[]
#endif
InstalledAssemblyTables { get; set; }
[Output]
public ITaskItem[] RelatedFiles {
get { return relatedFiles; }
@@ -64,12 +64,15 @@ namespace System {
[DllImport ("__Internal")]
extern static IntPtr monotouch_timezone_get_data (string name, ref int size);
static Stream GetMonoTouchData (string name)
static Stream GetMonoTouchData (string name, bool throw_on_error = true)
{
int size = 0;
IntPtr data = monotouch_timezone_get_data (name, ref size);
if (size <= 0)
throw new TimeZoneNotFoundException ();
if (size <= 0) {
if (throw_on_error)
throw new TimeZoneNotFoundException ();
return null;
}
unsafe {
var s = new UnmanagedMemoryStream ((byte*) data, size);
+3 -1
View File
@@ -651,7 +651,9 @@ namespace System
#elif MONOTOUCH
if (systemTimeZones.Count == 0) {
foreach (string name in GetMonoTouchNames ()) {
using (Stream stream = GetMonoTouchData (name)) {
using (Stream stream = GetMonoTouchData (name, false)) {
if (stream == null)
continue;
systemTimeZones.Add (BuildFromStream (name, stream));
}
}
@@ -225,6 +225,7 @@ sqliteDataAdapter.Update (dataSet, "Primus");
}
[Test]
[Category ("NotWorking")] // Requires newer sqlite than is on wrench
public void UpdateResetRowErrorCorrectly ()
{
const string connectionString = "URI = file::memory:; Version = 3";
@@ -306,6 +306,8 @@ namespace System.Net.Http
item_headers.TryAddWithoutValidation (key, value);
}
requestMessage.RequestUri = wr.ResponseUri;
return response;
}
@@ -800,6 +800,30 @@ namespace MonoTests.System.Net.Http
}
}
[Test]
public void RequestUriAfterRedirect ()
{
var listener = CreateListener (l => {
var request = l.Request;
var response = l.Response;
response.StatusCode = (int)HttpStatusCode.Moved;
response.RedirectLocation = "http://xamarin.com/";
});
try {
var chandler = new HttpClientHandler ();
chandler.AllowAutoRedirect = true;
var client = new HttpClient (chandler);
var resp = client.GetAsync (LocalServer).Result;
Assert.AreEqual ("http://xamarin.com/", resp.RequestMessage.RequestUri.AbsoluteUri, "#1");
} finally {
listener.Abort ();
listener.Close ();
}
}
[Test]
/*
* Properties may only be modified before sending the first request.
@@ -336,7 +336,13 @@ namespace System {
if (ch == '%'){
if (!Uri.IsHexEncoding (part, index))
return false;
var oldIndex = index;
ch = Uri.HexUnescape (part, ref index);
index--;
if (ch == '@') {
sb.Append (part.Substring (oldIndex, index - oldIndex + 1));
continue;
}
}
if (Char.IsLetterOrDigit (ch) || IsUnreserved (ch) || IsSubDelim (ch) || ch == ':'){
+18
View File
@@ -0,0 +1,18 @@
// CS0171: Field `S1.s2' must be fully assigned before control leaves the constructor
// Line: 11
using System;
struct S1
{
S2 s2;
public S1 (int arg)
{
}
}
struct S2
{
int field;
}
+6 -2
View File
@@ -1792,8 +1792,12 @@ namespace Mono.CSharp {
// this argument is generated during compilation which speeds up dispatch
// by about 25%
//
method_parameters = ParametersCompiled.Prefix (method_parameters,
new Parameter (null, null, 0, null, loc), ec.Module.Compiler.BuiltinTypes.Object);
//
// Disabled for now due to JIT bug
//
//method_parameters = ParametersCompiled.Prefix (method_parameters,
// new Parameter (null, null, 0, null, loc), ec.Module.Compiler.BuiltinTypes.Object);
}
if (storey == null && hoisted_tparams == null)
+5 -9
View File
@@ -44,7 +44,6 @@ namespace Mono.CSharp
public abstract class TypeContainer : MemberCore
{
public readonly MemberKind Kind;
public readonly string Basename;
protected List<TypeContainer> containers;
@@ -62,9 +61,6 @@ namespace Mono.CSharp
: base (parent, name, attrs)
{
this.Kind = kind;
if (name != null)
this.Basename = name.Basename;
defined_names = new Dictionary<string, MemberCore> ();
}
@@ -111,7 +107,7 @@ namespace Mono.CSharp
public virtual void AddPartial (TypeDefinition next_part)
{
MemberCore mc;
(PartialContainer ?? this).defined_names.TryGetValue (next_part.Basename, out mc);
(PartialContainer ?? this).defined_names.TryGetValue (next_part.MemberName.Basename, out mc);
AddPartial (next_part, mc as TypeDefinition);
}
@@ -380,7 +376,7 @@ namespace Mono.CSharp
containers.Remove (cont);
var tc = Parent == Module ? Module : this;
tc.defined_names.Remove (cont.Basename);
tc.defined_names.Remove (cont.MemberName.Basename);
}
public virtual void VerifyMembers ()
@@ -772,7 +768,7 @@ namespace Mono.CSharp
public override void AddTypeContainer (TypeContainer tc)
{
AddNameToContainer (tc, tc.Basename);
AddNameToContainer (tc, tc.MemberName.Basename);
base.AddTypeContainer (tc);
}
@@ -1295,7 +1291,7 @@ namespace Mono.CSharp
CreateMetadataName (sb);
TypeBuilder = Module.CreateBuilder (sb.ToString (), TypeAttr, type_size);
} else {
TypeBuilder = parent_def.TypeBuilder.DefineNestedType (Basename, TypeAttr, null, type_size);
TypeBuilder = parent_def.TypeBuilder.DefineNestedType (MemberName.Basename, TypeAttr, null, type_size);
}
if (DeclaringAssembly.Importer != null)
@@ -1795,7 +1791,7 @@ namespace Mono.CSharp
{
base.RemoveContainer (cont);
Members.Remove (cont);
Cache.Remove (cont.Basename);
Cache.Remove (cont.MemberName.Basename);
}
protected virtual bool DoResolveTypeParameters ()
-5
View File
@@ -195,11 +195,6 @@ namespace Mono.CSharp {
return name + "`" + args.Count;
}
public static string MakeName (string name, int count)
{
return name + "`" + count;
}
}
public class SimpleMemberName
+1 -1
View File
@@ -1277,7 +1277,7 @@ namespace Mono.CSharp
if (current_container.Containers != null)
{
var existing = current_container.Containers.FirstOrDefault (l => l.Basename == tc.Basename);
var existing = current_container.Containers.FirstOrDefault (l => l.MemberName.Basename == tc.MemberName.Basename);
if (existing != null) {
current_container.RemoveContainer (existing);
undo_actions.Add (() => current_container.AddTypeContainer (existing));
-8
View File
@@ -697,14 +697,6 @@ namespace Mono.CSharp {
if ((name_entry.Modifiers & Modifiers.STATIC) != 0)
continue;
//
// Ignore user private fields for definite assignment. This is sort of unexpected but
// rationale is to have consistent results when using reference assemblies which don't
// include any private fields and full assemblies
//
if ((name_entry.Modifiers & (Modifiers.PRIVATE | Modifiers.BACKING_FIELD)) == Modifiers.PRIVATE)
continue;
//
// Fixed size buffers are not subject to definite assignment checking
//
+3 -4
View File
@@ -488,8 +488,8 @@ namespace Mono.CSharp {
public void RemoveContainer (TypeContainer tc)
{
types.Remove (tc.Basename);
cached_types.Remove (tc.Basename);
types.Remove (tc.MemberName.Basename);
cached_types.Remove (tc.MemberName.Basename);
}
public void SetBuiltinType (BuiltinTypeSpec pts)
@@ -790,9 +790,8 @@ namespace Mono.CSharp {
public override void AddTypeContainer (TypeContainer tc)
{
string name = tc.Basename;
var mn = tc.MemberName;
var name = mn.Basename;
while (mn.Left != null) {
mn = mn.Left;
name = mn.Name;
-24
View File
@@ -1,24 +0,0 @@
using System;
// C#6 change
struct S1
{
S2 s2;
public S1 (int arg)
{
}
}
struct S2
{
int field;
}
class X
{
public static void Main ()
{
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Reflection;
class CorrectEncodingOfNestedTypes
{
static async Task<T> GetAsync<T>(string s) where T : new()
{
return await Task.Factory.StartNew(async () => {
var response = await Task.FromResult (s);
return (T)new object();
}).Unwrap();
}
public static int Main ()
{
var t = typeof (CorrectEncodingOfNestedTypes).GetNestedTypes (BindingFlags.NonPublic) [0].GetNestedTypes (BindingFlags.NonPublic) [0];
var m = t.GetMethods (BindingFlags.NonPublic | BindingFlags.Instance) [0];
var ca = (AsyncStateMachineAttribute) m.GetCustomAttributes (true) [0];
if (ca.StateMachineType.GetGenericArguments ().Length != 1)
return 1;
return 0;
}
}
File diff suppressed because it is too large. Load diff
@@ -340,10 +340,4 @@ endif
endif
EXTRA_DIST = make-bundle.pl sample-bundle $(win32_sources) $(unix_sources) $(null_sources) runtime.h \
tpool-poll.c tpool-epoll.c tpool-kqueue.c Makefile.am.in
if HAS_EXTENSION_MODULE
else
Makefile.am: Makefile.am.in
cp $< $@
endif
tpool-poll.c tpool-epoll.c tpool-kqueue.c
+1
View File
@@ -175,6 +175,7 @@ typedef struct
typedef struct
{
guint32 stack_size;
guint32 epilog_size;
} MonoArchEHJitInfo;
typedef struct {
+9
View File
@@ -138,6 +138,9 @@ static const MonoRuntimeInfo supported_runtimes[] = {
static MonoCreateDomainFunc create_domain_hook;
static MonoFreeDomainFunc free_domain_hook;
/* AOT cache configuration */
static MonoAotCacheConfig aot_cache_config;
/* This is intentionally not in the header file, so people don't misuse it. */
extern void _mono_debug_init_corlib (MonoDomain *domain);
@@ -2776,3 +2779,9 @@ mono_enable_debug_domain_unload (gboolean enable)
{
debug_domain_unload = enable;
}
MonoAotCacheConfig *
mono_get_aot_cache_config (void)
{
return &aot_cache_config;
}
+12
View File
@@ -2266,6 +2266,18 @@ mono_stack_walk_no_il (MonoStackWalk func, gpointer user_data)
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_DEFAULT, &ud);
}
/*
* mono_stack_walk_async_safe:
*
* Async safe version callable from signal handlers.
*/
void
mono_stack_walk_async_safe (MonoStackWalk func, gpointer user_data)
{
StackWalkUserData ud = { func, user_data };
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_NONE, &ud);
}
static gboolean
last_managed (MonoMethod *m, gint no, gint ilo, gboolean managed, gpointer data)
{
+3
View File
@@ -90,6 +90,9 @@ mono_stack_walk (MonoStackWalk func, void* user_data);
MONO_API void
mono_stack_walk_no_il (MonoStackWalk func, void* user_data);
MONO_API void
mono_stack_walk_async_safe (MonoStackWalk func, void* user_data);
MONO_END_DECLS
#endif
+15
View File
@@ -523,6 +523,19 @@ struct _MonoMethodSignature {
MonoType *params [MONO_ZERO_LEN_ARRAY];
};
/*
* AOT cache configuration loaded from config files.
* Doesn't really belong here.
*/
typedef struct {
/*
* Enable aot caching for applications whose main assemblies are in
* this list.
*/
GSList *apps;
GSList *assemblies;
} MonoAotCacheConfig;
#define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
static inline gboolean
@@ -785,5 +798,7 @@ MonoMethod *mono_get_method_constrained_with_method (MonoImage *image, MonoMetho
void mono_type_set_alignment (MonoTypeEnum type, int align) MONO_INTERNAL;
MonoAotCacheConfig *mono_get_aot_cache_config (void) MONO_INTERNAL;
#endif /* __MONO_METADATA_INTERNALS_H__ */
+49 -1
View File
@@ -357,6 +357,54 @@ legacyUEP_handler = {
NULL, /* finish */
};
static void
aot_cache_start (gpointer user_data,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values)
{
int i;
MonoAotCacheConfig *config;
if (strcmp (element_name, "aotcache") != 0)
return;
config = mono_get_aot_cache_config ();
/* Per-app configuration */
for (i = 0; attribute_names [i]; ++i) {
if (!strcmp (attribute_names [i], "app")) {
config->apps = g_slist_prepend (config->apps, g_strdup (attribute_values [i]));
return;
}
}
/* Global configuration */
for (i = 0; attribute_names [i]; ++i) {
if (!strcmp (attribute_names [i], "assemblies")) {
char **parts, **ptr;
char *part;
parts = g_strsplit (attribute_values [i], " ", -1);
for (ptr = parts; ptr && *ptr; ptr ++) {
part = *ptr;
config->assemblies = g_slist_prepend (config->assemblies, g_strdup (part));
}
g_strfreev (parts);
}
}
}
static const MonoParseHandler
aot_cache_handler = {
"aotcache",
NULL, /* init */
aot_cache_start,
NULL, /* text */
NULL, /* end */
NULL, /* finish */
};
static int inited = 0;
static void
@@ -366,6 +414,7 @@ mono_config_init (void)
config_handlers = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (config_handlers, (gpointer) dllmap_handler.element_name, (gpointer) &dllmap_handler);
g_hash_table_insert (config_handlers, (gpointer) legacyUEP_handler.element_name, (gpointer) &legacyUEP_handler);
g_hash_table_insert (config_handlers, (gpointer) aot_cache_handler.element_name, (gpointer) &aot_cache_handler);
}
void
@@ -407,7 +456,6 @@ mono_config_parse_file_with_context (ParseState *state, const char *filename)
if (!g_file_get_contents (filename, &text, &len, NULL))
return 0;
offset = 0;
if (len > 3 && text [0] == '\xef' && text [1] == (gchar) '\xbb' && text [2] == '\xbf')
offset = 3; /* Skip UTF-8 BOM */
+43 -5
View File
@@ -7501,14 +7501,52 @@ mono_reflection_get_type_internal (MonoImage *rootimage, MonoImage* image, MonoT
mono_class_init (parent);
while ((klass = mono_class_get_nested_types (parent, &iter))) {
if (ignorecase) {
if (mono_utf8_strcasecmp (klass->name, mod->data) == 0)
break;
char *lastp;
char *nested_name, *nested_nspace;
gboolean match = TRUE;
lastp = strrchr (mod->data, '.');
if (lastp) {
/* Nested classes can have namespaces */
int nspace_len;
nested_name = g_strdup (lastp + 1);
nspace_len = lastp - (char*)mod->data;
nested_nspace = g_malloc (nspace_len + 1);
memcpy (nested_nspace, mod->data, nspace_len);
nested_nspace [nspace_len] = '\0';
} else {
if (strcmp (klass->name, mod->data) == 0)
break;
nested_name = mod->data;
nested_nspace = NULL;
}
if (nested_nspace) {
if (ignorecase) {
if (!(klass->name_space && mono_utf8_strcasecmp (klass->name_space, nested_nspace) == 0))
match = FALSE;
} else {
if (!(klass->name_space && strcmp (klass->name_space, nested_nspace) == 0))
match = FALSE;
}
}
if (match) {
if (ignorecase) {
if (mono_utf8_strcasecmp (klass->name, nested_name) != 0)
match = FALSE;
} else {
if (strcmp (klass->name, nested_name) != 0)
match = FALSE;
}
}
if (lastp) {
g_free (nested_name);
g_free (nested_nspace);
}
if (match)
break;
}
if (!klass)
break;
}
+2 -2
View File
@@ -3835,11 +3835,11 @@ sgen_thread_register (SgenThreadInfo* info, void *addr)
binary_protocol_thread_register ((gpointer)mono_thread_info_get_tid (info));
/* On win32, stack_start_limit should be 0, since the stack can grow dynamically */
#ifndef HOST_WIN32
mono_thread_info_get_stack_bounds (&staddr, &stsize);
#endif
if (staddr) {
#ifndef HOST_WIN32
info->stack_start_limit = staddr;
#endif
info->stack_end = staddr + stsize;
} else {
gsize stack_bottom = (gsize)addr;
+2 -12
View File
@@ -5333,18 +5333,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
encoded = mono_unwind_ops_encode (cfg->unwind_ops, &encoded_len);
unwind_desc = get_unwind_info_offset (acfg, encoded, encoded_len);
g_assert (unwind_desc < 0xffff);
if (cfg->has_unwind_info_for_epilog) {
/*
* The lower 16 bits identify the unwind descriptor, the upper 16 bits contain the offset of
* the start of the epilog from the end of the method.
*/
g_assert (cfg->code_size - cfg->epilog_begin < 0xffff);
encode_value (((cfg->code_size - cfg->epilog_begin) << 16) | unwind_desc, p, &p);
g_free (encoded);
} else {
encode_value (unwind_desc, p, &p);
}
encode_value (unwind_desc, p, &p);
} else {
encode_value (jinfo->unwind_info, p, &p);
}
@@ -5443,6 +5432,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
eh_info = mono_jit_info_get_arch_eh_info (jinfo);
encode_value (eh_info->stack_size, p, &p);
encode_value (eh_info->epilog_size, p, &p);
}
if (jinfo->has_generic_jit_info) {
+260 -106
View File
@@ -55,12 +55,17 @@
#include <mono/utils/mono-mmap.h>
#include "mono/utils/mono-compiler.h"
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-digest.h>
#include "mini.h"
#include "version.h"
#ifndef DISABLE_AOT
#ifdef TARGET_OSX
#define ENABLE_AOT_CACHE
#endif
#ifdef TARGET_WIN32
#define SHARED_EXT ".dll"
#elif ((defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__)) || defined(__MACH__)) && !defined(__linux__)
@@ -167,15 +172,11 @@ static GHashTable *ji_to_amodule;
/*
* Whenever to AOT compile loaded assemblies on demand and store them in
* a cache under $HOME/.mono/aot-cache.
* a cache.
*/
static gboolean use_aot_cache = FALSE;
static gboolean enable_aot_cache = FALSE;
/*
* Whenever to spawn a new process to AOT a file or do it in-process. Only relevant if
* use_aot_cache is TRUE.
*/
static gboolean spawn_compiler = TRUE;
static gboolean mscorlib_aot_loaded;
/* For debugging */
static gint32 mono_last_aot_method = -1;
@@ -243,7 +244,7 @@ load_image (MonoAotModule *amodule, int index, gboolean set_error)
assembly = mono_assembly_load (&amodule->image_names [index], amodule->assembly->basedir, &status);
if (!assembly) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable because dependency %s is not found.\n", amodule->aot_name, amodule->image_names [index].name);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable because dependency %s is not found.\n", amodule->aot_name, amodule->image_names [index].name);
amodule->out_of_date = TRUE;
if (set_error) {
@@ -255,7 +256,7 @@ load_image (MonoAotModule *amodule, int index, gboolean set_error)
}
if (strcmp (assembly->image->guid, amodule->image_guids [index])) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').\n", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').\n", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
amodule->out_of_date = TRUE;
return NULL;
}
@@ -1272,132 +1273,270 @@ decode_resolve_method_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf)
return decode_resolve_method_ref_with_target (module, NULL, buf, endbuf);
}
#ifdef ENABLE_AOT_CACHE
/* AOT CACHE */
/*
* FIXME:
* - Add options for controlling the cache size
* - Handle full cache by deleting old assemblies lru style
* - Maybe add a threshold after an assembly is AOT compiled
* - Add options for enabling this for specific main assemblies
*/
/* The cache directory */
static char *cache_dir;
/* The number of assemblies AOTed in this run */
static int cache_count;
/* Whenever to AOT in-process */
static gboolean in_process;
static void
create_cache_structure (void)
collect_assemblies (gpointer data, gpointer user_data)
{
const char *home;
char *tmp;
int err;
MonoAssembly *ass = data;
GSList **l = user_data;
home = g_get_home_dir ();
if (!home)
*l = g_slist_prepend (*l, ass);
}
#define SHA1_DIGEST_LENGTH 20
/*
* get_aot_config_hash:
*
* Return a hash for all the version information an AOT module depends on.
*/
static G_GNUC_UNUSED char*
get_aot_config_hash (MonoAssembly *assembly)
{
char *build_info;
GSList *l, *assembly_list = NULL;
GString *s;
int i;
guint8 digest [SHA1_DIGEST_LENGTH];
char *digest_str;
build_info = mono_get_runtime_build_info ();
s = g_string_new (build_info);
mono_assembly_foreach (collect_assemblies, &assembly_list);
/*
* The assembly list includes the current assembly as well, no need
* to add it.
*/
for (l = assembly_list; l; l = l->next) {
MonoAssembly *ass = l->data;
g_string_append (s, "_");
g_string_append (s, ass->aname.name);
g_string_append (s, "_");
g_string_append (s, ass->image->guid);
}
for (i = 0; i < s->len; ++i) {
if (!isalnum (s->str [i]) && s->str [i] != '-')
s->str [i] = '_';
}
mono_sha1_get_digest ((guint8*)s->str, s->len, digest);
digest_str = g_malloc0 ((SHA1_DIGEST_LENGTH * 2) + 1);
for (i = 0; i < SHA1_DIGEST_LENGTH; ++i)
sprintf (digest_str + (i * 2), "%02x", digest [i]);
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: file dependencies: %s, hash %s", s->str, digest_str);
g_string_free (s, TRUE);
return digest_str;
}
static void
aot_cache_init (void)
{
if (mono_aot_only)
return;
tmp = g_build_filename (home, ".mono", NULL);
if (!g_file_test (tmp, G_FILE_TEST_IS_DIR)) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT creating directory %s", tmp);
#ifdef HOST_WIN32
err = mkdir (tmp);
#else
err = mkdir (tmp, 0777);
#endif
if (err) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT failed: %s", g_strerror (errno));
g_free (tmp);
return;
}
}
g_free (tmp);
tmp = g_build_filename (home, ".mono", "aot-cache", NULL);
if (!g_file_test (tmp, G_FILE_TEST_IS_DIR)) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT creating directory %s", tmp);
#ifdef HOST_WIN32
err = mkdir (tmp);
#else
err = mkdir (tmp, 0777);
#endif
if (err) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT failed: %s", g_strerror (errno));
g_free (tmp);
return;
}
}
g_free (tmp);
enable_aot_cache = TRUE;
in_process = TRUE;
}
/*
* load_aot_module_from_cache:
* aot_cache_load_module:
*
* Experimental code to AOT compile loaded assemblies on demand.
*
* FIXME:
* - Add environment variable MONO_AOT_CACHE_OPTIONS
* - Add options for controlling the cache size
* - Handle full cache by deleting old assemblies lru style
* - Add options for excluding assemblies during development
* - Maybe add a threshold after an assembly is AOT compiled
* - invoking a new mono process is a security risk
* - recompile the AOT module if one of its dependencies changes
* Load the AOT image corresponding to ASSEMBLY from the aot cache, AOTing it if neccessary.
*/
static MonoDl*
load_aot_module_from_cache (MonoAssembly *assembly, char **aot_name)
aot_cache_load_module (MonoAssembly *assembly, char **aot_name)
{
char *fname, *cmd, *tmp2, *aot_options;
MonoAotCacheConfig *config;
GSList *l;
char *fname, *tmp2, *aot_options;
const char *home;
MonoDl *module;
gboolean res;
gchar *out, *err;
gint exit_status;
char *hash;
int pid;
gboolean enabled;
*aot_name = NULL;
if (image_is_dynamic (assembly->image))
return NULL;
create_cache_structure ();
/* Check in the list of assemblies enabled for aot caching */
config = mono_get_aot_cache_config ();
home = g_get_home_dir ();
enabled = FALSE;
if (config->apps) {
MonoDomain *domain = mono_domain_get ();
MonoAssembly *entry_assembly = domain->entry_assembly;
tmp2 = g_strdup_printf ("%s-%s%s", assembly->image->assembly_name, assembly->image->guid, SHARED_EXT);
fname = g_build_filename (home, ".mono", "aot-cache", tmp2, NULL);
for (l = config->apps; l; l = l->next) {
char *n = l->data;
if ((entry_assembly && !strcmp (entry_assembly->aname.name, n)) || (!entry_assembly && !strcmp (assembly->aname.name, n)))
break;
}
if (l)
enabled = TRUE;
}
if (!enabled) {
for (l = config->assemblies; l; l = l->next) {
char *n = l->data;
if (!strcmp (assembly->aname.name, n))
break;
}
if (l)
enabled = TRUE;
}
if (!enabled)
return NULL;
if (!cache_dir) {
home = g_get_home_dir ();
if (!home)
return NULL;
cache_dir = g_strdup_printf ("%s/Library/Caches/mono/aot-cache", home);
if (!g_file_test (cache_dir, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_DIR))
g_mkdir_with_parents (cache_dir, 0777);
}
/*
* The same assembly can be used in multiple configurations, i.e. multiple
* versions of the runtime, with multiple versions of dependent assemblies etc.
* To handle this, we compute a version string containing all this information, hash it,
* and use the hash as a filename suffix.
*/
hash = get_aot_config_hash (assembly);
tmp2 = g_strdup_printf ("%s-%s%s", assembly->image->assembly_name, hash, SHARED_EXT);
fname = g_build_filename (cache_dir, tmp2, NULL);
*aot_name = fname;
g_free (tmp2);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT trying to load from cache: '%s'.", fname);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loading from cache: '%s'.", fname);
module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
if (!module) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT not found.");
if (module)
return module;
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT precompiling assembly '%s'... ", assembly->image->name);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: not found.");
if (!strcmp (assembly->aname.name, "mscorlib") && !mono_defaults.corlib)
/* Can't AOT this during startup */
return NULL;
/* Only AOT one assembly per run to avoid slowing down execution too much */
if (cache_count > 0)
return NULL;
cache_count ++;
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compiling assembly '%s'... ", assembly->image->name);
/*
* We need to invoke the AOT compiler here. There are multiple approaches:
* - spawn a new runtime process. This can be hard when running with mkbundle, and
* its hard to make the new process load the same set of assemblies.
* - doing it in-process. This exposes the current process to bugs/leaks/side effects of
* the AOT compiler.
* - fork a new process and do the work there.
*/
if (in_process) {
FILE *logfile;
char *logfile_name;
logfile_name = g_strdup_printf ("%s/aot.log", cache_dir);
logfile = fopen (logfile_name, "a+");
aot_options = g_strdup_printf ("outfile=%s", fname);
/* Maybe due this in another thread ? */
res = mono_compile_assembly (assembly, mono_parse_default_optimizations (NULL), aot_options);
// FIXME: Cache failures
} else {
/*
* - Avoid waiting for the aot process to finish ?
* (less overhead, but multiple processes could aot the same assembly at the same time)
*/
pid = fork ();
if (pid == 0) {
FILE *logfile;
char *logfile_name;
if (spawn_compiler) {
/* FIXME: security */
/* FIXME: Has to pass the assembly loading path to the child process */
cmd = g_strdup_printf ("mono -O=all --aot=%s %s", aot_options, assembly->image->name);
/* Child */
res = g_spawn_command_line_sync (cmd, &out, &err, &exit_status, NULL);
logfile_name = g_strdup_printf ("%s/aot.log", cache_dir);
logfile = fopen (logfile_name, "a+");
g_free (logfile_name);
#if !defined(HOST_WIN32) && !defined(__ppc__) && !defined(__ppc64__) && !defined(__powerpc__)
if (res) {
if (!WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) == 0))
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT failed: %s.", err);
else
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT succeeded.");
g_free (out);
g_free (err);
}
#endif
g_free (cmd);
} else {
dup2 (fileno (logfile), 1);
dup2 (fileno (logfile), 2);
aot_options = g_strdup_printf ("outfile=%s", fname);
res = mono_compile_assembly (assembly, mono_parse_default_optimizations (NULL), aot_options);
if (!res) {
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT failed.");
exit (1);
} else {
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT succeeded.");
exit (0);
}
} else {
/* Parent */
waitpid (pid, &exit_status, 0);
if (!WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) == 0))
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: failed.");
else
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: succeeded.");
}
module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
g_free (aot_options);
}
module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
return module;
}
#else
static void
aot_cache_init (void)
{
}
static MonoDl*
aot_cache_load_module (MonoAssembly *assembly, char **aot_name)
{
return NULL;
}
#endif
static void
find_symbol (MonoDl *module, gpointer *globals, const char *name, gpointer *value)
{
@@ -1589,6 +1728,10 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
if (mono_security_cas_enabled ())
return;
if (enable_aot_cache && !strcmp (assembly->aname.name, "mscorlib") && !mono_defaults.corlib && !mono_aot_only)
/* Loaded later from mono_aot_get_method () */
return;
mono_aot_lock ();
if (static_aot_modules)
info = g_hash_table_lookup (static_aot_modules, assembly->aname.name);
@@ -1596,16 +1739,17 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
info = NULL;
mono_aot_unlock ();
sofile = NULL;
if (info) {
/* Statically linked AOT module */
sofile = NULL;
aot_name = g_strdup_printf ("%s", assembly->aname.name);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "Found statically linked AOT module '%s'.\n", aot_name);
globals = info->globals;
} else {
if (use_aot_cache)
sofile = load_aot_module_from_cache (assembly, &aot_name);
else {
if (enable_aot_cache)
sofile = aot_cache_load_module (assembly, &aot_name);
if (!sofile) {
char *err;
aot_name = g_strdup_printf ("%s%s", assembly->image->name, SHARED_EXT);
@@ -1652,7 +1796,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
fprintf (stderr, "Failed to load AOT module '%s' while running in aot-only mode: %s.\n", aot_name, msg);
exit (1);
} else {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable: %s.\n", aot_name, msg);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable: %s.\n", aot_name, msg);
}
g_free (msg);
g_free (aot_name);
@@ -1873,14 +2017,14 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
}
if (amodule->out_of_date) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT Module %s is unusable because a dependency is out-of-date.\n", assembly->image->name);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: Module %s is unusable because a dependency is out-of-date.\n", assembly->image->name);
if (mono_aot_only) {
fprintf (stderr, "Failed to load AOT module '%s' while running in aot-only mode because a dependency cannot be found or it is out of date.\n", aot_name);
exit (1);
}
}
else
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT loaded AOT Module for %s.\n", assembly->image->name);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loaded AOT Module for %s.\n", assembly->image->name);
}
/*
@@ -1943,8 +2087,9 @@ mono_aot_init (void)
if (g_getenv ("MONO_LASTAOT"))
mono_last_aot_method = atoi (g_getenv ("MONO_LASTAOT"));
if (g_getenv ("MONO_AOT_CACHE"))
use_aot_cache = TRUE;
#ifdef ENABLE_AOT_CACHE
aot_cache_init ();
#endif
}
void
@@ -2537,6 +2682,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
eh_info = mono_jit_info_get_arch_eh_info (jinfo);
eh_info->stack_size = decode_value (p, &p);
eh_info->epilog_size = decode_value (p, &p);
}
if (async) {
@@ -2696,8 +2842,7 @@ mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
mono_aot_unlock ();
}
/* The upper 16 bits of ji->unwind_info might contain the epilog offset */
p = amodule->unwind_info + (ji->unwind_info & 0xffff);
p = amodule->unwind_info + ji->unwind_info;
*unwind_info_len = decode_value (p, &p);
return p;
}
@@ -3324,7 +3469,7 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
if (!method)
method = mono_get_method (image, token, NULL);
full_name = mono_method_full_name (method, TRUE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT NOT FOUND: %s.", full_name);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: NOT FOUND: %s.", full_name);
g_free (full_name);
}
return NULL;
@@ -3443,7 +3588,7 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
if (!jinfo)
jinfo = mono_aot_find_jit_info (domain, amodule->assembly->image, code);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT FOUND method %s [%p - %p %p]", full_name, code, code + jinfo->code_size, info);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: FOUND method %s [%p - %p %p]", full_name, code, code + jinfo->code_size, info);
g_free (full_name);
}
@@ -3639,6 +3784,15 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
MonoAotModule *amodule = klass->image->aot_module;
guint8 *code;
if (enable_aot_cache && !amodule && domain->entry_assembly && klass->image == mono_defaults.corlib) {
/* This cannot be AOTed during startup, so do it now */
if (!mscorlib_aot_loaded) {
load_aot_module (klass->image->assembly, NULL);
amodule = klass->image->aot_module;
}
mscorlib_aot_loaded = TRUE;
}
if (!amodule)
return NULL;
@@ -4149,7 +4303,7 @@ load_function_full (MonoAotModule *amodule, const char *name, MonoTrampInfo **ou
if (!code)
g_error ("Symbol '%s' not found in AOT file '%s'.\n", name, amodule->aot_name);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT FOUND function '%s' in AOT file '%s'.", name, amodule->aot_name);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: FOUND function '%s' in AOT file '%s'.", name, amodule->aot_name);
/* Load info */
@@ -4770,7 +4924,7 @@ mono_aot_set_make_unreadable (gboolean unreadable)
make_unreadable = unreadable;
if (make_unreadable && !inited) {
mono_counters_register ("AOT pagefaults", MONO_COUNTER_JIT | MONO_COUNTER_INT, &n_pagefaults);
mono_counters_register ("AOT: pagefaults", MONO_COUNTER_JIT | MONO_COUNTER_INT, &n_pagefaults);
}
}
+3 -3
View File
@@ -321,9 +321,9 @@ icompare_imm: src1:i len:12
long_conv_to_ovf_i4_2: dest:i src1:i src2:i len:36
vcall2: len:32 clob:c
vcall2_reg: src1:i len:32 clob:c
vcall2_membase: src1:b len:32 clob:c
vcall2: len:40 clob:c
vcall2_reg: src1:i len:40 clob:c
vcall2_membase: src1:b len:40 clob:c
dyn_call: src1:i src2:i len:120 clob:c
# This is different from the original JIT opcodes
+1 -1
View File
@@ -1581,7 +1581,7 @@ transport_handshake (void)
/* Read answer */
res = transport_recv (buf, strlen (handshake_msg));
if ((res != strlen (handshake_msg)) || (memcmp (buf, handshake_msg, strlen (handshake_msg) != 0))) {
if ((res != strlen (handshake_msg)) || (memcmp (buf, handshake_msg, strlen (handshake_msg)) != 0)) {
fprintf (stderr, "debugger-agent: DWP handshake failed.\n");
return FALSE;
}
+5 -5
View File
@@ -1903,6 +1903,11 @@ mono_main (int argc, char* argv[])
mono_load_coree (argv [i]);
#endif
/* Parse gac loading options before loading assemblies. */
if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
mono_config_parse (config_file);
}
mono_set_defaults (mini_verbose, opt);
domain = mini_init (argv [i], forced_version);
@@ -1968,11 +1973,6 @@ mono_main (int argc, char* argv[])
break;
}
/* Parse gac loading options before loading assemblies. */
if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
mono_config_parse (config_file);
}
#ifdef MONO_JIT_INFO_TABLE_TEST
if (test_jit_info_table)
jit_info_table_test (domain);
+1 -1
View File
@@ -604,7 +604,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
printf ("%s %p %p\n", ji->d.method->name, ji->code_start, ip);
mono_print_unwind_info (unwind_info, unwind_info_len);
*/
epilog = (guint8*)ji->code_start + ji->code_size - (ji->unwind_info >> 16);
epilog = (guint8*)ji->code_start + ji->code_size - mono_jinfo_get_epilog_size (ji);
regs [AMD64_RAX] = new_ctx->rax;
regs [AMD64_RBX] = new_ctx->rbx;
+41
View File
@@ -944,6 +944,47 @@ public class Tests
return 0;
}
public interface IFace1<T> {
void m1 ();
void m2 ();
void m3 ();
void m4 ();
void m5 ();
}
public class ClassIFace<T> : IFace1<T> {
public void m1 () {
}
public void m2 () {
}
public void m3 () {
}
public void m4 () {
}
public void m5 () {
}
}
interface IFaceIFaceCall {
void call<T, T2> (IFace1<object> iface);
}
class MakeIFaceCall : IFaceIFaceCall {
public void call<T, T2> (IFace1<object> iface) {
iface.m1 ();
}
}
// Check normal interface calls from gsharedvt call to fully instantiated methods
public static int test_0_instatiated_iface_call () {
ClassIFace<object> c1 = new ClassIFace<object> ();
IFaceIFaceCall c = new MakeIFaceCall ();
c.call<object, int> (c1);
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
static string to_string<T, T2>(T t, T2 t2) {
return t.ToString ();
+5
View File
@@ -8432,6 +8432,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
cmethod, MONO_RGCTX_INFO_METHOD);
/* This is not needed, as the trampoline code will pass one, and it might be passed in the same reg as the imt arg */
vtable_arg = NULL;
} else if ((cmethod->klass->flags & TYPE_ATTRIBUTE_INTERFACE) && !imt_arg) {
/* This can happen when we call a fully instantiated iface method */
imt_arg = emit_get_rgctx_method (cfg, context_used,
cmethod, MONO_RGCTX_INFO_METHOD);
vtable_arg = NULL;
}
}
+12 -2
View File
@@ -2759,6 +2759,16 @@ mono_jinfo_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
if (ji->from_aot)
return mono_aot_get_unwind_info (ji, unwind_info_len);
else
/* The upper 16 bits of ji->unwind_info might contain the epilog offset */
return mono_get_cached_unwind_info (ji->unwind_info & 0xffff, unwind_info_len);
return mono_get_cached_unwind_info (ji->unwind_info, unwind_info_len);
}
int
mono_jinfo_get_epilog_size (MonoJitInfo *ji)
{
MonoArchEHJitInfo *info;
info = mono_jit_info_get_arch_eh_info (ji);
g_assert (info);
return info->epilog_size;
}
+1 -1
View File
@@ -3156,7 +3156,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
index = LLVMConstInt (LLVMInt32Type (), ins->inst_offset / size, FALSE);
addr = LLVMBuildGEP (builder, convert (ctx, values [ins->inst_destbasereg], LLVMPointerType (t, 0)), &index, 1, "");
}
emit_store (ctx, bb, &builder, size, convert (ctx, LLVMConstInt (IntPtrType (), ins->inst_imm, FALSE), t), addr, is_volatile);
emit_store (ctx, bb, &builder, size, convert (ctx, LLVMConstInt (IntPtrType (), ins->inst_imm, FALSE), t), convert (ctx, addr, LLVMPointerType (t, 0)), is_volatile);
break;
}
+1 -1
View File
@@ -983,7 +983,7 @@ create_delegate_trampoline_data (MonoDomain *domain, MonoClass *klass, MonoMetho
invoke = mono_get_delegate_invoke (klass);
g_assert (invoke);
tramp_data = mono_domain_alloc (domain, sizeof (MonoDelegateTrampInfo));
tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo));
tramp_data->invoke = invoke;
tramp_data->invoke_sig = mono_method_signature (invoke);
tramp_data->impl_this = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
+9 -9
View File
@@ -4354,6 +4354,9 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
if (stack_size)
arch_eh_info_size = sizeof (MonoArchEHJitInfo);
}
if (cfg->has_unwind_info_for_epilog && !arch_eh_info_size)
arch_eh_info_size = sizeof (MonoArchEHJitInfo);
if (cfg->try_block_holes) {
for (tmp = cfg->try_block_holes; tmp; tmp = tmp->next) {
@@ -4651,16 +4654,13 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
unwind_desc = mono_cache_unwind_info (unwind_info, info_len);
if (cfg->has_unwind_info_for_epilog) {
/*
* The lower 16 bits identify the unwind descriptor, the upper 16 bits contain the offset of
* the start of the epilog from the end of the method.
*/
g_assert (unwind_desc < 0xffff);
g_assert (cfg->code_size - cfg->epilog_begin < 0xffff);
jinfo->unwind_info = ((cfg->code_size - cfg->epilog_begin) << 16) | unwind_desc;
} else {
jinfo->unwind_info = unwind_desc;
MonoArchEHJitInfo *info;
info = mono_jit_info_get_arch_eh_info (jinfo);
g_assert (info);
info->epilog_size = cfg->code_size - cfg->epilog_begin;
}
jinfo->unwind_info = unwind_desc;
g_free (unwind_info);
} else {
jinfo->unwind_info = cfg->used_int_regs;
+2 -1
View File
@@ -123,7 +123,7 @@
#endif
/* Version number of the AOT file format */
#define MONO_AOT_FILE_VERSION 101
#define MONO_AOT_FILE_VERSION 102
//TODO: This is x86/amd64 specific.
#define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
@@ -2511,6 +2511,7 @@ typedef gboolean (*MonoExceptionFrameWalk) (MonoMethod *method, gpointer ip
gboolean mono_exception_walk_trace (MonoException *ex, MonoExceptionFrameWalk func, gpointer user_data);
void mono_restore_context (MonoContext *ctx) MONO_INTERNAL;
guint8* mono_jinfo_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len) MONO_INTERNAL;
int mono_jinfo_get_epilog_size (MonoJitInfo *ji) MONO_INTERNAL;
gboolean
mono_find_jit_info_ext (MonoDomain *domain, MonoJitTlsData *jit_tls,
+9 -6
View File
@@ -831,10 +831,13 @@ walk_stack (MonoMethod *method, int32_t native_offset, int32_t il_offset, mono_b
* event, hence the collect_bt/emit_bt split.
*/
static void
collect_bt (FrameData *data)
collect_bt (FrameData *data, gboolean async_safe)
{
data->count = 0;
mono_stack_walk_no_il (walk_stack, data);
if (async_safe)
mono_stack_walk_async_safe (walk_stack, data);
else
mono_stack_walk_no_il (walk_stack, data);
}
static void
@@ -867,7 +870,7 @@ gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
len += 7;
len &= ~7;
if (do_bt)
collect_bt (&data);
collect_bt (&data, FALSE);
logbuffer = ensure_logbuf (32 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "gcalloc");
@@ -1132,7 +1135,7 @@ throw_exc (MonoProfiler *prof, MonoObject *object)
FrameData data;
LogBuffer *logbuffer;
if (do_bt)
collect_bt (&data);
collect_bt (&data, FALSE);
logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "throw");
@@ -1168,7 +1171,7 @@ monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEv
FrameData data;
LogBuffer *logbuffer;
if (do_bt)
collect_bt (&data);
collect_bt (&data, FALSE);
logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
now = current_time ();
ENTER_LOG (logbuffer, "monitor");
@@ -1230,7 +1233,7 @@ mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
if (in_shutdown)
return;
now = current_time ();
collect_bt (&bt_data);
collect_bt (&bt_data, TRUE);
elapsed = (now - profiler->startup_time) / 10000;
if (do_debug) {
int len;
+7 -1
View File
@@ -99,6 +99,10 @@ monoutils_sources = \
mono-threads-mach.c \
mono-threads-mach-helper.c \
mono-threads-windows.c \
mono-threads-linux.c \
mono-threads-freebsd.c \
mono-threads-openbsd.c \
mono-threads-android.c \
mono-threads.h \
mono-tls.h \
mono-tls.c \
@@ -112,7 +116,9 @@ monoutils_sources = \
bsearch.c \
mono-signal-handler.h \
mono-conc-hashtable.h \
mono-conc-hashtable.c
mono-conc-hashtable.c \
sha1.h \
sha1.c
arch_sources =
+9
View File
@@ -0,0 +1,9 @@
#include <config.h>
#if defined(PLATFORM_ANDROID)
#ifdef ENABLE_EXTENSION_MODULE
#include "../../../mono-extensions/mono/utils/mono-threads-android.c"
#endif
#endif
+24
View File
@@ -0,0 +1,24 @@
#include <config.h>
#if defined(__FreeBSD__)
#include <pthread.h>
#include <pthread_np.h>
void
mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
pthread_attr_t attr;
guint8 *current = (guint8*)&attr;
*staddr = NULL;
*stsize = (size_t)-1;
pthread_attr_init (&attr);
pthread_attr_get_np (pthread_self (), &attr);
pthread_attr_getstack (&attr, (void**)staddr, stsize);
pthread_attr_destroy (&attr);
}
#endif
+21
View File
@@ -0,0 +1,21 @@
#include <config.h>
#if defined(__linux__) && !defined(PLATFORM_ANDROID)
#include <mono/utils/mono-threads.h>
#include <pthread.h>
void
mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
pthread_attr_t attr;
*staddr = NULL;
*stsize = (size_t)-1;
pthread_getattr_np (pthread_self (), &attr);
pthread_attr_getstack (&attr, (void**)staddr, stsize);
pthread_attr_destroy (&attr);
}
#endif
+24 -3
View File
@@ -11,18 +11,19 @@
#if defined(__MACH__)
/* For pthread_main_np, pthread_get_stackaddr_np and pthread_get_stacksize_np */
#define _DARWIN_C_SOURCE 1
#include <mono/utils/mach-support.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-semaphore.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/mono-mmap.h>
#include <mono/metadata/gc-internal.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/threads-types.h>
#include <pthread.h>
#include <errno.h>
void
mono_threads_init_platform (void)
{
@@ -148,4 +149,24 @@ mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
/* pthread_setnmae_np() on Mac is not documented and doesn't receive thread id. */
}
void
mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
*staddr = (guint8*)pthread_get_stackaddr_np (pthread_self());
*stsize = pthread_get_stacksize_np (pthread_self());
#ifdef TARGET_OSX
/*
* Mavericks reports stack sizes as 512kb:
* http://permalink.gmane.org/gmane.comp.java.openjdk.hotspot.devel/11590
* https://bugs.openjdk.java.net/browse/JDK-8020753
*/
if (pthread_main_np () && *stsize == 512 * 1024)
*stsize = 2048 * mono_pagesize ();
#endif
/* staddr points to the start of the stack, not the end */
*staddr -= *stsize;
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#include <config.h>
#if defined(__OpenBSD__)
#include <pthread.h>
#include <pthread_np.h>
void
mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
/* TODO : Determine if this code is actually still needed. It may already be covered by the case above. */
pthread_attr_t attr;
guint8 *current = (guint8*)&attr;
*staddr = NULL;
*stsize = (size_t)-1;
pthread_attr_init (&attr);
stack_t ss;
int rslt;
rslt = pthread_stackseg_np (pthread_self (), &ss);
g_assert (rslt == 0);
*staddr = (guint8*)((size_t)ss.ss_sp - ss.ss_size);
*stsize = ss.ss_size;
pthread_attr_destroy (&attr);
}
#endif
-123
View File
@@ -9,17 +9,6 @@
#include <config.h>
#if defined(TARGET_OSX)
/* For pthread_main_np () */
#define _DARWIN_C_SOURCE 1
#include <pthread.h>
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__)
#include <pthread.h>
#include <pthread_np.h>
#endif
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-semaphore.h>
#include <mono/utils/mono-threads.h>
@@ -34,11 +23,6 @@
extern int tkill (pid_t tid, int signal);
#endif
#if defined(PLATFORM_MACOSX) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
void *pthread_get_stackaddr_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
#endif
#if defined(_POSIX_VERSION) || defined(__native_client__)
#include <sys/resource.h>
#include <signal.h>
@@ -185,113 +169,6 @@ mono_threads_core_resume_created (MonoThreadInfo *info, MonoNativeThreadId tid)
MONO_SEM_POST (&info->create_suspended_sem);
}
void
mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
#if defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
/* Mac OS X */
*staddr = (guint8*)pthread_get_stackaddr_np (pthread_self());
*stsize = pthread_get_stacksize_np (pthread_self());
#ifdef TARGET_OSX
/*
* Mavericks reports stack sizes as 512kb:
* http://permalink.gmane.org/gmane.comp.java.openjdk.hotspot.devel/11590
* https://bugs.openjdk.java.net/browse/JDK-8020753
*/
if (pthread_main_np () && *stsize == 512 * 1024)
*stsize = 2048 * mono_pagesize ();
#endif
/* staddr points to the start of the stack, not the end */
*staddr -= *stsize;
/* When running under emacs, sometimes staddr is not aligned to a page size */
*staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize() - 1));
return;
#elif (defined(HAVE_PTHREAD_GETATTR_NP) || defined(HAVE_PTHREAD_ATTR_GET_NP)) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
/* Linux, BSD */
pthread_attr_t attr;
guint8 *current = (guint8*)&attr;
*staddr = NULL;
*stsize = (size_t)-1;
pthread_attr_init (&attr);
#if defined(HAVE_PTHREAD_GETATTR_NP)
/* Linux */
pthread_getattr_np (pthread_self(), &attr);
#elif defined(HAVE_PTHREAD_ATTR_GET_NP)
/* BSD */
pthread_attr_get_np (pthread_self(), &attr);
#else
#error Cannot determine which API is needed to retrieve pthread attributes.
#endif
pthread_attr_getstack (&attr, (void**)staddr, stsize);
pthread_attr_destroy (&attr);
if (*staddr)
g_assert ((current > *staddr) && (current < *staddr + *stsize));
/* When running under emacs, sometimes staddr is not aligned to a page size */
*staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1));
return;
#elif defined(__OpenBSD__)
/* OpenBSD */
/* TODO : Determine if this code is actually still needed. It may already be covered by the case above. */
pthread_attr_t attr;
guint8 *current = (guint8*)&attr;
*staddr = NULL;
*stsize = (size_t)-1;
pthread_attr_init (&attr);
stack_t ss;
int rslt;
rslt = pthread_stackseg_np(pthread_self(), &ss);
g_assert (rslt == 0);
*staddr = (guint8*)((size_t)ss.ss_sp - ss.ss_size);
*stsize = ss.ss_size;
pthread_attr_destroy (&attr);
if (*staddr)
g_assert ((current > *staddr) && (current < *staddr + *stsize));
/* When running under emacs, sometimes staddr is not aligned to a page size */
*staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1));
return;
#elif defined(sun) || defined(__native_client__)
/* Solaris/Illumos, NaCl */
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_getstacksize (&attr, &stsize);
pthread_attr_destroy (&attr);
*staddr = NULL;
return;
#else
/* FIXME: It'd be better to use the 'error' preprocessor macro here so we know
at compile-time if the target platform isn't supported. */
#warning "Unable to determine how to retrieve a thread's stack-bounds for this platform in 'mono_thread_get_stack_bounds()'."
*staddr = NULL;
*stsize = 0;
return;
#endif
}
gboolean
mono_threads_core_yield (void)
{
+10
View File
@@ -14,6 +14,7 @@
#include <mono/utils/mono-tls.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/mono-mmap.h>
#include <errno.h>
@@ -787,7 +788,16 @@ mono_threads_create_thread (LPTHREAD_START_ROUTINE start, gpointer arg, guint32
void
mono_thread_info_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
guint8 *current = (guint8 *)&stsize;
mono_threads_core_get_stack_bounds (staddr, stsize);
if (!*staddr)
return;
/* Sanity check the result */
g_assert ((current > *staddr) && (current < *staddr + *stsize));
/* When running under emacs, sometimes staddr is not aligned to a page size */
*staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1));
}
gboolean
+176
View File
@@ -0,0 +1,176 @@
/* $OpenBSD: sha1.c,v 1.22 2012/08/27 21:05:43 miod Exp $ */
/*
* SHA-1 in C
* By Steve Reid <steve@edmweb.com>
* 100% Public Domain
*
* Test Vectors (from FIPS PUB 180-1)
* "abc"
* A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
* "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
* 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
* A million repetitions of "a"
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
#include <sys/param.h>
#include <string.h>
#include <stdint.h>
#include <sha1.h>
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/*
* blk0() and blk() perform the initial expand.
* I got the idea of expanding during the round function from SSLeay
*/
#if BYTE_ORDER == LITTLE_ENDIAN
# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#else
# define blk0(i) block->l[i]
#endif
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))
/*
* (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
*/
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
typedef union {
guint8 c[64];
guint32 l[16];
} CHAR64LONG16;
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
void
SHA1Transform(guint32 state[5], const guint8 buffer[SHA1_BLOCK_LENGTH])
{
guint32 a, b, c, d, e;
guint8 workspace[SHA1_BLOCK_LENGTH];
CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
(void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}
/*
* SHA1Init - Initialize new context
*/
void
SHA1Init(SHA1_CTX *context)
{
/* SHA1 initialization constants */
context->count = 0;
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
context->state[2] = 0x98BADCFE;
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
}
/*
* Run your data through this.
*/
void
SHA1Update(SHA1_CTX *context, const guint8 *data, size_t len)
{
size_t i, j;
j = (size_t)((context->count >> 3) & 63);
context->count += (len << 3);
if ((j + len) > 63) {
(void)memcpy(&context->buffer[j], data, (i = 64-j));
SHA1Transform(context->state, context->buffer);
for ( ; i + 63 < len; i += 64)
SHA1Transform(context->state, (guint8 *)&data[i]);
j = 0;
} else {
i = 0;
}
(void)memcpy(&context->buffer[j], &data[i], len - i);
}
/*
* Add padding and return the message digest.
*/
void
SHA1Pad(SHA1_CTX *context)
{
guint8 finalcount[8];
guint i;
for (i = 0; i < 8; i++) {
finalcount[i] = (guint8)((context->count >>
((7 - (i & 7)) * 8)) & 255); /* Endian independent */
}
SHA1Update(context, (guint8 *)"\200", 1);
while ((context->count & 504) != 448)
SHA1Update(context, (guint8 *)"\0", 1);
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
}
void
SHA1Final(guint8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
{
guint i;
SHA1Pad(context);
if (digest) {
for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
digest[i] = (guint8)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
memset(context, 0, sizeof(*context));
}
}
+50
View File
@@ -0,0 +1,50 @@
/* $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $ */
/*
* SHA-1 in C
* By Steve Reid <steve@edmweb.com>
* 100% Public Domain
*/
#ifndef _SHA1_H
#define _SHA1_H
#include <glib.h>
#define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
typedef struct {
guint32 state[5];
guint64 count;
guint8 buffer[SHA1_BLOCK_LENGTH];
} SHA1_CTX;
__BEGIN_DECLS
void SHA1Init(SHA1_CTX *);
void SHA1Pad(SHA1_CTX *);
void SHA1Transform(guint32 [5], const guint8 [SHA1_BLOCK_LENGTH]);
void SHA1Update(SHA1_CTX *, const guint8 *, size_t);
void SHA1Final(guint8 [SHA1_DIGEST_LENGTH], SHA1_CTX *);
char *SHA1End(SHA1_CTX *, char *);
char *SHA1File(const char *, char *);
char *SHA1FileChunk(const char *, char *, off_t, off_t);
char *SHA1Data(const guint8 *, size_t, char *);
__END_DECLS
#define HTONDIGEST(x) do { \
x[0] = htonl(x[0]); \
x[1] = htonl(x[1]); \
x[2] = htonl(x[2]); \
x[3] = htonl(x[3]); \
x[4] = htonl(x[4]); } while (0)
#define NTOHDIGEST(x) do { \
x[0] = ntohl(x[0]); \
x[1] = ntohl(x[1]); \
x[2] = ntohl(x[2]); \
x[3] = ntohl(x[3]); \
x[4] = ntohl(x[4]); } while (0)
#endif /* _SHA1_H */