Commit 1f2fd64e authored by Kanghua Yu's avatar Kanghua Yu Committed by Commit Bot

[x64] Prevent using stack to swap two registers

R=jgruber@chromium.org

Bug: 
Change-Id: I344697a56cfc6d66173806c0038a5edcd94f8260
Reviewed-on: https://chromium-review.googlesource.com/842183
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50521}
parent 1f596d46
......@@ -298,15 +298,35 @@ void TurboAssembler::CallRecordWriteStub(
Register fp_mode_parameter(callable.descriptor().GetRegisterParameter(
RecordWriteDescriptor::kFPMode));
pushq(object);
pushq(address);
popq(slot_parameter);
popq(object_parameter);
// Prepare argument registers for calling RecordWrite
// slot_parameter <= address
// object_parameter <= object
if (slot_parameter != object) {
// Normal case
Move(slot_parameter, address);
Move(object_parameter, object);
} else if (object_parameter != address) {
// Only slot_parameter and object are the same register
// object_parameter <= object
// slot_parameter <= address
Move(object_parameter, object);
Move(slot_parameter, address);
} else {
// slot_parameter \/ address
// object_parameter /\ object
xchgq(slot_parameter, object_parameter);
}
LoadAddress(isolate_parameter, ExternalReference::isolate_address(isolate()));
Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action));
Move(fp_mode_parameter, Smi::FromEnum(fp_mode));
Smi* smi_rsa = Smi::FromEnum(remembered_set_action);
Smi* smi_fm = Smi::FromEnum(fp_mode);
Move(remembered_set_parameter, smi_rsa);
if (smi_rsa != smi_fm) {
Move(fp_mode_parameter, smi_fm);
} else {
movq(fp_mode_parameter, remembered_set_parameter);
}
Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreRegisters(registers);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment