Re: miniSphere 4.8.6
Reply #2119 –
So I tried implementing this: https://github.com/Microsoft/ChakraCore/issues/3623
It was a surprisingly simple addition to the Chakra source, the below in JSRT.cpp + a stub in ChakraCore.h
//proposed new api to skip string type conversion
CHAKRA_API JSCreatePropertyIDfromJSString(
_In_ JsValueRef stringValue,
_Out_ JsPropertyIdRef *propertyId)
{
const char16* str = nullptr;
size_t strLength = 0;
JsErrorCode errorCode = JsStringToPointer(stringValue, &str, &strLength);
if (errorCode != JsNoError)
{
return errorCode;
}
return JsGetPropertyIdFromName(str, propertyId);
}
Then using that in make_property_id instead of the JSCopyString call; the result was a 20-25% performance improvement on common api calls; not enough to catch up with the old Duktape yet but it got rid of the majority of the slowdown in the Specs battle system - to the point that I would consider it playable.
I think we either should suggest this addition to ChakraCore OR we should just use it within the miniSPhere code base by using JSStringtoPointer - technically JSStringtoPointer is a windows only api BUT CC code uses it internally more than once so it is clearly functional on other platforms just as long as one is careful with sizes.
To optimise further I think it's worth tidying up uses of int and double; my brief testing earlier suggested that letting CC do the type conversion saves a few CPU cycles over doing type conversion in the miniSphere code.
I also think that all uses of JSCopyString should be examined, that function is just anti-speed.