Bug 1629791 part 20 - Auto-generate boilerplate for more ops. r=iain

This adds support for instructions that return a new value. In this case the
CacheIRWriter returns a new id of this kind.

Depends on D71520

Differential Revision: https://phabricator.services.mozilla.com/D71521
This commit is contained in:
Jan de Mooij 2020-04-21 06:23:50 +00:00
Родитель 00c4a6085c
Коммит 24b5053306
6 изменённых файлов: 130 добавлений и 223 удалений

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

@ -1723,18 +1723,20 @@ bool BaselineCacheIRCompiler::emitLoadArgumentDynamicSlot() {
return true;
}
bool BaselineCacheIRCompiler::emitGuardAndGetIterator() {
bool BaselineCacheIRCompiler::emitGuardAndGetIterator(
ObjOperandId objId, uint32_t iterOffset, uint32_t enumeratorsAddrOffset,
ObjOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register obj = allocator.useRegister(masm, objId);
AutoScratchRegister scratch1(allocator, masm);
AutoScratchRegister scratch2(allocator, masm);
AutoScratchRegister niScratch(allocator, masm);
Address iterAddr(stubAddress(reader.stubOffset()));
Address enumeratorsAddr(stubAddress(reader.stubOffset()));
Address iterAddr(stubAddress(iterOffset));
Address enumeratorsAddr(stubAddress(enumeratorsAddrOffset));
Register output = allocator.defineRegister(masm, reader.objOperandId());
Register output = allocator.defineRegister(masm, resultId);
FailurePath* failure;
if (!addFailurePath(&failure)) {

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

@ -581,6 +581,11 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter {
"GuardClassKind must fit in a byte");
buffer_.writeByte(uint8_t(kind));
}
void writeValueTypeImm(ValueType type) {
static_assert(sizeof(ValueType) == sizeof(uint8_t),
"ValueType must fit in uint8_t");
buffer_.writeByte(uint8_t(type));
}
void writeJSWhyMagicImm(JSWhyMagic whyMagic) {
static_assert(JS_WHY_MAGIC_COUNT <= UINT8_MAX,
"JSWhyMagic must fit in uint8_t");
@ -615,6 +620,8 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter {
}
void writeStaticStringImm(const char* str) { writePointer(str); }
uint32_t newOperandId() { return nextOperandId_++; }
CacheIRWriter(const CacheIRWriter&) = delete;
CacheIRWriter& operator=(const CacheIRWriter&) = delete;
@ -688,13 +695,6 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter {
return ObjOperandId(val.id());
}
Int32OperandId guardToBoolean(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardToBoolean, val);
writeOperandId(res);
return res;
}
StringOperandId guardToString(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardToString, val);
return StringOperandId(val.id());
@ -710,73 +710,11 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter {
return BigIntOperandId(val.id());
}
Int32OperandId guardToInt32(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardToInt32, val);
writeOperandId(res);
return res;
}
Int32OperandId guardToInt32Index(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardToInt32Index, val);
writeOperandId(res);
return res;
}
Int32OperandId guardToTypedArrayIndex(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardToTypedArrayIndex, val);
writeOperandId(res);
return res;
}
Int32OperandId guardToInt32ModUint32(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardToInt32ModUint32, val);
writeOperandId(res);
return res;
}
Int32OperandId guardToUint8Clamped(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardToUint8Clamped, val);
writeOperandId(res);
return res;
}
NumberOperandId guardIsNumber(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardIsNumber, val);
return NumberOperandId(val.id());
}
void guardType(ValOperandId val, ValueType type) {
writeOpWithOperandId(CacheOp::GuardType, val);
static_assert(sizeof(type) == sizeof(uint8_t),
"JS::ValueType should fit in a byte");
buffer_.writeByte(uint32_t(type));
}
void guardIsObjectOrNull(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardIsObjectOrNull, val);
}
void guardIsNullOrUndefined(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardIsNullOrUndefined, val);
}
void guardIsNotNullOrUndefined(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardIsNotNullOrUndefined, val);
}
void guardIsNull(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardIsNull, val);
}
void guardIsUndefined(ValOperandId val) {
writeOpWithOperandId(CacheOp::GuardIsUndefined, val);
}
void guardShapeForClass(ObjOperandId obj, Shape* shape) {
// Guard shape to ensure that object class is unchanged. This is true
// for all shapes.
@ -840,79 +778,11 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter {
return guardSpecificObject(obj, expected);
}
Int32OperandId guardAndGetIndexFromString(StringOperandId str) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardAndGetIndexFromString, str);
writeOperandId(res);
return res;
}
Int32OperandId guardAndGetInt32FromString(StringOperandId str) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardAndGetInt32FromString, str);
writeOperandId(res);
return res;
}
NumberOperandId guardAndGetNumberFromString(StringOperandId str) {
NumberOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardAndGetNumberFromString, str);
writeOperandId(res);
return res;
}
NumberOperandId guardAndGetNumberFromBoolean(Int32OperandId boolean) {
NumberOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardAndGetNumberFromBoolean, boolean);
writeOperandId(res);
return res;
}
ObjOperandId guardAndGetIterator(ObjOperandId obj,
PropertyIteratorObject* iter,
NativeIterator** enumeratorsAddr) {
ObjOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::GuardAndGetIterator, obj);
addStubField(uintptr_t(iter), StubField::Type::JSObject);
addStubField(uintptr_t(enumeratorsAddr), StubField::Type::RawWord);
writeOperandId(res);
return res;
}
void guardTagNotEqual(ValueTagOperandId lhs, ValueTagOperandId rhs) {
writeOpWithOperandId(CacheOp::GuardTagNotEqual, lhs);
writeOperandId(rhs);
}
ObjOperandId loadObject(JSObject* obj) {
assertSameCompartment(obj);
ObjOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::LoadObject, res);
addStubField(uintptr_t(obj), StubField::Type::JSObject);
return res;
}
ObjOperandId loadProto(ObjOperandId obj) {
ObjOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::LoadProto, obj);
writeOperandId(res);
return res;
}
ObjOperandId loadEnclosingEnvironment(ObjOperandId obj) {
ObjOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::LoadEnclosingEnvironment, obj);
writeOperandId(res);
return res;
}
ObjOperandId loadWrapperTarget(ObjOperandId obj) {
ObjOperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::LoadWrapperTarget, obj);
writeOperandId(res);
return res;
}
Int32OperandId truncateDoubleToUInt32(ValOperandId val) {
Int32OperandId res(nextOperandId_++);
writeOpWithOperandId(CacheOp::TruncateDoubleToUInt32, val);

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

@ -1370,9 +1370,8 @@ bool CacheIRCompiler::emitGuardToObject() {
return true;
}
bool CacheIRCompiler::emitGuardIsNullOrUndefined() {
bool CacheIRCompiler::emitGuardIsNullOrUndefined(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
JSValueType knownType = allocator.knownType(inputId);
if (knownType == JSVAL_TYPE_UNDEFINED || knownType == JSVAL_TYPE_NULL) {
return true;
@ -1392,9 +1391,8 @@ bool CacheIRCompiler::emitGuardIsNullOrUndefined() {
return true;
}
bool CacheIRCompiler::emitGuardIsNotNullOrUndefined() {
bool CacheIRCompiler::emitGuardIsNotNullOrUndefined(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
JSValueType knownType = allocator.knownType(inputId);
if (knownType == JSVAL_TYPE_UNDEFINED || knownType == JSVAL_TYPE_NULL) {
return false;
@ -1412,9 +1410,8 @@ bool CacheIRCompiler::emitGuardIsNotNullOrUndefined() {
return true;
}
bool CacheIRCompiler::emitGuardIsNull() {
bool CacheIRCompiler::emitGuardIsNull(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
JSValueType knownType = allocator.knownType(inputId);
if (knownType == JSVAL_TYPE_NULL) {
return true;
@ -1431,9 +1428,8 @@ bool CacheIRCompiler::emitGuardIsNull() {
return true;
}
bool CacheIRCompiler::emitGuardIsUndefined() {
bool CacheIRCompiler::emitGuardIsUndefined(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
JSValueType knownType = allocator.knownType(inputId);
if (knownType == JSVAL_TYPE_UNDEFINED) {
return true;
@ -1449,9 +1445,8 @@ bool CacheIRCompiler::emitGuardIsUndefined() {
return true;
}
bool CacheIRCompiler::emitGuardIsObjectOrNull() {
bool CacheIRCompiler::emitGuardIsObjectOrNull(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
JSValueType knownType = allocator.knownType(inputId);
if (knownType == JSVAL_TYPE_OBJECT || knownType == JSVAL_TYPE_NULL) {
return true;
@ -1470,10 +1465,10 @@ bool CacheIRCompiler::emitGuardIsObjectOrNull() {
return true;
}
bool CacheIRCompiler::emitGuardToBoolean() {
bool CacheIRCompiler::emitGuardToBoolean(ValOperandId inputId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register output = allocator.defineRegister(masm, resultId);
if (allocator.knownType(inputId) == JSVAL_TYPE_BOOLEAN) {
Register input = allocator.useRegister(masm, Int32OperandId(inputId.id()));
@ -1540,10 +1535,10 @@ bool CacheIRCompiler::emitGuardToBigInt() {
return true;
}
bool CacheIRCompiler::emitGuardToInt32() {
bool CacheIRCompiler::emitGuardToInt32(ValOperandId inputId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register output = allocator.defineRegister(masm, resultId);
if (allocator.knownType(inputId) == JSVAL_TYPE_INT32) {
Register input = allocator.useRegister(masm, Int32OperandId(inputId.id()));
@ -1624,10 +1619,10 @@ static void EmitGuardInt32OrDouble(CacheIRCompiler* compiler,
masm.bind(&done);
}
bool CacheIRCompiler::emitGuardToInt32Index() {
bool CacheIRCompiler::emitGuardToInt32Index(ValOperandId inputId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register output = allocator.defineRegister(masm, resultId);
if (allocator.knownType(inputId) == JSVAL_TYPE_INT32) {
Register input = allocator.useRegister(masm, Int32OperandId(inputId.id()));
@ -1655,10 +1650,10 @@ bool CacheIRCompiler::emitGuardToInt32Index() {
return true;
}
bool CacheIRCompiler::emitGuardToTypedArrayIndex() {
bool CacheIRCompiler::emitGuardToTypedArrayIndex(ValOperandId inputId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register output = allocator.defineRegister(masm, resultId);
if (allocator.knownType(inputId) == JSVAL_TYPE_INT32) {
Register input = allocator.useRegister(masm, Int32OperandId(inputId.id()));
@ -1698,10 +1693,10 @@ bool CacheIRCompiler::emitGuardToTypedArrayIndex() {
return true;
}
bool CacheIRCompiler::emitGuardToInt32ModUint32() {
bool CacheIRCompiler::emitGuardToInt32ModUint32(ValOperandId inputId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register output = allocator.defineRegister(masm, resultId);
if (allocator.knownType(inputId) == JSVAL_TYPE_INT32) {
ConstantOrRegister input = allocator.useConstantOrRegister(masm, inputId);
@ -1733,10 +1728,10 @@ bool CacheIRCompiler::emitGuardToInt32ModUint32() {
return true;
}
bool CacheIRCompiler::emitGuardToUint8Clamped() {
bool CacheIRCompiler::emitGuardToUint8Clamped(ValOperandId inputId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register output = allocator.defineRegister(masm, resultId);
if (allocator.knownType(inputId) == JSVAL_TYPE_INT32) {
ConstantOrRegister input = allocator.useConstantOrRegister(masm, inputId);
@ -1770,10 +1765,8 @@ bool CacheIRCompiler::emitGuardToUint8Clamped() {
return true;
}
bool CacheIRCompiler::emitGuardType() {
bool CacheIRCompiler::emitGuardType(ValOperandId inputId, ValueType type) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
ValOperandId inputId = reader.valOperandId();
ValueType type = reader.valueType();
if (allocator.knownType(inputId) == JSValueType(type)) {
return true;
@ -2031,10 +2024,11 @@ bool CacheIRCompiler::emitGuardNoDenseElements(ObjOperandId objId) {
return true;
}
bool CacheIRCompiler::emitGuardAndGetInt32FromString() {
bool CacheIRCompiler::emitGuardAndGetInt32FromString(StringOperandId strId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register str = allocator.useRegister(masm, reader.stringOperandId());
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register str = allocator.useRegister(masm, strId);
Register output = allocator.defineRegister(masm, resultId);
AutoScratchRegister scratch(allocator, masm);
FailurePath* failure;
@ -2092,11 +2086,11 @@ bool CacheIRCompiler::emitGuardAndGetInt32FromString() {
return true;
}
bool CacheIRCompiler::emitGuardAndGetNumberFromString() {
bool CacheIRCompiler::emitGuardAndGetNumberFromString(
StringOperandId strId, NumberOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register str = allocator.useRegister(masm, reader.stringOperandId());
ValueOperand output =
allocator.defineValueRegister(masm, reader.valOperandId());
Register str = allocator.useRegister(masm, strId);
ValueOperand output = allocator.defineValueRegister(masm, resultId);
AutoScratchRegister scratch(allocator, masm);
FailurePath* failure;
@ -2159,19 +2153,20 @@ bool CacheIRCompiler::emitGuardAndGetNumberFromString() {
return true;
}
bool CacheIRCompiler::emitGuardAndGetNumberFromBoolean() {
bool CacheIRCompiler::emitGuardAndGetNumberFromBoolean(
Int32OperandId booleanId, NumberOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register boolean = allocator.useRegister(masm, reader.int32OperandId());
ValueOperand output =
allocator.defineValueRegister(masm, reader.valOperandId());
Register boolean = allocator.useRegister(masm, booleanId);
ValueOperand output = allocator.defineValueRegister(masm, resultId);
masm.tagValue(JSVAL_TYPE_INT32, boolean, output);
return true;
}
bool CacheIRCompiler::emitGuardAndGetIndexFromString() {
bool CacheIRCompiler::emitGuardAndGetIndexFromString(StringOperandId strId,
Int32OperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register str = allocator.useRegister(masm, reader.stringOperandId());
Register output = allocator.defineRegister(masm, reader.int32OperandId());
Register str = allocator.useRegister(masm, strId);
Register output = allocator.defineRegister(masm, resultId);
FailurePath* failure;
if (!addFailurePath(&failure)) {
@ -2205,27 +2200,29 @@ bool CacheIRCompiler::emitGuardAndGetIndexFromString() {
return true;
}
bool CacheIRCompiler::emitLoadProto() {
bool CacheIRCompiler::emitLoadProto(ObjOperandId objId, ObjOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register reg = allocator.defineRegister(masm, reader.objOperandId());
Register obj = allocator.useRegister(masm, objId);
Register reg = allocator.defineRegister(masm, resultId);
masm.loadObjProto(obj, reg);
return true;
}
bool CacheIRCompiler::emitLoadEnclosingEnvironment() {
bool CacheIRCompiler::emitLoadEnclosingEnvironment(ObjOperandId objId,
ObjOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register reg = allocator.defineRegister(masm, reader.objOperandId());
Register obj = allocator.useRegister(masm, objId);
Register reg = allocator.defineRegister(masm, resultId);
masm.unboxObject(
Address(obj, EnvironmentObject::offsetOfEnclosingEnvironment()), reg);
return true;
}
bool CacheIRCompiler::emitLoadWrapperTarget() {
bool CacheIRCompiler::emitLoadWrapperTarget(ObjOperandId objId,
ObjOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register reg = allocator.defineRegister(masm, reader.objOperandId());
Register obj = allocator.useRegister(masm, objId);
Register reg = allocator.defineRegister(masm, resultId);
masm.loadPtr(Address(obj, ProxyObject::offsetOfReservedSlots()), reg);
masm.unboxObject(
@ -4208,10 +4205,10 @@ bool CacheIRCompiler::emitLoadTypeOfObjectResult(ObjOperandId objId) {
return true;
}
bool CacheIRCompiler::emitLoadInt32TruthyResult() {
bool CacheIRCompiler::emitLoadInt32TruthyResult(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
AutoOutputRegister output(*this);
ValueOperand val = allocator.useValueRegister(masm, reader.valOperandId());
ValueOperand val = allocator.useValueRegister(masm, inputId);
Label ifFalse, done;
masm.branchTestInt32Truthy(false, val, &ifFalse);
@ -4243,10 +4240,10 @@ bool CacheIRCompiler::emitLoadStringTruthyResult(StringOperandId strId) {
return true;
}
bool CacheIRCompiler::emitLoadDoubleTruthyResult() {
bool CacheIRCompiler::emitLoadDoubleTruthyResult(ValOperandId inputId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
AutoOutputRegister output(*this);
ValueOperand val = allocator.useValueRegister(masm, reader.valOperandId());
ValueOperand val = allocator.useValueRegister(masm, inputId);
AutoScratchFloatRegister floatReg(this);
@ -5489,10 +5486,11 @@ bool CacheIRCompiler::emitGuardGroupHasUnanalyzedNewScript(
return true;
}
bool CacheIRCompiler::emitLoadObject() {
bool CacheIRCompiler::emitLoadObject(ObjOperandId resultId,
uint32_t objOffset) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register reg = allocator.defineRegister(masm, reader.objOperandId());
StubFieldOffset obj(reader.stubOffset(), StubField::Type::JSObject);
Register reg = allocator.defineRegister(masm, resultId);
StubFieldOffset obj(objOffset, StubField::Type::JSObject);
emitLoadStubField(obj, reg);
return true;
}

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

@ -39,6 +39,9 @@
# - Immediate (BoolImm, Int32Imm, JSOpImm, ...): a value baked directly into
# the bytecode stream. This is useful for bits of state that need to be
# available to all CacheIR compilers/transpilers.
#
# If there's an operand named 'result', the generated CacheIRWriter method will
# return a new OperandId of this type.
- name: GuardToObject
shared: true
@ -47,33 +50,39 @@
- name: GuardIsObjectOrNull
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
- name: GuardIsNullOrUndefined
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
- name: GuardIsNotNullOrUndefined
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
- name: GuardIsNull
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
- name: GuardIsUndefined
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
- name: GuardToBoolean
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
result: Int32Id
- name: GuardToString
@ -98,38 +107,44 @@
- name: GuardToInt32
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
result: Int32Id
- name: GuardToInt32Index
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
result: Int32Id
- name: GuardToTypedArrayIndex
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
result: Int32Id
- name: GuardToInt32ModUint32
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
result: Int32Id
- name: GuardToUint8Clamped
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
result: Int32Id
- name: GuardType
shared: true
gen_boilerplate: true
operands:
val: ValId
input: ValId
type: ValueTypeImm
- name: GuardShape
@ -263,30 +278,35 @@
- name: GuardAndGetIndexFromString
shared: true
gen_boilerplate: true
operands:
str: StrId
result: Int32Id
- name: GuardAndGetInt32FromString
shared: true
gen_boilerplate: true
operands:
str: StrId
result: Int32Id
- name: GuardAndGetNumberFromString
shared: true
gen_boilerplate: true
operands:
str: StrId
result: NumId
- name: GuardAndGetNumberFromBoolean
shared: true
gen_boilerplate: true
operands:
boolean: Int32Id
result: NumId
- name: GuardAndGetIterator
shared: false
gen_boilerplate: true
operands:
obj: ObjId
iter: ObjectField
@ -399,24 +419,28 @@
- name: LoadObject
shared: true
gen_boilerplate: true
operands:
result: ObjId
obj: ObjectField
- name: LoadProto
shared: true
gen_boilerplate: true
operands:
obj: ObjId
result: ObjId
- name: LoadEnclosingEnvironment
shared: true
gen_boilerplate: true
operands:
obj: ObjId
result: ObjId
- name: LoadWrapperTarget
shared: true
gen_boilerplate: true
operands:
obj: ObjId
result: ObjId

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

@ -84,6 +84,7 @@ operand_writer_info = {
'BoolImm': ('bool', 'writeBoolImm'),
'ByteImm': ('uint32_t', 'writeByteImm'), # uint32_t to enable fits-in-byte asserts.
'GuardClassKindImm': ('GuardClassKind', 'writeGuardClassKindImm'),
'ValueTypeImm': ('ValueType', 'writeValueTypeImm'),
'JSWhyMagicImm': ('JSWhyMagic', 'writeJSWhyMagicImm'),
'CallFlagsImm': ('CallFlags', 'writeCallFlagsImm'),
'TypedThingLayoutImm': ('TypedThingLayout', 'writeTypedThingLayoutImm'),
@ -112,16 +113,24 @@ def gen_writer_method(name, operands):
method_name = name[0].lower() + name[1:]
args_sig = []
ret_type = 'void'
operands_code = ''
if operands:
for opnd_name, opnd_type in six.iteritems(operands):
argtype, write_method = operand_writer_info[opnd_type]
args_sig.append('{} {}'.format(argtype, opnd_name))
operands_code += ' {}({});\\\n'.format(write_method, opnd_name)
if opnd_name == 'result':
ret_type = argtype
operands_code += ' {} result(newOperandId());\\\n'.format(argtype)
operands_code += ' writeOperandId(result);\\\n'
else:
args_sig.append('{} {}'.format(argtype, opnd_name))
operands_code += ' {}({});\\\n'.format(write_method, opnd_name)
code = 'void {}({}) {{\\\n'.format(method_name, ', '.join(args_sig))
code = '{} {}({}) {{\\\n'.format(ret_type, method_name, ', '.join(args_sig))
code += ' writeOp(CacheOp::{});\\\n'.format(name)
code += operands_code
if ret_type != 'void':
code += ' return result;\\\n'
code += '}'
return code
@ -154,6 +163,7 @@ operand_compiler_info = {
'BoolImm': ('bool', '', 'reader.readBool()'),
'ByteImm': ('uint8_t', '', 'reader.readByte()'),
'GuardClassKindImm': ('GuardClassKind', '', 'reader.guardClassKind()'),
'ValueTypeImm': ('ValueType', '', 'reader.valueType()'),
'JSWhyMagicImm': ('JSWhyMagic', '', 'reader.whyMagic()'),
'CallFlagsImm': ('CallFlags', '', 'reader.callFlags()'),
'TypedThingLayoutImm': ('TypedThingLayout', '', 'reader.typedThingLayout()'),

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

@ -2093,20 +2093,23 @@ bool IonCacheIRCompiler::emitReturnFromIC() {
return true;
}
bool IonCacheIRCompiler::emitGuardAndGetIterator() {
bool IonCacheIRCompiler::emitGuardAndGetIterator(ObjOperandId objId,
uint32_t iterOffset,
uint32_t enumeratorsAddrOffset,
ObjOperandId resultId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register obj = allocator.useRegister(masm, objId);
AutoScratchRegister scratch1(allocator, masm);
AutoScratchRegister scratch2(allocator, masm);
AutoScratchRegister niScratch(allocator, masm);
PropertyIteratorObject* iterobj =
&objectStubField(reader.stubOffset())->as<PropertyIteratorObject>();
&objectStubField(iterOffset)->as<PropertyIteratorObject>();
NativeIterator** enumerators =
rawWordStubField<NativeIterator**>(reader.stubOffset());
rawWordStubField<NativeIterator**>(enumeratorsAddrOffset);
Register output = allocator.defineRegister(masm, reader.objOperandId());
Register output = allocator.defineRegister(masm, resultId);
FailurePath* failure;
if (!addFailurePath(&failure)) {