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) { ...@@ -2870,6 +2870,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
} }
int element_size_shift = ElementsKindToShiftSize(elements_kind); int element_size_shift = ElementsKindToShiftSize(elements_kind);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int base_offset = instr->base_offset(); int base_offset = instr->base_offset();
bool use_scratch = false; bool use_scratch = false;
...@@ -2883,7 +2884,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { ...@@ -2883,7 +2884,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
use_scratch = true; use_scratch = true;
} }
} else { } else {
__ IndexToArrayOffset(scratch0(), key, element_size_shift, key_is_smi); __ IndexToArrayOffset(scratch0(), key, element_size_shift, key_is_smi,
keyMaybeNegative);
use_scratch = true; use_scratch = true;
} }
if (elements_kind == FLOAT32_ELEMENTS) { if (elements_kind == FLOAT32_ELEMENTS) {
...@@ -2903,7 +2905,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { ...@@ -2903,7 +2905,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
Register result = ToRegister(instr->result()); Register result = ToRegister(instr->result());
MemOperand mem_operand = MemOperand mem_operand =
PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi, 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) { switch (elements_kind) {
case INT8_ELEMENTS: case INT8_ELEMENTS:
__ LoadB(result, mem_operand); __ LoadB(result, mem_operand);
...@@ -2957,6 +2960,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { ...@@ -2957,6 +2960,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
int element_size_shift = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS); int element_size_shift = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int constant_key = 0; int constant_key = 0;
if (key_is_constant) { if (key_is_constant) {
constant_key = ToInteger32(LConstantOperand::cast(instr->key())); constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
...@@ -2971,7 +2975,8 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { ...@@ -2971,7 +2975,8 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
intptr_t base_offset = instr->base_offset() + constant_key * kDoubleSize; intptr_t base_offset = instr->base_offset() + constant_key * kDoubleSize;
if (!key_is_constant) { if (!key_is_constant) {
use_scratch = true; 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 // Memory references support up to 20-bits signed displacement in RXY form
...@@ -3093,7 +3098,8 @@ MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base, ...@@ -3093,7 +3098,8 @@ MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base,
bool key_is_constant, bool key_is_smi, bool key_is_constant, bool key_is_smi,
int constant_key, int constant_key,
int element_size_shift, int element_size_shift,
int base_offset) { int base_offset,
bool keyMaybeNegative) {
Register scratch = scratch0(); Register scratch = scratch0();
if (key_is_constant) { if (key_is_constant) {
...@@ -3111,7 +3117,8 @@ MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base, ...@@ -3111,7 +3117,8 @@ MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base,
(element_size_shift != (key_is_smi ? kSmiTagSize + kSmiShiftSize : 0)); (element_size_shift != (key_is_smi ? kSmiTagSize + kSmiShiftSize : 0));
if (needs_shift) { if (needs_shift) {
__ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi); __ IndexToArrayOffset(scratch, key, element_size_shift, key_is_smi,
keyMaybeNegative);
} else { } else {
scratch = key; scratch = key;
} }
...@@ -4050,6 +4057,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { ...@@ -4050,6 +4057,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
} }
int element_size_shift = ElementsKindToShiftSize(elements_kind); int element_size_shift = ElementsKindToShiftSize(elements_kind);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int base_offset = instr->base_offset(); int base_offset = instr->base_offset();
if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) {
...@@ -4069,7 +4077,8 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { ...@@ -4069,7 +4077,8 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
address = external_pointer; address = external_pointer;
} }
} else { } else {
__ IndexToArrayOffset(address, key, element_size_shift, key_is_smi); __ IndexToArrayOffset(address, key, element_size_shift, key_is_smi,
keyMaybeNegative);
__ AddP(address, external_pointer); __ AddP(address, external_pointer);
} }
if (elements_kind == FLOAT32_ELEMENTS) { if (elements_kind == FLOAT32_ELEMENTS) {
...@@ -4082,7 +4091,8 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { ...@@ -4082,7 +4091,8 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
Register value(ToRegister(instr->value())); Register value(ToRegister(instr->value()));
MemOperand mem_operand = MemOperand mem_operand =
PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi, 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) { switch (elements_kind) {
case UINT8_ELEMENTS: case UINT8_ELEMENTS:
case UINT8_CLAMPED_ELEMENTS: case UINT8_CLAMPED_ELEMENTS:
...@@ -4150,6 +4160,7 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { ...@@ -4150,6 +4160,7 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
} }
int element_size_shift = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS); int element_size_shift = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS);
bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi();
bool keyMaybeNegative = instr->hydrogen()->IsDehoisted();
int base_offset = instr->base_offset() + constant_key * kDoubleSize; int base_offset = instr->base_offset() + constant_key * kDoubleSize;
bool use_scratch = false; bool use_scratch = false;
intptr_t address_offset = base_offset; intptr_t address_offset = base_offset;
...@@ -4163,7 +4174,8 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { ...@@ -4163,7 +4174,8 @@ void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
} }
} else { } else {
use_scratch = true; 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 // Memory references support up to 20-bits signed displacement in RXY form
if (!is_int20((address_offset))) { if (!is_int20((address_offset))) {
__ AddP(scratch, Operand(address_offset)); __ AddP(scratch, Operand(address_offset));
......
...@@ -116,7 +116,8 @@ class LCodeGen : public LCodeGenBase { ...@@ -116,7 +116,8 @@ class LCodeGen : public LCodeGenBase {
MemOperand PrepareKeyedOperand(Register key, Register base, MemOperand PrepareKeyedOperand(Register key, Register base,
bool key_is_constant, bool key_is_tagged, bool key_is_constant, bool key_is_tagged,
int constant_key, int element_size_shift, int constant_key, int element_size_shift,
int base_offset); int base_offset,
bool keyMaybeNegative = true);
// Emit frame translation commands for an environment. // Emit frame translation commands for an environment.
void WriteTranslation(LEnvironment* environment, Translation* translation); void WriteTranslation(LEnvironment* environment, Translation* translation);
......
...@@ -1582,17 +1582,29 @@ class MacroAssembler : public Assembler { ...@@ -1582,17 +1582,29 @@ class MacroAssembler : public Assembler {
} }
void IndexToArrayOffset(Register dst, Register src, int elementSizeLog2, void IndexToArrayOffset(Register dst, Register src, int elementSizeLog2,
bool isSmi) { bool isSmi, bool keyMaybeNegative) {
if (isSmi) { if (isSmi) {
SmiToArrayOffset(dst, src, elementSizeLog2); SmiToArrayOffset(dst, src, elementSizeLog2);
} else { } else if (keyMaybeNegative ||
!CpuFeatures::IsSupported(GENERAL_INSTR_EXT)) {
#if V8_TARGET_ARCH_S390X #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 // src (key) is a 32-bit integer. Sign extension ensures
// upper 32-bit does not contain garbage before being used to // upper 32-bit does not contain garbage before being used to
// reference memory. // reference memory.
lgfr(src, src); lgfr(src, src);
#endif #endif
ShiftLeftP(dst, src, Operand(elementSizeLog2)); 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