Bug 1131996 - Part 3: Support out-of-bounds read access on arguments objects in Warp. r=iain

Transpile the CacheIR operation from part 2.

Differential Revision: https://phabricator.services.mozilla.com/D129621
This commit is contained in:
André Bargull 2021-11-05 08:28:20 +00:00
Родитель 4576174865
Коммит 3013e201cd
7 изменённых файлов: 63 добавлений и 1 удалений

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

@ -1799,7 +1799,7 @@
- name: LoadArgumentsObjectArgHoleResult
shared: true
transpile: false
transpile: true
cost_estimate: 2
args:
obj: ObjId

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

@ -7487,6 +7487,18 @@ void CodeGenerator::visitLoadArgumentsObjectArg(LLoadArgumentsObjectArg* lir) {
bailoutFrom(&bail, lir->snapshot());
}
void CodeGenerator::visitLoadArgumentsObjectArgHole(
LLoadArgumentsObjectArgHole* lir) {
Register temp = ToRegister(lir->temp0());
Register argsObj = ToRegister(lir->argsObject());
Register index = ToRegister(lir->index());
ValueOperand out = ToOutValue(lir);
Label bail;
masm.loadArgumentsObjectElementHole(argsObj, index, out, temp, &bail);
bailoutFrom(&bail, lir->snapshot());
}
void CodeGenerator::visitArgumentsObjectLength(LArgumentsObjectLength* lir) {
Register argsObj = ToRegister(lir->argsObject());
Register out = ToRegister(lir->output());

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

@ -414,6 +414,14 @@
index: WordSized
num_temps: 1
# Load an element from an arguments object. Handles out-of-bounds accesses.
- name: LoadArgumentsObjectArgHole
result_type: BoxedValue
operands:
argsObject: WordSized
index: WordSized
num_temps: 1
# Return |arguments.length| unless it has been overridden.
- name: ArgumentsObjectLength
result_type: WordSized

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

@ -371,6 +371,20 @@ void LIRGenerator::visitLoadArgumentsObjectArg(MLoadArgumentsObjectArg* ins) {
defineBox(lir, ins);
}
void LIRGenerator::visitLoadArgumentsObjectArgHole(
MLoadArgumentsObjectArgHole* ins) {
MDefinition* argsObj = ins->argsObject();
MOZ_ASSERT(argsObj->type() == MIRType::Object);
MDefinition* index = ins->index();
MOZ_ASSERT(index->type() == MIRType::Int32);
auto* lir = new (alloc()) LLoadArgumentsObjectArgHole(
useRegister(argsObj), useRegister(index), temp());
assignSnapshot(lir, ins->bailoutKind());
defineBox(lir, ins);
}
void LIRGenerator::visitArgumentsObjectLength(MArgumentsObjectLength* ins) {
MDefinition* argsObj = ins->argsObject();
MOZ_ASSERT(argsObj->type() == MIRType::Object);

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

@ -3203,6 +3203,10 @@ AliasSet MLoadArgumentsObjectArg::getAliasSet() const {
return AliasSet::Load(AliasSet::Any);
}
AliasSet MLoadArgumentsObjectArgHole::getAliasSet() const {
return AliasSet::Load(AliasSet::Any);
}
AliasSet MArgumentsObjectLength::getAliasSet() const {
return AliasSet::Load(AliasSet::ObjectFields | AliasSet::FixedSlot |
AliasSet::DynamicSlot);

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

@ -431,6 +431,18 @@
congruent_to: if_operands_equal
alias_set: custom
# Load |arguments[index]| from a mapped or unmapped arguments object. Bails out
# if any elements were overridden or deleted. Returns undefined if the index is
# out of bounds.
- name: LoadArgumentsObjectArgHole
operands:
argsObject: Object
index: Int32
result_type: Value
guard: true
congruent_to: if_operands_equal
alias_set: custom
# Load |arguments.length|. Bails out if the length has been overriden.
- name: ArgumentsObjectLength
operands:

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

@ -1578,6 +1578,18 @@ bool WarpCacheIRTranspiler::emitLoadArgumentsObjectArgResult(
return true;
}
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectArgHoleResult(
ObjOperandId objId, Int32OperandId indexId) {
MDefinition* obj = getOperand(objId);
MDefinition* index = getOperand(indexId);
auto* load = MLoadArgumentsObjectArgHole::New(alloc(), obj, index);
add(load);
pushResult(load);
return true;
}
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectLengthResult(
ObjOperandId objId) {
MDefinition* obj = getOperand(objId);