mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 01:41:18 -10:00
Compare commits
16
Commits
compression
...
asmbinder
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a2cc76c29 | ||
|
|
6542626e1c | ||
|
|
09366779f0 | ||
|
|
8b1ca21e8f | ||
|
|
70a2afb818 | ||
|
|
2fa83d9a8c | ||
|
|
356e0f2bea | ||
|
|
3d24680ebe | ||
|
|
44b1144ed1 | ||
|
|
8e4d85b584 | ||
|
|
683527c694 | ||
|
|
86c7d75bce | ||
|
|
29a2d0db57 | ||
|
|
b4786dbd7e | ||
|
|
dbad80b39b | ||
|
|
e8f4c106a4 |
No files matched your search
+33
-11
@@ -1,4 +1,3 @@
|
||||
|
||||
Guidelines
|
||||
==========
|
||||
|
||||
@@ -32,18 +31,41 @@ file in this directory.
|
||||
|
||||
When contributing code, make sure that your contribution falls under
|
||||
the appropriate license. For example, contributions to code licensed
|
||||
under MIT X11 code, should be MIT X11 code.
|
||||
under MIT/X11 code, should be MIT/X11 code.
|
||||
|
||||
The Runtime is a special case. The code is dual licensed by Xamarin
|
||||
under both the GNU LGPL v2 license and is also available under
|
||||
commercial terms. For the runtime, you should either sign an
|
||||
The runtime (`mono/...`) is a special case. The code is dual-licensed
|
||||
by Xamarin under both the GNU LGPL v2 license and is also available
|
||||
under commercial terms. For the runtime, you should either sign an
|
||||
agreement that grants Xamarin the rights to relicense your code under
|
||||
other licenses other than the LGPL v2 or your contribution must be
|
||||
made as an MIT X11 license which grants us the same rights, but
|
||||
involves no paperwork.
|
||||
made as an MIT/X11 license which grants us the same rights, but
|
||||
involves no paperwork. For the latter case, please specify on your
|
||||
commit(s) that you are licensing the changes under MIT/X11.
|
||||
|
||||
Submitting Patches
|
||||
==================
|
||||
For other parts of the project that are dual-licensed, please state
|
||||
on your commit(s) what license you are contributing the changes under.
|
||||
|
||||
When Submitting patches to the dual-licensed portions, please specify
|
||||
on the commit the license that the code is under.
|
||||
Testing
|
||||
=======
|
||||
|
||||
Pull requests go through testing on our [Jenkins server][2]. We will
|
||||
usually only merge a pull request if it causes no regressions in a
|
||||
test run there.
|
||||
|
||||
When you submit a pull request, one of two things happens:
|
||||
|
||||
* If you are a new contributor, Jenkins will ask for permissions (on
|
||||
the pull request) to test it. A maintainer will reply to approve
|
||||
the test run if they find the patch appropriate. After you have
|
||||
submitted a few patches, a maintainer will whitelist you so that
|
||||
all of your future pull requests are tested automatically.
|
||||
* If you are a well-known, whitelisted contributor, Jenkins will go
|
||||
ahead and test your pull request as soon as a test machine is
|
||||
available.
|
||||
|
||||
When your pull request has been built, Jenkins will update the build
|
||||
status of your pull request. If it succeeded and we like the changes,
|
||||
a maintainer will likely merge it. Otherwise, you can amend your pull
|
||||
request to fix build breakage and Jenkins will test it again.
|
||||
|
||||
[2] http://monojenkins.cloudapp.net
|
||||
@@ -322,7 +322,6 @@ namespace Mono.Data.Tds {
|
||||
result.Append (size > 8000 ? "(max)" : String.Format ("({0})", size));
|
||||
break;
|
||||
case "nvarchar":
|
||||
case "xml":
|
||||
int paramSize = Size < 0 ? GetActualSize () / 2 : Size;
|
||||
result.Append (paramSize > 0 ? (paramSize > 4000 ? "(max)" : String.Format ("({0})", paramSize)) : "(4000)");
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// AssemblyInfo.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar ([email protected])
|
||||
//
|
||||
// Copyright 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about the assembly
|
||||
|
||||
[assembly: AssemblyTitle ("Mono.Runtime.dll")]
|
||||
[assembly: AssemblyDescription ("Mono.Runtime.dll")]
|
||||
[assembly: AssemblyDefaultAlias ("Mono.Runtime.dll")]
|
||||
|
||||
[assembly: AssemblyCompany (Consts.MonoCompany)]
|
||||
[assembly: AssemblyProduct (Consts.MonoProduct)]
|
||||
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
|
||||
[assembly: AssemblyVersion (Consts.FxVersion)]
|
||||
[assembly: SatelliteContractVersion (Consts.FxVersion)]
|
||||
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
|
||||
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
|
||||
|
||||
[assembly: NeutralResourcesLanguage ("en-US")]
|
||||
[assembly: CLSCompliant (true)]
|
||||
[assembly: AssemblyDelaySign (true)]
|
||||
|
||||
[assembly: AssemblyKeyFile ("../mono.pub")]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
thisdir = class/Mono.Runtime
|
||||
SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LIBRARY = Mono.Runtime.dll
|
||||
|
||||
LIB_MCS_FLAGS = -r:System.Core.dll -r:System.dll -unsafe
|
||||
|
||||
include ../../build/library.make
|
||||
@@ -0,0 +1,3 @@
|
||||
../../build/common/Consts.cs
|
||||
Assembly/AssemblyInfo.cs
|
||||
Mono.Runtime/InlineAsm.cs
|
||||
@@ -0,0 +1,244 @@
|
||||
//
|
||||
// InlineAsm.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Runtime {
|
||||
|
||||
[Flags]
|
||||
public enum InlineAsmFlags {
|
||||
None = 0,
|
||||
ClobbersFlags = 1 << 1,
|
||||
ClobbersMemory = 1 << 2,
|
||||
Volatile = 1 << 3,
|
||||
}
|
||||
|
||||
// architecture constraints
|
||||
public enum Amd64Asm {
|
||||
Rax,
|
||||
Rcx,
|
||||
Rdx,
|
||||
Rbx,
|
||||
Rsp,
|
||||
Rbp,
|
||||
Rsi,
|
||||
Rdi,
|
||||
R8,
|
||||
R9,
|
||||
R10,
|
||||
R11,
|
||||
R12,
|
||||
R13,
|
||||
R14,
|
||||
R15,
|
||||
Xmm0,
|
||||
Xmm1,
|
||||
Xmm2,
|
||||
Xmm3,
|
||||
Xmm4,
|
||||
Xmm5,
|
||||
Xmm6,
|
||||
Xmm7,
|
||||
Xmm8,
|
||||
Xmm9,
|
||||
Xmm10,
|
||||
Xmm11,
|
||||
Xmm12,
|
||||
Xmm13,
|
||||
Xmm14,
|
||||
Xmm15,
|
||||
Input = 1 << 24,
|
||||
Output = 1 << 25,
|
||||
ArrayStart = 1 << 26,
|
||||
}
|
||||
|
||||
public enum X86Asm {
|
||||
Eax,
|
||||
Ecx,
|
||||
Edx,
|
||||
Ebx,
|
||||
Esp,
|
||||
Ebp,
|
||||
Esi,
|
||||
Edi,
|
||||
Xmm0,
|
||||
Xmm1,
|
||||
Xmm2,
|
||||
Xmm3,
|
||||
Xmm4,
|
||||
Xmm5,
|
||||
Xmm6,
|
||||
Xmm7,
|
||||
Input = 1 << 24,
|
||||
Output = 1 << 25,
|
||||
ArrayStart = 1 << 26,
|
||||
}
|
||||
|
||||
public enum ArmAsm {
|
||||
R0,
|
||||
R1,
|
||||
R2,
|
||||
R3,
|
||||
R4,
|
||||
R5,
|
||||
R6,
|
||||
R7,
|
||||
R8,
|
||||
R9,
|
||||
R10,
|
||||
R11,
|
||||
R12,
|
||||
R13,
|
||||
R14,
|
||||
R15,
|
||||
F0,
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
F16,
|
||||
F17,
|
||||
F18,
|
||||
F19,
|
||||
F20,
|
||||
F21,
|
||||
F22,
|
||||
F23,
|
||||
F24,
|
||||
F25,
|
||||
F26,
|
||||
F27,
|
||||
F28,
|
||||
F29,
|
||||
F30,
|
||||
F31,
|
||||
Input = 1 << 24,
|
||||
Output = 1 << 25,
|
||||
ArrayStart = 1 << 26,
|
||||
}
|
||||
|
||||
/*
|
||||
public class ArmXXX
|
||||
{
|
||||
public enum Descriptor
|
||||
{
|
||||
R0,
|
||||
R1,
|
||||
R2,
|
||||
R3,
|
||||
R4,
|
||||
R5,
|
||||
R6,
|
||||
R7,
|
||||
R8,
|
||||
R9,
|
||||
R10,
|
||||
R11,
|
||||
R12,
|
||||
R13,
|
||||
R14,
|
||||
R15,
|
||||
}
|
||||
|
||||
public Arm (object value, Descriptor descriptor)
|
||||
{
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static class InlineAsm {
|
||||
|
||||
// Each of the methods here is in practice an internal call: the JIT will
|
||||
// substitute the correct result inline, while on runtimes that don't support the
|
||||
// feature, the code executes as is and everything is disabled (the developer
|
||||
// should insert a fallback to handle this case)
|
||||
public static bool ArmSupported {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool X86Supported {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Amd64Supported {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SSE2Supported {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The following methods are never seen by the JIT (and even if someone tries to
|
||||
// sneak them in they do nothing). Instead, the C# compiler intercepts them and
|
||||
// replaces the call with a ldtoken/pop IL instruction sequence: the resulting IL
|
||||
// code is valid IL (and would do nothing anyway on a runtime without inline asm support).
|
||||
// the token references a field with a data blob that contains the serialized information
|
||||
// (flags, compiled assembly code, argument constraints, optionally the original assembly code).
|
||||
// this is similar to the ldtoken use for array initialization.
|
||||
// args contains pairs of local vars (including method arguments) and their constraints
|
||||
// the C# compiler needs to make sure the constraints are of the right type and constants
|
||||
// for arguments flagged with Output, the C# compiler should treat the variable like
|
||||
// if it was passed as out varname to a method for definitive assignment purposes
|
||||
//
|
||||
|
||||
public static void Arm (InlineAsmFlags options, string code, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public static void X86 (InlineAsmFlags options, string code, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public static void Amd64 (InlineAsmFlags options, string code, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
// GPU code?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// asm.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Runtime
|
||||
{
|
||||
public static class asm
|
||||
{
|
||||
public static void BindParameter (int register, object parameter)
|
||||
{
|
||||
throw CreateException ();
|
||||
}
|
||||
|
||||
[CLSCompliant (false)]
|
||||
public unsafe static void BindParameter (int register, void* parameter)
|
||||
{
|
||||
throw CreateException ();
|
||||
}
|
||||
|
||||
public static void BindVariable (int register, object variable)
|
||||
{
|
||||
throw CreateException ();
|
||||
}
|
||||
|
||||
[CLSCompliant (false)]
|
||||
public unsafe static void BindVariable (int register, void* variable)
|
||||
{
|
||||
throw CreateException ();
|
||||
}
|
||||
|
||||
static Exception CreateException ()
|
||||
{
|
||||
return new NotSupportedException ("The assembler binder requires Mono C# compiler to be used for compilation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,22 +347,31 @@ namespace System.Net
|
||||
if (webHeaders == null)
|
||||
return;
|
||||
|
||||
string value = webHeaders.Get ("Set-Cookie");
|
||||
if (value != null) {
|
||||
SetCookie (value);
|
||||
//
|
||||
// Don't terminate response reading on bad cookie value
|
||||
//
|
||||
string value;
|
||||
try {
|
||||
value = webHeaders.Get ("Set-Cookie");
|
||||
if (value != null && SetCookie (value))
|
||||
return;
|
||||
} catch {
|
||||
}
|
||||
|
||||
value = webHeaders.Get ("Set-Cookie2");
|
||||
if (value != null) {
|
||||
SetCookie (value);
|
||||
try {
|
||||
value = webHeaders.Get ("Set-Cookie2");
|
||||
if (value != null)
|
||||
SetCookie (value);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
void SetCookie (string header)
|
||||
bool SetCookie (string header)
|
||||
{
|
||||
if (cookieCollection == null)
|
||||
cookieCollection = new CookieCollection ();
|
||||
|
||||
bool at_least_one_set = false;
|
||||
var parser = new CookieParser (header);
|
||||
foreach (var cookie in parser.Parse ()) {
|
||||
if (cookie.Domain == "") {
|
||||
@@ -375,9 +384,13 @@ namespace System.Net
|
||||
continue;
|
||||
|
||||
cookieCollection.Add (cookie);
|
||||
if (cookie_container != null)
|
||||
if (cookie_container != null) {
|
||||
cookie_container.Add (uri, cookie);
|
||||
at_least_one_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
return at_least_one_set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+69
-51
@@ -1315,32 +1315,23 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AttributeEncoder
|
||||
public class BlobEncoder
|
||||
{
|
||||
[Flags]
|
||||
public enum EncodedTypeProperties
|
||||
{
|
||||
None = 0,
|
||||
DynamicType = 1,
|
||||
TypeParameter = 1 << 1
|
||||
}
|
||||
|
||||
public static readonly byte[] Empty;
|
||||
|
||||
byte[] buffer;
|
||||
int pos;
|
||||
const ushort Version = 1;
|
||||
|
||||
static AttributeEncoder ()
|
||||
{
|
||||
Empty = new byte[4];
|
||||
Empty[0] = (byte) Version;
|
||||
}
|
||||
|
||||
public AttributeEncoder ()
|
||||
public BlobEncoder ()
|
||||
{
|
||||
buffer = new byte[32];
|
||||
Encode (Version);
|
||||
}
|
||||
|
||||
public void Add (byte[] data)
|
||||
{
|
||||
if (pos + data.Length > buffer.Length)
|
||||
Grow (data.Length);
|
||||
|
||||
Buffer.BlockCopy (data, 0, buffer, pos, data.Length);
|
||||
pos += data.Length;
|
||||
}
|
||||
|
||||
public void Encode (bool value)
|
||||
@@ -1353,7 +1344,7 @@ namespace Mono.CSharp {
|
||||
if (pos == buffer.Length)
|
||||
Grow (1);
|
||||
|
||||
buffer [pos++] = value;
|
||||
buffer[pos++] = value;
|
||||
}
|
||||
|
||||
public void Encode (sbyte value)
|
||||
@@ -1428,7 +1419,7 @@ namespace Mono.CSharp {
|
||||
return;
|
||||
}
|
||||
|
||||
var buf = Encoding.UTF8.GetBytes(value);
|
||||
var buf = Encoding.UTF8.GetBytes (value);
|
||||
WriteCompressedValue (buf.Length);
|
||||
|
||||
if (pos + buf.Length > buffer.Length)
|
||||
@@ -1438,6 +1429,62 @@ namespace Mono.CSharp {
|
||||
pos += buf.Length;
|
||||
}
|
||||
|
||||
|
||||
void Grow (int inc)
|
||||
{
|
||||
int size = System.Math.Max (pos * 4, pos + inc + 2);
|
||||
Array.Resize (ref buffer, size);
|
||||
}
|
||||
|
||||
public void WriteCompressedValue (int value)
|
||||
{
|
||||
if (value < 0x80) {
|
||||
Encode ((byte) value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < 0x4000) {
|
||||
Encode ((byte) (0x80 | (value >> 8)));
|
||||
Encode ((byte) value);
|
||||
return;
|
||||
}
|
||||
|
||||
Encode (value);
|
||||
}
|
||||
|
||||
public byte[] ToArray ()
|
||||
{
|
||||
byte[] buf = new byte[pos];
|
||||
Array.Copy (buffer, buf, pos);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AttributeEncoder : BlobEncoder
|
||||
{
|
||||
[Flags]
|
||||
public enum EncodedTypeProperties
|
||||
{
|
||||
None = 0,
|
||||
DynamicType = 1,
|
||||
TypeParameter = 1 << 1
|
||||
}
|
||||
|
||||
public static readonly byte[] Empty;
|
||||
|
||||
const ushort Version = 1;
|
||||
|
||||
static AttributeEncoder ()
|
||||
{
|
||||
Empty = new byte[4];
|
||||
Empty[0] = (byte) Version;
|
||||
}
|
||||
|
||||
public AttributeEncoder ()
|
||||
{
|
||||
Encode (Version);
|
||||
}
|
||||
|
||||
public EncodedTypeProperties Encode (TypeSpec type)
|
||||
{
|
||||
switch (type.BuiltinType) {
|
||||
@@ -1567,35 +1614,6 @@ namespace Mono.CSharp {
|
||||
{
|
||||
Encode ((ushort) 0);
|
||||
}
|
||||
|
||||
void Grow (int inc)
|
||||
{
|
||||
int size = System.Math.Max (pos * 4, pos + inc + 2);
|
||||
Array.Resize (ref buffer, size);
|
||||
}
|
||||
|
||||
void WriteCompressedValue (int value)
|
||||
{
|
||||
if (value < 0x80) {
|
||||
Encode ((byte) value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < 0x4000) {
|
||||
Encode ((byte) (0x80 | (value >> 8)));
|
||||
Encode ((byte) value);
|
||||
return;
|
||||
}
|
||||
|
||||
Encode (value);
|
||||
}
|
||||
|
||||
public byte[] ToArray ()
|
||||
{
|
||||
byte[] buf = new byte[pos];
|
||||
Array.Copy (buffer, buf, pos);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3721,6 +3721,9 @@ namespace Mono.CSharp {
|
||||
get {
|
||||
return best_candidate;
|
||||
}
|
||||
set {
|
||||
best_candidate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TypeSpec BestCandidateReturnType {
|
||||
|
||||
@@ -5865,6 +5865,22 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
class LocalVariableReferenceIndex : IntConstant
|
||||
{
|
||||
LocalVariable lvi;
|
||||
|
||||
public LocalVariableReferenceIndex (BuiltinTypes types, LocalVariable lvi, Location loc)
|
||||
: base (types, -1, loc)
|
||||
{
|
||||
this.lvi = lvi;
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
ec.EmitInt (lvi.LocalIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This represents a reference to a parameter in the intermediate
|
||||
/// representation.
|
||||
@@ -6224,6 +6240,10 @@ namespace Mono.CSharp
|
||||
return DoResolveDynamic (ec, member_expr);
|
||||
|
||||
var method = mg.BestCandidate;
|
||||
if (method.DeclaringType == ec.Module.PredefinedTypes.InlineAsm.TypeSpec) {
|
||||
return new InlineAsmStatement (arguments, mg.BestCandidate).Resolve (ec);
|
||||
}
|
||||
|
||||
type = mg.BestCandidateReturnType;
|
||||
|
||||
if (arguments == null && method.DeclaringType.BuiltinType == BuiltinTypeSpec.Type.Object && method.Name == Destructor.MetadataName) {
|
||||
@@ -11289,4 +11309,164 @@ namespace Mono.CSharp
|
||||
this.loc = loc;
|
||||
}
|
||||
}
|
||||
|
||||
class InlineAsmStatement : ExpressionStatement
|
||||
{
|
||||
readonly Arguments arguments;
|
||||
readonly MethodSpec method;
|
||||
|
||||
public InlineAsmStatement (Arguments arguments, MethodSpec method)
|
||||
{
|
||||
this.arguments = arguments;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public override Expression CreateExpressionTree (ResolveContext ec)
|
||||
{
|
||||
throw new NotSupportedException ("ET");
|
||||
}
|
||||
|
||||
protected override Expression DoResolve (ResolveContext rc)
|
||||
{
|
||||
// TODO: Add proper arguments checks
|
||||
var c = arguments[0].Expr as Constant;
|
||||
if (c == null)
|
||||
throw new ArgumentException ();
|
||||
|
||||
c = arguments[1].Expr as Constant;
|
||||
if (c == null)
|
||||
throw new NotImplementedException ();
|
||||
|
||||
if (c.GetValueAsLiteral () == null)
|
||||
throw new NotImplementedException ();
|
||||
|
||||
var args = arguments[2].Expr;
|
||||
var args_array = args as ArrayCreation;
|
||||
if (args_array == null)
|
||||
throw new NotImplementedException ();
|
||||
|
||||
PredefinedType flags_type;
|
||||
switch (method.Name) {
|
||||
case "Arm":
|
||||
flags_type = rc.Module.PredefinedTypes.AsmArm;
|
||||
break;
|
||||
case "X86":
|
||||
flags_type = rc.Module.PredefinedTypes.AsmX86;
|
||||
break;
|
||||
case "Amd64":
|
||||
flags_type = rc.Module.PredefinedTypes.AsmAmd64;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
var elements = args_array.Initializers.Elements;
|
||||
for (int i = 0; i < elements.Count / 2; ++i) {
|
||||
var expr = elements[i * 2];
|
||||
expr = ExtractInlineAsmArgument (rc, expr);
|
||||
if (expr == null)
|
||||
break;
|
||||
|
||||
elements[i * 2] = expr;
|
||||
|
||||
c = elements[i * 2 + 1] as Constant;
|
||||
if (c == null)
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
if (elements.Count % 2 != 0)
|
||||
rc.Report.Error (-101, args_array.Location, "Every argument requires associated `{0}' to be specified", flags_type.GetSignatureForError ());
|
||||
|
||||
type = rc.Module.Compiler.BuiltinTypes.Void;
|
||||
eclass = ExprClass.Value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void EmitStatement (EmitContext ec)
|
||||
{
|
||||
var enc = new BlobEncoder ();
|
||||
enc.Encode ((byte) 1); // version
|
||||
|
||||
var c = (Constant) arguments[0].Expr;
|
||||
enc.Encode ((int) c.GetValueAsLong ()); // options
|
||||
|
||||
var args_array = (ArrayCreation) arguments[2].Expr;
|
||||
|
||||
var elements = args_array.Initializers.Elements;
|
||||
var count = elements.Count / 2;
|
||||
// TODO: Why byte?
|
||||
enc.Encode ((byte) count); // arguments count
|
||||
for (int i = 0; i < count; ++i) {
|
||||
// argument type
|
||||
EncodeInlineAsmArgument (enc, elements[i * 2]);
|
||||
|
||||
c = (Constant) elements[i * 2 + 1];
|
||||
// argument options
|
||||
enc.Encode ((int) c.GetValueAsLong ());
|
||||
}
|
||||
|
||||
c = (Constant) arguments[1].Expr;
|
||||
var code = c.GetValueAsLiteral ();
|
||||
|
||||
var fb = ec.CurrentTypeDefinition.Module.MakeInlineAsmData (enc.ToArray (), loc);
|
||||
ec.Emit (OpCodes.Ldtoken, fb);
|
||||
ec.Emit (OpCodes.Pop);
|
||||
}
|
||||
|
||||
static Expression ExtractInlineAsmArgument (ResolveContext rc, Expression expr)
|
||||
{
|
||||
var cast = expr as TypeCast;
|
||||
if (cast != null)
|
||||
return ExtractInlineAsmArgument (rc, cast.Child);
|
||||
|
||||
// TODO: check for hoisted version
|
||||
// TODO: reject out/ref parameters?
|
||||
if (expr is ParameterReference)
|
||||
return expr;
|
||||
|
||||
// TODO: check for hoisted version
|
||||
// TODO: check for local constant?
|
||||
// TODO: check for locked foreach/using variable
|
||||
if (expr is LocalVariableReference)
|
||||
return expr;
|
||||
|
||||
rc.Report.Error (-100, expr.Location, "Parameter binder argument must be local variable or parameter reference");
|
||||
return null;
|
||||
}
|
||||
|
||||
static void EncodeInlineAsmArgument (BlobEncoder encoder, Expression expr)
|
||||
{
|
||||
var pr = expr as ParameterReference;
|
||||
if (pr != null) {
|
||||
encoder.Encode ((byte) 0);
|
||||
encoder.WriteCompressedValue (pr.Parameter.PositionalIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
var lv = expr as LocalVariableReference;
|
||||
if (lv != null) {
|
||||
// TODO: check for hoisted version
|
||||
// TODO: check for local constant?
|
||||
// TODO: check for locked foreach/using variable
|
||||
encoder.Encode ((byte) 1);
|
||||
encoder.WriteCompressedValue (lv.local_info.LocalIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InternalErrorException ();
|
||||
}
|
||||
|
||||
static void EncodeInlineAsmCode (BlobEncoder enc, string code)
|
||||
{
|
||||
// TODO: Get it from external lib
|
||||
byte[] bcode = new byte[] { 1, 2, 3 };
|
||||
enc.WriteCompressedValue (bcode.Length);
|
||||
enc.Add (bcode);
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-2
@@ -41,8 +41,8 @@ namespace Mono.CSharp
|
||||
readonly Dictionary<int, Struct> size_types;
|
||||
int fields;
|
||||
|
||||
public StaticDataContainer (ModuleContainer module)
|
||||
: base (module, new MemberName ("<PrivateImplementationDetails>" + module.builder.ModuleVersionId.ToString ("B"), Location.Null),
|
||||
public StaticDataContainer (ModuleContainer module, string containerName = "<PrivateImplementationDetails>")
|
||||
: base (module, new MemberName (containerName + module.builder.ModuleVersionId.ToString ("B"), Location.Null),
|
||||
Modifiers.STATIC | Modifiers.INTERNAL)
|
||||
{
|
||||
size_types = new Dictionary<int, Struct> ();
|
||||
@@ -87,6 +87,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
StaticDataContainer static_data;
|
||||
StaticDataContainer inline_asm_data;
|
||||
|
||||
//
|
||||
// Makes const data field inside internal type container
|
||||
@@ -103,6 +104,19 @@ namespace Mono.CSharp
|
||||
|
||||
return static_data.DefineInitializedData (data, loc);
|
||||
}
|
||||
|
||||
public FieldSpec MakeInlineAsmData (byte[] data, Location loc)
|
||||
{
|
||||
if (inline_asm_data == null) {
|
||||
inline_asm_data = new StaticDataContainer (this, "<InlineAsmData>");
|
||||
inline_asm_data.CreateContainer ();
|
||||
inline_asm_data.DefineContainer ();
|
||||
|
||||
AddCompilerGeneratedClass (inline_asm_data);
|
||||
}
|
||||
|
||||
return inline_asm_data.DefineInitializedData (data, loc);
|
||||
}
|
||||
#endif
|
||||
|
||||
public CharSet? DefaultCharSet;
|
||||
|
||||
@@ -570,6 +570,12 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public int PositionalIndex {
|
||||
get {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
|
||||
public Modifier ModFlags {
|
||||
get { return modFlags & ~Modifier.This; }
|
||||
}
|
||||
|
||||
@@ -2436,6 +2436,12 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public int LocalIndex {
|
||||
get {
|
||||
return builder.LocalIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
|
||||
@@ -234,6 +234,14 @@ namespace Mono.CSharp
|
||||
public readonly PredefinedType INotifyCompletion;
|
||||
public readonly PredefinedType ICriticalNotifyCompletion;
|
||||
|
||||
//
|
||||
// Mono extensions
|
||||
//
|
||||
public readonly PredefinedType AsmAmd64;
|
||||
public readonly PredefinedType AsmX86;
|
||||
public readonly PredefinedType AsmArm;
|
||||
public readonly PredefinedType InlineAsm;
|
||||
|
||||
public PredefinedTypes (ModuleContainer module)
|
||||
{
|
||||
TypedReference = new PredefinedType (module, MemberKind.Struct, "System", "TypedReference");
|
||||
@@ -287,6 +295,11 @@ namespace Mono.CSharp
|
||||
INotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "INotifyCompletion");
|
||||
ICriticalNotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "ICriticalNotifyCompletion");
|
||||
|
||||
InlineAsm = new PredefinedType (module, MemberKind.Class, "Mono.Runtime", "InlineAsm");
|
||||
AsmAmd64 = new PredefinedType (module, MemberKind.Enum, "Mono.Runtime", "Amd64Asm");
|
||||
AsmX86 = new PredefinedType (module, MemberKind.Enum, "Mono.Runtime", "X86Asm");
|
||||
AsmArm = new PredefinedType (module, MemberKind.Enum, "Mono.Runtime", "ArmAsm");
|
||||
|
||||
//
|
||||
// Define types which are used for comparison. It does not matter
|
||||
// if they don't exist as no error report is needed
|
||||
@@ -321,6 +334,8 @@ namespace Mono.CSharp
|
||||
Task.Define ();
|
||||
if (TaskGeneric.Define ())
|
||||
TaskGeneric.TypeSpec.IsGenericTask = true;
|
||||
|
||||
InlineAsm.Define ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,6 +406,7 @@ namespace Mono.CSharp
|
||||
var types = module.PredefinedTypes;
|
||||
var atypes = module.PredefinedAttributes;
|
||||
var btypes = module.Compiler.BuiltinTypes;
|
||||
var void_star = PointerContainer.MakeType (module, btypes.Void);
|
||||
|
||||
var tp = new TypeParameter (0, new MemberName ("T"), null, null, Variance.None);
|
||||
|
||||
|
||||
+3
-3
@@ -1134,11 +1134,11 @@ mono_gc_init (void)
|
||||
MONO_GC_REGISTER_ROOT_FIXED (gc_handles [HANDLE_NORMAL].entries);
|
||||
MONO_GC_REGISTER_ROOT_FIXED (gc_handles [HANDLE_PINNED].entries);
|
||||
|
||||
mono_counters_register ("Created object count", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &mono_stats.new_object_count);
|
||||
mono_counters_register ("Created object count", MONO_COUNTER_GC | MONO_COUNTER_LONG, &mono_stats.new_object_count);
|
||||
mono_counters_register ("Minor GC collections", MONO_COUNTER_GC | MONO_COUNTER_INT, &gc_stats.minor_gc_count);
|
||||
mono_counters_register ("Major GC collections", MONO_COUNTER_GC | MONO_COUNTER_INT, &gc_stats.major_gc_count);
|
||||
mono_counters_register ("Minor GC time", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &gc_stats.minor_gc_time_usecs);
|
||||
mono_counters_register ("Major GC time", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &gc_stats.major_gc_time_usecs);
|
||||
mono_counters_register ("Minor GC time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.minor_gc_time_usecs);
|
||||
mono_counters_register ("Major GC time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.major_gc_time_usecs);
|
||||
|
||||
mono_gc_base_init ();
|
||||
|
||||
|
||||
@@ -774,8 +774,8 @@ sgen_card_table_init (SgenRemeberedSet *remset)
|
||||
mono_counters_register ("cardtable large objects", MONO_COUNTER_GC | MONO_COUNTER_LONG, &large_objects);
|
||||
mono_counters_register ("cardtable bloby objects", MONO_COUNTER_GC | MONO_COUNTER_LONG, &bloby_objects);
|
||||
#endif
|
||||
mono_counters_register ("cardtable major scan time", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &major_card_scan_time);
|
||||
mono_counters_register ("cardtable los scan time", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &los_card_scan_time);
|
||||
mono_counters_register ("cardtable major scan time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &major_card_scan_time);
|
||||
mono_counters_register ("cardtable los scan time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &los_card_scan_time);
|
||||
|
||||
|
||||
remset->wbarrier_set_field = sgen_card_table_wbarrier_set_field;
|
||||
|
||||
+21
-21
@@ -1894,28 +1894,28 @@ init_stats (void)
|
||||
if (inited)
|
||||
return;
|
||||
|
||||
mono_counters_register ("Minor fragment clear", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_pre_collection_fragment_clear);
|
||||
mono_counters_register ("Minor pinning", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_pinning);
|
||||
mono_counters_register ("Minor scan remembered set", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_scan_remsets);
|
||||
mono_counters_register ("Minor scan pinned", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_scan_pinned);
|
||||
mono_counters_register ("Minor scan registered roots", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_scan_registered_roots);
|
||||
mono_counters_register ("Minor scan thread data", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_scan_thread_data);
|
||||
mono_counters_register ("Minor finish gray stack", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_finish_gray_stack);
|
||||
mono_counters_register ("Minor fragment creation", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_fragment_creation);
|
||||
mono_counters_register ("Minor fragment clear", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_pre_collection_fragment_clear);
|
||||
mono_counters_register ("Minor pinning", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_pinning);
|
||||
mono_counters_register ("Minor scan remembered set", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_scan_remsets);
|
||||
mono_counters_register ("Minor scan pinned", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_scan_pinned);
|
||||
mono_counters_register ("Minor scan registered roots", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_scan_registered_roots);
|
||||
mono_counters_register ("Minor scan thread data", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_scan_thread_data);
|
||||
mono_counters_register ("Minor finish gray stack", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_finish_gray_stack);
|
||||
mono_counters_register ("Minor fragment creation", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_minor_fragment_creation);
|
||||
|
||||
mono_counters_register ("Major fragment clear", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_pre_collection_fragment_clear);
|
||||
mono_counters_register ("Major pinning", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_pinning);
|
||||
mono_counters_register ("Major scan pinned", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_scan_pinned);
|
||||
mono_counters_register ("Major scan registered roots", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_scan_registered_roots);
|
||||
mono_counters_register ("Major scan thread data", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_scan_thread_data);
|
||||
mono_counters_register ("Major scan alloc_pinned", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_scan_alloc_pinned);
|
||||
mono_counters_register ("Major scan finalized", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_scan_finalized);
|
||||
mono_counters_register ("Major scan big objects", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_scan_big_objects);
|
||||
mono_counters_register ("Major finish gray stack", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_finish_gray_stack);
|
||||
mono_counters_register ("Major free big objects", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_free_bigobjs);
|
||||
mono_counters_register ("Major LOS sweep", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_los_sweep);
|
||||
mono_counters_register ("Major sweep", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_sweep);
|
||||
mono_counters_register ("Major fragment creation", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_major_fragment_creation);
|
||||
mono_counters_register ("Major fragment clear", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_pre_collection_fragment_clear);
|
||||
mono_counters_register ("Major pinning", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_pinning);
|
||||
mono_counters_register ("Major scan pinned", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_scan_pinned);
|
||||
mono_counters_register ("Major scan registered roots", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_scan_registered_roots);
|
||||
mono_counters_register ("Major scan thread data", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_scan_thread_data);
|
||||
mono_counters_register ("Major scan alloc_pinned", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_scan_alloc_pinned);
|
||||
mono_counters_register ("Major scan finalized", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_scan_finalized);
|
||||
mono_counters_register ("Major scan big objects", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_scan_big_objects);
|
||||
mono_counters_register ("Major finish gray stack", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_finish_gray_stack);
|
||||
mono_counters_register ("Major free big objects", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_free_bigobjs);
|
||||
mono_counters_register ("Major LOS sweep", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_los_sweep);
|
||||
mono_counters_register ("Major sweep", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_sweep);
|
||||
mono_counters_register ("Major fragment creation", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_major_fragment_creation);
|
||||
|
||||
mono_counters_register ("Number of pinned objects", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_pinned_objects);
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ NurseryClearPolicy sgen_get_nursery_clear_policy (void) MONO_INTERNAL;
|
||||
|
||||
#define SGEN_TV_DECLARE(name) gint64 name
|
||||
#define SGEN_TV_GETTIME(tv) tv = mono_100ns_ticks ()
|
||||
#define SGEN_TV_ELAPSED(start,end) (int)((end-start) / 10)
|
||||
#define SGEN_TV_ELAPSED_MS(start,end) ((SGEN_TV_ELAPSED((start),(end)) + 500) / 1000)
|
||||
#define SGEN_TV_ELAPSED(start,end) (int)((end-start))
|
||||
#define SGEN_TV_ELAPSED_MS(start,end) ((SGEN_TV_ELAPSED((start),(end)) + 5000) / 10000)
|
||||
|
||||
#if !defined(__MACH__) && !MONO_MACH_ARCH_SUPPORTED && defined(HAVE_PTHREAD_KILL)
|
||||
#define SGEN_POSIX_STW 1
|
||||
|
||||
@@ -324,8 +324,8 @@ sgen_restart_world (int generation, GGTimingInfo *timing)
|
||||
void
|
||||
sgen_init_stw (void)
|
||||
{
|
||||
mono_counters_register ("World stop", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_stop_world);
|
||||
mono_counters_register ("World restart", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_restart_world);
|
||||
mono_counters_register ("World stop", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_stop_world);
|
||||
mono_counters_register ("World restart", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &time_restart_world);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -917,7 +917,7 @@ mono_class_init_trampoline (mgreg_t *regs, guint8 *code, MonoVTable *vtable, gui
|
||||
|
||||
if (vtable->initialized) {
|
||||
if (plt_entry)
|
||||
mono_arch_nullify_plt_entry (plt_entry, regs);
|
||||
mono_arch_patch_plt_entry (plt_entry, NULL, regs, mini_get_nullified_class_init_trampoline ());
|
||||
else
|
||||
mono_arch_nullify_class_init_trampoline (code, regs);
|
||||
}
|
||||
|
||||
@@ -2419,7 +2419,6 @@ gpointer mono_arch_get_gsharedvt_arg_trampoline (MonoDomain *domain, gpointer ar
|
||||
void mono_arch_patch_callsite (guint8 *method_start, guint8 *code, guint8 *addr) MONO_INTERNAL;
|
||||
void mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *addr) MONO_INTERNAL;
|
||||
void mono_arch_nullify_class_init_trampoline(guint8 *code, mgreg_t *regs) MONO_INTERNAL;
|
||||
void mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs) MONO_INTERNAL;
|
||||
int mono_arch_get_this_arg_reg (guint8 *code) MONO_INTERNAL;
|
||||
gpointer mono_arch_get_this_arg_from_call (mgreg_t *regs, guint8 *code) MONO_INTERNAL;
|
||||
gpointer mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_target) MONO_INTERNAL;
|
||||
|
||||
@@ -392,12 +392,6 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
static void
|
||||
stack_unaligned (MonoTrampolineType tramp_type)
|
||||
{
|
||||
|
||||
@@ -132,12 +132,6 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
mono_arch_patch_callsite (NULL, code, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
#ifndef DISABLE_JIT
|
||||
|
||||
#define arm_is_imm12(v) ((int)(v) > -4096 && (int)(v) < 4096)
|
||||
|
||||
@@ -169,12 +169,6 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
mono_arch_flush_icache (callsite_begin, code - callsite_begin);
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
guchar*
|
||||
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
|
||||
{
|
||||
|
||||
@@ -111,12 +111,6 @@ mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *a
|
||||
|
||||
#define STACK (int)(ALIGN_TO(4*IREG_SIZE + 8 + sizeof(MonoLMF) + 32, 8))
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
|
||||
@@ -203,12 +203,6 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
mono_arch_patch_callsite (NULL, code, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
/* Stack size for trampoline function
|
||||
* PPC_MINIMAL_STACK_SIZE + 16 (args + alignment to ppc_magic_trampoline)
|
||||
* + MonoLMF + 14 fp regs + 13 gregs + alignment
|
||||
|
||||
@@ -217,22 +217,6 @@ mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
|
||||
|
||||
/*========================= End of Function ========================*/
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Name - mono_arch_nullify_plt_entry */
|
||||
/* */
|
||||
/* Function - Nullify a PLT entry call. */
|
||||
/* */
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
/*========================= End of Function ========================*/
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Name - mono_arch_create_trampoline_code */
|
||||
|
||||
@@ -75,12 +75,6 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
sparc_nop (code);
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
#define ALIGN_TO(val,align) (((val) + ((align) - 1)) & ~((align) - 1))
|
||||
|
||||
guchar*
|
||||
|
||||
@@ -292,12 +292,6 @@ mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
|
||||
{
|
||||
mono_arch_patch_plt_entry (code, NULL, regs, mini_get_nullified_class_init_trampoline ());
|
||||
}
|
||||
|
||||
guchar*
|
||||
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
|
||||
{
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#endif
|
||||
|
||||
static uintptr_t code_memory_used = 0;
|
||||
static gulong dynamic_code_alloc_count;
|
||||
static gulong dynamic_code_bytes_count;
|
||||
static gulong dynamic_code_frees_count;
|
||||
static size_t dynamic_code_alloc_count;
|
||||
static size_t dynamic_code_bytes_count;
|
||||
static size_t dynamic_code_frees_count;
|
||||
|
||||
/*
|
||||
* AMD64 processors maintain icache coherency only for pages which are
|
||||
@@ -304,9 +304,9 @@ codechunk_cleanup (void)
|
||||
void
|
||||
mono_code_manager_init (void)
|
||||
{
|
||||
mono_counters_register ("Dynamic code allocs", MONO_COUNTER_JIT | MONO_COUNTER_ULONG, &dynamic_code_alloc_count);
|
||||
mono_counters_register ("Dynamic code bytes", MONO_COUNTER_JIT | MONO_COUNTER_ULONG, &dynamic_code_bytes_count);
|
||||
mono_counters_register ("Dynamic code frees", MONO_COUNTER_JIT | MONO_COUNTER_ULONG, &dynamic_code_frees_count);
|
||||
mono_counters_register ("Dynamic code allocs", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &dynamic_code_alloc_count);
|
||||
mono_counters_register ("Dynamic code bytes", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &dynamic_code_bytes_count);
|
||||
mono_counters_register ("Dynamic code frees", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &dynamic_code_frees_count);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+31
-34
@@ -7,8 +7,6 @@
|
||||
#include <glib.h>
|
||||
#include "mono-counters.h"
|
||||
|
||||
typedef struct _MonoCounter MonoCounter;
|
||||
|
||||
struct _MonoCounter {
|
||||
MonoCounter *next;
|
||||
const char *name;
|
||||
@@ -20,6 +18,18 @@ static MonoCounter *counters = NULL;
|
||||
static int valid_mask = 0;
|
||||
static int set_mask = 0;
|
||||
|
||||
static int
|
||||
mono_counter_get_variance (MonoCounter *counter)
|
||||
{
|
||||
return counter->type & MONO_COUNTER_VARIANCE_MASK;
|
||||
}
|
||||
|
||||
static int
|
||||
mono_counter_get_unit (MonoCounter *counter)
|
||||
{
|
||||
return counter->type & MONO_COUNTER_UNIT_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* mono_counters_enable:
|
||||
* @section_mask: a mask listing the sections that will be displayed
|
||||
@@ -73,9 +83,7 @@ mono_counters_register (const char* name, int type, void *addr)
|
||||
}
|
||||
|
||||
typedef int (*IntFunc) (void);
|
||||
typedef guint (*UIntFunc) (void);
|
||||
typedef gint64 (*LongFunc) (void);
|
||||
typedef guint64 (*ULongFunc) (void);
|
||||
typedef gssize (*PtrFunc) (void);
|
||||
typedef double (*DoubleFunc) (void);
|
||||
typedef char* (*StrFunc) (void);
|
||||
@@ -84,9 +92,7 @@ typedef char* (*StrFunc) (void);
|
||||
static void
|
||||
dump_counter (MonoCounter *counter, FILE *outfile) {
|
||||
int intval;
|
||||
guint uintval;
|
||||
gint64 int64val;
|
||||
guint64 uint64val;
|
||||
gssize wordval;
|
||||
double dval;
|
||||
const char *str;
|
||||
@@ -98,37 +104,22 @@ dump_counter (MonoCounter *counter, FILE *outfile) {
|
||||
intval = *(int*)counter->addr;
|
||||
fprintf (outfile, ENTRY_FMT "%d\n", counter->name, intval);
|
||||
break;
|
||||
case MONO_COUNTER_UINT:
|
||||
if (counter->type & MONO_COUNTER_CALLBACK)
|
||||
uintval = ((UIntFunc)counter->addr) ();
|
||||
else
|
||||
uintval = *(guint*)counter->addr;
|
||||
fprintf (outfile, ENTRY_FMT "%u\n", counter->name, uintval);
|
||||
break;
|
||||
case MONO_COUNTER_LONG:
|
||||
if (counter->type & MONO_COUNTER_CALLBACK)
|
||||
int64val = ((LongFunc)counter->addr) ();
|
||||
else
|
||||
int64val = *(gint64*)counter->addr;
|
||||
fprintf (outfile, ENTRY_FMT "%lld\n", counter->name, (long long)int64val);
|
||||
break;
|
||||
case MONO_COUNTER_ULONG:
|
||||
if (counter->type & MONO_COUNTER_CALLBACK)
|
||||
uint64val = ((ULongFunc)counter->addr) ();
|
||||
if (mono_counter_get_unit (counter) == MONO_COUNTER_TIME)
|
||||
fprintf (outfile, ENTRY_FMT "%.2f ms\n", counter->name, (double)int64val / 10000.0);
|
||||
else
|
||||
uint64val = *(guint64*)counter->addr;
|
||||
fprintf (outfile, ENTRY_FMT "%llu\n", counter->name, (unsigned long long)uint64val);
|
||||
fprintf (outfile, ENTRY_FMT "%lld\n", counter->name, (long long)int64val);
|
||||
break;
|
||||
case MONO_COUNTER_WORD:
|
||||
if (counter->type & MONO_COUNTER_CALLBACK)
|
||||
wordval = ((PtrFunc)counter->addr) ();
|
||||
else
|
||||
wordval = *(gssize*)counter->addr;
|
||||
#if SIZEOF_VOID_P == 8
|
||||
fprintf (outfile, ENTRY_FMT "%lld\n", counter->name, (gint64)wordval);
|
||||
#else
|
||||
fprintf (outfile, ENTRY_FMT "%d\n", counter->name, (gint)wordval);
|
||||
#endif
|
||||
fprintf (outfile, ENTRY_FMT "%zd\n", counter->name, (gint64)wordval);
|
||||
break;
|
||||
case MONO_COUNTER_DOUBLE:
|
||||
if (counter->type & MONO_COUNTER_CALLBACK)
|
||||
@@ -144,13 +135,17 @@ dump_counter (MonoCounter *counter, FILE *outfile) {
|
||||
str = *(char**)counter->addr;
|
||||
fprintf (outfile, ENTRY_FMT "%s\n", counter->name, str);
|
||||
break;
|
||||
case MONO_COUNTER_TIME_INTERVAL:
|
||||
if (counter->type & MONO_COUNTER_CALLBACK)
|
||||
int64val = ((LongFunc)counter->addr) ();
|
||||
else
|
||||
int64val = *(gint64*)counter->addr;
|
||||
fprintf (outfile, ENTRY_FMT "%.2f ms\n", counter->name, (double)int64val / 1000.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mono_counters_foreach (CountersEnumCallback cb, gpointer user_data)
|
||||
{
|
||||
MonoCounter *counter;
|
||||
|
||||
for (counter = counters; counter; counter = counter->next) {
|
||||
if (!cb (counter, user_data))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +155,9 @@ section_names [][10] = {
|
||||
"GC",
|
||||
"Metadata",
|
||||
"Generics",
|
||||
"Security"
|
||||
"Security",
|
||||
"Runtime",
|
||||
"System",
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -168,7 +165,7 @@ mono_counters_dump_section (int section, FILE *outfile)
|
||||
{
|
||||
MonoCounter *counter = counters;
|
||||
while (counter) {
|
||||
if (counter->type & section)
|
||||
if (counter->type & section && mono_counter_get_variance (counter) == MONO_COUNTER_MONOTONIC)
|
||||
dump_counter (counter, outfile);
|
||||
counter = counter->next;
|
||||
}
|
||||
|
||||
@@ -5,26 +5,46 @@
|
||||
#include <mono/utils/mono-publib.h>
|
||||
|
||||
enum {
|
||||
/* Counter type, bits 0-7. */
|
||||
MONO_COUNTER_INT, /* 32 bit int */
|
||||
MONO_COUNTER_UINT, /* 32 bit uint */
|
||||
MONO_COUNTER_WORD, /* pointer-sized int */
|
||||
MONO_COUNTER_LONG, /* 64 bit int */
|
||||
MONO_COUNTER_ULONG, /* 64 bit uint */
|
||||
MONO_COUNTER_DOUBLE,
|
||||
MONO_COUNTER_STRING, /* char* */
|
||||
MONO_COUNTER_TIME_INTERVAL, /* 64 bits signed int holding usecs. */
|
||||
MONO_COUNTER_TYPE_MASK = 0xf,
|
||||
MONO_COUNTER_CALLBACK = 128, /* ORed with the other values */
|
||||
MONO_COUNTER_SECTION_MASK = 0xffffff00,
|
||||
/* sections */
|
||||
/* Sections, bits 8-15 */
|
||||
MONO_COUNTER_JIT = 1 << 8,
|
||||
MONO_COUNTER_GC = 1 << 9,
|
||||
MONO_COUNTER_METADATA = 1 << 10,
|
||||
MONO_COUNTER_GENERICS = 1 << 11,
|
||||
MONO_COUNTER_SECURITY = 1 << 12,
|
||||
MONO_COUNTER_LAST_SECTION
|
||||
MONO_COUNTER_RUNTIME = 1 << 13,
|
||||
MONO_COUNTER_SYSTEM = 1 << 14,
|
||||
MONO_COUNTER_LAST_SECTION,
|
||||
|
||||
/* Unit, bits 16-23 */
|
||||
MONO_COUNTER_UNIT_SHIFT = 16,
|
||||
MONO_COUNTER_UNIT_MASK = 0xFFu << MONO_COUNTER_UNIT_SHIFT,
|
||||
MONO_COUNTER_RAW = 0 << 16, /* Raw value */
|
||||
MONO_COUNTER_BYTES = 1 << 16, /* Quantity of bytes. RSS, active heap, etc */
|
||||
MONO_COUNTER_TIME = 2 << 16, /* Time interval in 100ns units. Minor pause, JIT compilation*/
|
||||
MONO_COUNTER_EVENTS = 3 << 16, /* Number of times the given event happens. Major collections, Compiled methods. */
|
||||
MONO_COUNTER_ITEMS = 4 << 16, /* Current number of things. Threads, queued jobs.*/
|
||||
MONO_COUNTER_PERCENTAGE = 5 << 16, /* [0-1] Fraction Percentage of something. Load average. */
|
||||
|
||||
/* Monotonicity, bits 24-31 */
|
||||
MONO_COUNTER_VARIANCE_SHIFT = 24,
|
||||
MONO_COUNTER_VARIANCE_MASK = 0xFFu << MONO_COUNTER_VARIANCE_SHIFT,
|
||||
MONO_COUNTER_MONOTONIC = 0 << 24, /* This counter value always increase/decreases over time. Reported by --stat. */
|
||||
MONO_COUNTER_CONSTANT = 1 << 24, /* Fixed value. Used by configuration data. */
|
||||
MONO_COUNTER_VARIABLE = 2 << 24, /* This counter value can be anything on each sampling. Only interesting when sampling. */
|
||||
};
|
||||
|
||||
typedef struct _MonoCounter MonoCounter;
|
||||
|
||||
|
||||
MONO_API void mono_counters_enable (int section_mask);
|
||||
|
||||
/*
|
||||
@@ -41,6 +61,10 @@ MONO_API void mono_counters_dump (int section_mask, FILE *outfile);
|
||||
|
||||
MONO_API void mono_counters_cleanup (void);
|
||||
|
||||
typedef mono_bool (*CountersEnumCallback) (MonoCounter *counter, void *user_data);
|
||||
|
||||
MONO_API void mono_counters_foreach (CountersEnumCallback cb, void *user_data);
|
||||
|
||||
typedef enum {
|
||||
MONO_RESOURCE_JIT_CODE, /* bytes */
|
||||
MONO_RESOURCE_METADATA, /* bytes */
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
all: genproj.exe
|
||||
all: genproj.exe prepare.exe
|
||||
mono genproj.exe
|
||||
|
||||
genproj.exe: genproj.cs
|
||||
mcs genproj.cs -pkg:dotnet -r:System.Xml.Linq
|
||||
mcs genproj.cs -r:System.Xml.Linq
|
||||
|
||||
prepare.exe: prepare.cs
|
||||
mcs prepare.cs
|
||||
@@ -1,7 +1,7 @@
|
||||
$(ProjectDir)\..\..\..\mono\msvc\scripts\prepare.exe $(ProjectDir)..\.. xml
|
||||
$(ProjectDir)\..\..\jay\jay.exe -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\System.Xml.XPath\Parser.jay > $(ProjectDir)\System.Xml.XPath\Parser.cs
|
||||
echo #define XSLT_PATTERN > $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs
|
||||
$(ProjectDir)\..\..\jay\jay.exe -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Mono.Xml.Xsl\PatternParser.jay >> $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs
|
||||
echo #define XSLT_PATTERN > $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs
|
||||
type $(ProjectDir)\System.Xml.XPath\Tokenizer.cs >> $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs
|
||||
@MONO@ $(ProjectDir)\..\..\..\msvc\scripts\prepare.exe $(ProjectDir)..\.. xml
|
||||
$(ProjectDir)\..\..\jay\jay -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\System.Xml.XPath\Parser.jay > $(ProjectDir)\System.Xml.XPath\Parser.cs
|
||||
echo "#define XSLT_PATTERN" > $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs
|
||||
$(ProjectDir)\..\..\jay\jay -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Mono.Xml.Xsl\PatternParser.jay >> $(ProjectDir)\Mono.Xml.Xsl\PatternParser.cs
|
||||
echo "#define XSLT_PATTERN" > $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs
|
||||
@CAT@ $(ProjectDir)\System.Xml.XPath\Tokenizer.cs >> $(ProjectDir)\Mono.Xml.Xsl\PatternTokenizer.cs
|
||||
␍
|
||||
@@ -53,9 +53,7 @@
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
@PREBUILD@
|
||||
</PreBuildEvent>
|
||||
@POSTBUILD@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
+21
-15
@@ -630,11 +630,26 @@ class MsbuildGenerator {
|
||||
// inputs/LIBRARY.pre
|
||||
//
|
||||
string prebuild = Load (library + ".pre");
|
||||
|
||||
string prebuild_windows, prebuild_unix;
|
||||
|
||||
int q = library.IndexOf ("-");
|
||||
if (q != -1)
|
||||
prebuild = prebuild + Load (library.Substring (0, q) + ".pre");
|
||||
|
||||
if (prebuild.IndexOf ("@MONO@") != -1){
|
||||
prebuild_unix = prebuild.Replace ("@MONO@", "mono").Replace ("@CAT@", "cat");
|
||||
prebuild_windows = prebuild.Replace ("@MONO@", "").Replace ("@CAT@", "type");
|
||||
} else {
|
||||
prebuild_unix = prebuild;
|
||||
prebuild_windows = prebuild;
|
||||
}
|
||||
|
||||
const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \"";
|
||||
const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \"";
|
||||
prebuild =
|
||||
" <PreBuildEvent " + condition_unix + ">\n" + prebuild_unix + "\n </PreBuildEvent>\n" +
|
||||
" <PreBuildEvent " + condition_windows + ">\n" + prebuild_windows + "\n </PreBuildEvent>\n";
|
||||
|
||||
var all_args = new Queue<string []> ();
|
||||
all_args.Enqueue (flags.Split ());
|
||||
while (all_args.Count > 0) {
|
||||
@@ -794,8 +809,6 @@ class MsbuildGenerator {
|
||||
build_output_dir = "bin\\Debug\\" + library;
|
||||
|
||||
|
||||
const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \"";
|
||||
const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \"";
|
||||
string postbuild_unix = string.Empty;
|
||||
string postbuild_windows = string.Empty;
|
||||
|
||||
@@ -850,23 +863,16 @@ class MsbuildGenerator {
|
||||
refs.AppendFormat (" <ProjectReference Include=\"{0}\">{1}", GetRelativePath (result.csprojFileName, lastMatching.csprojFileName), NewLine);
|
||||
refs.Append (" <Project>" + lastMatching.projectGuid + "</Project>" + NewLine);
|
||||
refs.Append (" <Name>" + Path.GetFileNameWithoutExtension (lastMatching.csprojFileName) + "</Name>" + NewLine);
|
||||
//refs.Append(" <HintPath>" + r + "</HintPath>" + NewLine);
|
||||
refs.Append (" </ProjectReference>" + NewLine);
|
||||
if (!result.projReferences.Contains (lastMatching))
|
||||
result.projReferences.Add (lastMatching);
|
||||
}
|
||||
|
||||
static string GetRelativePath (string referencerPath, string referenceePath)
|
||||
static string GetRelativePath (string from, string to)
|
||||
{
|
||||
// F:\src\mono\msvc\scripts\
|
||||
//..\..\mcs\class\System\System-net_2_0.csproj
|
||||
//..\..\mcs\class\corlib\corlib-net_2_0.csproj
|
||||
// So from \System\, corlib needs to be referenced as:
|
||||
// ..\corlib\corlib-net_2_0.csproj
|
||||
|
||||
// Could be possible to use PathRelativePathTo, but this is a P/Invoke to Win32 API.
|
||||
// For now, simpler but less robust:
|
||||
return referenceePath.Replace (@"..\..\mcs\class", "..").Replace ("/", "\\");
|
||||
var fromUri = new Uri (Path.GetFullPath (from));
|
||||
var toUri = new Uri (Path.GetFullPath (to));
|
||||
return fromUri.MakeRelativeUri (toUri).ToString ();
|
||||
}
|
||||
|
||||
static VsCsproj GetMatchingCsproj (string dllReferenceName, List<VsCsproj> projects)
|
||||
@@ -1032,4 +1038,4 @@ public class Driver {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user