Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #756 from WalterBright/xmmflag
Browse files Browse the repository at this point in the history
because calling toString() in stdarg is slow, impure, can allocate memory and throw
  • Loading branch information
andralex committed Mar 25, 2014
2 parents 7989183 + ad8eedf commit 283f1e3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/core/stdc/stdarg.d
Expand Up @@ -347,17 +347,9 @@ else version (X86_64)
TypeInfo arg1, arg2;
if (!ti.argTypes(arg1, arg2))
{
bool inXMMregister(TypeInfo arg) nothrow
bool inXMMregister(TypeInfo arg) pure nothrow @safe
{
try
{
auto s = arg.toString();
return (s == "double" || s == "float" || s == "idouble" || s == "ifloat");
}
catch (Exception e)
{
return false;
}
return (arg.flags & 2) != 0;
}

TypeInfo_Vector v1 = arg1 ? cast(TypeInfo_Vector)arg1 : null;
Expand Down
5 changes: 3 additions & 2 deletions src/object_.d
Expand Up @@ -30,7 +30,7 @@ private
import rt.minfo;
debug(PRINTF) import core.stdc.stdio;

extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow; /* dmd @@@BUG11461@@@ */
extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow; /* dmd @@@BUG11461@@@ */
extern (C) Object _d_newclass(const TypeInfo_Class ci);
extern (C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) nothrow;
extern (C) size_t _d_arraysetcapacity(const TypeInfo ti, size_t newcapacity, void *arrptr) pure nothrow;
Expand Down Expand Up @@ -278,7 +278,8 @@ class TypeInfo
// TODO: make this a property, but may need to be renamed to diambiguate with T.init...
const(void)[] init() nothrow pure const @safe { return null; }

/// Get flags for type: 1 means GC should scan for pointers
/// Get flags for type: 1 means GC should scan for pointers,
/// 2 means arg of this type is passed in XMM register
@property uint flags() nothrow pure const @safe { return 0; }

/// Get type information on the contents of the type; null if not available
Expand Down
9 changes: 9 additions & 0 deletions src/rt/typeinfo/ti_double.d
Expand Up @@ -87,4 +87,13 @@ class TypeInfo_d : TypeInfo
{
return double.alignof;
}

version (Windows)
{
}
else version (X86_64)
{
// 2 means arg to function is passed in XMM registers
override @property uint flags() nothrow pure const @safe { return 2; }
}
}
9 changes: 9 additions & 0 deletions src/rt/typeinfo/ti_float.d
Expand Up @@ -80,4 +80,13 @@ class TypeInfo_f : TypeInfo

return (cast(float *)&r)[0 .. 1];
}

version (Windows)
{
}
else version (X86_64)
{
// 2 means arg to function is passed in XMM registers
override @property uint flags() nothrow pure const @safe { return 2; }
}
}

0 comments on commit 283f1e3

Please sign in to comment.