зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1646975 - Transpile ToString instructions. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D80359
This commit is contained in:
Родитель
b332c5e31f
Коммит
dfd88da8cf
|
@ -0,0 +1,9 @@
|
|||
var a = [true, false];
|
||||
for (var i = 0; i < 1e4; i++) {
|
||||
var str = "x: " + a[i & 1];
|
||||
if (i & 1) {
|
||||
assertEq(str, "x: false");
|
||||
} else {
|
||||
assertEq(str, "x: true");
|
||||
}
|
||||
}
|
|
@ -1046,7 +1046,7 @@
|
|||
|
||||
- name: CallInt32ToString
|
||||
shared: true
|
||||
transpile: false
|
||||
transpile: true
|
||||
cost_estimate: 4
|
||||
args:
|
||||
input: Int32Id
|
||||
|
@ -1054,7 +1054,7 @@
|
|||
|
||||
- name: CallNumberToString
|
||||
shared: true
|
||||
transpile: false
|
||||
transpile: true
|
||||
cost_estimate: 4
|
||||
args:
|
||||
input: NumberId
|
||||
|
@ -1062,7 +1062,7 @@
|
|||
|
||||
- name: BooleanToString
|
||||
shared: true
|
||||
transpile: false
|
||||
transpile: true
|
||||
cost_estimate: 2
|
||||
args:
|
||||
input: Int32Id
|
||||
|
|
|
@ -108,6 +108,8 @@ class MOZ_RAII WarpCacheIRTranspiler : public WarpBuilderShared {
|
|||
|
||||
MOZ_MUST_USE bool emitGuardTo(ValOperandId inputId, MIRType type);
|
||||
|
||||
MOZ_MUST_USE bool emitToString(OperandId inputId, StringOperandId resultId);
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool emitDoubleBinaryArithResult(NumberOperandId lhsId,
|
||||
NumberOperandId rhsId);
|
||||
|
@ -486,6 +488,42 @@ bool WarpCacheIRTranspiler::emitGuardToInt32ModUint32(ValOperandId valId,
|
|||
return defineOperand(resultId, ins);
|
||||
}
|
||||
|
||||
bool WarpCacheIRTranspiler::emitToString(OperandId inputId,
|
||||
StringOperandId resultId) {
|
||||
MDefinition* input = getOperand(inputId);
|
||||
auto* ins =
|
||||
MToString::New(alloc(), input, MToString::SideEffectHandling::Bailout);
|
||||
add(ins);
|
||||
|
||||
return defineOperand(resultId, ins);
|
||||
}
|
||||
|
||||
bool WarpCacheIRTranspiler::emitCallInt32ToString(Int32OperandId inputId,
|
||||
StringOperandId resultId) {
|
||||
return emitToString(inputId, resultId);
|
||||
}
|
||||
|
||||
bool WarpCacheIRTranspiler::emitCallNumberToString(NumberOperandId inputId,
|
||||
StringOperandId resultId) {
|
||||
return emitToString(inputId, resultId);
|
||||
}
|
||||
|
||||
bool WarpCacheIRTranspiler::emitBooleanToString(Int32OperandId inputId,
|
||||
StringOperandId resultId) {
|
||||
MDefinition* input = getOperand(inputId);
|
||||
|
||||
// Remove the MToIntegerInt32 instruction added by emitGuardToBoolean.
|
||||
// TODO: Bug 1647602 add a BooleanOperandId.
|
||||
MDefinition* boolean = input->toToIntegerInt32()->input();
|
||||
MOZ_ASSERT(boolean->type() == MIRType::Boolean);
|
||||
|
||||
auto* ins =
|
||||
MToString::New(alloc(), boolean, MToString::SideEffectHandling::Bailout);
|
||||
add(ins);
|
||||
|
||||
return defineOperand(resultId, ins);
|
||||
}
|
||||
|
||||
bool WarpCacheIRTranspiler::emitLoadInt32Result(Int32OperandId valId) {
|
||||
MDefinition* val = getOperand(valId);
|
||||
MOZ_ASSERT(val->type() == MIRType::Int32);
|
||||
|
|
Загрузка…
Ссылка в новой задаче