Compare commits

...
17 Commits
Author SHA1 Message Date
Rodrigo Kumpera c9d9a10ff0 Merge remote-tracking branch 'origin/pr/1908' into HEAD 2015-07-02 14:04:45 -04:00
Alex Rønne Petersen 198235db76 [profiler] Fix missing TYPE_JIT events for alloc/exception/monitor backtraces. 2015-06-05 22:10:07 +02:00
Alexis Christoforides 046a426065 Restore "Fix XAttribute.ToString method (Xamarin-29935)"
The patch is now accepted.
2015-06-05 15:33:58 -04:00
Atsushi Eno 19be22ca00 [xbuild] for resolving assemblies from pkg-config, prefer specified version
... even if SpecificVersion is false. There is no reason to prefer any
mismatching version when SpecificVersion=false.

That behavior caused monodevelop build failures because of incorrectly-
resolved gtk# packages. After this fix, this issue goes away.
https://github.com/mono/monodevelop/blob/2436ad1874694ec811871dacf9a659a79b5fad0d/README.md#known-problems
2015-06-05 14:19:03 -04:00
Miguel de Icaza 02adfce5cf [monop] Band-aid, cope with IKVM's Type.Namespace crashing on generic types
[monop] Add test suite for monop
2015-06-05 14:14:24 -04:00
Rodrigo Kumpera 8019f53849 Bump mono to 4.0.2 2015-06-05 14:14:21 -04:00
Zoltan Varga e967ed4868 [arm64] Increase the size of the thunk area to work around https://bugzilla.xamarin.com/show_bug.cgi?id=28747. 2015-06-05 14:02:47 -04:00
Zoltan Varga 2a0f19e0d2 [jit] Emulate OP_RREM if OP_FREM is emulated. Fixes #30698. 2015-06-03 15:31:48 -04:00
Alexander Kyte ef16e5a45c [runtime] Don't set flag to skip future initialization on half-baked classes 2015-06-03 12:13:20 +02:00
Zoltan Varga c68e6be205 [runtime] Fix the signature of native-func-aot wrappers. AOT the delegate invoke wrapper which is used to invoke it. Fixes #29970. 2015-06-02 19:05:26 -04:00
Sebastien Pouliot fad43d28b9 [corlib] Xamarin.Mac to continue default to the OS default codepage
XM 2.0 was the first version to ship the mobile (w/unified) and it used
the OS default codepage.

The previous, system mono, profile was already using the OS default
codepage so it make sense for XM to be consistent across profiles (
including the 4.5 subset)
2015-06-02 16:53:53 -04:00
Sebastien Pouliot e4510d8546 [corlib] Let XI and XM define their own default encoding [#29928]
605192528d used UTF8Unmarked for MONOTOUCH
and XAMMAC. However it's initialized differently (than the old UTF8) and
caused unit test regressions in System and System.Net.Http unit tests

This new logic moves the default encoding creation into the products
themselves.
2015-06-02 16:53:42 -04:00
Alexis Christoforides a3b2464acb Bump to include xamarin/bockbuild@0669caebbc 2015-06-02 16:02:38 -04:00
Alex Rønne Petersen 0bf88ca938 [profiler] Initialize threads in runtime initialization callback.
For the helper and writer thread to actually work, we need Mono's threading
subsystem to be initialized (so we can use TLS and hazard pointers). We now
wait with starting these threads until Mono gives us the go-ahead.

This means that a bit more data will be buffered up in the thread-local log
buffers during startup, but it shouldn't really matter in practice.
2015-06-02 15:50:15 -04:00
Zoltan Varga 348b0980cd [arm] Fix the handling of callee saved fp registers during unwinding, previously they were saved in an 32 bit array. Fixes #29726. 2015-06-02 15:28:12 -04:00
Zoltan Varga 80c4f56c1c [aot] Avoid duplicate plt symbols for plt entries for synchronized methods. Fixes #28961. 2015-06-02 15:27:14 -04:00
Sebastien Pouliot 955b2d61c9 [linker] Resolve AssemblyName[Reference] when sweeping [#29211]
The exact name (e.g. version) might differ between the original
AssemblyNameReference and the one being used (e.g. PCL).

To make sure we remove unused references we need to resolve
the AssemblyNameReference into AssemblyDefinition and then
continue the sweep based on the _new_ AssemblyNameReference.
2015-06-02 14:58:50 -04:00
23 changed files with 254 additions and 97 deletions

No files matched your search

+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, [4.0.1],
AC_INIT(mono, [4.0.2],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
@@ -256,9 +256,8 @@ namespace Microsoft.Build.Tasks {
{
PackageAssemblyInfo pkg = null;
if (specific_version) {
pkg = PcCache.GetAssemblyLocation (reference.ItemSpec);
} else {
pkg = PcCache.GetAssemblyLocation (reference.ItemSpec);
if (pkg == null && !specific_version) {
// if not specific version, then just match simple name
string name = reference.ItemSpec;
if (name.IndexOf (',') > 0)
@@ -26,6 +26,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
@@ -334,34 +336,29 @@ namespace System.Xml.Linq
static readonly char [] escapeChars = new char [] {'<', '>', '&', '"', '\r', '\n', '\t'};
private static string GetPrefixOfNamespace (XNamespace ns)
{
string namespaceName = ns.NamespaceName;
if (namespaceName.Length == 0)
return string.Empty;
if (namespaceName == XNamespace.Xml.NamespaceName)
return "xml";
if (namespaceName == XNamespace.Xmlns.NamespaceName)
return "xmlns";
return null;
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
sb.Append (name.ToString ());
sb.Append ("=\"");
int start = 0;
do {
int idx = value.IndexOfAny (escapeChars, start);
if (idx < 0) {
if (start > 0)
sb.Append (value, start, value.Length - start);
else
sb.Append (value);
sb.Append ("\"");
return sb.ToString ();
using (StringWriter sw = new StringWriter (CultureInfo.InvariantCulture)) {
XmlWriterSettings ws = new XmlWriterSettings ();
ws.ConformanceLevel = ConformanceLevel.Fragment;
using (XmlWriter w = XmlWriter.Create (sw, ws)) {
w.WriteAttributeString (GetPrefixOfNamespace (Name.Namespace), Name.LocalName,
Name.NamespaceName, Value);
}
sb.Append (value, start, idx - start);
switch (value [idx]) {
case '&': sb.Append ("&amp;"); break;
case '<': sb.Append ("&lt;"); break;
case '>': sb.Append ("&gt;"); break;
case '"': sb.Append ("&quot;"); break;
case '\r': sb.Append ("&#xD;"); break;
case '\n': sb.Append ("&#xA;"); break;
case '\t': sb.Append ("&#x9;"); break;
}
start = idx + 1;
} while (true);
return sw.ToString ().Trim ();
}
}
}
}
@@ -205,6 +205,14 @@ namespace MonoTests.System.Xml.Linq
Assert.AreEqual ("a=\" &gt;_&lt; \"", a.ToString ());
}
[Test]
public void ToString_Xamarin29935 ()
{
var doc = XDocument.Parse ("<?xml version='1.0' encoding='utf-8'?><lift xmlns:test='http://test.example.com'></lift>");
Assert.AreEqual ("xmlns:test=\"http://test.example.com\"",
doc.Root.Attributes ().Select (s => s.ToString ()).First ());
}
[Test]
public void DateTimeAttribute ()
{
@@ -7,7 +7,7 @@ using System.Security;
namespace System.Text
{
internal static class EncodingHelper
internal static partial class EncodingHelper
{
//
// Only internal, to be used by the class libraries: Unmarked and non-input-validating
@@ -71,6 +71,7 @@ internal static class EncodingHelper
[MethodImpl (MethodImplOptions.InternalCall)]
extern internal static string InternalCodePage (ref int code_page);
#if !MONOTOUCH
internal static Encoding GetDefaultEncoding ()
{
Encoding enc = null;
@@ -105,6 +106,7 @@ internal static class EncodingHelper
}
return enc;
}
#endif
// Loaded copy of the "I18N" assembly. We need to move
// this into a class in "System.Private" eventually.
@@ -100,7 +100,8 @@ namespace Mono.Linker.Steps {
var references = assembly.MainModule.AssemblyReferences;
for (int i = 0; i < references.Count; i++) {
var reference = references [i];
if (!AreSameReference (reference, target.Name))
var r = Context.Resolver.Resolve (reference);
if (!AreSameReference (r.Name, target.Name))
continue;
references.RemoveAt (i);
+6
View File
@@ -8,3 +8,9 @@ LOCAL_MCS_FLAGS += -d:NO_AUTHENTICODE,STATIC,NO_SYMBOL_WRITER
CLEAN_FILES = monop.exe monop2.exe *.mdb
include ../../build/executable.make
run-test-local : basic-tests
basic-tests:
for type in System.Array System.String 'System.Collections.Generic.List`1'; do \
echo $$type; $(RUNTIME) $(build_lib) $$type >/dev/null || exit 1; done
+7 -6
View File
@@ -301,10 +301,10 @@ class MonoP {
static Options options = new Options ();
static void Main (string [] args)
static int Main (string [] args)
{
if (!options.ProcessArgs (args))
return;
return 1;
if (options.Style == null)
mscorlib = universe.LoadFile (typeof (int).Assembly.Location);
@@ -318,14 +318,14 @@ class MonoP {
if (options.ShowAll){
ShowAll (assembly, options.ShowPrivate, options.FilterObsolete);
return;
return 0;
} else {
if (options.Type == null) {
if (options.PrintRefs)
PrintRefs (assembly);
else
PrintTypes (assembly, options.ShowPrivate, options.FilterObsolete);
return;
return 0;
}
}
}
@@ -348,7 +348,7 @@ class MonoP {
if (count > 1){
Console.WriteLine ("Found " + count + " types that match:");
Console.WriteLine (matches);
return;
return 0;
}
}
@@ -394,7 +394,7 @@ class MonoP {
notfound:
if (t == null) {
Console.WriteLine ("Could not find {0}", tname);
return;
return 1;
}
found:
//
@@ -406,6 +406,7 @@ class MonoP {
if (message != null)
Console.WriteLine (message);
return 0;
}
}
+16 -2
View File
@@ -42,6 +42,19 @@ using System.Reflection;
#endif
namespace Mono.CSharp {
public static class TypeExtensions {
public static string GetNamespace (this Type t)
{
// IKVM crashes here with a null ref sometimes
try {
return t.Namespace;
} catch {
return null;
}
}
}
public class Outline {
bool declared_only;
bool show_private;
@@ -636,7 +649,7 @@ public class Outline {
if (!type.StartsWith ("System.")) {
if (type.IndexOf (".") == -1)
return type;
if (t.Namespace == this.t.Namespace)
if (t.GetNamespace () == this.t.GetNamespace ())
return t.Name;
return type;
}
@@ -745,7 +758,8 @@ public class Outline {
}
if (!recursed) {
string ns = t.Namespace;
string ns;
ns = t.GetNamespace ();
if ((ns != null) && (ns != "")) {
sb.Append (ns);
sb.Append (".");
+7 -1
View File
@@ -6049,7 +6049,13 @@ mono_generic_class_get_class (MonoGenericClass *gclass)
mono_generic_class_setup_parent (klass, gklass);
if (gclass->is_dynamic) {
klass->inited = 1;
/*
* We don't need to do any init workf with unbaked typebuilders. Generic instances created at this point will be later unregistered and/or fixed.
* This is to avoid work that would probably give wrong results as fields change as we build the TypeBuilder.
* See remove_instantiations_of_and_ensure_contents in reflection.c and its usage in reflection.c to understand the fixup stage of SRE banking.
*/
if (!gklass->wastypebuilder)
klass->inited = 1;
mono_class_setup_supertypes (klass);
+2 -2
View File
@@ -3031,7 +3031,7 @@ free_signature_pointer_pair (SignaturePointerPair *pair)
g_free (pair);
}
static MonoMethod *
MonoMethod *
mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method)
{
MonoMethodSignature *sig, *static_sig, *invoke_sig;
@@ -7474,7 +7474,7 @@ mono_marshal_get_native_func_wrapper_aot (MonoClass *klass)
info->d.managed_to_native.method = invoke;
g_assert (!sig->hasthis);
csig = signature_dup_add_this (image, sig, mono_defaults.int_class);
csig = signature_dup_add_this (image, sig, mono_defaults.object_class);
csig->pinvoke = 0;
res = mono_mb_create_and_cache_full (cache, invoke,
mb, csig, csig->param_count + 16,
+3
View File
@@ -308,6 +308,9 @@ mono_marshal_get_delegate_end_invoke (MonoMethod *method) MONO_INTERNAL;
MonoMethod *
mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del) MONO_INTERNAL;
MonoMethod *
mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method) MONO_INTERNAL;
MonoMethod *
mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual) MONO_INTERNAL;
+22 -2
View File
@@ -3090,6 +3090,8 @@ static MonoPltEntry*
get_plt_entry (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
{
MonoPltEntry *res;
gboolean synchronized = FALSE;
static int synchronized_symbol_idx;
if (!is_plt_patch (patch_info))
return NULL;
@@ -3105,6 +3107,7 @@ get_plt_entry (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
* wrapper.
*/
res = NULL;
synchronized = TRUE;
}
if (!res) {
@@ -3118,6 +3121,13 @@ get_plt_entry (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
res->symbol = get_plt_symbol (acfg, res->plt_offset, patch_info);
if (acfg->aot_opts.write_symbols)
res->debug_sym = get_plt_entry_debug_sym (acfg, res->ji, acfg->plt_entry_debug_sym_cache);
if (synchronized) {
/* Avoid duplicate symbols because we don't cache */
res->symbol = g_strdup_printf ("%s_%d", res->symbol, synchronized_symbol_idx);
if (res->debug_sym)
res->debug_sym = g_strdup_printf ("%s_%d", res->debug_sym, synchronized_symbol_idx);
synchronized_symbol_idx ++;
}
if (res->debug_sym)
res->llvm_symbol = g_strdup_printf ("%s_%s_llvm", res->symbol, res->debug_sym);
else
@@ -3622,8 +3632,18 @@ add_wrappers (MonoAotCompile *acfg)
for (j = 0; j < cattr->num_attrs; ++j)
if (cattr->attrs [j].ctor && (!strcmp (cattr->attrs [j].ctor->klass->name, "MonoNativeFunctionWrapperAttribute") || !strcmp (cattr->attrs [j].ctor->klass->name, "UnmanagedFunctionPointerAttribute")))
break;
if (j < cattr->num_attrs)
add_method (acfg, mono_marshal_get_native_func_wrapper_aot (klass));
if (j < cattr->num_attrs) {
MonoMethod *invoke;
MonoMethod *wrapper;
MonoMethod *del_invoke;
/* Add wrappers needed by mono_ftnptr_to_delegate () */
invoke = mono_get_delegate_invoke (klass);
wrapper = mono_marshal_get_native_func_wrapper_aot (klass);
del_invoke = mono_marshal_get_delegate_invoke_internal (invoke, FALSE, TRUE, wrapper);
add_method (acfg, wrapper);
add_method (acfg, del_invoke);
}
}
} else if ((acfg->opts & MONO_OPT_GSHAREDVT) && klass->generic_container) {
MonoError error;
+6
View File
@@ -704,6 +704,12 @@ class Tests
return (int)(f1 / f2);
}
public static int test_1_frem_r4 () {
float f1 = 7.0f;
float f2 = 2.0f;
return (int)(f1 % f2);
}
public static int test_0_fcmp_eq_r4 () {
float f1 = 1.0f;
float f2 = 1.0f;
+3 -3
View File
@@ -401,7 +401,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
if (ji != NULL) {
int i;
gssize regs [MONO_MAX_IREGS + 1 + 8];
mono_unwind_reg_t regs [MONO_MAX_IREGS + 1 + 8];
guint8 *cfa;
guint32 unwind_info_len;
guint8 *unwind_info;
@@ -420,7 +420,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
#ifdef TARGET_IOS
/* On IOS, d8..d15 are callee saved. They are mapped to 8..15 in unwind.c */
for (i = 0; i < 8; ++i)
regs [MONO_MAX_IREGS + i] = new_ctx->fregs [8 + i];
regs [MONO_MAX_IREGS + i] = *(guint64*)&(new_ctx->fregs [8 + i]);
#endif
mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start,
@@ -434,7 +434,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
new_ctx->regs [ARMREG_SP] = (gsize)cfa;
#ifdef TARGET_IOS
for (i = 0; i < 8; ++i)
new_ctx->fregs [8 + i] = regs [MONO_MAX_IREGS + i];
new_ctx->fregs [8 + i] = *(double*)&(regs [MONO_MAX_IREGS + i]);
#endif
/* Clear thumb bit */
+3
View File
@@ -124,6 +124,9 @@
* reproduceable results for benchmarks */
#define MONO_ARCH_CODE_ALIGNMENT 32
/* This needs to hold both a 32 bit int and a 64 bit double */
#define mono_unwind_reg_t guint64
/* Argument marshallings for calls between gsharedvt and normal code */
typedef enum {
GSHAREDVT_ARG_NONE = 0,
+6 -1
View File
@@ -12,6 +12,11 @@
#include "mini.h"
/* This is the same as mgreg_t, except on 32 bit bit platforms with callee saved fp regs */
#ifndef mono_unwind_reg_t
#define mono_unwind_reg_t mgreg_t
#endif
/*
* This is a platform-independent interface for unwinding through stack frames
* based on the Dwarf unwinding interface.
@@ -145,7 +150,7 @@ mono_unwind_ops_encode (GSList *unwind_ops, guint32 *out_len) MONO_INTERNAL;
void
mono_unwind_frame (guint8 *unwind_info, guint32 unwind_info_len,
guint8 *start_ip, guint8 *end_ip, guint8 *ip, guint8 **mark_locations,
mgreg_t *regs, int nregs,
mono_unwind_reg_t *regs, int nregs,
mgreg_t **save_locations, int save_locations_len,
guint8 **out_cfa) MONO_INTERNAL;
+1
View File
@@ -7600,6 +7600,7 @@ register_icalls (void)
#ifdef MONO_ARCH_EMULATE_FREM
#if defined(__default_codegen__)
register_opcode_emulation (OP_FREM, "__emul_frem", "double double double", fmod, "fmod", FALSE);
register_opcode_emulation (OP_RREM, "__emul_rrem", "float float float", fmodf, "fmodf", FALSE);
#elif defined(__native_client_codegen__)
register_opcode_emulation (OP_FREM, "__emul_frem", "double double double", mono_fmod, "mono_fmod", FALSE);
#endif
+11 -3
View File
@@ -51,11 +51,12 @@ static int map_hw_reg_to_dwarf_reg [] = { 0, 2, 1, 3, 7, 6, 4, 5, 8, 9, 10, 11,
#define DWARF_PC_REG (mono_hw_reg_to_dwarf_reg (AMD64_RIP))
#elif defined(TARGET_ARM)
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040a/IHI0040A_aadwarf.pdf
/* Assign d8..d15 to hregs 16..24 */
/* Assign d8..d15 to hregs 16..24 (dwarf regs 264..271) */
static int map_hw_reg_to_dwarf_reg [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 264, 265, 266, 267, 268, 269, 270, 271 };
#define NUM_REGS 272
#define DWARF_DATA_ALIGN (-4)
#define DWARF_PC_REG (mono_hw_reg_to_dwarf_reg (ARMREG_LR))
#define IS_DOUBLE_REG(dwarf_reg) (((dwarf_reg) >= 264) && ((dwarf_reg) <= 271))
#elif defined(TARGET_ARM64)
#define NUM_REGS 96
#define DWARF_DATA_ALIGN (-8)
@@ -109,6 +110,10 @@ static int map_hw_reg_to_dwarf_reg [16];
#define DWARF_PC_REG -1
#endif
#ifndef IS_DOUBLE_REG
#define IS_DOUBLE_REG(dwarf_reg) 0
#endif
static gboolean dwarf_reg_to_hw_reg_inited;
static int map_dwarf_reg_to_hw_reg [NUM_REGS];
@@ -480,7 +485,7 @@ typedef struct {
void
mono_unwind_frame (guint8 *unwind_info, guint32 unwind_info_len,
guint8 *start_ip, guint8 *end_ip, guint8 *ip, guint8 **mark_locations,
mgreg_t *regs, int nregs,
mono_unwind_reg_t *regs, int nregs,
mgreg_t **save_locations, int save_locations_len,
guint8 **out_cfa)
{
@@ -602,7 +607,10 @@ mono_unwind_frame (guint8 *unwind_info, guint32 unwind_info_len,
if (reg_saved [i] && locations [i].loc_type == LOC_OFFSET) {
int hreg = mono_dwarf_reg_to_hw_reg (i);
g_assert (hreg < nregs);
regs [hreg] = *(mgreg_t*)(cfa_val + locations [i].offset);
if (IS_DOUBLE_REG (i))
regs [hreg] = *(guint64*)(cfa_val + locations [i].offset);
else
regs [hreg] = *(mgreg_t*)(cfa_val + locations [i].offset);
if (save_locations && hreg < save_locations_len)
save_locations [hreg] = (mgreg_t*)(cfa_val + locations [i].offset);
}
+60 -45
View File
@@ -93,7 +93,8 @@ static int use_zip = 0;
static int do_report = 0;
static int do_heap_shot = 0;
static int max_call_depth = 100;
static int runtime_inited = 0;
static volatile int runtime_inited = 0;
static int need_helper_thread = 0;
static int command_port = 0;
static int heapshot_requested = 0;
static int sample_type = 0;
@@ -623,11 +624,8 @@ find_method (MonoDomain *domain, void *user_data)
}
static void
register_method_local (MonoProfiler *prof, MonoDomain *domain, MonoMethod *method, MonoJitInfo *ji)
register_method_local (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *ji)
{
if (!domain)
g_assert (ji);
if (!mono_conc_hashtable_lookup (prof->method_table, method)) {
if (!ji) {
MethodSearch search = { method, NULL };
@@ -649,12 +647,19 @@ register_method_local (MonoProfiler *prof, MonoDomain *domain, MonoMethod *metho
}
static void
emit_method (MonoProfiler *prof, LogBuffer *logbuffer, MonoDomain *domain, MonoMethod *method)
emit_method (MonoProfiler *prof, LogBuffer *logbuffer, MonoMethod *method)
{
register_method_local (prof, domain, method, NULL);
register_method_local (prof, method, NULL);
emit_method_inner (logbuffer, method);
}
static void
emit_method_as_ptr (MonoProfiler *prof, LogBuffer *logbuffer, MonoMethod *method)
{
register_method_local (prof, method, NULL);
emit_ptr (logbuffer, method);
}
static void
emit_obj (LogBuffer *logbuffer, void *ptr)
{
@@ -802,24 +807,22 @@ process_requests (MonoProfiler *profiler)
static void counters_init (MonoProfiler *profiler);
static void counters_sample (MonoProfiler *profiler, uint64_t timestamp);
static void
runtime_initialized (MonoProfiler *profiler)
{
runtime_inited = 1;
#ifndef DISABLE_HELPER_THREAD
counters_init (profiler);
counters_sample (profiler, 0);
#endif
/* ensure the main thread data and startup are available soon */
safe_send (profiler, ensure_logbuf (0));
}
/*
* Can be called only at safe callback locations.
*/
static void
safe_send (MonoProfiler *profiler, LogBuffer *logbuffer)
{
/* We need the runtime initialized so that we have threads and hazard
* pointers available. Otherwise, the lock free queue will not work and
* there won't be a thread to process the data.
*
* While the runtime isn't initialized, we just accumulate data in the
* thread local buffer list.
*/
if (!InterlockedRead (&runtime_inited))
return;
int cd = logbuffer->call_depth;
send_buffer (profiler, TLS_GET (GPtrArray, tlsmethodlist), TLS_GET (LogBuffer, tlsbuffer));
@@ -967,7 +970,7 @@ collect_bt (FrameData *data)
}
static void
emit_bt (LogBuffer *logbuffer, FrameData *data)
emit_bt (MonoProfiler *prof, LogBuffer *logbuffer, FrameData *data)
{
/* FIXME: this is actually tons of data and we should
* just output it the first time and use an id the next
@@ -979,7 +982,7 @@ emit_bt (LogBuffer *logbuffer, FrameData *data)
//if (*p != data.count) {
// printf ("bad num frames enc at %d: %d -> %d\n", count, data.count, *p); printf ("frames end: %p->%p\n", p, logbuffer->data); exit(0);}
while (data->count) {
emit_ptr (logbuffer, data->methods [--data->count]);
emit_method_as_ptr (prof, logbuffer, data->methods [--data->count]);
}
}
@@ -988,7 +991,7 @@ gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
{
uint64_t now;
uintptr_t len;
int do_bt = (nocalls && runtime_inited && !notraces)? TYPE_ALLOC_BT: 0;
int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces)? TYPE_ALLOC_BT: 0;
FrameData data;
LogBuffer *logbuffer;
len = mono_object_get_size (obj);
@@ -1006,7 +1009,7 @@ gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
emit_obj (logbuffer, obj);
emit_value (logbuffer, len);
if (do_bt)
emit_bt (logbuffer, &data);
emit_bt (prof, logbuffer, &data);
EXIT_LOG (logbuffer);
if (logbuffer->next)
safe_send (prof, logbuffer);
@@ -1144,7 +1147,7 @@ class_loaded (MonoProfiler *prof, MonoClass *klass, int result)
LogBuffer *logbuffer;
if (result != MONO_PROFILE_OK)
return;
if (runtime_inited)
if (InterlockedRead (&runtime_inited))
name = mono_type_get_name (mono_class_get_type (klass));
else
name = type_name (klass);
@@ -1183,7 +1186,7 @@ method_enter (MonoProfiler *prof, MonoMethod *method)
ENTER_LOG (logbuffer, "enter");
emit_byte (logbuffer, TYPE_ENTER | TYPE_METHOD);
emit_time (logbuffer, now);
emit_method (prof, logbuffer, mono_domain_get (), method);
emit_method (prof, logbuffer, method);
EXIT_LOG (logbuffer);
process_requests (prof);
}
@@ -1199,7 +1202,7 @@ method_leave (MonoProfiler *prof, MonoMethod *method)
ENTER_LOG (logbuffer, "leave");
emit_byte (logbuffer, TYPE_LEAVE | TYPE_METHOD);
emit_time (logbuffer, now);
emit_method (prof, logbuffer, mono_domain_get (), method);
emit_method (prof, logbuffer, method);
EXIT_LOG (logbuffer);
if (logbuffer->next)
safe_send (prof, logbuffer);
@@ -1220,7 +1223,7 @@ method_exc_leave (MonoProfiler *prof, MonoMethod *method)
ENTER_LOG (logbuffer, "eleave");
emit_byte (logbuffer, TYPE_EXC_LEAVE | TYPE_METHOD);
emit_time (logbuffer, now);
emit_method (prof, logbuffer, mono_domain_get (), method);
emit_method (prof, logbuffer, method);
EXIT_LOG (logbuffer);
process_requests (prof);
}
@@ -1231,7 +1234,7 @@ method_jitted (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *ji, int resu
if (result != MONO_PROFILE_OK)
return;
register_method_local (prof, NULL, method, ji);
register_method_local (prof, method, ji);
}
static void
@@ -1267,7 +1270,7 @@ code_buffer_new (MonoProfiler *prof, void *buffer, int size, MonoProfilerCodeBuf
static void
throw_exc (MonoProfiler *prof, MonoObject *object)
{
int do_bt = (nocalls && runtime_inited && !notraces)? TYPE_EXCEPTION_BT: 0;
int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces)? TYPE_EXCEPTION_BT: 0;
uint64_t now;
FrameData data;
LogBuffer *logbuffer;
@@ -1280,7 +1283,7 @@ throw_exc (MonoProfiler *prof, MonoObject *object)
emit_time (logbuffer, now);
emit_obj (logbuffer, object);
if (do_bt)
emit_bt (logbuffer, &data);
emit_bt (prof, logbuffer, &data);
EXIT_LOG (logbuffer);
process_requests (prof);
}
@@ -1296,14 +1299,14 @@ clause_exc (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_
emit_time (logbuffer, now);
emit_value (logbuffer, clause_type);
emit_value (logbuffer, clause_num);
emit_method (prof, logbuffer, mono_domain_get (), method);
emit_method (prof, logbuffer, method);
EXIT_LOG (logbuffer);
}
static void
monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEvent event)
{
int do_bt = (nocalls && runtime_inited && !notraces && event == MONO_PROFILER_MONITOR_CONTENTION)? TYPE_MONITOR_BT: 0;
int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces && event == MONO_PROFILER_MONITOR_CONTENTION)? TYPE_MONITOR_BT: 0;
uint64_t now;
FrameData data;
LogBuffer *logbuffer;
@@ -1316,7 +1319,7 @@ monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEv
emit_time (logbuffer, now);
emit_obj (logbuffer, object);
if (do_bt)
emit_bt (logbuffer, &data);
emit_bt (profiler, logbuffer, &data);
EXIT_LOG (logbuffer);
process_requests (profiler);
}
@@ -1829,10 +1832,9 @@ dump_sample_hits (MonoProfiler *prof, StatBuffer *sbuf)
emit_uvalue (logbuffer, mbt_count);
for (i = 0; i < mbt_count; ++i) {
MonoMethod *method = (MonoMethod *) sample [i * 4 + 0];
MonoDomain *domain = (MonoDomain *) sample [i * 4 + 1];
uintptr_t native_offset = sample [i * 4 + 3];
emit_method (prof, logbuffer, domain, method);
emit_method (prof, logbuffer, method);
emit_svalue (logbuffer, 0); /* il offset will always be 0 from now on */
emit_svalue (logbuffer, native_offset);
}
@@ -2724,7 +2726,7 @@ helper_thread (void* arg)
if (strcmp (buf, "heapshot\n") == 0) {
heapshot_requested = 1;
//fprintf (stderr, "perform heapshot\n");
if (runtime_inited && !thread) {
if (InterlockedRead (&runtime_inited) && !thread) {
thread = mono_thread_attach (mono_get_root_domain ());
/*fprintf (stderr, "attached\n");*/
}
@@ -2878,13 +2880,33 @@ start_writer_thread (MonoProfiler* prof)
return !pthread_create (&prof->writer_thread, NULL, writer_thread, prof);
}
static void
runtime_initialized (MonoProfiler *profiler)
{
#ifndef DISABLE_HELPER_THREAD
if (hs_mode_ondemand || need_helper_thread) {
if (!start_helper_thread (profiler))
profiler->command_port = 0;
}
#endif
start_writer_thread (profiler);
InterlockedWrite (&runtime_inited, 1);
#ifndef DISABLE_HELPER_THREAD
counters_init (profiler);
counters_sample (profiler, 0);
#endif
/* ensure the main thread data and startup are available soon */
safe_send (profiler, ensure_logbuf (0));
}
static MonoProfiler*
create_profiler (const char *filename)
{
MonoProfiler *prof;
char *nf;
int force_delete = 0;
int need_helper_thread = 0;
prof = calloc (1, sizeof (MonoProfiler));
prof->command_port = command_port;
@@ -2943,12 +2965,7 @@ create_profiler (const char *filename)
if (do_counters && !need_helper_thread) {
need_helper_thread = 1;
}
#ifndef DISABLE_HELPER_THREAD
if (hs_mode_ondemand || need_helper_thread) {
if (!start_helper_thread (prof))
prof->command_port = 0;
}
#else
#ifdef DISABLE_HELPER_THREAD
if (hs_mode_ondemand)
fprintf (stderr, "Ondemand heapshot unavailable on this arch.\n");
#endif
@@ -2957,8 +2974,6 @@ create_profiler (const char *filename)
mono_mutex_init (&prof->method_table_mutex);
prof->method_table = mono_conc_hashtable_new (&prof->method_table_mutex, NULL, NULL);
start_writer_thread (prof);
prof->startup_time = current_time ();
return prof;
}
+1
View File
@@ -307,6 +307,7 @@ BASE_TEST_CS_SRC= \
generic-typedef.2.cs \
generic-marshalbyref.2.cs \
generic-xdomain.2.cs \
dynamic-generic-size.cs \
bug-431413.2.cs \
bug-459285.2.cs \
generic-virtual-invoke.2.cs \
+61
View File
@@ -0,0 +1,61 @@
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections.Generic;
namespace GenericSize
{
class GenericSize
{
static int Iterations = 10000;
static AssemblyBuilder assembly;
static ModuleBuilder module;
static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
static void SetUp ()
{
AssemblyName assemblyName = new AssemblyName ();
assemblyName.Name = ASSEMBLY_NAME;
assembly =
Thread.GetDomain ().DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.Run);
module = assembly.DefineDynamicModule ("module1");
}
static int Main()
{
SetUp ();
TypeBuilder tb = module.DefineType ("Test", TypeAttributes.Public);
tb.DefineGenericParameters ("T");
var tb_ctor = tb.DefineDefaultConstructor (MethodAttributes.Public);
var tb2 = module.DefineType ("Test2", TypeAttributes.Public);
var g0 = tb2.DefineGenericParameters ("T");
var mb = tb2.DefineMethod ("Foo", MethodAttributes.Public | MethodAttributes.Static, typeof (object), new Type [0]);
var il = mb.GetILGenerator();
il.Emit(OpCodes.Newobj, TypeBuilder.GetConstructor (tb.MakeGenericType (g0), tb_ctor));
il.Emit(OpCodes.Ret);
var t1 = tb.CreateType ();
var t2 = tb2.CreateType ();
var ginst = t2.MakeGenericType (typeof (string));
var method = ginst.GetMethod ("Foo", BindingFlags.Public | BindingFlags.Static);
var lst = new List<Object>();
for (int i = 0; i < GenericSize.Iterations; i++) {
lst.Add (method.Invoke (null, null));
if (i % 15 == 0)
GC.Collect();
}
return 0;
}
}
}
+1 -1
View File
@@ -492,7 +492,7 @@ mono_code_manager_foreach (MonoCodeManager *cman, MonoCodeManagerFunc func, void
#define BIND_ROOM 8
#endif
#if defined(TARGET_ARM64)
#define BIND_ROOM 8
#define BIND_ROOM 4
#endif
static CodeChunk*