[v8/el6: 3/4] backports for nodejs 0.10.36

T.C. Hollingsworth patches at fedoraproject.org
Thu Feb 19 07:40:03 UTC 2015


commit e4755738a485286973972965a6686adb5ecf94da
Author: T.C. Hollingsworth <tchollingsworth at gmail.com>
Date:   Thu Feb 19 00:38:15 2015 -0700

    backports for nodejs 0.10.36

 v8-3.14.5.10-abort-uncaught-exception.patch |  139 +++++++++++++++++++++++++++
 v8-3.14.5.10-busy-loop.patch                |  137 ++++++++++++++++++++++++++
 v8-3.14.5.10-profiler-log.patch             |   43 ++++++++
 v8-3.14.5.10-unhandled-ReferenceError.patch |   37 +++++++
 v8.spec                                     |   30 ++++++-
 5 files changed, 385 insertions(+), 1 deletions(-)
---
diff --git a/v8-3.14.5.10-abort-uncaught-exception.patch b/v8-3.14.5.10-abort-uncaught-exception.patch
new file mode 100644
index 0000000..b2f2a08
--- /dev/null
+++ b/v8-3.14.5.10-abort-uncaught-exception.patch
@@ -0,0 +1,139 @@
+From fbff7054a47551387a99244e2cf0631f30406798 Mon Sep 17 00:00:00 2001
+From: Trevor Norris <trev.norris at gmail.com>
+Date: Tue, 18 Nov 2014 16:37:54 -0800
+Subject: [PATCH] v8: add api for aborting on uncaught exception
+
+Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
+notified when an uncaught exception has bubbled.
+
+PR-URL: https://github.com/joyent/node/pull/8666
+Reviewed-by: Trevor Norris <trev.norris at gmail.com>
+---
+ include/v8.h   | 11 +++++++++++
+ src/api.cc     |  5 +++++
+ src/isolate.cc | 33 +++++++++++++++++++++++----------
+ src/isolate.h  |  5 +++++
+ 4 files changed, 44 insertions(+), 10 deletions(-)
+
+diff --git a/include/v8.h b/include/v8.h
+index 71a0d01..e229ed9 100644
+--- a/include/v8.h
++++ b/include/v8.h
+@@ -2842,6 +2842,17 @@ class V8EXPORT Isolate {
+   static Isolate* GetCurrent();
+ 
+   /**
++   * Custom callback used by embedders to help V8 determine if it should abort
++   * when it throws and no internal handler can catch the exception.
++   * If FLAG_abort_on_uncaught_exception is true, then V8 will abort if either:
++   * - no custom callback is set.
++   * - the custom callback set returns true.
++   * Otherwise it won't abort.
++   */
++  typedef bool (*abort_on_uncaught_exception_t)();
++  void SetAbortOnUncaughtException(abort_on_uncaught_exception_t callback);
++
++  /**
+    * Methods below this point require holding a lock (using Locker) in
+    * a multi-threaded environment.
+    */
+diff --git a/src/api.cc b/src/api.cc
+index 96d564f..4b1aa67 100644
+--- a/src/api.cc
++++ b/src/api.cc
+@@ -5550,6 +5550,11 @@ void Isolate::Enter() {
+   isolate->Enter();
+ }
+ 
++void Isolate::SetAbortOnUncaughtException(
++      abort_on_uncaught_exception_t callback) {
++  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
++  isolate->SetAbortOnUncaughtException(callback);
++}
+ 
+ void Isolate::Exit() {
+   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+diff --git a/src/isolate.cc b/src/isolate.cc
+index 5a5293e..0b38616 100644
+--- a/src/isolate.cc
++++ b/src/isolate.cc
+@@ -1152,18 +1152,26 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) {
+         thread_local_top()->pending_message_end_pos_ = location->end_pos();
+       }
+ 
+-      // If the abort-on-uncaught-exception flag is specified, abort on any
+-      // exception not caught by JavaScript, even when an external handler is
+-      // present.  This flag is intended for use by JavaScript developers, so
+-      // print a user-friendly stack trace (not an internal one).
++      // If the abort-on-uncaught-exception flag is specified, and if the
++      // exception is not caught by JavaScript (even when an external handler is
++      // present).
+       if (fatal_exception_depth == 0 &&
+           FLAG_abort_on_uncaught_exception &&
+           (report_exception || can_be_caught_externally)) {
+-        fatal_exception_depth++;
+-        fprintf(stderr, "%s\n\nFROM\n",
+-          *MessageHandler::GetLocalizedMessage(message_obj));
+-        PrintCurrentStackTrace(stderr);
+-        OS::Abort();
++        // If the embedder didn't specify a custom uncaught exception callback,
++        // or if the custom callback determined that V8 should abort, then
++        // abort
++        bool should_abort = !abort_on_uncaught_exception_callback_ ||
++                             abort_on_uncaught_exception_callback_();
++        if (should_abort) {
++          fatal_exception_depth++;
++          // This flag is intended for use by JavaScript developers, so
++          // print a user-friendly stack trace (not an internal one).
++          fprintf(stderr, "%s\n\nFROM\n",
++            *MessageHandler::GetLocalizedMessage(message_obj));
++          PrintCurrentStackTrace(stderr);
++          OS::Abort();
++        }
+       }
+     } else if (location != NULL && !location->script().is_null()) {
+       // We are bootstrapping and caught an error where the location is set
+@@ -1339,6 +1347,10 @@ void Isolate::SetCaptureStackTraceForUncaughtExceptions(
+   stack_trace_for_uncaught_exceptions_options_ = options;
+ }
+ 
++void Isolate::SetAbortOnUncaughtException(
++      v8::Isolate::abort_on_uncaught_exception_t callback) {
++  abort_on_uncaught_exception_callback_ = callback;
++}
+ 
+ bool Isolate::is_out_of_memory() {
+   if (has_pending_exception()) {
+@@ -1534,7 +1546,8 @@ Isolate::Isolate()
+       date_cache_(NULL),
+       context_exit_happened_(false),
+       deferred_handles_head_(NULL),
+-      optimizing_compiler_thread_(this) {
++      optimizing_compiler_thread_(this),
++      abort_on_uncaught_exception_callback_(NULL) {
+   TRACE_ISOLATE(constructor);
+ 
+   memset(isolate_addresses_, 0,
+diff --git a/src/isolate.h b/src/isolate.h
+index 2769ca7..8719aa1 100644
+--- a/src/isolate.h
++++ b/src/isolate.h
+@@ -692,6 +692,9 @@ class Isolate {
+       int frame_limit,
+       StackTrace::StackTraceOptions options);
+ 
++  typedef bool (*abort_on_uncaught_exception_t)();
++  void SetAbortOnUncaughtException(abort_on_uncaught_exception_t callback);
++
+   // Tells whether the current context has experienced an out of memory
+   // exception.
+   bool is_out_of_memory();
+@@ -1292,6 +1295,8 @@ class Isolate {
+   DeferredHandles* deferred_handles_head_;
+   OptimizingCompilerThread optimizing_compiler_thread_;
+ 
++  abort_on_uncaught_exception_t abort_on_uncaught_exception_callback_;
++
+   friend class ExecutionAccess;
+   friend class HandleScopeImplementer;
+   friend class IsolateInitializer;
diff --git a/v8-3.14.5.10-busy-loop.patch b/v8-3.14.5.10-busy-loop.patch
new file mode 100644
index 0000000..fcc906c
--- /dev/null
+++ b/v8-3.14.5.10-busy-loop.patch
@@ -0,0 +1,137 @@
+From 6ebd85e10535dfaa9181842fe73834e51d4d3e6c Mon Sep 17 00:00:00 2001
+From: Ben Noordhuis <info at bnoordhuis.nl>
+Date: Thu, 27 Nov 2014 07:15:54 +0100
+Subject: [PATCH] v8: don't busy loop in cpu profiler thread
+
+Reduce the overhead of the CPU profiler by replacing sched_yield() with
+nanosleep() in V8's tick event processor thread.  The former only yields
+the CPU when there is another process scheduled on the same CPU.
+
+Before this commit, the thread would effectively busy loop and consume
+100% CPU time.  By forcing a one nanosecond sleep period rounded up to
+the task scheduler's granularity (about 50 us on Linux), CPU usage for
+the processor thread now hovers around 10-20% for a busy application.
+
+PR-URL: https://github.com/joyent/node/pull/8789
+Ref: https://github.com/strongloop/strong-agent/issues/3
+Reviewed-by: Trevor Norris <trev.norris at gmail.com>
+---
+ src/platform-freebsd.cc | 5 -----
+ src/platform-linux.cc   | 5 -----
+ src/platform-macos.cc   | 5 -----
+ src/platform-openbsd.cc | 5 -----
+ src/platform-posix.cc   | 6 ++++++
+ src/platform-solaris.cc | 5 -----
+ tools/gyp/v8.gyp        | 2 +-
+ 7 files changed, 7 insertions(+), 26 deletions(-)
+
+diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
+index 511759c..5c90c6b 100644
+--- a/src/platform-freebsd.cc
++++ b/src/platform-freebsd.cc
+@@ -539,11 +539,6 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
+ }
+ 
+ 
+-void Thread::YieldCPU() {
+-  sched_yield();
+-}
+-
+-
+ class FreeBSDMutex : public Mutex {
+  public:
+   FreeBSDMutex() {
+diff --git a/src/platform-linux.cc b/src/platform-linux.cc
+index beb2cce..3d6b304 100644
+--- a/src/platform-linux.cc
++++ b/src/platform-linux.cc
+@@ -812,11 +812,6 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
+ }
+ 
+ 
+-void Thread::YieldCPU() {
+-  sched_yield();
+-}
+-
+-
+ class LinuxMutex : public Mutex {
+  public:
+   LinuxMutex() {
+diff --git a/src/platform-macos.cc b/src/platform-macos.cc
+index a216f6e..e54e3e4 100644
+--- a/src/platform-macos.cc
++++ b/src/platform-macos.cc
+@@ -640,11 +640,6 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
+ }
+ 
+ 
+-void Thread::YieldCPU() {
+-  sched_yield();
+-}
+-
+-
+ class MacOSMutex : public Mutex {
+  public:
+   MacOSMutex() {
+diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc
+index 408d4dc..72167de 100644
+--- a/src/platform-openbsd.cc
++++ b/src/platform-openbsd.cc
+@@ -593,11 +593,6 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
+ }
+ 
+ 
+-void Thread::YieldCPU() {
+-  sched_yield();
+-}
+-
+-
+ class OpenBSDMutex : public Mutex {
+  public:
+   OpenBSDMutex() {
+diff --git a/src/platform-posix.cc b/src/platform-posix.cc
+index 5c3529d..8aecd56 100644
+--- a/src/platform-posix.cc
++++ b/src/platform-posix.cc
+@@ -392,6 +392,12 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
+ }
+ 
+ 
++void Thread::YieldCPU() {
++  const timespec delay = { 0, 1 };
++  nanosleep(&delay, NULL);
++}
++
++
+ // ----------------------------------------------------------------------------
+ // POSIX socket support.
+ //
+diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc
+index 07718fe..4e95ecc 100644
+--- a/src/platform-solaris.cc
++++ b/src/platform-solaris.cc
+@@ -527,11 +527,6 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
+ }
+ 
+ 
+-void Thread::YieldCPU() {
+-  sched_yield();
+-}
+-
+-
+ class SolarisMutex : public Mutex {
+  public:
+   SolarisMutex() {
+diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
+index 71cf366..c304925 100644
+--- a/tools/gyp/v8.gyp
++++ b/tools/gyp/v8.gyp
+@@ -715,7 +715,7 @@
+             ['OS=="solaris"', {
+                 'link_settings': {
+                   'libraries': [
+-                    '-lsocket -lnsl',
++                    '-lsocket -lnsl -lrt',
+                 ]},
+                 'sources': [
+                   '../../src/platform-solaris.cc',
diff --git a/v8-3.14.5.10-profiler-log.patch b/v8-3.14.5.10-profiler-log.patch
new file mode 100644
index 0000000..2530e54
--- /dev/null
+++ b/v8-3.14.5.10-profiler-log.patch
@@ -0,0 +1,43 @@
+From 431eb172f97434a3b0868a610bc14d8ff7d9efd9 Mon Sep 17 00:00:00 2001
+From: Ben Noordhuis <info at bnoordhuis.nl>
+Date: Fri, 16 Jan 2015 13:44:42 +0100
+Subject: [PATCH] deps: log V8 version in profiler log file
+
+Patch from issue 800293002 authored by ben at strongloop.com
+
+Review URL: https://codereview.chromium.org/806143002
+
+PR-URL: https://github.com/joyent/node/pull/9043
+Reviewed-by: Trevor Norris <trev.norris at gmail.com>
+Reviewed-By: Timothy J Fontaine <tjfontaine at gmail.com>
+---
+ src/log-utils.cc | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/src/log-utils.cc b/src/log-utils.cc
+index 5e607da..622cc51 100644
+--- a/src/log-utils.cc
++++ b/src/log-utils.cc
+@@ -29,6 +29,7 @@
+ 
+ #include "log-utils.h"
+ #include "string-stream.h"
++#include "version.h"
+ 
+ namespace v8 {
+ namespace internal {
+@@ -136,6 +137,14 @@ void Log::Initialize() {
+       }
+     }
+   }
++
++  if (output_handle_ != NULL) {
++    LogMessageBuilder msg(logger_);
++    msg.Append("v8-version,%d,%d,%d,%d,%d\n", Version::GetMajor(),
++               Version::GetMinor(), Version::GetBuild(), Version::GetPatch(),
++               Version::IsCandidate());
++    msg.WriteToLogFile();
++  }
+ }
+ 
+ 
diff --git a/v8-3.14.5.10-unhandled-ReferenceError.patch b/v8-3.14.5.10-unhandled-ReferenceError.patch
new file mode 100644
index 0000000..7762fa8
--- /dev/null
+++ b/v8-3.14.5.10-unhandled-ReferenceError.patch
@@ -0,0 +1,37 @@
+From 0ff51c6e063e3eea9e4d9ea68edc82d935626fc7 Mon Sep 17 00:00:00 2001
+From: Julien Gilli <julien.gilli at joyent.com>
+Date: Fri, 28 Nov 2014 15:33:35 -0800
+Subject: [PATCH] deps: backport 2ad2237 from v8 upstream
+
+Original commit message:
+
+Fix Unhandled ReferenceError in debug-debugger.js
+
+This fixes following exception in Sky on attempt to set a breakpoint
+"Unhandled: Uncaught ReferenceError: break_point is not defined"
+I think this happens in Sky but not in Chrome because Sky scripts are executed in strict mode.
+
+BUG=None
+LOG=N
+R=yangguo at chromium.org
+
+Review URL: https://codereview.chromium.org/741683002
+
+Cr-Commit-Position: refs/heads/master@{#25415}
+---
+ src/debug-debugger.js | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/debug-debugger.js b/src/debug-debugger.js
+index dfad902..a27961f 100644
+--- a/src/debug-debugger.js
++++ b/src/debug-debugger.js
+@@ -442,7 +442,7 @@ ScriptBreakPoint.prototype.set = function (script) {
+   if (position === null) return;
+ 
+   // Create a break point object and set the break point.
+-  break_point = MakeBreakPoint(position, this);
++  var break_point = MakeBreakPoint(position, this);
+   break_point.setIgnoreCount(this.ignoreCount());
+   var actual_position = %SetScriptBreakPoint(script, position, break_point);
+   if (IS_UNDEFINED(actual_position)) {
diff --git a/v8.spec b/v8.spec
index 12c8eda..45b05ec 100644
--- a/v8.spec
+++ b/v8.spec
@@ -23,7 +23,7 @@
 
 Name:		v8
 Version:	%{somajor}.%{sominor}.%{sobuild}.%{sotiny}
-Release:	16%{?dist}
+Release:	17%{?dist}
 Epoch:		1
 Summary:	JavaScript Engine
 Group:		System Environment/Libraries
@@ -97,6 +97,27 @@ Patch13:    v8-3.14.5.10-CVE-2013-6668-segfault.patch
 # https://bugzilla.redhat.com/show_bug.cgi?id=1141483
 Patch14:    v8-3.14.5.10-system-valgrind.patch
 
+# Fix issues with abort on uncaught exception
+# https://github.com/joyent/node/pull/8666
+# https://github.com/joyent/node/issues/8631
+# https://github.com/joyent/node/issues/8630
+Patch15:    v8-3.14.5.10-abort-uncaught-exception.patch
+
+# Fix unhandled ReferenceError in debug-debugger.js
+# https://github.com/joyent/node/commit/0ff51c6e063e3eea9e4d9ea68edc82d935626fc7
+# https://codereview.chromium.org/741683002
+Patch16:    v8-3.14.5.10-unhandled-ReferenceError.patch
+
+# Don't busy loop in CPU profiler thread
+# https://github.com/joyent/node/pull/8789
+Patch17:    v8-3.14.5.10-busy-loop.patch
+
+# Log V8 version in profiler log file
+# (needed for compatibility with profiler tools)
+# https://github.com/joyent/node/pull/9043
+# https://codereview.chromium.org/806143002
+Patch18:    v8-3.14.5.10-profiler-log.patch
+
 %description
 V8 is Google's open source JavaScript engine. V8 is written in C++ and is used 
 in Google Chrome, the open source browser from Google. V8 implements ECMAScript 
@@ -126,6 +147,10 @@ Development headers and libraries for v8.
 %patch12 -p1
 %patch13 -p1
 %patch14 -p1 -b .system-valgrind
+%patch15 -p1 -b .abort-uncaught-exception
+%patch16 -p1 -b .unhandled-ReferenceError
+%patch17 -p1 -b .busy-loop
+%patch18 -p1 -b .profiler-log
 
 # Do not need this lying about.
 rm -rf src/third_party/valgrind
@@ -293,6 +318,9 @@ rm -rf %{buildroot}
 %{python_sitelib}/j*.py*
 
 %changelog
+* Thu Feb 19 2015 T.C. Hollingsworth <tchollingsworth at gmail.com> - 1:3.14.5.10-17
+- backports for nodejs 0.10.36
+
 * Mon Jan 26 2015 David Tardon <dtardon at redhat.com> - 1:3.14.5.10-16
 - rebuild for ICU 54.1
 


More information about the scm-commits mailing list