From 95d5ce39dbaa4048c6d4b5207278555b4e22e2ee Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 24 Oct 2014 14:16:51 -0400 Subject: [PATCH] deps: apply floating irhydra patch to v8 Reviewed-By: Fedor Indutny PR-URL: #8476 Port 270e998c90323785ef5da32acc247b2963afd0b8 to deps/v8ppc --- deps/v8ppc/src/codegen.cc | 2 +- deps/v8ppc/src/hydrogen.cc | 2 +- deps/v8ppc/src/objects.cc | 5 ++++- deps/v8ppc/src/ostreams.cc | 17 ++++++++++++++--- deps/v8ppc/src/ostreams.h | 15 ++++++++++++++- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/deps/v8ppc/src/codegen.cc b/deps/v8ppc/src/codegen.cc index af35d052e704..c45c3f180600 100644 --- a/deps/v8ppc/src/codegen.cc +++ b/deps/v8ppc/src/codegen.cc @@ -204,7 +204,7 @@ void CodeGenerator::PrintCode(Handle 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"; diff --git a/deps/v8ppc/src/hydrogen.cc b/deps/v8ppc/src/hydrogen.cc index 551c5e5583a4..ca6e549d8925 100644 --- a/deps/v8ppc/src/hydrogen.cc +++ b/deps/v8ppc/src/hydrogen.cc @@ -3500,7 +3500,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()); } } } diff --git a/deps/v8ppc/src/objects.cc b/deps/v8ppc/src/objects.cc index 2fe60c541b24..6ab4cf1c59fe 100644 --- a/deps/v8ppc/src/objects.cc +++ b/deps/v8ppc/src/objects.cc @@ -11424,7 +11424,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) { diff --git a/deps/v8ppc/src/ostreams.cc b/deps/v8ppc/src/ostreams.cc index 0f5bec41d2b8..62304eb90812 100644 --- a/deps/v8ppc/src/ostreams.cc +++ b/deps/v8ppc/src/ostreams.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include +#include #include #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; } diff --git a/deps/v8ppc/src/ostreams.h b/deps/v8ppc/src/ostreams.h index f70b6de230d4..08f53c52ac32 100644 --- a/deps/v8ppc/src/ostreams.h +++ b/deps/v8ppc/src/ostreams.h @@ -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