DFG inlining should be hardened for the no-result case
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 17:46:38 +0000 (17:46 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 17:46:38 +0000 (17:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172290

Reviewed by Saam Barati.
JSTests:

* stress/array-constructor-no-result.js: Added.
(foo):
* stress/pow-no-result.js: Added.
(foo):

Source/JavaScriptCore:

Previously, if we were inlining a setter call, we might have a bad time because the setter's
result register is the invalid VirtualRegister(), and much of the intrinsic handling code
assumes that the result register is valid.

This doesn't usually cause problems because people don't usually point a setter at something
that we recognize as an intrinsic.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/air/AirAllocateRegistersAndStackByLinearScan.cpp: Fix a comment.
* dfg/DFGByteCodeParser.cpp: Make RELEASE_ASSERT give accurate stacks. I was getting an absurd stack from the assert I added in DelayedSetLocal.
(JSC::DFG::ByteCodeParser::DelayedSetLocal::DelayedSetLocal): Assert so we catch the problem sooner.
(JSC::DFG::ByteCodeParser::handleIntrinsicCall): Fix the bug.
(JSC::DFG::ByteCodeParser::handleConstantInternalFunction): Fix the bug if constant internal functions were setter-inlineable (they ain't, because the bytecode parser doesn't fold GetSetter).
* runtime/Intrinsic.cpp: Added. I needed this to debug.
(JSC::intrinsicName):
(WTF::printInternal):
* runtime/Intrinsic.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@217050 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
JSTests/stress/array-constructor-no-result.js [new file with mode: 0644]
JSTests/stress/pow-no-result.js [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackByLinearScan.cpp
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/runtime/Intrinsic.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/Intrinsic.h

index aec40e5..ad2c932 100644 (file)
@@ -1,3 +1,15 @@
+2017-05-18  Filip Pizlo  <fpizlo@apple.com>
+
+        DFG inlining should be hardened for the no-result case
+        https://bugs.webkit.org/show_bug.cgi?id=172290
+
+        Reviewed by Saam Barati.
+
+        * stress/array-constructor-no-result.js: Added.
+        (foo):
+        * stress/pow-no-result.js: Added.
+        (foo):
+
 2017-05-18  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r217031, r217032, and r217037.
diff --git a/JSTests/stress/array-constructor-no-result.js b/JSTests/stress/array-constructor-no-result.js
new file mode 100644 (file)
index 0000000..be2df9f
--- /dev/null
@@ -0,0 +1,13 @@
+var o = {};
+o.__defineSetter__("foo", Array);
+
+function foo()
+{
+    o.foo = 42;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 10000; ++i)
+    foo();
+
diff --git a/JSTests/stress/pow-no-result.js b/JSTests/stress/pow-no-result.js
new file mode 100644 (file)
index 0000000..ebe8f1f
--- /dev/null
@@ -0,0 +1,13 @@
+var o = {};
+o.__defineSetter__("foo", Math.pow);
+
+function foo()
+{
+    o.foo = 42;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 10000; ++i)
+    foo();
+
index 31d7ca3..47c1cbe 100644 (file)
@@ -753,6 +753,7 @@ set(JavaScriptCore_SOURCES
     runtime/InitializeThreading.cpp
     runtime/InspectorInstrumentationObject.cpp
     runtime/InternalFunction.cpp
+    runtime/Intrinsic.cpp
     runtime/IntlCollator.cpp
     runtime/IntlCollatorConstructor.cpp
     runtime/IntlCollatorPrototype.cpp
index 7b37334..d10c128 100644 (file)
@@ -1,3 +1,29 @@
+2017-05-18  Filip Pizlo  <fpizlo@apple.com>
+
+        DFG inlining should be hardened for the no-result case
+        https://bugs.webkit.org/show_bug.cgi?id=172290
+
+        Reviewed by Saam Barati.
+        
+        Previously, if we were inlining a setter call, we might have a bad time because the setter's
+        result register is the invalid VirtualRegister(), and much of the intrinsic handling code
+        assumes that the result register is valid.
+        
+        This doesn't usually cause problems because people don't usually point a setter at something
+        that we recognize as an intrinsic.
+        
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * b3/air/AirAllocateRegistersAndStackByLinearScan.cpp: Fix a comment.
+        * dfg/DFGByteCodeParser.cpp: Make RELEASE_ASSERT give accurate stacks. I was getting an absurd stack from the assert I added in DelayedSetLocal.
+        (JSC::DFG::ByteCodeParser::DelayedSetLocal::DelayedSetLocal): Assert so we catch the problem sooner.
+        (JSC::DFG::ByteCodeParser::handleIntrinsicCall): Fix the bug.
+        (JSC::DFG::ByteCodeParser::handleConstantInternalFunction): Fix the bug if constant internal functions were setter-inlineable (they ain't, because the bytecode parser doesn't fold GetSetter).
+        * runtime/Intrinsic.cpp: Added. I needed this to debug.
+        (JSC::intrinsicName):
+        (WTF::printInternal):
+        * runtime/Intrinsic.h:
+
 2017-05-18  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r217031, r217032, and r217037.
index 24af7af..cb589e0 100644 (file)
                0F25F1B2181635F300522F39 /* FTLSlowPathCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F25F1AB181635F300522F39 /* FTLSlowPathCall.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F25F1B3181635F300522F39 /* FTLSlowPathCallKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F25F1AC181635F300522F39 /* FTLSlowPathCallKey.cpp */; };
                0F25F1B4181635F300522F39 /* FTLSlowPathCallKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F25F1AD181635F300522F39 /* FTLSlowPathCallKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               0F275F2D1ECE079800620D47 /* Intrinsic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F275F2C1ECE079600620D47 /* Intrinsic.cpp */; };
                0F2AC5661E8A0B770001EE3F /* AirFixSpillsAfterTerminals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2AC5641E8A0B760001EE3F /* AirFixSpillsAfterTerminals.cpp */; };
                0F2AC5671E8A0B790001EE3F /* AirFixSpillsAfterTerminals.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2AC5651E8A0B760001EE3F /* AirFixSpillsAfterTerminals.h */; };
                0F2AC56A1E8A0BD30001EE3F /* AirAllocateRegistersAndStackByLinearScan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2AC5681E8A0BD10001EE3F /* AirAllocateRegistersAndStackByLinearScan.cpp */; };
                0F25F1AB181635F300522F39 /* FTLSlowPathCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLSlowPathCall.h; path = ftl/FTLSlowPathCall.h; sourceTree = "<group>"; };
                0F25F1AC181635F300522F39 /* FTLSlowPathCallKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLSlowPathCallKey.cpp; path = ftl/FTLSlowPathCallKey.cpp; sourceTree = "<group>"; };
                0F25F1AD181635F300522F39 /* FTLSlowPathCallKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLSlowPathCallKey.h; path = ftl/FTLSlowPathCallKey.h; sourceTree = "<group>"; };
+               0F275F2C1ECE079600620D47 /* Intrinsic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Intrinsic.cpp; sourceTree = "<group>"; };
                0F2AC5641E8A0B760001EE3F /* AirFixSpillsAfterTerminals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirFixSpillsAfterTerminals.cpp; path = b3/air/AirFixSpillsAfterTerminals.cpp; sourceTree = "<group>"; };
                0F2AC5651E8A0B760001EE3F /* AirFixSpillsAfterTerminals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirFixSpillsAfterTerminals.h; path = b3/air/AirFixSpillsAfterTerminals.h; sourceTree = "<group>"; };
                0F2AC5681E8A0BD10001EE3F /* AirAllocateRegistersAndStackByLinearScan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirAllocateRegistersAndStackByLinearScan.cpp; path = b3/air/AirAllocateRegistersAndStackByLinearScan.cpp; sourceTree = "<group>"; };
                                A7E5A3A61797432D00E893C0 /* CompilationResult.h */,
                                969A09220ED1E09C00F1F681 /* Completion.cpp */,
                                F5BB2BC5030F772101FCFE1D /* Completion.h */,
+                               0FDB2CE9174896C7007B3C1B /* ConcurrentJSLock.h */,
                                658824B01E5CFDF400FB7359 /* ConfigFile.cpp */,
                                658824AE1E5CFDB000FB7359 /* ConfigFile.h */,
-                               0FDB2CE9174896C7007B3C1B /* ConcurrentJSLock.h */,
                                A5B6A74C18C6DBA600F11E91 /* ConsoleClient.cpp */,
                                A53CE08918BC21C300BEDF76 /* ConsoleClient.h */,
                                A55714BC1CD8048E0004D2C6 /* ConsoleObject.cpp */,
                                14A1563010966365006FA260 /* DateInstanceCache.h */,
                                BCD203470E17135E002C7E82 /* DatePrototype.cpp */,
                                BCD203480E17135E002C7E82 /* DatePrototype.h */,
-                               534638761E71E06E00F12AC1 /* PromiseDeferredTimer.cpp */,
-                               534638741E70DDEC00F12AC1 /* PromiseDeferredTimer.h */,
                                169948EDE68D4054B01EF797 /* DefinePropertyAttributes.h */,
                                0FE0500F1AA9091100D33B33 /* DirectArguments.cpp */,
                                0FE050101AA9091100D33B33 /* DirectArguments.h */,
                                E178633F0D9BEC0000D74E75 /* InitializeThreading.h */,
                                E35E035D1B7AB43E0073AD2A /* InspectorInstrumentationObject.cpp */,
                                E35E035E1B7AB43E0073AD2A /* InspectorInstrumentationObject.h */,
+                               A7A8AF2B17ADB5F3005AB174 /* Int8Array.h */,
                                A7A8AF2C17ADB5F3005AB174 /* Int16Array.h */,
                                A7A8AF2D17ADB5F3005AB174 /* Int32Array.h */,
-                               A7A8AF2B17ADB5F3005AB174 /* Int8Array.h */,
                                BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */,
                                BC11667A0E199C05008066DD /* InternalFunction.h */,
                                A1B9E2331B4E0D6700BC7FED /* IntlCollator.cpp */,
                                A12BBFF31B044A9800664B69 /* IntlObject.cpp */,
                                A12BBFF11B044A8B00664B69 /* IntlObject.h */,
                                708EBE231CE8F35000453146 /* IntlObjectInlines.h */,
+                               0F275F2C1ECE079600620D47 /* Intrinsic.cpp */,
                                86BF642A148DB2B5004DE36A /* Intrinsic.h */,
                                8B9F6D551D5912FA001C739F /* IterationKind.h */,
                                FE4D55B71AE716CA0052E459 /* IterationStatus.h */,
                                BC756FC60E2031B200DE7D12 /* JSGlobalObjectFunctions.cpp */,
                                BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */,
                                79B819921DD25CF500DDC714 /* JSGlobalObjectInlines.h */,
+                               0F2B66C917B6B5AB00A7AE3F /* JSInt8Array.h */,
                                0F2B66CA17B6B5AB00A7AE3F /* JSInt16Array.h */,
                                0F2B66CB17B6B5AB00A7AE3F /* JSInt32Array.h */,
-                               0F2B66C917B6B5AB00A7AE3F /* JSInt8Array.h */,
                                E33F507E1B8429A400413856 /* JSInternalPromise.cpp */,
                                E33F507F1B8429A400413856 /* JSInternalPromise.h */,
                                E33F50761B84225700413856 /* JSInternalPromiseConstructor.cpp */,
                                E3EF88731B66DF23003F26CB /* JSPropertyNameIterator.h */,
                                862553CE16136AA5009F17D0 /* JSProxy.cpp */,
                                862553CF16136AA5009F17D0 /* JSProxy.h */,
+                               534638721E70D01500F12AC1 /* JSRunLoopTimer.cpp */,
+                               534638701E70CF3D00F12AC1 /* JSRunLoopTimer.h */,
                                14874AE115EBDE4A002E3587 /* JSScope.cpp */,
                                14874AE215EBDE4A002E3587 /* JSScope.h */,
                                11C197C2624848EDA84CED7F /* JSScriptFetcher.cpp */,
                                53F256E11B87E28000B4B768 /* JSTypedArrayViewPrototype.cpp */,
                                53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */,
                                6507D2970E871E4A00D7D896 /* JSTypeInfo.h */,
-                               0F2B66D417B6B5AB00A7AE3F /* JSUint16Array.h */,
-                               0F2B66D517B6B5AB00A7AE3F /* JSUint32Array.h */,
                                0F2B66D217B6B5AB00A7AE3F /* JSUint8Array.h */,
                                0F2B66D317B6B5AB00A7AE3F /* JSUint8ClampedArray.h */,
+                               0F2B66D417B6B5AB00A7AE3F /* JSUint16Array.h */,
+                               0F2B66D517B6B5AB00A7AE3F /* JSUint32Array.h */,
                                A7CA3AE117DA41AE006538AF /* JSWeakMap.cpp */,
                                A7CA3AE217DA41AE006538AF /* JSWeakMap.h */,
                                709FB8611AE335C60039D069 /* JSWeakSet.cpp */,
                                A7E2EA690FB460CF00601F06 /* LiteralParser.h */,
                                F692A8680255597D01FF60F7 /* Lookup.cpp */,
                                F692A8690255597D01FF60F7 /* Lookup.h */,
+                               28806E21155E478A93FA7B02 /* MachineContext.h */,
                                795B19951D78BE3500262FA0 /* MapBase.cpp */,
                                795B19961D78BE3500262FA0 /* MapBase.h */,
                                A700873717CBE85300C3E643 /* MapConstructor.cpp */,
                                868916A9155F285400CB2B9A /* PrivateName.h */,
                                147341DF1DC2CE9600AA29BA /* ProgramExecutable.cpp */,
                                147341D31DC02E6D00AA29BA /* ProgramExecutable.h */,
+                               534638761E71E06E00F12AC1 /* PromiseDeferredTimer.cpp */,
+                               534638741E70DDEC00F12AC1 /* PromiseDeferredTimer.h */,
                                A7FB60A3103F7DC20017A286 /* PropertyDescriptor.cpp */,
                                A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */,
                                BC95437C0EBA70FD0072B6D3 /* PropertyMapHashTable.h */,
                                0F7C39FC1C8F659500480151 /* RegExpObjectInlines.h */,
                                BCD202BF0E1706A7002C7E82 /* RegExpPrototype.cpp */,
                                BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */,
-                               534638721E70D01500F12AC1 /* JSRunLoopTimer.cpp */,
-                               534638701E70CF3D00F12AC1 /* JSRunLoopTimer.h */,
                                70B0A9D01A9B66200001306A /* RuntimeFlags.h */,
                                527773DD1AAF83AC00BDE7E8 /* RuntimeType.cpp */,
                                52C0611D1AA51E1B00B4ADBA /* RuntimeType.h */,
                                0F2D4DE019832D91007D4B19 /* TypeProfilerLog.h */,
                                0F2D4DE319832D91007D4B19 /* TypeSet.cpp */,
                                0F2D4DE419832D91007D4B19 /* TypeSet.h */,
+                               A7A8AF3017ADB5F3005AB174 /* Uint8Array.h */,
+                               A7A8AF3117ADB5F3005AB174 /* Uint8ClampedArray.h */,
                                A7A8AF3217ADB5F3005AB174 /* Uint16Array.h */,
                                866739D113BFDE710023D87C /* Uint16WithFraction.h */,
                                A7A8AF3317ADB5F3005AB174 /* Uint32Array.h */,
-                               A7A8AF3017ADB5F3005AB174 /* Uint8Array.h */,
-                               A7A8AF3117ADB5F3005AB174 /* Uint8ClampedArray.h */,
                                0FE050231AA9095600D33B33 /* VarOffset.cpp */,
                                0FE050241AA9095600D33B33 /* VarOffset.h */,
                                E18E3A570DF9278C00D90B34 /* VM.cpp */,
                                709FB8661AE335C60039D069 /* WeakSetPrototype.h */,
                                A7DCB77912E3D90500911940 /* WriteBarrier.h */,
                                C2B6D75218A33793004A9301 /* WriteBarrierInlines.h */,
-                               28806E21155E478A93FA7B02 /* MachineContext.h */,
                        );
                        path = runtime;
                        sourceTree = "<group>";
                                863C6D9C1521111A00585E4E /* YarrCanonicalizeUCS2.cpp in Sources */,
                                65FB63A41C8EA09C0020719B /* YarrCanonicalizeUnicode.cpp in Sources */,
                                86704B8412DBA33700A9FE7B /* YarrInterpreter.cpp in Sources */,
+                               0F275F2D1ECE079800620D47 /* Intrinsic.cpp in Sources */,
                                86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
                                86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
                                86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
index f7f0b6e..d39debf 100644 (file)
@@ -237,9 +237,8 @@ private:
             
             auto record = [&] (unsigned instIndex) {
                 // FIXME: This could get the register sets from somewhere else, like the
-                // liveness constraints. Except we want those constraints to be laid out like
-                // how they would have been by RegLiveness, since we want to separate the lates
-                // of one inst from the earlies of the next.
+                // liveness constraints. Except we want those constraints to separate the late
+                // actions of one instruction from the early actions of the next.
                 // https://bugs.webkit.org/show_bug.cgi?id=170850
                 const RegisterSet& regs = localCalc.live();
                 if (Inst* prev = block->get(instIndex - 1)) {
index 78a5fb7..1f20f90 100644 (file)
 
 namespace JSC { namespace DFG {
 
+namespace {
+
+NO_RETURN_DUE_TO_CRASH NEVER_INLINE void crash()
+{
+    CRASH();
+}
+
+#undef RELEASE_ASSERT
+#define RELEASE_ASSERT(assertion) do { \
+    if (UNLIKELY(!(assertion))) { \
+        WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \
+        crash(); \
+    } \
+} while (0)
+
+} // anonymous namespace
+
 static const bool verbose = false;
 
 class ConstantBufferKey {
@@ -1189,6 +1206,7 @@ private:
             , m_operand(operand)
             , m_value(value)
         {
+            RELEASE_ASSERT(operand.isValid());
         }
         
         Node* execute(ByteCodeParser* parser, SetMode setMode = NormalSet)
@@ -2146,6 +2164,18 @@ bool ByteCodeParser::handleMinMax(int resultOperand, NodeType op, int registerOf
 template<typename ChecksFunctor>
 bool ByteCodeParser::handleIntrinsicCall(Node* callee, int resultOperand, Intrinsic intrinsic, int registerOffset, int argumentCountIncludingThis, SpeculatedType prediction, const ChecksFunctor& insertChecks)
 {
+    if (Options::verboseDFGByteCodeParsing())
+        dataLog("       The intrinsic is ", intrinsic, "\n");
+    
+    // It so happens that the code below doesn't handle the invalid result case. We could fix that, but
+    // it would only benefit intrinsics called as setters, like if you do:
+    //
+    //     o.__defineSetter__("foo", Math.pow)
+    //
+    // Which is extremely amusing, but probably not worth optimizing.
+    if (!VirtualRegister(resultOperand).isValid())
+        return false;
+    
     switch (intrinsic) {
 
     // Intrinsic Functions:
@@ -3078,8 +3108,13 @@ bool ByteCodeParser::handleConstantInternalFunction(
     Node* callTargetNode, int resultOperand, InternalFunction* function, int registerOffset,
     int argumentCountIncludingThis, CodeSpecializationKind kind, SpeculatedType prediction, const ChecksFunctor& insertChecks)
 {
-    if (verbose)
+    if (Options::verboseDFGByteCodeParsing())
         dataLog("    Handling constant internal function ", JSValue(function), "\n");
+    
+    // It so happens that the code below assumes that the result operand is valid. It's extremely
+    // unlikely that the result operand would be invalid - you'd have to call this via a setter call.
+    if (!VirtualRegister(resultOperand).isValid())
+        return false;
 
     if (kind == CodeForConstruct) {
         Node* newTargetNode = get(virtualRegisterForArgument(0, registerOffset));
diff --git a/Source/JavaScriptCore/runtime/Intrinsic.cpp b/Source/JavaScriptCore/runtime/Intrinsic.cpp
new file mode 100644 (file)
index 0000000..97e02cc
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2017 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 "Intrinsic.h"
+
+#include <wtf/PrintStream.h>
+
+namespace JSC {
+
+const char* intrinsicName(Intrinsic intrinsic)
+{
+    switch (intrinsic) {
+    case NoIntrinsic:
+        return "NoIntrinsic";
+    case AbsIntrinsic:
+        return "AbsIntrinsic";
+    case ACosIntrinsic:
+        return "ACosIntrinsic";
+    case ASinIntrinsic:
+        return "ASinIntrinsic";
+    case ATanIntrinsic:
+        return "ATanIntrinsic";
+    case ACoshIntrinsic:
+        return "ACoshIntrinsic";
+    case ASinhIntrinsic:
+        return "ASinhIntrinsic";
+    case ATanhIntrinsic:
+        return "ATanhIntrinsic";
+    case MinIntrinsic:
+        return "MinIntrinsic";
+    case MaxIntrinsic:
+        return "MaxIntrinsic";
+    case SqrtIntrinsic:
+        return "SqrtIntrinsic";
+    case SinIntrinsic:
+        return "SinIntrinsic";
+    case CbrtIntrinsic:
+        return "CbrtIntrinsic";
+    case Clz32Intrinsic:
+        return "Clz32Intrinsic";
+    case CosIntrinsic:
+        return "CosIntrinsic";
+    case TanIntrinsic:
+        return "TanIntrinsic";
+    case CoshIntrinsic:
+        return "CoshIntrinsic";
+    case SinhIntrinsic:
+        return "SinhIntrinsic";
+    case TanhIntrinsic:
+        return "TanhIntrinsic";
+    case ArrayPushIntrinsic:
+        return "ArrayPushIntrinsic";
+    case ArrayPopIntrinsic:
+        return "ArrayPopIntrinsic";
+    case ArraySliceIntrinsic:
+        return "ArraySliceIntrinsic";
+    case CharCodeAtIntrinsic:
+        return "CharCodeAtIntrinsic";
+    case CharAtIntrinsic:
+        return "CharAtIntrinsic";
+    case FromCharCodeIntrinsic:
+        return "FromCharCodeIntrinsic";
+    case PowIntrinsic:
+        return "PowIntrinsic";
+    case FloorIntrinsic:
+        return "FloorIntrinsic";
+    case CeilIntrinsic:
+        return "CeilIntrinsic";
+    case RoundIntrinsic:
+        return "RoundIntrinsic";
+    case ExpIntrinsic:
+        return "ExpIntrinsic";
+    case Expm1Intrinsic:
+        return "Expm1Intrinsic";
+    case LogIntrinsic:
+        return "LogIntrinsic";
+    case Log10Intrinsic:
+        return "Log10Intrinsic";
+    case Log1pIntrinsic:
+        return "Log1pIntrinsic";
+    case Log2Intrinsic:
+        return "Log2Intrinsic";
+    case RegExpExecIntrinsic:
+        return "RegExpExecIntrinsic";
+    case RegExpTestIntrinsic:
+        return "RegExpTestIntrinsic";
+    case RegExpTestFastIntrinsic:
+        return "RegExpTestFastIntrinsic";
+    case StringPrototypeValueOfIntrinsic:
+        return "StringPrototypeValueOfIntrinsic";
+    case StringPrototypeReplaceIntrinsic:
+        return "StringPrototypeReplaceIntrinsic";
+    case StringPrototypeReplaceRegExpIntrinsic:
+        return "StringPrototypeReplaceRegExpIntrinsic";
+    case StringPrototypeToLowerCaseIntrinsic:
+        return "StringPrototypeToLowerCaseIntrinsic";
+    case NumberPrototypeToStringIntrinsic:
+        return "NumberPrototypeToStringIntrinsic";
+    case IMulIntrinsic:
+        return "IMulIntrinsic";
+    case RandomIntrinsic:
+        return "RandomIntrinsic";
+    case FRoundIntrinsic:
+        return "FRoundIntrinsic";
+    case TruncIntrinsic:
+        return "TruncIntrinsic";
+    case IsTypedArrayViewIntrinsic:
+        return "IsTypedArrayViewIntrinsic";
+    case BoundThisNoArgsFunctionCallIntrinsic:
+        return "BoundThisNoArgsFunctionCallIntrinsic";
+    case JSMapGetIntrinsic:
+        return "JSMapGetIntrinsic";
+    case JSMapHasIntrinsic:
+        return "JSMapHasIntrinsic";
+    case JSSetHasIntrinsic:
+        return "JSSetHasIntrinsic";
+    case HasOwnPropertyIntrinsic:
+        return "HasOwnPropertyIntrinsic";
+    case AtomicsAddIntrinsic:
+        return "AtomicsAddIntrinsic";
+    case AtomicsAndIntrinsic:
+        return "AtomicsAndIntrinsic";
+    case AtomicsCompareExchangeIntrinsic:
+        return "AtomicsCompareExchangeIntrinsic";
+    case AtomicsExchangeIntrinsic:
+        return "AtomicsExchangeIntrinsic";
+    case AtomicsIsLockFreeIntrinsic:
+        return "AtomicsIsLockFreeIntrinsic";
+    case AtomicsLoadIntrinsic:
+        return "AtomicsLoadIntrinsic";
+    case AtomicsOrIntrinsic:
+        return "AtomicsOrIntrinsic";
+    case AtomicsStoreIntrinsic:
+        return "AtomicsStoreIntrinsic";
+    case AtomicsSubIntrinsic:
+        return "AtomicsSubIntrinsic";
+    case AtomicsWaitIntrinsic:
+        return "AtomicsWaitIntrinsic";
+    case AtomicsWakeIntrinsic:
+        return "AtomicsWakeIntrinsic";
+    case AtomicsXorIntrinsic:
+        return "AtomicsXorIntrinsic";
+    case ParseIntIntrinsic:
+        return "ParseIntIntrinsic";
+    case TypedArrayLengthIntrinsic:
+        return "TypedArrayLengthIntrinsic";
+    case TypedArrayByteLengthIntrinsic:
+        return "TypedArrayByteLengthIntrinsic";
+    case TypedArrayByteOffsetIntrinsic:
+        return "TypedArrayByteOffsetIntrinsic";
+    case DFGTrueIntrinsic:
+        return "DFGTrueIntrinsic";
+    case OSRExitIntrinsic:
+        return "OSRExitIntrinsic";
+    case IsFinalTierIntrinsic:
+        return "IsFinalTierIntrinsic";
+    case SetInt32HeapPredictionIntrinsic:
+        return "SetInt32HeapPredictionIntrinsic";
+    case CheckInt32Intrinsic:
+        return "CheckInt32Intrinsic";
+    case FiatInt52Intrinsic:
+        return "FiatInt52Intrinsic";
+    }
+    RELEASE_ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
+} // namespace JSC
+
+namespace WTF {
+
+void printInternal(PrintStream& out, JSC::Intrinsic intrinsic)
+{
+    out.print(JSC::intrinsicName(intrinsic));
+}
+
+} // namespace WTF
+
index 16c5835..639590b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -111,4 +111,16 @@ enum Intrinsic {
     FiatInt52Intrinsic,
 };
 
+const char* intrinsicName(Intrinsic);
+
 } // namespace JSC
+
+namespace WTF {
+
+class PrintStream;
+
+void printInternal(PrintStream&, JSC::Intrinsic);
+
+} // namespace WTF
+
+