Skip to content

Commit

Permalink
Bug 1642493: Apply clang-format to shim files r=mgaudet
Browse files Browse the repository at this point in the history
Now this code is less of a weird outlier.

Differential Revision: https://phabricator.services.mozilla.com/D77732
  • Loading branch information
iainireland committed Jun 4, 2020
1 parent a26cca3 commit 608ff71
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 141 deletions.
5 changes: 2 additions & 3 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ config/msvc-stl-wrapper.template.h
js/src/builtin/intl/LanguageTagGenerated.cpp
js/src/builtin/intl/TimeZoneDataGenerated.h

# Don't want to reformat irregexp. bug 1510128
js/src/irregexp/.*
js/src/new-regexp/.*
# Don't want to reformat irregexp (third-party code)
js/src/irregexp/imported/.*

# Don't want to reformat zydis (third-party library subject to occasional updates).
js/src/zydis/.*
Expand Down
13 changes: 5 additions & 8 deletions js/src/irregexp/RegExpAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ Isolate* CreateIsolate(JSContext* cx) {
return isolate.release();
}

void DestroyIsolate(Isolate* isolate) {
js_delete(isolate);
}
void DestroyIsolate(Isolate* isolate) { js_delete(isolate); }

static size_t ComputeColumn(const Latin1Char* begin, const Latin1Char* end) {
return PointerRangeSize(begin, end);
Expand Down Expand Up @@ -548,7 +546,7 @@ RegExpRunStatus ExecuteRaw(jit::JitCode* code, const CharT* chars,
auto function = reinterpret_cast<RegExpCodeSignature>(code->raw());
{
JS::AutoSuppressGCAnalysis nogc;
return (RegExpRunStatus) CALL_GENERATED_1(function, &data);
return (RegExpRunStatus)CALL_GENERATED_1(function, &data);
}
}

Expand All @@ -568,8 +566,8 @@ RegExpRunStatus Interpret(JSContext* cx, MutableHandleRegExpShared re,

RegExpRunStatus status =
(RegExpRunStatus)IrregexpInterpreter::MatchForCallFromRuntime(
cx->isolate, wrappedRegExp, wrappedInput, matches->pairsRaw(),
matches->pairCount() * 2, startIndex);
cx->isolate, wrappedRegExp, wrappedInput, matches->pairsRaw(),
uint32_t(matches->pairCount() * 2), uint32_t(startIndex));

MOZ_ASSERT(status == RegExpRunStatus_Error ||
status == RegExpRunStatus_Success ||
Expand Down Expand Up @@ -603,8 +601,7 @@ RegExpRunStatus Execute(JSContext* cx, MutableHandleRegExpShared re,

RegExpRunStatus ExecuteForFuzzing(JSContext* cx, HandleAtom pattern,
HandleLinearString input,
JS::RegExpFlags flags,
size_t startIndex,
JS::RegExpFlags flags, size_t startIndex,
VectorMatchPairs* matches,
RegExpShared::CodeKind codeKind) {
RootedRegExpShared re(cx, cx->zone()->regExps().get(cx, pattern, flags));
Expand Down
3 changes: 1 addition & 2 deletions js/src/irregexp/RegExpAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ RegExpRunStatus Execute(JSContext* cx, MutableHandleRegExpShared re,

RegExpRunStatus ExecuteForFuzzing(JSContext* cx, HandleAtom pattern,
HandleLinearString input,
JS::RegExpFlags flags,
size_t startIndex,
JS::RegExpFlags flags, size_t startIndex,
VectorMatchPairs* matches,
RegExpShared::CodeKind codeKind);

Expand Down
14 changes: 5 additions & 9 deletions js/src/irregexp/RegExpNativeMacroAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ void SMRegExpMacroAssembler::CheckAtStartImpl(int cp_offset, Label* on_cond,
Address addr(current_position_, cp_offset * char_size());
masm_.computeEffectiveAddress(addr, temp0_);

masm_.branchPtr(cond, inputStart(), temp0_,
LabelOrBacktrack(on_cond));
masm_.branchPtr(cond, inputStart(), temp0_, LabelOrBacktrack(on_cond));
}

void SMRegExpMacroAssembler::CheckAtStart(int cp_offset, Label* on_at_start) {
Expand Down Expand Up @@ -165,8 +164,7 @@ void SMRegExpMacroAssembler::CheckCharacterAfterAndImpl(uint32_t c,
}
}

void SMRegExpMacroAssembler::CheckCharacterAfterAnd(uint32_t c,
uint32_t mask,
void SMRegExpMacroAssembler::CheckCharacterAfterAnd(uint32_t c, uint32_t mask,
Label* on_equal) {
CheckCharacterAfterAndImpl(c, mask, on_equal, /*is_not =*/false);
}
Expand All @@ -177,7 +175,6 @@ void SMRegExpMacroAssembler::CheckNotCharacterAfterAnd(uint32_t c,
CheckCharacterAfterAndImpl(c, mask, on_not_equal, /*is_not =*/true);
}


// Subtract minus from the current character, then bitwise-and the
// result with mask, then check for a match with c.
void SMRegExpMacroAssembler::CheckNotCharacterAfterMinusAnd(
Expand Down Expand Up @@ -250,7 +247,7 @@ void SMRegExpMacroAssembler::CheckNotBackReferenceImpl(int start_reg,
// Captures are stored as a sequential pair of registers.
// Find the length of the back-referenced capture and load the
// capture's start index into current_character_.
masm_.loadPtr(register_location(start_reg), // index of start
masm_.loadPtr(register_location(start_reg), // index of start
current_character_);
masm_.loadPtr(register_location(start_reg + 1), temp0_); // index of end
masm_.subPtr(current_character_, temp0_); // length of capture
Expand Down Expand Up @@ -310,7 +307,7 @@ void SMRegExpMacroAssembler::CheckNotBackReferenceImpl(int start_reg,
masm_.passABIArg(current_position_);
masm_.passABIArg(temp0_);

bool unicode = true; // TODO: Fix V8 bug
bool unicode = true; // TODO: Fix V8 bug
if (unicode) {
uint32_t (*fun)(const char16_t*, const char16_t*, size_t) =
CaseInsensitiveCompareUCStrings;
Expand Down Expand Up @@ -491,8 +488,7 @@ bool SMRegExpMacroAssembler::CheckSpecialCharacterClass(uc16 type,
&success);

// Check '\t'..'\r'
masm_.computeEffectiveAddress(Address(current_character_, -'\t'),
temp0_);
masm_.computeEffectiveAddress(Address(current_character_, -'\t'), temp0_);
masm_.branch32(Assembler::BelowOrEqual, temp0_, Imm32('\r' - '\t'),
&success);

Expand Down
7 changes: 4 additions & 3 deletions js/src/irregexp/RegExpNativeMacroAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ struct FrameData {
void* backtrackStackBase;

// Copy of the input MatchPairs.
int32_t* matches; // pointer to capture array
int32_t numMatches; // size of capture array
int32_t* matches; // pointer to capture array
int32_t numMatches; // size of capture array
};

class SMRegExpMacroAssembler final : public NativeRegExpMacroAssembler {
public:
SMRegExpMacroAssembler(JSContext* cx, js::jit::StackMacroAssembler& masm,
Zone* zone, Mode mode, uint32_t num_capture_registers);
virtual ~SMRegExpMacroAssembler() {} // Nothing to do here
virtual ~SMRegExpMacroAssembler() = default;

virtual int stack_limit_slack();
virtual IrregexpImplementation Implementation();
Expand Down Expand Up @@ -103,6 +103,7 @@ class SMRegExpMacroAssembler final : public NativeRegExpMacroAssembler {
virtual Handle<HeapObject> GetCode(Handle<String> source);

virtual bool CanReadUnaligned();

private:
size_t frameSize_ = 0;

Expand Down
23 changes: 12 additions & 11 deletions js/src/irregexp/RegExpShim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ void PrintF(FILE* out, const char* format, ...) {
StdoutStream::operator std::ostream&() const { return std::cerr; }

template <typename T>
std::ostream& StdoutStream::operator<<(T t) { return std::cerr << t; }
std::ostream& StdoutStream::operator<<(T t) {
return std::cerr << t;
}

template std::ostream& StdoutStream::operator<<(char const* c);

Expand All @@ -64,8 +66,7 @@ std::ostream& operator<<(std::ostream& os, const AsUC32& c) {
return os << buf;
}

HandleScope::HandleScope(Isolate* isolate)
: isolate_(isolate) {
HandleScope::HandleScope(Isolate* isolate) : isolate_(isolate) {
isolate->openHandleScope(*this);
}

Expand All @@ -84,8 +85,8 @@ template Handle<String>::Handle(String s, Isolate* isolate);

template <typename T>
Handle<T>::Handle(const JS::Value& value, Isolate* isolate)
: location_(isolate->getHandleLocation(value)) {
T::cast(Object(value)); // Assert that value has the correct type.
: location_(isolate->getHandleLocation(value)) {
T::cast(Object(value)); // Assert that value has the correct type.
}

JS::Value* Isolate::getHandleLocation(const JS::Value& value) {
Expand Down Expand Up @@ -123,7 +124,7 @@ PseudoHandle<T> Isolate::takeOwnership(void* ptr) {

PseudoHandle<ByteArrayData> ByteArray::takeOwnership(Isolate* isolate) {
PseudoHandle<ByteArrayData> result =
isolate->takeOwnership<ByteArrayData>(value().toPrivate());
isolate->takeOwnership<ByteArrayData>(value().toPrivate());
setValue(JS::PrivateValue(nullptr));
return result;
}
Expand Down Expand Up @@ -182,7 +183,7 @@ Handle<ByteArray> Isolate::NewByteArray(int length, AllocationType alloc) {

size_t alloc_size = sizeof(uint32_t) + length;
ByteArrayData* data =
static_cast<ByteArrayData*>(allocatePseudoHandle(alloc_size));
static_cast<ByteArrayData*>(allocatePseudoHandle(alloc_size));
if (!data) {
oomUnsafe.crash("Irregexp NewByteArray");
}
Expand Down Expand Up @@ -212,10 +213,10 @@ Handle<String> Isolate::InternalizeString(const Vector<const CharT>& str) {
return Handle<String>(JS::StringValue(atom), this);
}

template Handle<String>
Isolate::InternalizeString(const Vector<const uint8_t>& str);
template Handle<String>
Isolate::InternalizeString(const Vector<const char16_t>& str);
template Handle<String> Isolate::InternalizeString(
const Vector<const uint8_t>& str);
template Handle<String> Isolate::InternalizeString(
const Vector<const char16_t>& str);

static_assert(JSRegExp::RegistersForCaptureCount(JSRegExp::kMaxCaptures) <=
RegExpMacroAssembler::kMaxRegisterCount);
Expand Down
Loading

0 comments on commit 608ff71

Please sign in to comment.