Bug 1479970 - Use early exits in AutoFrontendTraceLog. r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Fri, 12 Apr 2019 09:24:12 +0000
changeset 469272 2cc7599b9e92b2ff0d17e6f70b6cad4e0efcc8a4
parent 469271 bd6762543efec64230544fbfa7002a8a24198216
child 469273 32342cbe673a3fb37e9e9de2e818c379198a292c
push id112776
push usershindli@mozilla.com
push dateFri, 12 Apr 2019 16:20:17 +0000
treeherdermozilla-inbound@b4501ced5619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1479970
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1479970 - Use early exits in AutoFrontendTraceLog. r=jandem Avoid any risk of running non-trivial line-number or error reporting code. Differential Revision: https://phabricator.services.mozilla.com/D27110
js/src/frontend/BytecodeCompiler.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -310,16 +310,20 @@ class MOZ_STACK_CLASS frontend::Standalo
   }
 };
 
 AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx,
                                            const TraceLoggerTextId id,
                                            const ErrorReporter& errorReporter)
 #ifdef JS_TRACE_LOGGING
     : logger_(TraceLoggerForCurrentThread(cx)) {
+  if (!logger_) {
+    return;
+  }
+
   // If the tokenizer hasn't yet gotten any tokens, use the line and column
   // numbers from CompileOptions.
   uint32_t line, column;
   if (errorReporter.hasTokenizationStarted()) {
     line = errorReporter.options().lineno;
     column = errorReporter.options().column;
   } else {
     errorReporter.currentLineAndColumn(&line, &column);
@@ -335,32 +339,40 @@ AutoFrontendTraceLog::AutoFrontendTraceL
 #endif
 
 AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx,
                                            const TraceLoggerTextId id,
                                            const ErrorReporter& errorReporter,
                                            FunctionBox* funbox)
 #ifdef JS_TRACE_LOGGING
     : logger_(TraceLoggerForCurrentThread(cx)) {
+  if (!logger_) {
+    return;
+  }
+
   frontendEvent_.emplace(TraceLogger_Frontend, errorReporter.getFilename(),
                          funbox->startLine, funbox->startColumn);
   frontendLog_.emplace(logger_, *frontendEvent_);
   typeLog_.emplace(logger_, id);
 }
 #else
 {
 }
 #endif
 
 AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx,
                                            const TraceLoggerTextId id,
                                            const ErrorReporter& errorReporter,
                                            ParseNode* pn)
 #ifdef JS_TRACE_LOGGING
     : logger_(TraceLoggerForCurrentThread(cx)) {
+  if (!logger_) {
+    return;
+  }
+
   uint32_t line, column;
   errorReporter.lineAndColumnAt(pn->pn_pos.begin, &line, &column);
   frontendEvent_.emplace(TraceLogger_Frontend, errorReporter.getFilename(),
                          line, column);
   frontendLog_.emplace(logger_, *frontendEvent_);
   typeLog_.emplace(logger_, id);
 }
 #else