From facf8f705241957dfa55e5f6e72dca8419651f12 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 30 Jan 2015 16:05:55 -0800 Subject: [PATCH] Bug 1125202 - SpiderMonkey: Move AssemberBuffer spew code out of line r=h4writer --- .../jit/shared/AssemblerBuffer-x86-shared.cpp | 24 ++++++++++++++ .../jit/shared/AssemblerBuffer-x86-shared.h | 32 ++++++------------- js/src/moz.build | 1 + 3 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 js/src/jit/shared/AssemblerBuffer-x86-shared.cpp diff --git a/js/src/jit/shared/AssemblerBuffer-x86-shared.cpp b/js/src/jit/shared/AssemblerBuffer-x86-shared.cpp new file mode 100644 index 000000000000..3ef9d3ed6161 --- /dev/null +++ b/js/src/jit/shared/AssemblerBuffer-x86-shared.cpp @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sts=4 et sw=4 tw=99: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "jit/shared/AssemblerBuffer-x86-shared.h" + +#include "jsopcode.h" + +void js::jit::GenericAssembler::spew(const char *fmt, va_list va) +{ + // Buffer to hold the formatted string. Note that this may contain + // '%' characters, so do not pass it directly to printf functions. + char buf[200]; + + int i = vsnprintf(buf, sizeof(buf), fmt, va); + + if (i > -1) { + if (printer) + printer->printf("%s\n", buf); + js::jit::JitSpew(js::jit::JitSpew_Codegen, "%s", buf); + } +} diff --git a/js/src/jit/shared/AssemblerBuffer-x86-shared.h b/js/src/jit/shared/AssemblerBuffer-x86-shared.h index b583dc90807b..c9128c6efb45 100644 --- a/js/src/jit/shared/AssemblerBuffer-x86-shared.h +++ b/js/src/jit/shared/AssemblerBuffer-x86-shared.h @@ -30,17 +30,11 @@ #ifndef jit_shared_AssemblerBuffer_x86_shared_h #define jit_shared_AssemblerBuffer_x86_shared_h -#include #include #include -#include "jsfriendapi.h" -#include "jsopcode.h" -#include "jsutil.h" - #include "jit/ExecutableAllocator.h" #include "jit/JitSpewer.h" -#include "js/RootingAPI.h" // Spew formatting helpers. #define PRETTYHEX(x) (((x)<0)?"-":""),(((x)<0)?-(x):(x)) @@ -66,6 +60,9 @@ #define ADDR_o32bs(offset, base, index, scale) ADDR_obs(offset, base, index, scale) namespace js { + + class Sprinter; + namespace jit { class AssemblerBuffer { @@ -179,18 +176,15 @@ namespace jit { class GenericAssembler { - js::Sprinter *printer; + Sprinter *printer; public: - bool isOOLPath; - GenericAssembler() : printer(NULL) - , isOOLPath(false) {} - void setPrinter(js::Sprinter *sp) { + void setPrinter(Sprinter *sp) { printer = sp; } @@ -199,23 +193,15 @@ namespace jit { __attribute__ ((format (printf, 2, 3))) #endif { - if (printer || js::jit::JitSpewEnabled(js::jit::JitSpew_Codegen)) { - // Buffer to hold the formatted string. Note that this may contain - // '%' characters, so do not pass it directly to printf functions. - char buf[200]; - + if (MOZ_UNLIKELY(printer || JitSpewEnabled(JitSpew_Codegen))) { va_list va; va_start(va, fmt); - int i = vsnprintf(buf, sizeof(buf), fmt, va); + spew(fmt, va); va_end(va); - - if (i > -1) { - if (printer) - printer->printf("%s\n", buf); - js::jit::JitSpew(js::jit::JitSpew_Codegen, "%s", buf); - } } } + + MOZ_COLD void spew(const char *fmt, va_list va); }; } // namespace jit diff --git a/js/src/moz.build b/js/src/moz.build index f46ee9bc7253..e93d2eff71ad 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -322,6 +322,7 @@ if not CONFIG['ENABLE_ION']: elif CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']: UNIFIED_SOURCES += [ 'jit/shared/Assembler-x86-shared.cpp', + 'jit/shared/AssemblerBuffer-x86-shared.cpp', 'jit/shared/BaselineCompiler-x86-shared.cpp', 'jit/shared/BaselineIC-x86-shared.cpp', 'jit/shared/CodeGenerator-x86-shared.cpp',