Bug 1370208 - Inline Boolean constructor when called as a function. r=nbp

--HG--
extra : rebase_source : dcfc345881550a8e4179da27baade79dccff5e0b
This commit is contained in:
André Bargull 2017-06-05 16:26:24 +02:00
Родитель 65a48a95db
Коммит 46fea327c8
4 изменённых файлов: 35 добавлений и 1 удалений

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

@ -27,6 +27,8 @@
_(AtomicsXor) \
_(AtomicsIsLockFree) \
\
_(Boolean) \
\
_(IntlIsCollator) \
_(IntlIsDateTimeFormat) \
_(IntlIsNumberFormat) \

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

@ -633,6 +633,9 @@ class IonBuilder
InliningResult inlineArraySlice(CallInfo& callInfo);
InliningResult inlineArrayJoin(CallInfo& callInfo);
// Boolean natives.
InliningResult inlineBoolean(CallInfo& callInfo);
// Iterator intrinsics.
InliningResult inlineNewIterator(CallInfo& callInfo, MNewIterator::Type type);

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

@ -110,6 +110,10 @@ IonBuilder::inlineNativeCall(CallInfo& callInfo, JSFunction* target)
case InlinableNative::AtomicsIsLockFree:
return inlineAtomicsIsLockFree(callInfo);
// Boolean natives.
case InlinableNative::Boolean:
return inlineBoolean(callInfo);
// Intl natives.
case InlinableNative::IntlIsCollator:
return inlineHasClass(callInfo, &CollatorObject::class_);
@ -898,6 +902,28 @@ IonBuilder::inlineArraySlice(CallInfo& callInfo)
return InliningStatus_Inlined;
}
IonBuilder::InliningResult
IonBuilder::inlineBoolean(CallInfo& callInfo)
{
if (callInfo.constructing()) {
trackOptimizationOutcome(TrackedOutcome::CantInlineNativeBadForm);
return InliningStatus_NotInlined;
}
if (getInlineReturnType() != MIRType::Boolean)
return InliningStatus_NotInlined;
callInfo.setImplicitlyUsedUnchecked();
if (callInfo.argc() > 0) {
MDefinition* result = convertToBoolean(callInfo.getArg(0));
current->push(result);
} else {
pushConstant(BooleanValue(false));
}
return InliningStatus_Inlined;
}
IonBuilder::InliningResult
IonBuilder::inlineNewIterator(CallInfo& callInfo, MNewIterator::Type type)
{

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

@ -16,6 +16,7 @@
#include "jsobj.h"
#include "jstypes.h"
#include "jit/InlinableNatives.h"
#include "vm/GlobalObject.h"
#include "vm/ProxyObject.h"
#include "vm/StringBuffer.h"
@ -144,7 +145,9 @@ js::InitBooleanClass(JSContext* cx, HandleObject obj)
return nullptr;
booleanProto->setFixedSlot(BooleanObject::PRIMITIVE_VALUE_SLOT, BooleanValue(false));
RootedFunction ctor(cx, GlobalObject::createConstructor(cx, Boolean, cx->names().Boolean, 1));
RootedFunction ctor(cx, GlobalObject::createConstructor(cx, Boolean, cx->names().Boolean, 1,
gc::AllocKind::FUNCTION,
&jit::JitInfo_Boolean));
if (!ctor)
return nullptr;