deps: apply floating irhydra patch to v8
authorFedor Indutny <fedor@indutny.com>
Thu, 2 Oct 2014 04:16:24 +0000 (08:16 +0400)
committerFedor Indutny <fedor@indutny.com>
Wed, 8 Oct 2014 11:44:40 +0000 (15:44 +0400)
Reviewed-By: Fedor Indutny <fedor@indutny.com>
PR-URL: https://github.com/joyent/node/pull/8476

deps/v8/src/codegen.cc
deps/v8/src/hydrogen.cc
deps/v8/src/objects.cc
deps/v8/src/ostreams.cc
deps/v8/src/ostreams.h

index 6b12d64..a24220d 100644 (file)
@@ -190,7 +190,7 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
             function->end_position() - function->start_position() + 1;
         for (int i = 0; i < source_len; i++) {
           if (stream.HasMore()) {
-            os << AsUC16(stream.GetNext());
+            os << AsReversiblyEscapedUC16(stream.GetNext());
           }
         }
         os << "\n\n";
index 3ddd7cc..63174aa 100644 (file)
@@ -3498,7 +3498,7 @@ int HGraph::TraceInlinedFunction(
               shared->end_position() - shared->start_position() + 1;
           for (int i = 0; i < source_len; i++) {
             if (stream.HasMore()) {
-              os << AsUC16(stream.GetNext());
+              os << AsReversiblyEscapedUC16(stream.GetNext());
             }
           }
         }
index 29af1d8..cfdb9cc 100644 (file)
@@ -11417,7 +11417,10 @@ void Code::Disassemble(const char* name, OStream& os) {  // NOLINT
 
   os << "Instructions (size = " << instruction_size() << ")\n";
   // TODO(svenpanne) The Disassembler should use streams, too!
-  Disassembler::Decode(stdout, this);
+  {
+    CodeTracer::Scope trace_scope(GetIsolate()->GetCodeTracer());
+    Disassembler::Decode(trace_scope.file(), this);
+  }
   os << "\n";
 
   if (kind() == FUNCTION) {
index 0f5bec4..62304eb 100644 (file)
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include <algorithm>
+#include <cctype>
 #include <cmath>
 
 #include "src/base/platform/platform.h"  // For isinf/isnan with MSVC
@@ -163,11 +164,21 @@ OFStream& OFStream::flush() {
 }
 
 
+OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) {
+  char buf[10];
+  const char* format =
+      (std::isprint(c.value) || std::isspace(c.value)) && c.value != '\\'
+          ? "%c"
+          : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
+  snprintf(buf, sizeof(buf), format, c.value);
+  return os << buf;
+}
+
+
 OStream& operator<<(OStream& os, const AsUC16& c) {
   char buf[10];
-  const char* format = (0x20 <= c.value && c.value <= 0x7F)
-                           ? "%c"
-                           : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
+  const char* format =
+      std::isprint(c.value) ? "%c" : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
   snprintf(buf, sizeof(buf), format, c.value);
   return os << buf;
 }
index f70b6de..08f53c5 100644 (file)
@@ -117,13 +117,26 @@ class OFStream: public OStream {
 };
 
 
-// A wrapper to disambiguate uint16_t and uc16.
+// Wrappers to disambiguate uint16_t and uc16.
 struct AsUC16 {
   explicit AsUC16(uint16_t v) : value(v) {}
   uint16_t value;
 };
 
 
+struct AsReversiblyEscapedUC16 {
+  explicit AsReversiblyEscapedUC16(uint16_t v) : value(v) {}
+  uint16_t value;
+};
+
+
+// Writes the given character to the output escaping everything outside of
+// printable/space ASCII range. Additionally escapes '\' making escaping
+// reversible.
+OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c);
+
+// Writes the given character to the output escaping everything outside
+// of printable ASCII range.
 OStream& operator<<(OStream& os, const AsUC16& c);
 } }  // namespace v8::internal