Commit 1f2eaa1c authored by bryleun's avatar bryleun Committed by Commit bot

S390: Used RISBG in MacroAssembler::IndexToArrayOffset to improve performance.

R=joransiu@ca.ibm.com,michael_dawson@ca.ibm.com,mbrandy@us.ibm.com,jyan@ca.ibm.com

BUG=

Review-Url: https://codereview.chromium.org/2043843002
Cr-Commit-Position: refs/heads/master@{#36796}
parent 38ad63ff
......@@ -2870,6 +2870,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
}
int element_size_shift = ElementsKindToShiftSize(elements_kind);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int base_offset = instr->base_offset();
bool use_scratch = false;
......@@ -2883,7 +2884,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
use_scratch = true;
}
} else {
__ IndexToArrayOffset(scratch0(), key, element_size_shift, key_is_smi);
__ IndexToArrayOffset(scratch0(), key, element_size_shift, key_is_smi,
keyMaybeNegative);
use_scratch = true;
}
if (elements_kind == FLOAT32_ELEMENTS) {
......@@ -2903,7 +2905,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
Register result = ToRegister(instr->result());
MemOperand mem_operand =
PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi,
constant_key, element_size_shift, base_offset);
constant_key, element_size_shift, base_offset,
keyMaybeNegative);
switch (elements_kind) {
case INT8_ELEMENTS:
__ LoadB(result, mem_operand);
......@@ -2957,6 +2960,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
int element_size_shift = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int constant_key = 0;
if (key_is_constant) {
constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
......@@ -2971,7 +2975,8 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
intptr_t base_offset = instr->base_offset() + constant_key * kDoubleSize;
if (!key_is_constant) {
use_scratch = true;
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi);
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi,
keyMaybeNegative);
}
// Memory references support up to 20-bits signed displacement in RXY form
......@@ -3093,7 +3098,8 @@ MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base,
bool key_is_constant, bool key_is_smi,
int constant_key,
int element_size_shift,
int base_offset) {
int base_offset,
bool keyMaybeNegative) {
Register scratch = scratch0();
if (key_is_constant) {
......@@ -3111,7 +3117,8 @@ MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base,
(element_size_shift != (key_is_smi ? kSmiTagSize + kSmiShiftSize : 0));
if (needs_shift) {
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi);
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi,
keyMaybeNegative);
} else {
scratch = key;
}
......@@ -4050,6 +4057,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
}
int element_size_shift = ElementsKindToShiftSize(elements_kind);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int base_offset = instr->base_offset();
if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) {
......@@ -4069,7 +4077,8 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
address = external_pointer;
}
} else {
__ IndexToArrayOffset(address, key, element_size_shift, key_is_smi);
__ IndexToArrayOffset(address, key, element_size_shift, key_is_smi,
keyMaybeNegative);
__ AddP(address, external_pointer);
}
if (elements_kind == FLOAT32_ELEMENTS) {
......@@ -4082,7 +4091,8 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
Register value(ToRegister(instr->value()));
MemOperand mem_operand =
PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi,
constant_key, element_size_shift, base_offset);
constant_key, element_size_shift, base_offset,
keyMaybeNegative);
switch (elements_kind) {
case UINT8_ELEMENTS:
case UINT8_CLAMPED_ELEMENTS:
......@@ -4150,6 +4160,7 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
}
int element_size_shift = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int base_offset = instr->base_offset() + constant_key * kDoubleSize;
bool use_scratch = false;
intptr_t address_offset = base_offset;
......@@ -4163,7 +4174,8 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
}
} else {
use_scratch = true;
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi);
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi,
keyMaybeNegative);
// Memory references support up to 20-bits signed displacement in RXY form
if (!is_int20((address_offset))) {
__ AddP(scratch, Operand(address_offset));
......
......@@ -116,7 +116,8 @@ class LCodeGen : public LCodeGenBase {
MemOperand PrepareKeyedOperand(Register key, Register base,
bool key_is_constant, bool key_is_tagged,
int constant_key, int element_size_shift,
int base_offset);
int base_offset,
bool keyMaybeNegative = true);
// Emit frame translation commands for an environment.
void WriteTranslation(LEnvironment* environment, Translation* translation);
......
......@@ -1582,17 +1582,29 @@ class MacroAssembler : public Assembler {
}
void IndexToArrayOffset(Register dst, Register src, int elementSizeLog2,
bool isSmi) {
bool isSmi, bool keyMaybeNegative) {
if (isSmi) {
SmiToArrayOffset(dst, src, elementSizeLog2);
} else {
} else if (keyMaybeNegative ||
!CpuFeatures::IsSupported(GENERAL_INSTR_EXT)) {
#if V8_TARGET_ARCH_S390X
// If array access is dehoisted, the key, being an int32, can contain
// a negative value, as needs to be sign-extended to 64-bit for
// memory access.
//
// src (key) is a 32-bit integer. Sign extension ensures
// upper 32-bit does not contain garbage before being used to
// reference memory.
lgfr(src, src);
#endif
ShiftLeftP(dst, src, Operand(elementSizeLog2));
} else {
// Small optimization to reduce pathlength. After Bounds Check,
// the key is guaranteed to be non-negative. Leverage RISBG,
// which also performs zero-extension.
risbg(dst, src, Operand(32 - elementSizeLog2),
Operand(63 - elementSizeLog2), Operand(elementSizeLog2),
true);
}
}
......
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