Commit 447af335 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[cleanup] Fix (D)CHECK macros in src/regexp

Use the (D)CHECK_{EQ,NE,GT,...} macros instead of (D)CHECK with an
embedded comparison. This gives better error messages and also does the
right comparison for signed/unsigned mismatches.

This will allow us to reenable the readability/check cpplint check.

R=jgruber@chromium.org

Bug: v8:6837
Change-Id: I9c489ac0e1b15fd4789c37fd32c9d3c76121a288
Reviewed-on: https://chromium-review.googlesource.com/671343
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48079}
parent 4e5db9a6
...@@ -139,8 +139,8 @@ void RegExpMacroAssemblerARM::AdvanceCurrentPosition(int by) { ...@@ -139,8 +139,8 @@ void RegExpMacroAssemblerARM::AdvanceCurrentPosition(int by) {
void RegExpMacroAssemblerARM::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerARM::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
__ ldr(r0, register_location(reg)); __ ldr(r0, register_location(reg));
__ add(r0, r0, Operand(by)); __ add(r0, r0, Operand(by));
...@@ -448,7 +448,7 @@ void RegExpMacroAssemblerARM::CheckNotCharacterAfterMinusAnd( ...@@ -448,7 +448,7 @@ void RegExpMacroAssemblerARM::CheckNotCharacterAfterMinusAnd(
uc16 minus, uc16 minus,
uc16 mask, uc16 mask,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ sub(r0, current_character(), Operand(minus)); __ sub(r0, current_character(), Operand(minus));
__ and_(r0, r0, Operand(mask)); __ and_(r0, r0, Operand(mask));
__ cmp(r0, Operand(c)); __ cmp(r0, Operand(c));
...@@ -1071,7 +1071,7 @@ void RegExpMacroAssemblerARM::CallCheckStackGuardState() { ...@@ -1071,7 +1071,7 @@ void RegExpMacroAssemblerARM::CallCheckStackGuardState() {
// Drop the return address from the stack. // Drop the return address from the stack.
__ add(sp, sp, Operand(stack_alignment)); __ add(sp, sp, Operand(stack_alignment));
DCHECK(stack_alignment != 0); DCHECK_NE(0, stack_alignment);
__ ldr(sp, MemOperand(sp, 0)); __ ldr(sp, MemOperand(sp, 0));
__ mov(code_pointer(), Operand(masm_->CodeObject())); __ mov(code_pointer(), Operand(masm_->CodeObject()));
...@@ -1212,7 +1212,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1212,7 +1212,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset,
// If unaligned load/stores are not supported then this function must only // If unaligned load/stores are not supported then this function must only
// be used to load a single character at a time. // be used to load a single character at a time.
if (!CanReadUnaligned()) { if (!CanReadUnaligned()) {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
} }
if (mode_ == LATIN1) { if (mode_ == LATIN1) {
...@@ -1221,7 +1221,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1221,7 +1221,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
__ ldrh(current_character(), MemOperand(end_of_input_address(), offset)); __ ldrh(current_character(), MemOperand(end_of_input_address(), offset));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ ldrb(current_character(), MemOperand(end_of_input_address(), offset)); __ ldrb(current_character(), MemOperand(end_of_input_address(), offset));
} }
} else { } else {
...@@ -1229,7 +1229,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1229,7 +1229,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset,
if (characters == 2) { if (characters == 2) {
__ ldr(current_character(), MemOperand(end_of_input_address(), offset)); __ ldr(current_character(), MemOperand(end_of_input_address(), offset));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ ldrh(current_character(), MemOperand(end_of_input_address(), offset)); __ ldrh(current_character(), MemOperand(end_of_input_address(), offset));
} }
} }
......
...@@ -248,7 +248,7 @@ void RegExpMacroAssemblerARM64::CheckCharacters(Vector<const uc16> str, ...@@ -248,7 +248,7 @@ void RegExpMacroAssemblerARM64::CheckCharacters(Vector<const uc16> str,
for (int i = 0; i < str.length(); i++) { for (int i = 0; i < str.length(); i++) {
if (mode_ == LATIN1) { if (mode_ == LATIN1) {
__ Ldrb(w10, MemOperand(characters_address, 1, PostIndex)); __ Ldrb(w10, MemOperand(characters_address, 1, PostIndex));
DCHECK(str[i] <= String::kMaxOneByteCharCode); DCHECK_GE(String::kMaxOneByteCharCode, str[i]);
} else { } else {
__ Ldrh(w10, MemOperand(characters_address, 2, PostIndex)); __ Ldrh(w10, MemOperand(characters_address, 2, PostIndex));
} }
...@@ -278,7 +278,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase( ...@@ -278,7 +278,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase(
DCHECK(kCalleeSaved.IncludesAliasOf(capture_length)); DCHECK(kCalleeSaved.IncludesAliasOf(capture_length));
// Find length of back-referenced capture. // Find length of back-referenced capture.
DCHECK((start_reg % 2) == 0); DCHECK_EQ(0, start_reg % 2);
if (start_reg < kNumCachedRegisters) { if (start_reg < kNumCachedRegisters) {
__ Mov(capture_start_offset.X(), GetCachedRegister(start_reg)); __ Mov(capture_start_offset.X(), GetCachedRegister(start_reg));
__ Lsr(x11, GetCachedRegister(start_reg), kWRegSizeInBits); __ Lsr(x11, GetCachedRegister(start_reg), kWRegSizeInBits);
...@@ -374,7 +374,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase( ...@@ -374,7 +374,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase(
// The cached registers need to be retained. // The cached registers need to be retained.
CPURegList cached_registers(CPURegister::kRegister, kXRegSizeInBits, 0, 7); CPURegList cached_registers(CPURegister::kRegister, kXRegSizeInBits, 0, 7);
DCHECK((cached_registers.Count() * 2) == kNumCachedRegisters); DCHECK_EQ(kNumCachedRegisters, cached_registers.Count() * 2);
__ PushCPURegList(cached_registers); __ PushCPURegList(cached_registers);
// Put arguments into arguments registers. // Put arguments into arguments registers.
...@@ -439,7 +439,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReference(int start_reg, ...@@ -439,7 +439,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReference(int start_reg,
Register capture_length = w15; Register capture_length = w15;
// Find length of back-referenced capture. // Find length of back-referenced capture.
DCHECK((start_reg % 2) == 0); DCHECK_EQ(0, start_reg % 2);
if (start_reg < kNumCachedRegisters) { if (start_reg < kNumCachedRegisters) {
__ Mov(x10, GetCachedRegister(start_reg)); __ Mov(x10, GetCachedRegister(start_reg));
__ Lsr(x11, GetCachedRegister(start_reg), kWRegSizeInBits); __ Lsr(x11, GetCachedRegister(start_reg), kWRegSizeInBits);
...@@ -536,7 +536,7 @@ void RegExpMacroAssemblerARM64::CheckNotCharacterAfterMinusAnd( ...@@ -536,7 +536,7 @@ void RegExpMacroAssemblerARM64::CheckNotCharacterAfterMinusAnd(
uc16 minus, uc16 minus,
uc16 mask, uc16 mask,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ Sub(w10, current_character(), minus); __ Sub(w10, current_character(), minus);
__ And(w10, w10, mask); __ And(w10, w10, mask);
CompareAndBranchOrBacktrack(w10, c, ne, on_not_equal); CompareAndBranchOrBacktrack(w10, c, ne, on_not_equal);
...@@ -718,7 +718,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -718,7 +718,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
CPURegList argument_registers(x0, x5, x6, x7); CPURegList argument_registers(x0, x5, x6, x7);
CPURegList registers_to_retain = kCalleeSaved; CPURegList registers_to_retain = kCalleeSaved;
DCHECK(kCalleeSaved.Count() == 11); DCHECK_EQ(11, kCalleeSaved.Count());
registers_to_retain.Combine(lr); registers_to_retain.Combine(lr);
DCHECK(csp.Is(__ StackPointer())); DCHECK(csp.Is(__ StackPointer()));
...@@ -1030,7 +1030,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -1030,7 +1030,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
// Registers x0 to x7 are used to store the first captures, they need to be // Registers x0 to x7 are used to store the first captures, they need to be
// retained over calls to C++ code. // retained over calls to C++ code.
CPURegList cached_registers(CPURegister::kRegister, kXRegSizeInBits, 0, 7); CPURegList cached_registers(CPURegister::kRegister, kXRegSizeInBits, 0, 7);
DCHECK((cached_registers.Count() * 2) == kNumCachedRegisters); DCHECK_EQ(kNumCachedRegisters, cached_registers.Count() * 2);
if (check_preempt_label_.is_linked()) { if (check_preempt_label_.is_linked()) {
__ Bind(&check_preempt_label_); __ Bind(&check_preempt_label_);
...@@ -1275,7 +1275,7 @@ void RegExpMacroAssemblerARM64::ClearRegisters(int reg_from, int reg_to) { ...@@ -1275,7 +1275,7 @@ void RegExpMacroAssemblerARM64::ClearRegisters(int reg_from, int reg_to) {
if (num_registers > 0) { if (num_registers > 0) {
// If there are some remaining registers, they are stored on the stack. // If there are some remaining registers, they are stored on the stack.
DCHECK(reg_from >= kNumCachedRegisters); DCHECK_LE(kNumCachedRegisters, reg_from);
// Move down the indexes of the registers on stack to get the correct offset // Move down the indexes of the registers on stack to get the correct offset
// in memory. // in memory.
...@@ -1482,7 +1482,7 @@ void RegExpMacroAssemblerARM64::Pop(Register target) { ...@@ -1482,7 +1482,7 @@ void RegExpMacroAssemblerARM64::Pop(Register target) {
Register RegExpMacroAssemblerARM64::GetCachedRegister(int register_index) { Register RegExpMacroAssemblerARM64::GetCachedRegister(int register_index) {
DCHECK(register_index < kNumCachedRegisters); DCHECK_GT(kNumCachedRegisters, register_index);
return Register::Create(register_index / 2, kXRegSizeInBits); return Register::Create(register_index / 2, kXRegSizeInBits);
} }
...@@ -1490,7 +1490,7 @@ Register RegExpMacroAssemblerARM64::GetCachedRegister(int register_index) { ...@@ -1490,7 +1490,7 @@ Register RegExpMacroAssemblerARM64::GetCachedRegister(int register_index) {
Register RegExpMacroAssemblerARM64::GetRegister(int register_index, Register RegExpMacroAssemblerARM64::GetRegister(int register_index,
Register maybe_result) { Register maybe_result) {
DCHECK(maybe_result.Is32Bits()); DCHECK(maybe_result.Is32Bits());
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
if (num_registers_ <= register_index) { if (num_registers_ <= register_index) {
num_registers_ = register_index + 1; num_registers_ = register_index + 1;
} }
...@@ -1521,7 +1521,7 @@ Register RegExpMacroAssemblerARM64::GetRegister(int register_index, ...@@ -1521,7 +1521,7 @@ Register RegExpMacroAssemblerARM64::GetRegister(int register_index,
void RegExpMacroAssemblerARM64::StoreRegister(int register_index, void RegExpMacroAssemblerARM64::StoreRegister(int register_index,
Register source) { Register source) {
DCHECK(source.Is32Bits()); DCHECK(source.Is32Bits());
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
if (num_registers_ <= register_index) { if (num_registers_ <= register_index) {
num_registers_ = register_index + 1; num_registers_ = register_index + 1;
} }
...@@ -1574,7 +1574,7 @@ void RegExpMacroAssemblerARM64::SaveLinkRegister() { ...@@ -1574,7 +1574,7 @@ void RegExpMacroAssemblerARM64::SaveLinkRegister() {
MemOperand RegExpMacroAssemblerARM64::register_location(int register_index) { MemOperand RegExpMacroAssemblerARM64::register_location(int register_index) {
DCHECK(register_index < (1<<30)); DCHECK(register_index < (1<<30));
DCHECK(register_index >= kNumCachedRegisters); DCHECK_LE(kNumCachedRegisters, register_index);
if (num_registers_ <= register_index) { if (num_registers_ <= register_index) {
num_registers_ = register_index + 1; num_registers_ = register_index + 1;
} }
...@@ -1587,7 +1587,7 @@ MemOperand RegExpMacroAssemblerARM64::capture_location(int register_index, ...@@ -1587,7 +1587,7 @@ MemOperand RegExpMacroAssemblerARM64::capture_location(int register_index,
Register scratch) { Register scratch) {
DCHECK(register_index < (1<<30)); DCHECK(register_index < (1<<30));
DCHECK(register_index < num_saved_registers_); DCHECK(register_index < num_saved_registers_);
DCHECK(register_index >= kNumCachedRegisters); DCHECK_LE(kNumCachedRegisters, register_index);
DCHECK_EQ(register_index % 2, 0); DCHECK_EQ(register_index % 2, 0);
register_index -= kNumCachedRegisters; register_index -= kNumCachedRegisters;
int offset = kFirstCaptureOnStack - register_index * kWRegSize; int offset = kFirstCaptureOnStack - register_index * kWRegSize;
...@@ -1614,7 +1614,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1614,7 +1614,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset,
// disable it. // disable it.
// TODO(pielan): See whether or not we should disable unaligned accesses. // TODO(pielan): See whether or not we should disable unaligned accesses.
if (!CanReadUnaligned()) { if (!CanReadUnaligned()) {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
} }
if (cp_offset != 0) { if (cp_offset != 0) {
...@@ -1636,7 +1636,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1636,7 +1636,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
__ Ldrh(current_character(), MemOperand(input_end(), offset, SXTW)); __ Ldrh(current_character(), MemOperand(input_end(), offset, SXTW));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ Ldrb(current_character(), MemOperand(input_end(), offset, SXTW)); __ Ldrb(current_character(), MemOperand(input_end(), offset, SXTW));
} }
} else { } else {
...@@ -1644,7 +1644,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1644,7 +1644,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset,
if (characters == 2) { if (characters == 2) {
__ Ldr(current_character(), MemOperand(input_end(), offset, SXTW)); __ Ldr(current_character(), MemOperand(input_end(), offset, SXTW));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ Ldrh(current_character(), MemOperand(input_end(), offset, SXTW)); __ Ldrh(current_character(), MemOperand(input_end(), offset, SXTW));
} }
} }
......
...@@ -232,7 +232,7 @@ class RegExpMacroAssemblerARM64: public NativeRegExpMacroAssembler { ...@@ -232,7 +232,7 @@ class RegExpMacroAssemblerARM64: public NativeRegExpMacroAssembler {
}; };
RegisterState GetRegisterState(int register_index) { RegisterState GetRegisterState(int register_index) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
if (register_index >= kNumCachedRegisters) { if (register_index >= kNumCachedRegisters) {
return STACKED; return STACKED;
} else { } else {
......
...@@ -125,8 +125,8 @@ void RegExpMacroAssemblerIA32::AdvanceCurrentPosition(int by) { ...@@ -125,8 +125,8 @@ void RegExpMacroAssemblerIA32::AdvanceCurrentPosition(int by) {
void RegExpMacroAssemblerIA32::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerIA32::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
__ add(register_location(reg), Immediate(by)); __ add(register_location(reg), Immediate(by));
} }
...@@ -471,7 +471,7 @@ void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd( ...@@ -471,7 +471,7 @@ void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd(
uc16 minus, uc16 minus,
uc16 mask, uc16 mask,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ lea(eax, Operand(current_character(), -minus)); __ lea(eax, Operand(current_character(), -minus));
if (c == 0) { if (c == 0) {
__ test(eax, Immediate(mask)); __ test(eax, Immediate(mask));
...@@ -1249,7 +1249,7 @@ void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1249,7 +1249,7 @@ void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
__ movzx_w(current_character(), Operand(esi, edi, times_1, cp_offset)); __ movzx_w(current_character(), Operand(esi, edi, times_1, cp_offset));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ movzx_b(current_character(), Operand(esi, edi, times_1, cp_offset)); __ movzx_b(current_character(), Operand(esi, edi, times_1, cp_offset));
} }
} else { } else {
...@@ -1258,7 +1258,7 @@ void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1258,7 +1258,7 @@ void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset,
__ mov(current_character(), __ mov(current_character(),
Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); Operand(esi, edi, times_1, cp_offset * sizeof(uc16)));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ movzx_w(current_character(), __ movzx_w(current_character(),
Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); Operand(esi, edi, times_1, cp_offset * sizeof(uc16)));
} }
......
...@@ -114,13 +114,13 @@ static void TraceInterpreter(const byte* code_base, ...@@ -114,13 +114,13 @@ static void TraceInterpreter(const byte* code_base,
static int32_t Load32Aligned(const byte* pc) { static int32_t Load32Aligned(const byte* pc) {
DCHECK((reinterpret_cast<intptr_t>(pc) & 3) == 0); DCHECK_EQ(0, reinterpret_cast<intptr_t>(pc) & 3);
return *reinterpret_cast<const int32_t *>(pc); return *reinterpret_cast<const int32_t *>(pc);
} }
static int32_t Load16Aligned(const byte* pc) { static int32_t Load16Aligned(const byte* pc) {
DCHECK((reinterpret_cast<intptr_t>(pc) & 1) == 0); DCHECK_EQ(0, reinterpret_cast<intptr_t>(pc) & 1);
return *reinterpret_cast<const uint16_t *>(pc); return *reinterpret_cast<const uint16_t *>(pc);
} }
...@@ -300,7 +300,7 @@ static RegExpImpl::IrregexpResult RawMatch(Isolate* isolate, ...@@ -300,7 +300,7 @@ static RegExpImpl::IrregexpResult RawMatch(Isolate* isolate,
break; break;
} }
BYTECODE(LOAD_4_CURRENT_CHARS) { BYTECODE(LOAD_4_CURRENT_CHARS) {
DCHECK(sizeof(Char) == 1); DCHECK_EQ(1, sizeof(Char));
int pos = current + (insn >> BYTECODE_SHIFT); int pos = current + (insn >> BYTECODE_SHIFT);
if (pos + 4 > subject.length() || pos < 0) { if (pos + 4 > subject.length() || pos < 0) {
pc = code_base + Load32Aligned(pc + 4); pc = code_base + Load32Aligned(pc + 4);
...@@ -317,7 +317,7 @@ static RegExpImpl::IrregexpResult RawMatch(Isolate* isolate, ...@@ -317,7 +317,7 @@ static RegExpImpl::IrregexpResult RawMatch(Isolate* isolate,
break; break;
} }
BYTECODE(LOAD_4_CURRENT_CHARS_UNCHECKED) { BYTECODE(LOAD_4_CURRENT_CHARS_UNCHECKED) {
DCHECK(sizeof(Char) == 1); DCHECK_EQ(1, sizeof(Char));
int pos = current + (insn >> BYTECODE_SHIFT); int pos = current + (insn >> BYTECODE_SHIFT);
Char next1 = subject[pos + 1]; Char next1 = subject[pos + 1];
Char next2 = subject[pos + 2]; Char next2 = subject[pos + 2];
......
...@@ -78,8 +78,8 @@ ContainedInLattice AddRange(ContainedInLattice containment, ...@@ -78,8 +78,8 @@ ContainedInLattice AddRange(ContainedInLattice containment,
const int* ranges, const int* ranges,
int ranges_length, int ranges_length,
Interval new_range) { Interval new_range) {
DCHECK((ranges_length & 1) == 1); DCHECK_EQ(1, ranges_length & 1);
DCHECK(ranges[ranges_length - 1] == String::kMaxCodePoint + 1); DCHECK_EQ(String::kMaxCodePoint + 1, ranges[ranges_length - 1]);
if (containment == kLatticeUnknown) return containment; if (containment == kLatticeUnknown) return containment;
bool inside = false; bool inside = false;
int last = 0; int last = 0;
...@@ -209,8 +209,8 @@ int RegExpImpl::AtomExecRaw(Handle<JSRegExp> regexp, ...@@ -209,8 +209,8 @@ int RegExpImpl::AtomExecRaw(Handle<JSRegExp> regexp,
int output_size) { int output_size) {
Isolate* isolate = regexp->GetIsolate(); Isolate* isolate = regexp->GetIsolate();
DCHECK(0 <= index); DCHECK_LE(0, index);
DCHECK(index <= subject->length()); DCHECK_LE(index, subject->length());
subject = String::Flatten(subject); subject = String::Flatten(subject);
DisallowHeapAllocation no_gc; // ensure vectors stay valid DisallowHeapAllocation no_gc; // ensure vectors stay valid
...@@ -431,8 +431,8 @@ int RegExpImpl::IrregexpExecRaw(Handle<JSRegExp> regexp, ...@@ -431,8 +431,8 @@ int RegExpImpl::IrregexpExecRaw(Handle<JSRegExp> regexp,
Handle<FixedArray> irregexp(FixedArray::cast(regexp->data()), isolate); Handle<FixedArray> irregexp(FixedArray::cast(regexp->data()), isolate);
DCHECK(index >= 0); DCHECK_LE(0, index);
DCHECK(index <= subject->length()); DCHECK_LE(index, subject->length());
DCHECK(subject->IsFlat()); DCHECK(subject->IsFlat());
bool is_one_byte = subject->IsOneByteRepresentationUnderneath(); bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
...@@ -641,7 +641,7 @@ RegExpImpl::GlobalCache::GlobalCache(Handle<JSRegExp> regexp, ...@@ -641,7 +641,7 @@ RegExpImpl::GlobalCache::GlobalCache(Handle<JSRegExp> regexp,
// to the compiled regexp. // to the compiled regexp.
current_match_index_ = max_matches_ - 1; current_match_index_ = max_matches_ - 1;
num_matches_ = max_matches_; num_matches_ = max_matches_;
DCHECK(registers_per_match_ >= 2); // Each match has at least one capture. DCHECK_LE(2, registers_per_match_); // Each match has at least one capture.
DCHECK_GE(register_array_size_, registers_per_match_); DCHECK_GE(register_array_size_, registers_per_match_);
int32_t* last_match = int32_t* last_match =
&register_array_[current_match_index_ * registers_per_match_]; &register_array_[current_match_index_ * registers_per_match_];
...@@ -1050,7 +1050,7 @@ RegExpCompiler::RegExpCompiler(Isolate* isolate, Zone* zone, int capture_count, ...@@ -1050,7 +1050,7 @@ RegExpCompiler::RegExpCompiler(Isolate* isolate, Zone* zone, int capture_count,
isolate_(isolate), isolate_(isolate),
zone_(zone) { zone_(zone) {
accept_ = new(zone) EndNode(EndNode::ACCEPT, zone); accept_ = new(zone) EndNode(EndNode::ACCEPT, zone);
DCHECK(next_register_ - 1 <= RegExpMacroAssembler::kMaxRegister); DCHECK_GE(RegExpMacroAssembler::kMaxRegister, next_register_ - 1);
} }
...@@ -1707,7 +1707,7 @@ static inline bool EmitAtomLetter(Isolate* isolate, ...@@ -1707,7 +1707,7 @@ static inline bool EmitAtomLetter(Isolate* isolate,
macro_assembler->LoadCurrentCharacter(cp_offset, on_failure, check); macro_assembler->LoadCurrentCharacter(cp_offset, on_failure, check);
} }
Label ok; Label ok;
DCHECK(unibrow::Ecma262UnCanonicalize::kMaxWidth == 4); DCHECK_EQ(4, unibrow::Ecma262UnCanonicalize::kMaxWidth);
switch (length) { switch (length) {
case 2: { case 2: {
if (ShortCutEmitCharacterPair(macro_assembler, one_byte, chars[0], if (ShortCutEmitCharacterPair(macro_assembler, one_byte, chars[0],
...@@ -2927,7 +2927,7 @@ void ChoiceNode::GetQuickCheckDetails(QuickCheckDetails* details, ...@@ -2927,7 +2927,7 @@ void ChoiceNode::GetQuickCheckDetails(QuickCheckDetails* details,
bool not_at_start) { bool not_at_start) {
not_at_start = (not_at_start || not_at_start_); not_at_start = (not_at_start || not_at_start_);
int choice_count = alternatives_->length(); int choice_count = alternatives_->length();
DCHECK(choice_count > 0); DCHECK_LT(0, choice_count);
alternatives_->at(0).node()->GetQuickCheckDetails(details, alternatives_->at(0).node()->GetQuickCheckDetails(details,
compiler, compiler,
characters_filled_in, characters_filled_in,
...@@ -3255,7 +3255,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler, ...@@ -3255,7 +3255,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler,
int TextNode::Length() { int TextNode::Length() {
TextElement elm = elements()->last(); TextElement elm = elements()->last();
DCHECK(elm.cp_offset() >= 0); DCHECK_LE(0, elm.cp_offset());
return elm.cp_offset() + elm.length(); return elm.cp_offset() + elm.length();
} }
...@@ -3474,7 +3474,7 @@ void LoopChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) { ...@@ -3474,7 +3474,7 @@ void LoopChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) {
// Back edge of greedy optimized loop node graph. // Back edge of greedy optimized loop node graph.
int text_length = int text_length =
GreedyLoopTextLengthForAlternative(&(alternatives_->at(0))); GreedyLoopTextLengthForAlternative(&(alternatives_->at(0)));
DCHECK(text_length != kNodeIsTooComplexForGreedyLoops); DCHECK_NE(kNodeIsTooComplexForGreedyLoops, text_length);
// Update the counter-based backtracking info on the stack. This is an // Update the counter-based backtracking info on the stack. This is an
// optimization for greedy loops (see below). // optimization for greedy loops (see below).
DCHECK(trace->cp_offset() == text_length); DCHECK(trace->cp_offset() == text_length);
...@@ -3795,7 +3795,7 @@ void BoyerMooreLookahead::EmitSkipInstructions(RegExpMacroAssembler* masm) { ...@@ -3795,7 +3795,7 @@ void BoyerMooreLookahead::EmitSkipInstructions(RegExpMacroAssembler* masm) {
Handle<ByteArray> boolean_skip_table = factory->NewByteArray(kSize, TENURED); Handle<ByteArray> boolean_skip_table = factory->NewByteArray(kSize, TENURED);
int skip_distance = GetSkipTable( int skip_distance = GetSkipTable(
min_lookahead, max_lookahead, boolean_skip_table); min_lookahead, max_lookahead, boolean_skip_table);
DCHECK(skip_distance != 0); DCHECK_NE(0, skip_distance);
Label cont, again; Label cont, again;
masm->Bind(&again); masm->Bind(&again);
...@@ -4750,10 +4750,10 @@ static bool CompareInverseRanges(ZoneList<CharacterRange>* ranges, ...@@ -4750,10 +4750,10 @@ static bool CompareInverseRanges(ZoneList<CharacterRange>* ranges,
const int* special_class, const int* special_class,
int length) { int length) {
length--; // Remove final marker. length--; // Remove final marker.
DCHECK(special_class[length] == kRangeEndMarker); DCHECK_EQ(kRangeEndMarker, special_class[length]);
DCHECK(ranges->length() != 0); DCHECK_NE(0, ranges->length());
DCHECK(length != 0); DCHECK_NE(0, length);
DCHECK(special_class[0] != 0); DCHECK_NE(0, special_class[0]);
if (ranges->length() != (length >> 1) + 1) { if (ranges->length() != (length >> 1) + 1) {
return false; return false;
} }
...@@ -4781,7 +4781,7 @@ static bool CompareRanges(ZoneList<CharacterRange>* ranges, ...@@ -4781,7 +4781,7 @@ static bool CompareRanges(ZoneList<CharacterRange>* ranges,
const int* special_class, const int* special_class,
int length) { int length) {
length--; // Remove final marker. length--; // Remove final marker.
DCHECK(special_class[length] == kRangeEndMarker); DCHECK_EQ(kRangeEndMarker, special_class[length]);
if (ranges->length() * 2 != length) { if (ranges->length() * 2 != length) {
return false; return false;
} }
...@@ -5418,7 +5418,7 @@ class RegExpExpansionLimiter { ...@@ -5418,7 +5418,7 @@ class RegExpExpansionLimiter {
: compiler_(compiler), : compiler_(compiler),
saved_expansion_factor_(compiler->current_expansion_factor()), saved_expansion_factor_(compiler->current_expansion_factor()),
ok_to_expand_(saved_expansion_factor_ <= kMaxExpansionFactor) { ok_to_expand_(saved_expansion_factor_ <= kMaxExpansionFactor) {
DCHECK(factor > 0); DCHECK_LT(0, factor);
if (ok_to_expand_) { if (ok_to_expand_) {
if (factor > kMaxExpansionFactor) { if (factor > kMaxExpansionFactor) {
// Avoid integer overflow of the current expansion factor. // Avoid integer overflow of the current expansion factor.
...@@ -5507,7 +5507,7 @@ RegExpNode* RegExpQuantifier::ToNode(int min, ...@@ -5507,7 +5507,7 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
} }
} }
if (max <= kMaxUnrolledMaxMatches && min == 0) { if (max <= kMaxUnrolledMaxMatches && min == 0) {
DCHECK(max > 0); // Due to the 'if' above. DCHECK_LT(0, max); // Due to the 'if' above.
RegExpExpansionLimiter limiter(compiler, max); RegExpExpansionLimiter limiter(compiler, max);
if (limiter.ok_to_expand()) { if (limiter.ok_to_expand()) {
// Unroll the optional matches up to max. // Unroll the optional matches up to max.
...@@ -5804,7 +5804,7 @@ static void AddClass(const int* elmv, ...@@ -5804,7 +5804,7 @@ static void AddClass(const int* elmv,
ZoneList<CharacterRange>* ranges, ZoneList<CharacterRange>* ranges,
Zone* zone) { Zone* zone) {
elmc--; elmc--;
DCHECK(elmv[elmc] == kRangeEndMarker); DCHECK_EQ(kRangeEndMarker, elmv[elmc]);
for (int i = 0; i < elmc; i += 2) { for (int i = 0; i < elmc; i += 2) {
DCHECK(elmv[i] < elmv[i + 1]); DCHECK(elmv[i] < elmv[i + 1]);
ranges->Add(CharacterRange::Range(elmv[i], elmv[i + 1] - 1), zone); ranges->Add(CharacterRange::Range(elmv[i], elmv[i + 1] - 1), zone);
...@@ -5817,9 +5817,9 @@ static void AddClassNegated(const int *elmv, ...@@ -5817,9 +5817,9 @@ static void AddClassNegated(const int *elmv,
ZoneList<CharacterRange>* ranges, ZoneList<CharacterRange>* ranges,
Zone* zone) { Zone* zone) {
elmc--; elmc--;
DCHECK(elmv[elmc] == kRangeEndMarker); DCHECK_EQ(kRangeEndMarker, elmv[elmc]);
DCHECK(elmv[0] != 0x0000); DCHECK_NE(0x0000, elmv[0]);
DCHECK(elmv[elmc - 1] != String::kMaxCodePoint); DCHECK_NE(String::kMaxCodePoint, elmv[elmc - 1]);
uc16 last = 0x0000; uc16 last = 0x0000;
for (int i = 0; i < elmc; i += 2) { for (int i = 0; i < elmc; i += 2) {
DCHECK(last <= elmv[i] - 1); DCHECK(last <= elmv[i] - 1);
......
...@@ -406,8 +406,8 @@ class QuickCheckDetails { ...@@ -406,8 +406,8 @@ class QuickCheckDetails {
int characters() { return characters_; } int characters() { return characters_; }
void set_characters(int characters) { characters_ = characters; } void set_characters(int characters) { characters_ = characters; }
Position* positions(int index) { Position* positions(int index) {
DCHECK(index >= 0); DCHECK_LE(0, index);
DCHECK(index < characters_); DCHECK_GT(characters_, index);
return positions_ + index; return positions_ + index;
} }
uint32_t mask() { return mask_; } uint32_t mask() { return mask_; }
......
...@@ -145,8 +145,8 @@ void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) { ...@@ -145,8 +145,8 @@ void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) {
void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
__ lw(a0, register_location(reg)); __ lw(a0, register_location(reg));
__ Addu(a0, a0, Operand(by)); __ Addu(a0, a0, Operand(by));
...@@ -291,7 +291,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase( ...@@ -291,7 +291,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
__ Subu(current_input_offset(), current_input_offset(), Operand(t5)); __ Subu(current_input_offset(), current_input_offset(), Operand(t5));
} }
} else { } else {
DCHECK(mode_ == UC16); DCHECK_EQ(UC16, mode_);
// Put regexp engine registers on stack. // Put regexp engine registers on stack.
RegList regexp_registers_to_retain = current_input_offset().bit() | RegList regexp_registers_to_retain = current_input_offset().bit() |
current_character().bit() | backtrack_stackpointer().bit(); current_character().bit() | backtrack_stackpointer().bit();
...@@ -455,7 +455,7 @@ void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterMinusAnd( ...@@ -455,7 +455,7 @@ void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterMinusAnd(
uc16 minus, uc16 minus,
uc16 mask, uc16 mask,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ Subu(a0, current_character(), Operand(minus)); __ Subu(a0, current_character(), Operand(minus));
__ And(a0, a0, Operand(mask)); __ And(a0, a0, Operand(mask));
BranchOrBacktrack(on_not_equal, ne, a0, Operand(c)); BranchOrBacktrack(on_not_equal, ne, a0, Operand(c));
...@@ -1278,12 +1278,12 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1278,12 +1278,12 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
} }
// We assume that we cannot do unaligned loads on MIPS, so this function // We assume that we cannot do unaligned loads on MIPS, so this function
// must only be used to load a single character at a time. // must only be used to load a single character at a time.
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ Addu(t5, end_of_input_address(), Operand(offset)); __ Addu(t5, end_of_input_address(), Operand(offset));
if (mode_ == LATIN1) { if (mode_ == LATIN1) {
__ lbu(current_character(), MemOperand(t5, 0)); __ lbu(current_character(), MemOperand(t5, 0));
} else { } else {
DCHECK(mode_ == UC16); DCHECK_EQ(UC16, mode_);
__ lhu(current_character(), MemOperand(t5, 0)); __ lhu(current_character(), MemOperand(t5, 0));
} }
} }
......
...@@ -182,8 +182,8 @@ void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) { ...@@ -182,8 +182,8 @@ void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) {
void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
__ Ld(a0, register_location(reg)); __ Ld(a0, register_location(reg));
__ Daddu(a0, a0, Operand(by)); __ Daddu(a0, a0, Operand(by));
...@@ -486,7 +486,7 @@ void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterMinusAnd( ...@@ -486,7 +486,7 @@ void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterMinusAnd(
uc16 minus, uc16 minus,
uc16 mask, uc16 mask,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ Dsubu(a0, current_character(), Operand(minus)); __ Dsubu(a0, current_character(), Operand(minus));
__ And(a0, a0, Operand(mask)); __ And(a0, a0, Operand(mask));
BranchOrBacktrack(on_not_equal, ne, a0, Operand(c)); BranchOrBacktrack(on_not_equal, ne, a0, Operand(c));
...@@ -1316,7 +1316,7 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1316,7 +1316,7 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
} }
// We assume that we cannot do unaligned loads on MIPS, so this function // We assume that we cannot do unaligned loads on MIPS, so this function
// must only be used to load a single character at a time. // must only be used to load a single character at a time.
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ Daddu(t1, end_of_input_address(), Operand(offset)); __ Daddu(t1, end_of_input_address(), Operand(offset));
if (mode_ == LATIN1) { if (mode_ == LATIN1) {
__ Lbu(current_character(), MemOperand(t1, 0)); __ Lbu(current_character(), MemOperand(t1, 0));
......
...@@ -150,8 +150,8 @@ void RegExpMacroAssemblerPPC::AdvanceCurrentPosition(int by) { ...@@ -150,8 +150,8 @@ void RegExpMacroAssemblerPPC::AdvanceCurrentPosition(int by) {
void RegExpMacroAssemblerPPC::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerPPC::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
__ LoadP(r3, register_location(reg), r0); __ LoadP(r3, register_location(reg), r0);
__ mov(r0, Operand(by)); __ mov(r0, Operand(by));
...@@ -467,7 +467,7 @@ void RegExpMacroAssemblerPPC::CheckNotCharacterAfterAnd(unsigned c, ...@@ -467,7 +467,7 @@ void RegExpMacroAssemblerPPC::CheckNotCharacterAfterAnd(unsigned c,
void RegExpMacroAssemblerPPC::CheckNotCharacterAfterMinusAnd( void RegExpMacroAssemblerPPC::CheckNotCharacterAfterMinusAnd(
uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) { uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ subi(r3, current_character(), Operand(minus)); __ subi(r3, current_character(), Operand(minus));
__ mov(r0, Operand(mask)); __ mov(r0, Operand(mask));
__ and_(r3, r3, r0); __ and_(r3, r3, r0);
...@@ -1287,7 +1287,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1287,7 +1287,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
__ lhz(current_character(), MemOperand(current_character())); __ lhz(current_character(), MemOperand(current_character()));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ lbz(current_character(), MemOperand(current_character())); __ lbz(current_character(), MemOperand(current_character()));
} }
} else { } else {
...@@ -1295,7 +1295,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1295,7 +1295,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
if (characters == 2) { if (characters == 2) {
__ lwz(current_character(), MemOperand(current_character())); __ lwz(current_character(), MemOperand(current_character()));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ lhz(current_character(), MemOperand(current_character())); __ lhz(current_character(), MemOperand(current_character()));
} }
} }
...@@ -1306,7 +1306,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1306,7 +1306,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
__ lhbrx(current_character(), MemOperand(r0, current_character())); __ lhbrx(current_character(), MemOperand(r0, current_character()));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ lbz(current_character(), MemOperand(current_character())); __ lbz(current_character(), MemOperand(current_character()));
} }
} else { } else {
...@@ -1315,7 +1315,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1315,7 +1315,7 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
__ lwz(current_character(), MemOperand(current_character())); __ lwz(current_character(), MemOperand(current_character()));
__ rlwinm(current_character(), current_character(), 16, 0, 31); __ rlwinm(current_character(), current_character(), 16, 0, 31);
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ lhz(current_character(), MemOperand(current_character())); __ lhz(current_character(), MemOperand(current_character()));
} }
} }
......
...@@ -303,7 +303,7 @@ std::ostream& RegExpTree::Print(std::ostream& os, Zone* zone) { // NOLINT ...@@ -303,7 +303,7 @@ std::ostream& RegExpTree::Print(std::ostream& os, Zone* zone) { // NOLINT
RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives)
: alternatives_(alternatives) { : alternatives_(alternatives) {
DCHECK(alternatives->length() > 1); DCHECK_LT(1, alternatives->length());
RegExpTree* first_alternative = alternatives->at(0); RegExpTree* first_alternative = alternatives->at(0);
min_match_ = first_alternative->min_match(); min_match_ = first_alternative->min_match();
max_match_ = first_alternative->max_match(); max_match_ = first_alternative->max_match();
...@@ -326,7 +326,7 @@ static int IncreaseBy(int previous, int increase) { ...@@ -326,7 +326,7 @@ static int IncreaseBy(int previous, int increase) {
RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes) RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes)
: nodes_(nodes) { : nodes_(nodes) {
DCHECK(nodes->length() > 1); DCHECK_LT(1, nodes->length());
min_match_ = 0; min_match_ = 0;
max_match_ = 0; max_match_ = 0;
for (int i = 0; i < nodes->length(); i++) { for (int i = 0; i < nodes->length(); i++) {
......
...@@ -69,8 +69,8 @@ void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) { ...@@ -69,8 +69,8 @@ void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) {
void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) { void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_POP_REGISTER, register_index); Emit(BC_POP_REGISTER, register_index);
} }
...@@ -78,16 +78,16 @@ void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) { ...@@ -78,16 +78,16 @@ void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) {
void RegExpMacroAssemblerIrregexp::PushRegister( void RegExpMacroAssemblerIrregexp::PushRegister(
int register_index, int register_index,
StackCheckFlag check_stack_limit) { StackCheckFlag check_stack_limit) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_PUSH_REGISTER, register_index); Emit(BC_PUSH_REGISTER, register_index);
} }
void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister( void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister(
int register_index, int cp_offset) { int register_index, int cp_offset) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_SET_REGISTER_TO_CP, register_index); Emit(BC_SET_REGISTER_TO_CP, register_index);
Emit32(cp_offset); // Current position offset. Emit32(cp_offset); // Current position offset.
} }
...@@ -103,24 +103,24 @@ void RegExpMacroAssemblerIrregexp::ClearRegisters(int reg_from, int reg_to) { ...@@ -103,24 +103,24 @@ void RegExpMacroAssemblerIrregexp::ClearRegisters(int reg_from, int reg_to) {
void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister( void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister(
int register_index) { int register_index) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_SET_CP_TO_REGISTER, register_index); Emit(BC_SET_CP_TO_REGISTER, register_index);
} }
void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister( void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister(
int register_index) { int register_index) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_SET_REGISTER_TO_SP, register_index); Emit(BC_SET_REGISTER_TO_SP, register_index);
} }
void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister( void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister(
int register_index) { int register_index) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_SET_SP_TO_REGISTER, register_index); Emit(BC_SET_SP_TO_REGISTER, register_index);
} }
...@@ -132,16 +132,16 @@ void RegExpMacroAssemblerIrregexp::SetCurrentPositionFromEnd(int by) { ...@@ -132,16 +132,16 @@ void RegExpMacroAssemblerIrregexp::SetCurrentPositionFromEnd(int by) {
void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) { void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_SET_REGISTER, register_index); Emit(BC_SET_REGISTER, register_index);
Emit32(to); Emit32(to);
} }
void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) { void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_ADVANCE_REGISTER, register_index); Emit(BC_ADVANCE_REGISTER, register_index);
Emit32(by); Emit32(by);
} }
...@@ -195,8 +195,8 @@ void RegExpMacroAssemblerIrregexp::Fail() { ...@@ -195,8 +195,8 @@ void RegExpMacroAssemblerIrregexp::Fail() {
void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) { void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) {
DCHECK(by >= kMinCPOffset); DCHECK_LE(kMinCPOffset, by);
DCHECK(by <= kMaxCPOffset); DCHECK_GE(kMaxCPOffset, by);
advance_current_start_ = pc_; advance_current_start_ = pc_;
advance_current_offset_ = by; advance_current_offset_ = by;
Emit(BC_ADVANCE_CP, by); Emit(BC_ADVANCE_CP, by);
...@@ -215,8 +215,8 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, ...@@ -215,8 +215,8 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset,
Label* on_failure, Label* on_failure,
bool check_bounds, bool check_bounds,
int characters) { int characters) {
DCHECK(cp_offset >= kMinCPOffset); DCHECK_LE(kMinCPOffset, cp_offset);
DCHECK(cp_offset <= kMaxCPOffset); DCHECK_GE(kMaxCPOffset, cp_offset);
int bytecode; int bytecode;
if (check_bounds) { if (check_bounds) {
if (characters == 4) { if (characters == 4) {
...@@ -224,7 +224,7 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, ...@@ -224,7 +224,7 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
bytecode = BC_LOAD_2_CURRENT_CHARS; bytecode = BC_LOAD_2_CURRENT_CHARS;
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
bytecode = BC_LOAD_CURRENT_CHAR; bytecode = BC_LOAD_CURRENT_CHAR;
} }
} else { } else {
...@@ -233,7 +233,7 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, ...@@ -233,7 +233,7 @@ void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED; bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED;
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED; bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED;
} }
} }
...@@ -373,8 +373,8 @@ void RegExpMacroAssemblerIrregexp::CheckBitInTable( ...@@ -373,8 +373,8 @@ void RegExpMacroAssemblerIrregexp::CheckBitInTable(
void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg,
bool read_backward, bool read_backward,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(start_reg >= 0); DCHECK_LE(0, start_reg);
DCHECK(start_reg <= kMaxRegister); DCHECK_GE(kMaxRegister, start_reg);
Emit(read_backward ? BC_CHECK_NOT_BACK_REF_BACKWARD : BC_CHECK_NOT_BACK_REF, Emit(read_backward ? BC_CHECK_NOT_BACK_REF_BACKWARD : BC_CHECK_NOT_BACK_REF,
start_reg); start_reg);
EmitOrLink(on_not_equal); EmitOrLink(on_not_equal);
...@@ -383,8 +383,8 @@ void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, ...@@ -383,8 +383,8 @@ void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg,
void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
int start_reg, bool read_backward, bool unicode, Label* on_not_equal) { int start_reg, bool read_backward, bool unicode, Label* on_not_equal) {
DCHECK(start_reg >= 0); DCHECK_LE(0, start_reg);
DCHECK(start_reg <= kMaxRegister); DCHECK_GE(kMaxRegister, start_reg);
Emit(read_backward ? (unicode ? BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE_BACKWARD Emit(read_backward ? (unicode ? BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE_BACKWARD
: BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD) : BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD)
: (unicode ? BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE : (unicode ? BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE
...@@ -397,8 +397,8 @@ void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( ...@@ -397,8 +397,8 @@ void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index,
int comparand, int comparand,
Label* on_less_than) { Label* on_less_than) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_CHECK_REGISTER_LT, register_index); Emit(BC_CHECK_REGISTER_LT, register_index);
Emit32(comparand); Emit32(comparand);
EmitOrLink(on_less_than); EmitOrLink(on_less_than);
...@@ -408,8 +408,8 @@ void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, ...@@ -408,8 +408,8 @@ void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index,
void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index, void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index,
int comparand, int comparand,
Label* on_greater_or_equal) { Label* on_greater_or_equal) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_CHECK_REGISTER_GE, register_index); Emit(BC_CHECK_REGISTER_GE, register_index);
Emit32(comparand); Emit32(comparand);
EmitOrLink(on_greater_or_equal); EmitOrLink(on_greater_or_equal);
...@@ -418,8 +418,8 @@ void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index, ...@@ -418,8 +418,8 @@ void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index,
void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index, void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index,
Label* on_eq) { Label* on_eq) {
DCHECK(register_index >= 0); DCHECK_LE(0, register_index);
DCHECK(register_index <= kMaxRegister); DCHECK_GE(kMaxRegister, register_index);
Emit(BC_CHECK_REGISTER_EQ_POS, register_index); Emit(BC_CHECK_REGISTER_EQ_POS, register_index);
EmitOrLink(on_eq); EmitOrLink(on_eq);
} }
......
...@@ -36,7 +36,7 @@ int RegExpMacroAssembler::CaseInsensitiveCompareUC16(Address byte_offset1, ...@@ -36,7 +36,7 @@ int RegExpMacroAssembler::CaseInsensitiveCompareUC16(Address byte_offset1,
// This function is not allowed to cause a garbage collection. // This function is not allowed to cause a garbage collection.
// A GC might move the calling generated code and invalidate the // A GC might move the calling generated code and invalidate the
// return address on the stack. // return address on the stack.
DCHECK(byte_length % 2 == 0); DCHECK_EQ(0, byte_length % 2);
uc16* substring1 = reinterpret_cast<uc16*>(byte_offset1); uc16* substring1 = reinterpret_cast<uc16*>(byte_offset1);
uc16* substring2 = reinterpret_cast<uc16*>(byte_offset2); uc16* substring2 = reinterpret_cast<uc16*>(byte_offset2);
size_t length = byte_length >> 1; size_t length = byte_length >> 1;
...@@ -137,8 +137,8 @@ const byte* NativeRegExpMacroAssembler::StringCharacterPosition( ...@@ -137,8 +137,8 @@ const byte* NativeRegExpMacroAssembler::StringCharacterPosition(
if (subject->IsThinString()) { if (subject->IsThinString()) {
subject = ThinString::cast(subject)->actual(); subject = ThinString::cast(subject)->actual();
} }
DCHECK(start_index >= 0); DCHECK_LE(0, start_index);
DCHECK(start_index <= subject->length()); DCHECK_LE(start_index, subject->length());
if (subject->IsSeqOneByteString()) { if (subject->IsSeqOneByteString()) {
return reinterpret_cast<const byte*>( return reinterpret_cast<const byte*>(
SeqOneByteString::cast(subject)->GetChars() + start_index); SeqOneByteString::cast(subject)->GetChars() + start_index);
...@@ -223,8 +223,8 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match( ...@@ -223,8 +223,8 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match(
Isolate* isolate) { Isolate* isolate) {
DCHECK(subject->IsFlat()); DCHECK(subject->IsFlat());
DCHECK(previous_index >= 0); DCHECK_LE(0, previous_index);
DCHECK(previous_index <= subject->length()); DCHECK_LE(previous_index, subject->length());
// No allocations before calling the regexp, but we can't use // No allocations before calling the regexp, but we can't use
// DisallowHeapAllocation, since regexps might be preempted, and another // DisallowHeapAllocation, since regexps might be preempted, and another
......
...@@ -832,7 +832,7 @@ bool RegExpParser::CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name, ...@@ -832,7 +832,7 @@ bool RegExpParser::CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name,
} }
RegExpCapture* capture = GetCapture(index); RegExpCapture* capture = GetCapture(index);
DCHECK(capture->name() == nullptr); DCHECK_NULL(capture->name());
capture->set_name(name); capture->set_name(name);
named_captures_->Add(capture, zone()); named_captures_->Add(capture, zone());
...@@ -1364,7 +1364,7 @@ bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) { ...@@ -1364,7 +1364,7 @@ bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) {
uc32 RegExpParser::ParseClassCharacterEscape() { uc32 RegExpParser::ParseClassCharacterEscape() {
DCHECK(current() == '\\'); DCHECK_EQ('\\', current());
DCHECK(has_next() && !IsSpecialClassEscape(Next())); DCHECK(has_next() && !IsSpecialClassEscape(Next()));
Advance(); Advance();
switch (current()) { switch (current()) {
......
...@@ -45,7 +45,7 @@ class RegExpStack { ...@@ -45,7 +45,7 @@ class RegExpStack {
// Gives the top of the memory used as stack. // Gives the top of the memory used as stack.
Address stack_base() { Address stack_base() {
DCHECK(thread_local_.memory_size_ != 0); DCHECK_NE(0, thread_local_.memory_size_);
return thread_local_.memory_ + thread_local_.memory_size_; return thread_local_.memory_ + thread_local_.memory_size_;
} }
......
...@@ -144,8 +144,8 @@ void RegExpMacroAssemblerS390::AdvanceCurrentPosition(int by) { ...@@ -144,8 +144,8 @@ void RegExpMacroAssemblerS390::AdvanceCurrentPosition(int by) {
} }
void RegExpMacroAssemblerS390::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerS390::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
if (CpuFeatures::IsSupported(GENERAL_INSTR_EXT) && is_int8(by)) { if (CpuFeatures::IsSupported(GENERAL_INSTR_EXT) && is_int8(by)) {
__ AddMI(register_location(reg), Operand(by)); __ AddMI(register_location(reg), Operand(by));
...@@ -444,7 +444,7 @@ void RegExpMacroAssemblerS390::CheckNotCharacterAfterAnd(unsigned c, ...@@ -444,7 +444,7 @@ void RegExpMacroAssemblerS390::CheckNotCharacterAfterAnd(unsigned c,
void RegExpMacroAssemblerS390::CheckNotCharacterAfterMinusAnd( void RegExpMacroAssemblerS390::CheckNotCharacterAfterMinusAnd(
uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) { uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ lay(r2, MemOperand(current_character(), -minus)); __ lay(r2, MemOperand(current_character(), -minus));
__ And(r2, Operand(mask)); __ And(r2, Operand(mask));
if (c != 0) { if (c != 0) {
...@@ -1086,7 +1086,7 @@ void RegExpMacroAssemblerS390::CallCheckStackGuardState(Register scratch) { ...@@ -1086,7 +1086,7 @@ void RegExpMacroAssemblerS390::CallCheckStackGuardState(Register scratch) {
// Helper function for reading a value out of a stack frame. // Helper function for reading a value out of a stack frame.
template <typename T> template <typename T>
static T& frame_entry(Address re_frame, int frame_offset) { static T& frame_entry(Address re_frame, int frame_offset) {
DCHECK(sizeof(T) == kPointerSize); DCHECK_EQ(kPointerSize, sizeof(T));
#ifdef V8_TARGET_ARCH_S390X #ifdef V8_TARGET_ARCH_S390X
return reinterpret_cast<T&>(Memory::uint64_at(re_frame + frame_offset)); return reinterpret_cast<T&>(Memory::uint64_at(re_frame + frame_offset));
#else #else
...@@ -1208,7 +1208,7 @@ void RegExpMacroAssemblerS390::CheckStackLimit() { ...@@ -1208,7 +1208,7 @@ void RegExpMacroAssemblerS390::CheckStackLimit() {
void RegExpMacroAssemblerS390::CallCFunctionUsingStub( void RegExpMacroAssemblerS390::CallCFunctionUsingStub(
ExternalReference function, int num_arguments) { ExternalReference function, int num_arguments) {
// Must pass all arguments in registers. The stub pushes on the stack. // Must pass all arguments in registers. The stub pushes on the stack.
DCHECK(num_arguments <= 8); DCHECK_GE(8, num_arguments);
__ mov(code_pointer(), Operand(function)); __ mov(code_pointer(), Operand(function));
Label ret; Label ret;
__ larl(r14, &ret); __ larl(r14, &ret);
...@@ -1249,7 +1249,7 @@ void RegExpMacroAssemblerS390::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1249,7 +1249,7 @@ void RegExpMacroAssemblerS390::LoadCurrentCharacterUnchecked(int cp_offset,
cp_offset * char_size())); cp_offset * char_size()));
#endif #endif
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ LoadlB(current_character(), __ LoadlB(current_character(),
MemOperand(current_input_offset(), end_of_input_address(), MemOperand(current_input_offset(), end_of_input_address(),
cp_offset * char_size())); cp_offset * char_size()));
...@@ -1265,7 +1265,7 @@ void RegExpMacroAssemblerS390::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1265,7 +1265,7 @@ void RegExpMacroAssemblerS390::LoadCurrentCharacterUnchecked(int cp_offset,
__ rll(current_character(), current_character(), Operand(16)); __ rll(current_character(), current_character(), Operand(16));
#endif #endif
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ LoadLogicalHalfWordP( __ LoadLogicalHalfWordP(
current_character(), current_character(),
MemOperand(current_input_offset(), end_of_input_address(), MemOperand(current_input_offset(), end_of_input_address(),
......
...@@ -139,8 +139,8 @@ void RegExpMacroAssemblerX64::AdvanceCurrentPosition(int by) { ...@@ -139,8 +139,8 @@ void RegExpMacroAssemblerX64::AdvanceCurrentPosition(int by) {
void RegExpMacroAssemblerX64::AdvanceRegister(int reg, int by) { void RegExpMacroAssemblerX64::AdvanceRegister(int reg, int by) {
DCHECK(reg >= 0); DCHECK_LE(0, reg);
DCHECK(reg < num_registers_); DCHECK_GT(num_registers_, reg);
if (by != 0) { if (by != 0) {
__ addp(register_location(reg), Immediate(by)); __ addp(register_location(reg), Immediate(by));
} }
...@@ -493,7 +493,7 @@ void RegExpMacroAssemblerX64::CheckNotCharacterAfterMinusAnd( ...@@ -493,7 +493,7 @@ void RegExpMacroAssemblerX64::CheckNotCharacterAfterMinusAnd(
uc16 minus, uc16 minus,
uc16 mask, uc16 mask,
Label* on_not_equal) { Label* on_not_equal) {
DCHECK(minus < String::kMaxUtf16CodeUnit); DCHECK_GT(String::kMaxUtf16CodeUnit, minus);
__ leap(rax, Operand(current_character(), -minus)); __ leap(rax, Operand(current_character(), -minus));
__ andp(rax, Immediate(mask)); __ andp(rax, Immediate(mask));
__ cmpl(rax, Immediate(c)); __ cmpl(rax, Immediate(c));
...@@ -1379,7 +1379,7 @@ void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1379,7 +1379,7 @@ void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset,
} else if (characters == 2) { } else if (characters == 2) {
__ movzxwl(current_character(), Operand(rsi, rdi, times_1, cp_offset)); __ movzxwl(current_character(), Operand(rsi, rdi, times_1, cp_offset));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ movzxbl(current_character(), Operand(rsi, rdi, times_1, cp_offset)); __ movzxbl(current_character(), Operand(rsi, rdi, times_1, cp_offset));
} }
} else { } else {
...@@ -1388,7 +1388,7 @@ void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1388,7 +1388,7 @@ void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset,
__ movl(current_character(), __ movl(current_character(),
Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16)));
} else { } else {
DCHECK(characters == 1); DCHECK_EQ(1, characters);
__ movzxwl(current_character(), __ movzxwl(current_character(),
Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16)));
} }
......
...@@ -95,8 +95,8 @@ class CompiledReplacement { ...@@ -95,8 +95,8 @@ class CompiledReplacement {
return ReplacementPart(REPLACEMENT_STRING, 0); return ReplacementPart(REPLACEMENT_STRING, 0);
} }
static inline ReplacementPart ReplacementSubString(int from, int to) { static inline ReplacementPart ReplacementSubString(int from, int to) {
DCHECK(from >= 0); DCHECK_LE(0, from);
DCHECK(to > from); DCHECK_GT(to, from);
return ReplacementPart(-from, to); return ReplacementPart(-from, to);
} }
...@@ -388,7 +388,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder, ...@@ -388,7 +388,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern, void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern,
std::vector<int>* indices, unsigned int limit) { std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0); DCHECK_LT(0, limit);
// Collect indices of pattern in subject using memchr. // Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values. // Stop after finding at most limit values.
const uint8_t* subject_start = subject.start(); const uint8_t* subject_start = subject.start();
...@@ -406,7 +406,7 @@ void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern, ...@@ -406,7 +406,7 @@ void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern,
void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern, void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern,
std::vector<int>* indices, unsigned int limit) { std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0); DCHECK_LT(0, limit);
const uc16* subject_start = subject.start(); const uc16* subject_start = subject.start();
const uc16* subject_end = subject_start + subject.length(); const uc16* subject_end = subject_start + subject.length();
for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) { for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) {
...@@ -421,7 +421,7 @@ template <typename SubjectChar, typename PatternChar> ...@@ -421,7 +421,7 @@ template <typename SubjectChar, typename PatternChar>
void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject, void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject,
Vector<const PatternChar> pattern, Vector<const PatternChar> pattern,
std::vector<int>* indices, unsigned int limit) { std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0); DCHECK_LT(0, limit);
// Collect indices of pattern in subject. // Collect indices of pattern in subject.
// Stop after finding at most limit values. // Stop after finding at most limit values.
int pattern_length = pattern.length(); int pattern_length = pattern.length();
...@@ -827,11 +827,11 @@ RUNTIME_FUNCTION(Runtime_StringSplit) { ...@@ -827,11 +827,11 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]);
CHECK(limit > 0); CHECK_LT(0, limit);
int subject_length = subject->length(); int subject_length = subject->length();
int pattern_length = pattern->length(); int pattern_length = pattern->length();
CHECK(pattern_length > 0); CHECK_LT(0, pattern_length);
if (limit == 0xffffffffu) { if (limit == 0xffffffffu) {
FixedArray* last_match_cache_unused; FixedArray* last_match_cache_unused;
...@@ -938,8 +938,8 @@ RUNTIME_FUNCTION(Runtime_RegExpExec) { ...@@ -938,8 +938,8 @@ RUNTIME_FUNCTION(Runtime_RegExpExec) {
CONVERT_ARG_HANDLE_CHECKED(RegExpMatchInfo, last_match_info, 3); CONVERT_ARG_HANDLE_CHECKED(RegExpMatchInfo, last_match_info, 3);
// Due to the way the JS calls are constructed this must be less than the // Due to the way the JS calls are constructed this must be less than the
// length of a string, i.e. it is always a Smi. We check anyway for security. // length of a string, i.e. it is always a Smi. We check anyway for security.
CHECK(index >= 0); CHECK_LE(0, index);
CHECK(index <= subject->length()); CHECK_GE(subject->length(), index);
isolate->counters()->regexp_entry_runtime()->Increment(); isolate->counters()->regexp_entry_runtime()->Increment();
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, RegExpImpl::Exec(regexp, subject, index, last_match_info)); isolate, RegExpImpl::Exec(regexp, subject, index, last_match_info));
...@@ -1262,7 +1262,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject, ...@@ -1262,7 +1262,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
isolate->factory()->NewSubString(subject, start, end); isolate->factory()->NewSubString(subject, start, end);
elements->set(cursor++, *substring); elements->set(cursor++, *substring);
} else { } else {
DCHECK(current_match[i * 2 + 1] < 0); DCHECK_GT(0, current_match[i * 2 + 1]);
elements->set(cursor++, isolate->heap()->undefined_value()); elements->set(cursor++, isolate->heap()->undefined_value());
} }
} }
......
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