Merge pull request #91 from MichalStrehovsky/fixes

Set of random fixes for Hello World
This commit is contained in:
Jan Kotas 2015-10-21 22:52:53 -07:00
Родитель 5ed878b759 7e054034f4
Коммит d65860c6ad
13 изменённых файлов: 142 добавлений и 6 удалений

Просмотреть файл

@ -88,6 +88,14 @@ namespace Internal.TypeSystem
}
}
public override bool IsAbstract
{
get
{
return _methodDef.IsAbstract;
}
}
public override MethodDesc GetMethodDefinition()
{
return _methodDef;

Просмотреть файл

@ -283,6 +283,14 @@ namespace Internal.TypeSystem
}
}
public virtual bool IsAbstract
{
get
{
return false;
}
}
// Strips method instantiation. E.g C<int>.m<string> -> C<int>.m<U>
public virtual MethodDesc GetMethodDefinition()
{

Просмотреть файл

@ -83,6 +83,14 @@ namespace Internal.TypeSystem
}
}
public override bool IsAbstract
{
get
{
return _typicalMethodDef.IsAbstract;
}
}
public override MethodDesc GetTypicalMethodDefinition()
{
return _typicalMethodDef;

Просмотреть файл

@ -20,6 +20,7 @@ namespace Internal.TypeSystem.Ecma
BasicMetadataCache = 0x01,
Virtual = 0x02,
NewSlot = 0x04,
Abstract = 0x08,
};
EcmaType _type;
@ -117,6 +118,9 @@ namespace Internal.TypeSystem.Ecma
if ((methodAttributes & MethodAttributes.NewSlot) != 0)
flags |= MethodFlags.NewSlot;
if ((methodAttributes & MethodAttributes.Abstract) != 0)
flags |= MethodFlags.Abstract;
flags |= MethodFlags.BasicMetadataCache;
}
@ -151,6 +155,14 @@ namespace Internal.TypeSystem.Ecma
}
}
public override bool IsAbstract
{
get
{
return (GetMethodFlags(MethodFlags.BasicMetadataCache | MethodFlags.Abstract) & MethodFlags.Abstract) != 0;
}
}
public MethodAttributes Attributes
{
get

Просмотреть файл

@ -358,7 +358,19 @@ namespace ILToNative
if (methodIL == null)
return;
var methodCode = _corInfo.CompileMethod(method);
MethodCode methodCode;
try
{
methodCode = _corInfo.CompileMethod(method);
}
catch (Exception e)
{
Log.WriteLine(e.Message + " (" + method + ")");
methodCode = new MethodCode
{
Code = new byte[] { 0xCC }
};
}
ObjectDataBuilder objData = new ObjectDataBuilder();
objData.Alignment = _nodeFactory.Target.MinimumFunctionAlignment;

Просмотреть файл

@ -0,0 +1,63 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace ILToNative.DependencyAnalysis
{
public class BlobNode : ObjectNode, ISymbolNode
{
string _name;
string _section;
byte[] _data;
int _alignment;
public BlobNode(string name, string section, byte[] data, int alignment)
{
_name = name;
_section = section;
_data = data;
_alignment = alignment;
}
public override string Section
{
get
{
return _section;
}
}
public override bool StaticDependenciesAreComputed
{
get
{
return true;
}
}
string ISymbolNode.MangledName
{
get
{
return _name;
}
}
int ISymbolNode.Offset
{
get
{
return 0;
}
}
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
return new ObjectData(_data, null, _alignment, new ISymbolNode[] { this });
}
public override string GetName()
{
return ((ISymbolNode)this).MangledName;
}
}
}

Просмотреть файл

@ -185,7 +185,7 @@ namespace ILToNative.DependencyAnalysis
foreach (MethodDesc decl in VirtualFunctionResolution.EnumAllVirtualSlots((MetadataType)_type))
{
MethodDesc impl = VirtualFunctionResolution.FindVirtualFunctionTargetMethodOnObjectType(decl, (MetadataType)_type);
if (impl.OwningType == _type)
if (impl.OwningType == _type && !impl.IsAbstract)
{
yield return new DependencyNodeCore<NodeFactory>.CombinedDependencyListEntry(factory.MethodEntrypoint(impl), factory.VirtualMethodUse(decl), "Virtual method");
}
@ -210,7 +210,10 @@ namespace ILToNative.DependencyAnalysis
MethodDesc implMethod = VirtualFunctionResolution.FindVirtualFunctionTargetMethodOnObjectType(declMethod, implType.GetClosestDefType());
objData.EmitPointerReloc(context.MethodEntrypoint(implMethod));
if (!implMethod.IsAbstract)
objData.EmitPointerReloc(context.MethodEntrypoint(implMethod));
else
objData.EmitZeroPointer();
}
}
}

Просмотреть файл

@ -134,7 +134,7 @@ namespace ILToNative.DependencyAnalysis
int totalSize = 0;
foreach (int run in _runLengths)
{
totalSize += run;
totalSize += run * _targetPointerSize;
}
dataBuilder.EmitShort(0); // ComponentSize is always 0

Просмотреть файл

@ -14,6 +14,7 @@ namespace ILToNative.DependencyAnalysis
public MethodCodeNode(MethodDesc method)
{
Debug.Assert(!method.IsAbstract);
_method = method;
}

Просмотреть файл

@ -198,10 +198,18 @@ namespace ILToNative.DependencyAnalysis
return _GCStaticEETypes.GetOrAdd(gcdesc);
}
private BlobNode _writeBarrierHelper = new BlobNode("WriteBarrierWorkaround", "text", new byte[] { 0x48, 0x89, 0x11, 0xC3 }, 16);
private NodeCache<string, ExternSymbolNode> _externSymbols;
public ISymbolNode ExternSymbol(string name)
{
// We can't call the real C++ WriteBarrier implementation because that one expects
// a register spill zone. JIT doesn't generate a spill zone before the call.
if (name == "WriteBarrier")
{
return _writeBarrierHelper;
}
return _externSymbols.GetOrAdd(name);
}
@ -217,10 +225,16 @@ namespace ILToNative.DependencyAnalysis
public ISymbolNode MethodEntrypoint(MethodDesc method)
{
if (method.DetectSpecialMethodKind() == SpecialMethodKind.PInvoke)
var kind = method.DetectSpecialMethodKind();
if (kind == SpecialMethodKind.PInvoke)
{
return _jumpStubs.GetOrAdd(ExternSymbol(((EcmaMethod)method).GetPInvokeImportName()));
}
else if (kind == SpecialMethodKind.RuntimeImport)
{
return ExternSymbol(((EcmaMethod)method).GetRuntimeImportEntryPointName());
}
return _methodCode.GetOrAdd(method);
}

Просмотреть файл

@ -42,6 +42,7 @@
<Compile Include="Compiler\DependencyAnalysis\Target_X64\AddrMode.cs" />
<Compile Include="Compiler\DependencyAnalysis\AsmWriter.cs" />
<Compile Include="Compiler\DependencyAnalysis\AssemblyStubNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\BlobNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\EETypeNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\ExternSymbolNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\GCStaticEETypeNode.cs" />

Просмотреть файл

@ -251,6 +251,12 @@ Object * __get_commandline_args(int argc, char * argv[])
}
#endif
extern "C" void Buffer_BlockCopy(class System::Array * src, int srcOfs, class System::Array * dst, int dstOfs, int count)
{
// TODO: Argument validation
memmove((uint8_t*)dst + 2 * sizeof(void*) + dstOfs, (uint8_t*)src + 2 * sizeof(void*) + srcOfs, count);
}
extern "C" Object* RhMemberwiseClone(Object*)
{
throw 42;

Просмотреть файл

@ -13,7 +13,7 @@ namespace System
{
#if CORERT
// CORERT-TODO This depends on a lot of stuff that we do not handle yet
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[RuntimeImport("Buffer_BlockCopy")]
public static unsafe extern void BlockCopy(Array src, int srcOffset,
Array dst, int dstOffset,
int count);