Commit 7be96aa2 authored by Djordje.Pesic's avatar Djordje.Pesic Committed by Commit bot

Assertion failure when using --log-regexp

RegExpCompileEvent acquieres mutex from Log class during MessageBuilder creation. LogRegExpSource, called from RegExpCompileEvent creates another MessageBuilder object which also acquires the same mutex. This mutex is not recursive, so during second acquirement, assertion fail is happening. Solution: LogRegExpSource should use the same MessageBuilder object as RegExpCompileEvent.

Review URL: https://codereview.chromium.org/1207433002

Cr-Commit-Position: refs/heads/master@{#29347}
parent 2b87cf56
...@@ -953,57 +953,58 @@ TIMER_EVENTS_LIST(V) ...@@ -953,57 +953,58 @@ TIMER_EVENTS_LIST(V)
#undef V #undef V
void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { namespace {
// Emits the source code of a regexp. Used by regexp events.
void LogRegExpSource(Handle<JSRegExp> regexp, Isolate* isolate,
Log::MessageBuilder* msg) {
// Prints "/" + re.source + "/" + // Prints "/" + re.source + "/" +
// (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"")
Log::MessageBuilder msg(log_);
Handle<Object> source = Object::GetProperty( Handle<Object> source =
isolate_, regexp, "source").ToHandleChecked(); Object::GetProperty(isolate, regexp, "source").ToHandleChecked();
if (!source->IsString()) { if (!source->IsString()) {
msg.Append("no source"); msg->Append("no source");
return; return;
} }
switch (regexp->TypeTag()) { switch (regexp->TypeTag()) {
case JSRegExp::ATOM: case JSRegExp::ATOM:
msg.Append('a'); msg->Append('a');
break; break;
default: default:
break; break;
} }
msg.Append('/'); msg->Append('/');
msg.AppendDetailed(*Handle<String>::cast(source), false); msg->AppendDetailed(*Handle<String>::cast(source), false);
msg.Append('/'); msg->Append('/');
// global flag // global flag
Handle<Object> global = Object::GetProperty( Handle<Object> global =
isolate_, regexp, "global").ToHandleChecked(); Object::GetProperty(isolate, regexp, "global").ToHandleChecked();
if (global->IsTrue()) { if (global->IsTrue()) {
msg.Append('g'); msg->Append('g');
} }
// ignorecase flag // ignorecase flag
Handle<Object> ignorecase = Object::GetProperty( Handle<Object> ignorecase =
isolate_, regexp, "ignoreCase").ToHandleChecked(); Object::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked();
if (ignorecase->IsTrue()) { if (ignorecase->IsTrue()) {
msg.Append('i'); msg->Append('i');
} }
// multiline flag // multiline flag
Handle<Object> multiline = Object::GetProperty( Handle<Object> multiline =
isolate_, regexp, "multiline").ToHandleChecked(); Object::GetProperty(isolate, regexp, "multiline").ToHandleChecked();
if (multiline->IsTrue()) { if (multiline->IsTrue()) {
msg.Append('m'); msg->Append('m');
} }
msg.WriteToLogFile();
} }
} // namespace
void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) {
if (!log_->IsEnabled() || !FLAG_log_regexp) return; if (!log_->IsEnabled() || !FLAG_log_regexp) return;
Log::MessageBuilder msg(log_); Log::MessageBuilder msg(log_);
msg.Append("regexp-compile,"); msg.Append("regexp-compile,");
LogRegExpSource(regexp); LogRegExpSource(regexp, isolate_, &msg);
msg.Append(in_cache ? ",hit" : ",miss"); msg.Append(in_cache ? ",hit" : ",miss");
msg.WriteToLogFile(); msg.WriteToLogFile();
} }
......
...@@ -354,9 +354,6 @@ class Logger { ...@@ -354,9 +354,6 @@ class Logger {
// Internal configurable move event. // Internal configurable move event.
void MoveEventInternal(LogEventsAndTags event, Address from, Address to); void MoveEventInternal(LogEventsAndTags event, Address from, Address to);
// Emits the source code of a regexp. Used by regexp events.
void LogRegExpSource(Handle<JSRegExp> regexp);
// Used for logging stubs found in the snapshot. // Used for logging stubs found in the snapshot.
void LogCodeObject(Object* code_object); void LogCodeObject(Object* code_object);
......
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