}
-class OutOfLineLoadInteger FINAL : public OutOfLineCode {
+class OutOfLineLoadZero FINAL : public OutOfLineCode {
public:
- OutOfLineLoadInteger(CodeGenerator* gen, Register result)
+ OutOfLineLoadZero(CodeGenerator* gen, Register result)
: OutOfLineCode(gen), result_(result) {}
void Generate() FINAL { __ xorl(result_, result_); }
};
-class OutOfLineLoadFloat FINAL : public OutOfLineCode {
+class OutOfLineLoadNaN FINAL : public OutOfLineCode {
public:
- OutOfLineLoadFloat(CodeGenerator* gen, XMMRegister result)
+ OutOfLineLoadNaN(CodeGenerator* gen, XMMRegister result)
: OutOfLineCode(gen), result_(result) {}
void Generate() FINAL { __ pcmpeqd(result_, result_); }
} while (0)
-#define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \
- do { \
- auto result = i.OutputDoubleRegister(); \
- auto offset = i.InputRegister(0); \
- if (instr->InputAt(1)->IsRegister()) { \
- __ cmpl(offset, i.InputRegister(1)); \
- } else { \
- __ cmpl(offset, i.InputImmediate(1)); \
- } \
- OutOfLineCode* ool = new (zone()) OutOfLineLoadFloat(this, result); \
- __ j(above_equal, ool->entry()); \
- __ asm_instr(result, i.MemoryOperand(2)); \
- __ bind(ool->exit()); \
+#define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \
+ do { \
+ auto result = i.OutputDoubleRegister(); \
+ auto buffer = i.InputRegister(0); \
+ auto index1 = i.InputRegister(1); \
+ auto index2 = i.InputInt32(2); \
+ OutOfLineCode* ool; \
+ if (instr->InputAt(3)->IsRegister()) { \
+ auto length = i.InputRegister(3); \
+ DCHECK_EQ(0, index2); \
+ __ cmpl(index1, length); \
+ ool = new (zone()) OutOfLineLoadNaN(this, result); \
+ } else { \
+ auto length = i.InputInt32(3); \
+ DCHECK_LE(index2, length); \
+ __ cmpl(index1, Immediate(length - index2)); \
+ if (index2 == 0) { \
+ ool = new (zone()) OutOfLineLoadNaN(this, result); \
+ } else { \
+ class OutOfLineLoadFloat FINAL : public OutOfLineCode { \
+ public: \
+ OutOfLineLoadFloat(CodeGenerator* gen, XMMRegister result, \
+ Register buffer, Register index1, int32_t index2, \
+ int32_t length) \
+ : OutOfLineCode(gen), \
+ result_(result), \
+ buffer_(buffer), \
+ index1_(index1), \
+ index2_(index2), \
+ length_(length) {} \
+ \
+ void Generate() FINAL { \
+ DCHECK_NE(0, index2_); \
+ __ leal(kScratchRegister, Operand(index1_, index2_)); \
+ __ pcmpeqd(result_, result_); \
+ __ cmpl(kScratchRegister, Immediate(length_)); \
+ __ j(above_equal, exit()); \
+ __ asm_instr(result_, \
+ Operand(buffer_, kScratchRegister, times_1, 0)); \
+ } \
+ \
+ private: \
+ XMMRegister const result_; \
+ Register const buffer_; \
+ Register const index1_; \
+ int32_t const index2_; \
+ int32_t const length_; \
+ }; \
+ ool = new (zone()) \
+ OutOfLineLoadFloat(this, result, buffer, index1, index2, length); \
+ } \
+ } \
+ __ j(above_equal, ool->entry()); \
+ __ asm_instr(result, Operand(buffer, index1, times_1, index2)); \
+ __ bind(ool->exit()); \
+ } while (false)
+
+
+#define ASSEMBLE_CHECKED_LOAD_INTEGER(asm_instr) \
+ do { \
+ auto result = i.OutputRegister(); \
+ auto buffer = i.InputRegister(0); \
+ auto index1 = i.InputRegister(1); \
+ auto index2 = i.InputInt32(2); \
+ OutOfLineCode* ool; \
+ if (instr->InputAt(3)->IsRegister()) { \
+ auto length = i.InputRegister(3); \
+ DCHECK_EQ(0, index2); \
+ __ cmpl(index1, length); \
+ ool = new (zone()) OutOfLineLoadZero(this, result); \
+ } else { \
+ auto length = i.InputInt32(3); \
+ DCHECK_LE(index2, length); \
+ __ cmpl(index1, Immediate(length - index2)); \
+ if (index2 == 0) { \
+ ool = new (zone()) OutOfLineLoadZero(this, result); \
+ } else { \
+ class OutOfLineLoadInteger FINAL : public OutOfLineCode { \
+ public: \
+ OutOfLineLoadInteger(CodeGenerator* gen, Register result, \
+ Register buffer, Register index1, \
+ int32_t index2, int32_t length) \
+ : OutOfLineCode(gen), \
+ result_(result), \
+ buffer_(buffer), \
+ index1_(index1), \
+ index2_(index2), \
+ length_(length) {} \
+ \
+ void Generate() FINAL { \
+ DCHECK_NE(0, index2_); \
+ __ leal(kScratchRegister, Operand(index1_, index2_)); \
+ __ xorl(result_, result_); \
+ __ cmpl(kScratchRegister, Immediate(length_)); \
+ __ j(above_equal, exit()); \
+ __ asm_instr(result_, \
+ Operand(buffer_, kScratchRegister, times_1, 0)); \
+ } \
+ \
+ private: \
+ Register const result_; \
+ Register const buffer_; \
+ Register const index1_; \
+ int32_t const index2_; \
+ int32_t const length_; \
+ }; \
+ ool = new (zone()) OutOfLineLoadInteger(this, result, buffer, index1, \
+ index2, length); \
+ } \
+ } \
+ __ j(above_equal, ool->entry()); \
+ __ asm_instr(result, Operand(buffer, index1, times_1, index2)); \
+ __ bind(ool->exit()); \
} while (false)
-#define ASSEMBLE_CHECKED_LOAD_INTEGER(asm_instr) \
- do { \
- auto result = i.OutputRegister(); \
- auto offset = i.InputRegister(0); \
- if (instr->InputAt(1)->IsRegister()) { \
- __ cmpl(offset, i.InputRegister(1)); \
- } else { \
- __ cmpl(offset, i.InputImmediate(1)); \
- } \
- OutOfLineCode* ool = new (zone()) OutOfLineLoadInteger(this, result); \
- __ j(above_equal, ool->entry()); \
- __ asm_instr(result, i.MemoryOperand(2)); \
- __ bind(ool->exit()); \
+#define ASSEMBLE_CHECKED_STORE_FLOAT(asm_instr) \
+ do { \
+ auto buffer = i.InputRegister(0); \
+ auto index1 = i.InputRegister(1); \
+ auto index2 = i.InputInt32(2); \
+ auto value = i.InputDoubleRegister(4); \
+ if (instr->InputAt(3)->IsRegister()) { \
+ auto length = i.InputRegister(3); \
+ DCHECK_EQ(0, index2); \
+ Label done; \
+ __ cmpl(index1, length); \
+ __ j(above_equal, &done, Label::kNear); \
+ __ asm_instr(Operand(buffer, index1, times_1, index2), value); \
+ __ bind(&done); \
+ } else { \
+ auto length = i.InputInt32(3); \
+ DCHECK_LE(index2, length); \
+ __ cmpl(index1, Immediate(length - index2)); \
+ if (index2 == 0) { \
+ Label done; \
+ __ j(above_equal, &done, Label::kNear); \
+ __ asm_instr(Operand(buffer, index1, times_1, index2), value); \
+ __ bind(&done); \
+ } else { \
+ class OutOfLineStoreFloat FINAL : public OutOfLineCode { \
+ public: \
+ OutOfLineStoreFloat(CodeGenerator* gen, Register buffer, \
+ Register index1, int32_t index2, int32_t length, \
+ XMMRegister value) \
+ : OutOfLineCode(gen), \
+ buffer_(buffer), \
+ index1_(index1), \
+ index2_(index2), \
+ length_(length), \
+ value_(value) {} \
+ \
+ void Generate() FINAL { \
+ DCHECK_NE(0, index2_); \
+ __ leal(kScratchRegister, Operand(index1_, index2_)); \
+ __ cmpl(kScratchRegister, Immediate(length_)); \
+ __ j(above_equal, exit()); \
+ __ asm_instr(Operand(buffer_, kScratchRegister, times_1, 0), \
+ value_); \
+ } \
+ \
+ private: \
+ Register const buffer_; \
+ Register const index1_; \
+ int32_t const index2_; \
+ int32_t const length_; \
+ XMMRegister const value_; \
+ }; \
+ auto ool = new (zone()) \
+ OutOfLineStoreFloat(this, buffer, index1, index2, length, value); \
+ __ j(above_equal, ool->entry()); \
+ __ asm_instr(Operand(buffer, index1, times_1, index2), value); \
+ __ bind(ool->exit()); \
+ } \
+ } \
} while (false)
-#define ASSEMBLE_CHECKED_STORE_FLOAT(asm_instr) \
- do { \
- auto offset = i.InputRegister(0); \
- if (instr->InputAt(1)->IsRegister()) { \
- __ cmpl(offset, i.InputRegister(1)); \
- } else { \
- __ cmpl(offset, i.InputImmediate(1)); \
- } \
- Label done; \
- __ j(above_equal, &done, Label::kNear); \
- __ asm_instr(i.MemoryOperand(3), i.InputDoubleRegister(2)); \
- __ bind(&done); \
+#define ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Value) \
+ do { \
+ auto buffer = i.InputRegister(0); \
+ auto index1 = i.InputRegister(1); \
+ auto index2 = i.InputInt32(2); \
+ if (instr->InputAt(3)->IsRegister()) { \
+ auto length = i.InputRegister(3); \
+ DCHECK_EQ(0, index2); \
+ Label done; \
+ __ cmpl(index1, length); \
+ __ j(above_equal, &done, Label::kNear); \
+ __ asm_instr(Operand(buffer, index1, times_1, index2), value); \
+ __ bind(&done); \
+ } else { \
+ auto length = i.InputInt32(3); \
+ DCHECK_LE(index2, length); \
+ __ cmpl(index1, Immediate(length - index2)); \
+ if (index2 == 0) { \
+ Label done; \
+ __ j(above_equal, &done, Label::kNear); \
+ __ asm_instr(Operand(buffer, index1, times_1, index2), value); \
+ __ bind(&done); \
+ } else { \
+ class OutOfLineStoreInteger FINAL : public OutOfLineCode { \
+ public: \
+ OutOfLineStoreInteger(CodeGenerator* gen, Register buffer, \
+ Register index1, int32_t index2, \
+ int32_t length, Value value) \
+ : OutOfLineCode(gen), \
+ buffer_(buffer), \
+ index1_(index1), \
+ index2_(index2), \
+ length_(length), \
+ value_(value) {} \
+ \
+ void Generate() FINAL { \
+ DCHECK_NE(0, index2_); \
+ __ leal(kScratchRegister, Operand(index1_, index2_)); \
+ __ cmpl(kScratchRegister, Immediate(length_)); \
+ __ j(above_equal, exit()); \
+ __ asm_instr(Operand(buffer_, kScratchRegister, times_1, 0), \
+ value_); \
+ } \
+ \
+ private: \
+ Register const buffer_; \
+ Register const index1_; \
+ int32_t const index2_; \
+ int32_t const length_; \
+ Value const value_; \
+ }; \
+ auto ool = new (zone()) OutOfLineStoreInteger(this, buffer, index1, \
+ index2, length, value); \
+ __ j(above_equal, ool->entry()); \
+ __ asm_instr(Operand(buffer, index1, times_1, index2), value); \
+ __ bind(ool->exit()); \
+ } \
+ } \
} while (false)
-#define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \
- do { \
- auto offset = i.InputRegister(0); \
- if (instr->InputAt(1)->IsRegister()) { \
- __ cmpl(offset, i.InputRegister(1)); \
- } else { \
- __ cmpl(offset, i.InputImmediate(1)); \
- } \
- Label done; \
- __ j(above_equal, &done, Label::kNear); \
- if (instr->InputAt(2)->IsRegister()) { \
- __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \
- } else { \
- __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \
- } \
- __ bind(&done); \
+#define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \
+ do { \
+ if (instr->InputAt(4)->IsRegister()) { \
+ Register value = i.InputRegister(4); \
+ ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Register); \
+ } else { \
+ Immediate value = i.InputImmediate(4); \
+ ASSEMBLE_CHECKED_STORE_INTEGER_IMPL(asm_instr, Immediate); \
+ } \
} while (false)