Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (189129 => 189130)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2015-08-28 22:58:48 UTC (rev 189130)
@@ -63,6 +63,7 @@
assembler/MacroAssembler.cpp
assembler/MacroAssemblerARM.cpp
assembler/MacroAssemblerARMv7.cpp
+ assembler/MacroAssemblerPrinter.cpp
assembler/MacroAssemblerX86Common.cpp
bindings/ScriptFunctionCall.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (189129 => 189130)
--- trunk/Source/_javascript_Core/ChangeLog 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,3 +1,66 @@
+2015-08-28 Mark Lam <[email protected]>
+
+ Refactor the JIT printer out of the AbstractMacroAssembler into MacroAssemblerPrinter.
+ https://bugs.webkit.org/show_bug.cgi?id=148595
+
+ Reviewed by Geoffrey Garen.
+
+ Why do this?
+ 1. MacroAssembler::print() code (except for the prototype) need no longer be parsed
+ when compiling C++ files that don't need it.
+ 2. Adding support for more printable types to MacroAssemblerPrinter::PrintArg
+ triggers recompilation of less files.
+ 3. The printing code is for most the part common between all target platforms and
+ was previously duplicated by cut-and-paste to all the varieties of MacroAssemblers
+ that support the MASM_PROBE mechanism. Now, there is only one copy in
+ MacroAssemblerPrinter.
+
+ * CMakeLists.txt:
+ * _javascript_Core.vcxproj/_javascript_Core.vcxproj:
+ * _javascript_Core.vcxproj/_javascript_Core.vcxproj.filters:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+
+ * assembler/AbstractMacroAssembler.h:
+ (JSC::AbstractMacroAssembler::ProbeContext::print): Deleted.
+ - Removed this function because it is no longer useful since we have this more
+ flexible print() functionality.
+
+ (JSC::AbstractMacroAssembler::printIndent): Deleted.
+ (JSC::AbstractMacroAssembler::printCPU): Deleted.
+ (JSC::AbstractMacroAssembler::print): Deleted.
+ (JSC::AbstractMacroAssembler::PrintArg::PrintArg): Deleted.
+ (JSC::AbstractMacroAssembler::appendPrintArg): Deleted.
+ (JSC::AbstractMacroAssembler::printInternal): Deleted.
+ (JSC::AbstractMacroAssembler::printCallback): Deleted.
+ - These got moved into MacroAssemblerPrinter.cpp.
+
+ * assembler/MacroAssembler.h:
+ * assembler/MacroAssemblerARM.cpp:
+ (JSC::MacroAssemblerARM::printCPURegisters): Deleted.
+ (JSC::MacroAssemblerARM::printRegister): Deleted.
+ * assembler/MacroAssemblerARM.h:
+ * assembler/MacroAssemblerARMv7.cpp:
+ (JSC::MacroAssemblerARMv7::printCPURegisters): Deleted.
+ (JSC::MacroAssemblerARMv7::printRegister): Deleted.
+ * assembler/MacroAssemblerARMv7.h:
+ * assembler/MacroAssemblerX86Common.cpp:
+ (JSC::MacroAssemblerX86Common::printCPURegisters): Deleted.
+ (JSC::MacroAssemblerX86Common::printRegister): Deleted.
+ * assembler/MacroAssemblerX86Common.h:
+ - Deleted a whole bunch of mostly duplicated code.
+
+ * assembler/MacroAssemblerPrinter.cpp: Added.
+ (JSC::printIndent):
+ (JSC::printCPU):
+ (JSC::printCPURegisters):
+ (JSC::printRegister):
+ (JSC::MacroAssemblerPrinter::printCallback):
+ * assembler/MacroAssemblerPrinter.h: Added.
+ (JSC::MacroAssemblerPrinter::print):
+ (JSC::MacroAssemblerPrinter::PrintArg::PrintArg):
+ (JSC::MacroAssemblerPrinter::appendPrintArg):
+ (JSC::MacroAssembler::print):
+
2015-08-28 Filip Pizlo <[email protected]>
LICM should be sound even if the CFG has changed
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj (189129 => 189130)
--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj 2015-08-28 22:58:48 UTC (rev 189130)
@@ -305,6 +305,7 @@
<ClCompile Include="..\API\OpaqueJSString.cpp" />
<ClCompile Include="..\assembler\LinkBuffer.cpp" />
<ClCompile Include="..\assembler\MacroAssembler.cpp" />
+ <ClCompile Include="..\assembler\MacroAssemblerPrinter.cpp" />
<ClCompile Include="..\assembler\MacroAssemblerX86Common.cpp" />
<ClCompile Include="..\bindings\ScriptFunctionCall.cpp" />
<ClCompile Include="..\bindings\ScriptObject.cpp" />
@@ -986,6 +987,7 @@
<ClInclude Include="..\assembler\CodeLocation.h" />
<ClInclude Include="..\assembler\LinkBuffer.h" />
<ClInclude Include="..\assembler\MacroAssembler.h" />
+ <ClInclude Include="..\assembler\MacroAssemblerPrinter.h" />
<ClInclude Include="..\assembler\MacroAssemblerX86.h" />
<ClInclude Include="..\assembler\MacroAssemblerX86Common.h" />
<ClInclude Include="..\assembler\MacroAssemblerX86_64.h" />
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters (189129 => 189130)
--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters 2015-08-28 22:58:48 UTC (rev 189130)
@@ -132,6 +132,9 @@
<ClCompile Include="..\assembler\MacroAssembler.cpp">
<Filter>assembler</Filter>
</ClCompile>
+ <ClCompile Include="..\assembler\MacroAssemblerPrinter.cpp">
+ <Filter>assembler</Filter>
+ </ClCompile>
<ClCompile Include="..\assembler\MacroAssemblerX86Common.cpp">
<Filter>assembler</Filter>
</ClCompile>
@@ -1980,6 +1983,9 @@
<ClInclude Include="..\assembler\MacroAssembler.h">
<Filter>assembler</Filter>
</ClInclude>
+ <ClInclude Include="..\assembler\MacroAssemblerPrinter.h">
+ <Filter>assembler</Filter>
+ </ClInclude>
<ClInclude Include="..\assembler\MacroAssemblerX86.h">
<Filter>assembler</Filter>
</ClInclude>
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (189129 => 189130)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1751,6 +1751,8 @@
FE5068671AE25E280009DAB7 /* DeferredSourceDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE5068661AE25E280009DAB7 /* DeferredSourceDump.cpp */; };
FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */; };
FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ FE68C6371B90DE040042BCB3 /* MacroAssemblerPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ FE68C6381B90DE0B0042BCB3 /* MacroAssemblerPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE68C6351B90DDD90042BCB3 /* MacroAssemblerPrinter.cpp */; };
FE7BA60F1A1A7CEC00F1F7B4 /* HeapVerifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE7BA60D1A1A7CEC00F1F7B4 /* HeapVerifier.cpp */; };
FE7BA6101A1A7CEC00F1F7B4 /* HeapVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = FE7BA60E1A1A7CEC00F1F7B4 /* HeapVerifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3643,6 +3645,8 @@
FE5068661AE25E280009DAB7 /* DeferredSourceDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeferredSourceDump.cpp; sourceTree = "<group>"; };
FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMEntryScope.cpp; sourceTree = "<group>"; };
FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMEntryScope.h; sourceTree = "<group>"; };
+ FE68C6351B90DDD90042BCB3 /* MacroAssemblerPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerPrinter.cpp; sourceTree = "<group>"; };
+ FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerPrinter.h; sourceTree = "<group>"; };
FE7BA60D1A1A7CEC00F1F7B4 /* HeapVerifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapVerifier.cpp; sourceTree = "<group>"; };
FE7BA60E1A1A7CEC00F1F7B4 /* HeapVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapVerifier.h; sourceTree = "<group>"; };
FE90BB3A1B7CF64E006B3F03 /* VMInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInlines.h; sourceTree = "<group>"; };
@@ -5469,6 +5473,8 @@
86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */,
863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */,
86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */,
+ FE68C6351B90DDD90042BCB3 /* MacroAssemblerPrinter.cpp */,
+ FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */,
86AE64A6135E5E1C00963012 /* MacroAssemblerSH4.h */,
860161E00F3A83C100F84710 /* MacroAssemblerX86.h */,
860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */,
@@ -6139,6 +6145,7 @@
0F2B9CED19D0BA7D00B1D1B5 /* DFGPromotedHeapLocation.h in Headers */,
A704D90717A0BAA8006BA554 /* DFGMergeMode.h in Headers */,
0FB17663196B8F9E0091052A /* DFGPureValue.h in Headers */,
+ FE68C6371B90DE040042BCB3 /* MacroAssemblerPrinter.h in Headers */,
0F2BDC451522801B00CD8910 /* DFGMinifiedGraph.h in Headers */,
0F2E892D16D02BAF009E4FD2 /* DFGMinifiedID.h in Headers */,
0F2BDC461522802000CD8910 /* DFGMinifiedNode.h in Headers */,
@@ -7967,6 +7974,7 @@
E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */,
FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */,
FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */,
+ FE68C6381B90DE0B0042BCB3 /* MacroAssemblerPrinter.cpp in Sources */,
7B98D1361B60CD5F0023B1A4 /* JSWASMModule.cpp in Sources */,
0F919D2515853CE0004A4E7D /* Watchpoint.cpp in Sources */,
1ACF7377171CA6FB00C9BB1E /* Weak.cpp in Sources */,
Modified: trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h 2015-08-28 22:58:48 UTC (rev 189130)
@@ -908,99 +908,8 @@
void* arg1;
void* arg2;
CPUState cpu;
-
- void print(int indentation = 0)
- {
- #define INDENT MacroAssemblerType::printIndent(indentation)
-
- INDENT, dataLogF("ProbeContext %p {\n", this);
- indentation++;
- {
- INDENT, dataLogF("probeFunction: %p\n", probeFunction);
- INDENT, dataLogF("arg1: %p %llu\n", arg1, reinterpret_cast<int64_t>(arg1));
- INDENT, dataLogF("arg2: %p %llu\n", arg2, reinterpret_cast<int64_t>(arg2));
- MacroAssemblerType::printCPU(cpu, indentation);
- }
- indentation--;
- INDENT, dataLog("}\n");
-
- #undef INDENT
- }
};
- static void printIndent(int indentation)
- {
- for (; indentation > 0; indentation--)
- dataLog(" ");
- }
-
- static void printCPU(CPUState& cpu, int indentation = 0)
- {
- #define INDENT printIndent(indentation)
-
- INDENT, dataLog("cpu: {\n");
- MacroAssemblerType::printCPURegisters(cpu, indentation + 1);
- INDENT, dataLog("}\n");
-
- #undef INDENT
- }
-
- // This is a marker type only used with print(). See print() below for details.
- struct AllRegisters { };
-
- // Emits code which will print debugging info at runtime. The type of values that
- // can be printed is encapsulated in the PrintArg struct below. Here are some
- // examples:
- //
- // print("Hello world\n"); // Emits code to print the string.
- //
- // CodeBlock* cb = ...;
- // print(cb); // Emits code to print the pointer value.
- //
- // RegisterID regID = ...;
- // print(regID); // Emits code to print the register value (not the id).
- //
- // // Emits code to print all registers. Unlike other items, this prints
- // // multiple lines as follows:
- // // cpu {
- // // eax: 0x123456789
- // // ebx: 0x000000abc
- // // ...
- // // }
- // print(AllRegisters());
- //
- // // Print multiple things at once. This incurs the probe overhead only once
- // // to print all the items.
- // print("cb:", cb, " regID:", regID, " cpu:\n", AllRegisters());
-
- template<typename... Arguments>
- void print(Arguments... args)
- {
- printInternal(static_cast<MacroAssemblerType*>(this), args...);
- }
-
- // This function will be called by printCPU() to print the contents of the
- // target specific registers which are saved away in the CPUState struct.
- // printCPURegisters() should make use of printIndentation() to print the
- // registers with the appropriate amount of indentation.
- //
- // Note: printCPURegisters() should be implemented by the target specific
- // MacroAssembler. This prototype is only provided here to document the
- // interface.
-
- static void printCPURegisters(CPUState&, int indentation = 0);
-
- // This function will be called by print() to print the contents of a
- // specific register (from the CPUState) in line with other items in the
- // print stream. Hence, no indentation is needed.
- //
- // Note: printRegister() should be implemented by the target specific
- // MacroAssembler. These prototypes are only provided here to document their
- // interface.
-
- static void printRegister(CPUState&, RegisterID);
- static void printRegister(CPUState&, FPRegisterID);
-
// This function emits code to preserve the CPUState (e.g. registers),
// call a user supplied probe function, and restore the CPUState before
// continuing with other JIT generated code.
@@ -1186,139 +1095,6 @@
private:
-#if ENABLE(MASM_PROBE)
-
- struct PrintArg {
-
- enum class Type {
- AllRegisters,
- RegisterID,
- FPRegisterID,
- ConstCharPtr,
- ConstVoidPtr,
- IntptrValue,
- UintptrValue,
- };
-
- PrintArg(AllRegisters&)
- : type(Type::AllRegisters)
- {
- }
-
- PrintArg(RegisterID regID)
- : type(Type::RegisterID)
- {
- u.gpRegisterID = regID;
- }
-
- PrintArg(FPRegisterID regID)
- : type(Type::FPRegisterID)
- {
- u.fpRegisterID = regID;
- }
-
- PrintArg(const char* ptr)
- : type(Type::ConstCharPtr)
- {
- u.constCharPtr = ptr;
- }
-
- PrintArg(const void* ptr)
- : type(Type::ConstVoidPtr)
- {
- u.constVoidPtr = ptr;
- }
-
- PrintArg(int value)
- : type(Type::IntptrValue)
- {
- u.intptrValue = value;
- }
-
- PrintArg(unsigned value)
- : type(Type::UintptrValue)
- {
- u.intptrValue = value;
- }
-
- PrintArg(intptr_t value)
- : type(Type::IntptrValue)
- {
- u.intptrValue = value;
- }
-
- PrintArg(uintptr_t value)
- : type(Type::UintptrValue)
- {
- u.uintptrValue = value;
- }
-
- Type type;
- union {
- RegisterID gpRegisterID;
- FPRegisterID fpRegisterID;
- const char* constCharPtr;
- const void* constVoidPtr;
- intptr_t intptrValue;
- uintptr_t uintptrValue;
- } u;
- };
-
- typedef Vector<PrintArg> PrintArgsList;
-
- template<typename FirstArg, typename... Arguments>
- static void appendPrintArg(PrintArgsList* argsList, FirstArg& firstArg, Arguments... otherArgs)
- {
- argsList->append(PrintArg(firstArg));
- appendPrintArg(argsList, otherArgs...);
- }
-
- static void appendPrintArg(PrintArgsList*) { }
-
-
- template<typename... Arguments>
- static void printInternal(MacroAssemblerType* masm, Arguments... args)
- {
- auto argsList = std::make_unique<PrintArgsList>();
- appendPrintArg(argsList.get(), args...);
- masm->probe(printCallback, argsList.release());
- }
-
- static void printCallback(ProbeContext* context)
- {
- typedef PrintArg Arg;
- PrintArgsList& argsList =
- *reinterpret_cast<PrintArgsList*>(context->arg1);
- for (size_t i = 0; i < argsList.size(); i++) {
- auto& arg = argsList[i];
- switch (arg.type) {
- case Arg::Type::AllRegisters:
- MacroAssemblerType::printCPU(context->cpu);
- break;
- case Arg::Type::RegisterID:
- MacroAssemblerType::printRegister(context->cpu, arg.u.gpRegisterID);
- break;
- case Arg::Type::FPRegisterID:
- MacroAssemblerType::printRegister(context->cpu, arg.u.fpRegisterID);
- break;
- case Arg::Type::ConstCharPtr:
- dataLog(arg.u.constCharPtr);
- break;
- case Arg::Type::ConstVoidPtr:
- dataLogF("%p", arg.u.constVoidPtr);
- break;
- case Arg::Type::IntptrValue:
- dataLog(arg.u.intptrValue);
- break;
- case Arg::Type::UintptrValue:
- dataLog(arg.u.uintptrValue);
- break;
- }
- }
- }
-
-#endif // ENABLE(MASM_PROBE)
-
}; // class AbstractMacroAssembler
} // namespace JSC
Modified: trunk/Source/_javascript_Core/assembler/MacroAssembler.h (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssembler.h 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssembler.h 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1583,6 +1583,13 @@
{
urshift32(src, trustedImm32ForShift(amount), dest);
}
+
+#if ENABLE(MASM_PROBE)
+ // Let's you print from your JIT generated code.
+ // See comments in MacroAssemblerPrinter.h for examples of how to use this.
+ template<typename... Arguments>
+ void print(Arguments... args);
+#endif
};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM.cpp (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM.cpp 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM.cpp 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014 Apple Inc.
+ * Copyright (C) 2013-2015 Apple Inc.
* Copyright (C) 2009 University of Szeged
* All rights reserved.
*
@@ -97,51 +97,6 @@
#if ENABLE(MASM_PROBE)
-#define INDENT printIndent(indentation)
-
-void MacroAssemblerARM::printCPURegisters(CPUState& cpu, int indentation)
-{
- #define PRINT_GPREGISTER(_type, _regName) { \
- int32_t value = reinterpret_cast<int32_t>(cpu._regName); \
- INDENT, dataLogF("%5s: 0x%08x %d\n", #_regName, value, value) ; \
- }
- FOR_EACH_CPU_GPREGISTER(PRINT_GPREGISTER)
- FOR_EACH_CPU_SPECIAL_REGISTER(PRINT_GPREGISTER)
- #undef PRINT_GPREGISTER
-
- #define PRINT_FPREGISTER(_type, _regName) { \
- uint64_t* u = reinterpret_cast<uint64_t*>(&cpu._regName); \
- double* d = reinterpret_cast<double*>(&cpu._regName); \
- INDENT, dataLogF("%5s: 0x%016llx %.13g\n", #_regName, *u, *d); \
- }
- FOR_EACH_CPU_FPREGISTER(PRINT_FPREGISTER)
- #undef PRINT_FPREGISTER
-}
-
-#undef INDENT
-
-void MacroAssemblerARM::printRegister(MacroAssemblerARM::CPUState& cpu, RegisterID regID)
-{
- const char* name = CPUState::registerName(regID);
- union {
- void* voidPtr;
- intptr_t intptrValue;
- } u;
- u.voidPtr = cpu.registerValue(regID);
- dataLogF("%s:<%p %ld>", name, u.voidPtr, u.intptrValue);
-}
-
-void MacroAssemblerARM::printRegister(MacroAssemblerARM::CPUState& cpu, FPRegisterID regID)
-{
- const char* name = CPUState::registerName(regID);
- union {
- double doubleValue;
- uint64_t uint64Value;
- } u;
- u.doubleValue = cpu.registerValue(regID);
- dataLogF("%s:<0x%016llx %.13g>", name, u.uint64Value, u.doubleValue);
-}
-
extern "C" void ctiMasmProbeTrampoline();
// For details on "What code is emitted for the probe?" and "What values are in
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM.h (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM.h 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM.h 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2013, 2014 Apple Inc.
+ * Copyright (C) 2008, 2013-2015 Apple Inc.
* Copyright (C) 2009, 2010 University of Szeged
* All rights reserved.
*
@@ -1433,11 +1433,6 @@
}
#if ENABLE(MASM_PROBE)
- // Methods required by the MASM_PROBE mechanism as defined in
- // AbstractMacroAssembler.h.
- static void printCPURegisters(CPUState&, int indentation = 0);
- static void printRegister(CPUState&, RegisterID);
- static void printRegister(CPUState&, FPRegisterID);
void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0);
#endif // ENABLE(MASM_PROBE)
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.cpp (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.cpp 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.cpp 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,51 +32,6 @@
#if ENABLE(MASM_PROBE)
-#define INDENT printIndent(indentation)
-
-void MacroAssemblerARMv7::printCPURegisters(CPUState& cpu, int indentation)
-{
- #define PRINT_GPREGISTER(_type, _regName) { \
- int32_t value = reinterpret_cast<int32_t>(cpu._regName); \
- INDENT, dataLogF("%5s: 0x%08x %d\n", #_regName, value, value) ; \
- }
- FOR_EACH_CPU_GPREGISTER(PRINT_GPREGISTER)
- FOR_EACH_CPU_SPECIAL_REGISTER(PRINT_GPREGISTER)
- #undef PRINT_GPREGISTER
-
- #define PRINT_FPREGISTER(_type, _regName) { \
- uint64_t* u = reinterpret_cast<uint64_t*>(&cpu._regName); \
- double* d = reinterpret_cast<double*>(&cpu._regName); \
- INDENT, dataLogF("%5s: 0x%016llx %.13g\n", #_regName, *u, *d); \
- }
- FOR_EACH_CPU_FPREGISTER(PRINT_FPREGISTER)
- #undef PRINT_FPREGISTER
-}
-
-#undef INDENT
-
-void MacroAssemblerARMv7::printRegister(MacroAssemblerARMv7::CPUState& cpu, RegisterID regID)
-{
- const char* name = CPUState::registerName(regID);
- union {
- void* voidPtr;
- intptr_t intptrValue;
- } u;
- u.voidPtr = cpu.registerValue(regID);
- dataLogF("%s:<%p %ld>", name, u.voidPtr, u.intptrValue);
-}
-
-void MacroAssemblerARMv7::printRegister(MacroAssemblerARMv7::CPUState& cpu, FPRegisterID regID)
-{
- const char* name = CPUState::registerName(regID);
- union {
- double doubleValue;
- uint64_t uint64Value;
- } u;
- u.doubleValue = cpu.registerValue(regID);
- dataLogF("%s:<0x%016llx %.13g>", name, u.uint64Value, u.doubleValue);
-}
-
extern "C" void ctiMasmProbeTrampoline();
// For details on "What code is emitted for the probe?" and "What values are in
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2010, 2014-2015 Apple Inc. All rights reserved.
* Copyright (C) 2010 University of Szeged
*
* Redistribution and use in source and binary forms, with or without
@@ -1902,11 +1902,6 @@
}
#if ENABLE(MASM_PROBE)
- // Methods required by the MASM_PROBE mechanism as defined in
- // AbstractMacroAssembler.h.
- static void printCPURegisters(CPUState&, int indentation = 0);
- static void printRegister(CPUState&, RegisterID);
- static void printRegister(CPUState&, FPRegisterID);
void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0);
#endif // ENABLE(MASM_PROBE)
Added: trunk/Source/_javascript_Core/assembler/MacroAssemblerPrinter.cpp (0 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerPrinter.cpp (rev 0)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerPrinter.cpp 2015-08-28 22:58:48 UTC (rev 189130)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MacroAssemblerPrinter.h"
+
+#if ENABLE(MASM_PROBE)
+
+#include "MacroAssembler.h"
+
+namespace JSC {
+
+using CPUState = MacroAssembler::CPUState;
+using ProbeContext = MacroAssembler::ProbeContext;
+using RegisterID = MacroAssembler::RegisterID;
+using FPRegisterID = MacroAssembler::FPRegisterID;
+
+// These printers will print a block of information. That block may be
+// indented with the specified indentation.
+void printCPU(CPUState&, int indentation = 0);
+void printCPURegisters(CPUState&, int indentation = 0);
+
+// These printers will print the specified information in line in the
+// print stream. Hence, no indentation will be applied.
+void printRegister(CPUState&, RegisterID);
+void printRegister(CPUState&, FPRegisterID);
+
+static void printIndent(int indentation)
+{
+ for (; indentation > 0; indentation--)
+ dataLog(" ");
+}
+
+#define INDENT printIndent(indentation)
+
+void printCPU(CPUState& cpu, int indentation)
+{
+ INDENT, dataLog("cpu: {\n");
+ printCPURegisters(cpu, indentation + 1);
+ INDENT, dataLog("}\n");
+}
+
+void printCPURegisters(CPUState& cpu, int indentation)
+{
+#if USE(JSVALUE32_64)
+ #define INTPTR_HEX_VALUE_FORMAT "0x%08lx"
+#else
+ #define INTPTR_HEX_VALUE_FORMAT "0x%016lx"
+#endif
+
+ #define PRINT_GPREGISTER(_type, _regName) { \
+ intptr_t value = reinterpret_cast<intptr_t>(cpu._regName); \
+ INDENT, dataLogF("%6s: " INTPTR_HEX_VALUE_FORMAT " %ld\n", #_regName, value, value) ; \
+ }
+ FOR_EACH_CPU_GPREGISTER(PRINT_GPREGISTER)
+ FOR_EACH_CPU_SPECIAL_REGISTER(PRINT_GPREGISTER)
+ #undef PRINT_GPREGISTER
+ #undef INTPTR_HEX_VALUE_FORMAT
+
+ #define PRINT_FPREGISTER(_type, _regName) { \
+ uint64_t* u = reinterpret_cast<uint64_t*>(&cpu._regName); \
+ double* d = reinterpret_cast<double*>(&cpu._regName); \
+ INDENT, dataLogF("%6s: 0x%016llx %.13g\n", #_regName, *u, *d); \
+ }
+ FOR_EACH_CPU_FPREGISTER(PRINT_FPREGISTER)
+ #undef PRINT_FPREGISTER
+}
+
+void printRegister(CPUState& cpu, RegisterID regID)
+{
+ const char* name = CPUState::registerName(regID);
+ union {
+ void* voidPtr;
+ intptr_t intptrValue;
+ } u;
+ u.voidPtr = cpu.registerValue(regID);
+ dataLogF("%s:<%p %ld>", name, u.voidPtr, u.intptrValue);
+}
+
+void printRegister(CPUState& cpu, FPRegisterID regID)
+{
+ const char* name = CPUState::registerName(regID);
+ union {
+ double doubleValue;
+ uint64_t uint64Value;
+ } u;
+ u.doubleValue = cpu.registerValue(regID);
+ dataLogF("%s:<0x%016llx %.13g>", name, u.uint64Value, u.doubleValue);
+}
+
+void MacroAssemblerPrinter::printCallback(ProbeContext* context)
+{
+ typedef PrintArg Arg;
+ PrintArgsList& argsList =
+ *reinterpret_cast<PrintArgsList*>(context->arg1);
+ for (size_t i = 0; i < argsList.size(); i++) {
+ auto& arg = argsList[i];
+ switch (arg.type) {
+ case Arg::Type::AllRegisters:
+ printCPU(context->cpu, 1);
+ break;
+ case Arg::Type::RegisterID:
+ printRegister(context->cpu, arg.u.gpRegisterID);
+ break;
+ case Arg::Type::FPRegisterID:
+ printRegister(context->cpu, arg.u.fpRegisterID);
+ break;
+ case Arg::Type::ConstCharPtr:
+ dataLog(arg.u.constCharPtr);
+ break;
+ case Arg::Type::ConstVoidPtr:
+ dataLogF("%p", arg.u.constVoidPtr);
+ break;
+ case Arg::Type::IntptrValue:
+ dataLog(arg.u.intptrValue);
+ break;
+ case Arg::Type::UintptrValue:
+ dataLog(arg.u.uintptrValue);
+ break;
+ }
+ }
+}
+
+} // namespace JSC
+
+#endif // ENABLE(MASM_PROBE)
Added: trunk/Source/_javascript_Core/assembler/MacroAssemblerPrinter.h (0 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerPrinter.h (rev 0)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerPrinter.h 2015-08-28 22:58:48 UTC (rev 189130)
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MacroAssemblerPrinter_h
+#define MacroAssemblerPrinter_h
+
+#if ENABLE(MASM_PROBE)
+
+#include "MacroAssembler.h"
+
+namespace JSC {
+
+// What is MacroAssembler::print()?
+// ===============================
+// The MacroAsssembler::print() makes it easy to add print logging
+// from JIT compiled code, and can be used to print all types of values
+// at runtime e.g. CPU register values being operated on by the compiled
+// code.
+//
+// print() is built on top of MacroAsssembler::probe(), and hence
+// inserting logging in JIT compiled code will not perturb register values.
+// The only register value that is perturbed is the PC (program counter)
+// since there is now more compiled code to do the printing.
+//
+// How to use the MacroAssembler print()?
+// =====================================
+// 1. #include "MacroAssemblerPrinter.h" in the JIT file where you want to use print().
+//
+// 2. Add print() calls like these in your JIT code:
+//
+// jit.print("Hello world\n"); // Emits code to print the string.
+//
+// CodeBlock* cb = ...;
+// jit.print(cb, "\n"); // Emits code to print the pointer value.
+//
+// RegisterID regID = ...;
+// jit.print(regID, "\n"); // Emits code to print the register value (not the id).
+//
+// // Emits code to print all registers. Unlike other items, this prints
+// // multiple lines as follows:
+// // cpu {
+// // eax: 0x123456789
+// // ebx: 0x000000abc
+// // ...
+// // }
+// jit.print(AllRegisters());
+//
+// // Print multiple things at once. This incurs the probe overhead only once
+// // to print all the items.
+// jit.print("cb:", cb, " regID:", regID, " cpu:\n", AllRegisters());
+//
+// The type of values that can be printed is encapsulated in the PrintArg struct below.
+//
+// Note: print() does not automatically insert a '\n' at the end of the line.
+// If you want a '\n', you'll have to add it explicitly (as in the examples above).
+
+
+// This is a marker type only used with MacroAssemblerPrinter::print().
+// See MacroAssemblerPrinter::print() below for details.
+struct AllRegisters { };
+
+class MacroAssemblerPrinter {
+ using CPUState = MacroAssembler::CPUState;
+ using ProbeContext = MacroAssembler::ProbeContext;
+ using RegisterID = MacroAssembler::RegisterID;
+ using FPRegisterID = MacroAssembler::FPRegisterID;
+
+public:
+ template<typename... Arguments>
+ static void print(MacroAssembler* masm, Arguments... args)
+ {
+ auto argsList = std::make_unique<PrintArgsList>();
+ appendPrintArg(argsList.get(), args...);
+ masm->probe(printCallback, argsList.release());
+ }
+
+private:
+ struct PrintArg {
+
+ enum class Type {
+ AllRegisters,
+ RegisterID,
+ FPRegisterID,
+ ConstCharPtr,
+ ConstVoidPtr,
+ IntptrValue,
+ UintptrValue,
+ };
+
+ PrintArg(AllRegisters&)
+ : type(Type::AllRegisters)
+ {
+ }
+
+ PrintArg(RegisterID regID)
+ : type(Type::RegisterID)
+ {
+ u.gpRegisterID = regID;
+ }
+
+ PrintArg(FPRegisterID regID)
+ : type(Type::FPRegisterID)
+ {
+ u.fpRegisterID = regID;
+ }
+
+ PrintArg(const char* ptr)
+ : type(Type::ConstCharPtr)
+ {
+ u.constCharPtr = ptr;
+ }
+
+ PrintArg(const void* ptr)
+ : type(Type::ConstVoidPtr)
+ {
+ u.constVoidPtr = ptr;
+ }
+
+ PrintArg(int value)
+ : type(Type::IntptrValue)
+ {
+ u.intptrValue = value;
+ }
+
+ PrintArg(unsigned value)
+ : type(Type::UintptrValue)
+ {
+ u.intptrValue = value;
+ }
+
+ PrintArg(intptr_t value)
+ : type(Type::IntptrValue)
+ {
+ u.intptrValue = value;
+ }
+
+ PrintArg(uintptr_t value)
+ : type(Type::UintptrValue)
+ {
+ u.uintptrValue = value;
+ }
+
+ Type type;
+ union {
+ RegisterID gpRegisterID;
+ FPRegisterID fpRegisterID;
+ const char* constCharPtr;
+ const void* constVoidPtr;
+ intptr_t intptrValue;
+ uintptr_t uintptrValue;
+ } u;
+ };
+
+ typedef Vector<PrintArg> PrintArgsList;
+
+ template<typename FirstArg, typename... Arguments>
+ static void appendPrintArg(PrintArgsList* argsList, FirstArg& firstArg, Arguments... otherArgs)
+ {
+ argsList->append(PrintArg(firstArg));
+ appendPrintArg(argsList, otherArgs...);
+ }
+
+ static void appendPrintArg(PrintArgsList*) { }
+
+private:
+ static void printCallback(ProbeContext*);
+};
+
+template<typename... Arguments>
+void MacroAssembler::print(Arguments... args)
+{
+ MacroAssemblerPrinter::print(this, args...);
+}
+
+} // namespace JSC
+
+#endif // ENABLE(MASM_PROBE)
+
+#endif // MacroAssemblerPrinter_h
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.cpp (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.cpp 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.cpp 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,58 +32,6 @@
#if ENABLE(MASM_PROBE)
-#define INDENT printIndent(indentation)
-
-void MacroAssemblerX86Common::printCPURegisters(MacroAssemblerX86Common::CPUState& cpu, int indentation)
-{
-#if CPU(X86)
- #define PRINT_GPREGISTER(_type, _regName) { \
- int32_t value = reinterpret_cast<int32_t>(cpu._regName); \
- INDENT, dataLogF("%6s: 0x%08x %d\n", #_regName, value, value) ; \
- }
-#elif CPU(X86_64)
- #define PRINT_GPREGISTER(_type, _regName) { \
- int64_t value = reinterpret_cast<int64_t>(cpu._regName); \
- INDENT, dataLogF("%6s: 0x%016llx %lld\n", #_regName, value, value) ; \
- }
-#endif
- FOR_EACH_CPU_GPREGISTER(PRINT_GPREGISTER)
- FOR_EACH_CPU_SPECIAL_REGISTER(PRINT_GPREGISTER)
- #undef PRINT_GPREGISTER
-
- #define PRINT_FPREGISTER(_type, _regName) { \
- uint64_t* u = reinterpret_cast<uint64_t*>(&cpu._regName); \
- double* d = reinterpret_cast<double*>(&cpu._regName); \
- INDENT, dataLogF("%6s: 0x%016llx %.13g\n", #_regName, *u, *d); \
- }
- FOR_EACH_CPU_FPREGISTER(PRINT_FPREGISTER)
- #undef PRINT_FPREGISTER
-}
-
-#undef INDENT
-
-void MacroAssemblerX86Common::printRegister(MacroAssemblerX86Common::CPUState& cpu, RegisterID regID)
-{
- const char* name = CPUState::registerName(regID);
- union {
- void* voidPtr;
- intptr_t intptrValue;
- } u;
- u.voidPtr = cpu.registerValue(regID);
- dataLogF("%s:<%p %ld>", name, u.voidPtr, u.intptrValue);
-}
-
-void MacroAssemblerX86Common::printRegister(MacroAssemblerX86Common::CPUState& cpu, FPRegisterID regID)
-{
- const char* name = CPUState::registerName(regID);
- union {
- double doubleValue;
- uint64_t uint64Value;
- } u;
- u.doubleValue = cpu.registerValue(regID);
- dataLogF("%s:<0x%016llx %.13g>", name, u.uint64Value, u.doubleValue);
-}
-
extern "C" void ctiMasmProbeTrampoline();
// What code is emitted for the probe?
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h (189129 => 189130)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h 2015-08-28 22:57:01 UTC (rev 189129)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h 2015-08-28 22:58:48 UTC (rev 189130)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2014-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -1491,11 +1491,6 @@
}
#if ENABLE(MASM_PROBE)
- // Methods required by the MASM_PROBE mechanism as defined in
- // AbstractMacroAssembler.h.
- static void printCPURegisters(CPUState&, int indentation = 0);
- static void printRegister(CPUState&, RegisterID);
- static void printRegister(CPUState&, FPRegisterID);
void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0);
#endif // ENABLE(MASM_PROBE)