Bug 1015205 - Part 2: Inline self-hosting intrinsic ToString. r=bbouvier,h4writer

This commit is contained in:
Till Schneidereit 2014-05-25 13:06:36 +02:00
parent 57b7843472
commit 71a072dfc3
5 changed files with 24 additions and 4 deletions

View File

@ -257,7 +257,7 @@ function String_sup() {
function EscapeAttributeValue(v) {
var inputStr = ToString(v);
var inputLen = inputStr.length;
var outputStr = '';
var outputStr = "";
var chunkStart = 0;
for (var i = 0; i < inputLen; i++) {
if (inputStr[i] === '"') {

View File

@ -736,6 +736,7 @@ class IonBuilder : public MIRGenerator
InliningStatus inlineHaveSameClass(CallInfo &callInfo);
InliningStatus inlineToObject(CallInfo &callInfo);
InliningStatus inlineToInteger(CallInfo &callInfo);
InliningStatus inlineToString(CallInfo &callInfo);
InliningStatus inlineDump(CallInfo &callInfo);
InliningStatus inlineHasClass(CallInfo &callInfo, const Class *clasp) {
return inlineHasClasses(callInfo, clasp, nullptr);

View File

@ -165,6 +165,8 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
return inlineToObject(callInfo);
if (native == intrinsic_ToInteger)
return inlineToInteger(callInfo);
if (native == intrinsic_ToString)
return inlineToString(callInfo);
// TypedObject intrinsics.
if (native == intrinsic_ObjectIsTypedObject)
@ -1914,6 +1916,22 @@ IonBuilder::inlineToInteger(CallInfo &callInfo)
return InliningStatus_Inlined;
}
IonBuilder::InliningStatus
IonBuilder::inlineToString(CallInfo &callInfo)
{
if (callInfo.argc() != 1 || callInfo.constructing())
return InliningStatus_NotInlined;
if (getInlineReturnType() != MIRType_String)
return InliningStatus_NotInlined;
callInfo.setImplicitlyUsedUnchecked();
MToString *toString = MToString::New(alloc(), callInfo.getArg(0));
current->add(toString);
current->push(toString);
return InliningStatus_Inlined;
}
IonBuilder::InliningStatus
IonBuilder::inlineBailout(CallInfo &callInfo)
{

View File

@ -1002,6 +1002,7 @@ class ContextAllocPolicy
/* Exposed intrinsics so that Ion may inline them. */
bool intrinsic_ToObject(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_ToInteger(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_ToString(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_IsCallable(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_ThrowError(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_NewDenseArray(JSContext *cx, unsigned argc, Value *vp);

View File

@ -73,13 +73,13 @@ js::intrinsic_ToInteger(JSContext *cx, unsigned argc, Value *vp)
}
bool
intrinsic_ToString(JSContext *cx, unsigned argc, Value *vp)
js::intrinsic_ToString(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedString str(cx);
str = ToString<CanGC>(cx, args[0]);
if (!str)
return false;
if (!str)
return false;
args.rval().setString(str);
return true;
}