Title: [147985] trunk/Source/_javascript_Core
Revision
147985
Author
[email protected]
Date
2013-04-08 23:45:16 -0700 (Mon, 08 Apr 2013)

Log Message

Adds fromCharCode intrinsic support.
https://bugs.webkit.org/show_bug.cgi?id=104807

Patch by Vahag Vardanyan <[email protected]> on 2013-04-08
Reviewed by Oliver Hunt.

Switch to using fromCharCode intrinsic instead of call operation in some cases.

* dfg/DFGAbstractState.cpp:
(JSC::DFG::AbstractState::executeEffects):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsic):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGNodeType.h:
(DFG):
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileFromCharCode):
(DFG):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
(SpeculativeJIT):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* runtime/StringConstructor.cpp:
(JSC::stringFromCharCode):
(JSC):
* runtime/StringConstructor.h:
(JSC):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (147984 => 147985)


--- trunk/Source/_javascript_Core/ChangeLog	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-04-09 06:45:16 UTC (rev 147985)
@@ -1,3 +1,40 @@
+2013-04-08  Vahag Vardanyan  <[email protected]>
+
+        Adds fromCharCode intrinsic support.
+        https://bugs.webkit.org/show_bug.cgi?id=104807
+
+        Reviewed by Oliver Hunt.
+
+        Switch to using fromCharCode intrinsic instead of call operation in some cases.
+
+        * dfg/DFGAbstractState.cpp:
+        (JSC::DFG::AbstractState::executeEffects):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::handleIntrinsic):
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode):
+        * dfg/DFGNodeType.h:
+        (DFG):
+        * dfg/DFGOperations.cpp:
+        * dfg/DFGOperations.h:
+        * dfg/DFGPredictionPropagationPhase.cpp:
+        (JSC::DFG::PredictionPropagationPhase::propagate):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileFromCharCode):
+        (DFG):
+        * dfg/DFGSpeculativeJIT.h:
+        (JSC::DFG::SpeculativeJIT::callOperation):
+        (SpeculativeJIT):
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * runtime/StringConstructor.cpp:
+        (JSC::stringFromCharCode):
+        (JSC):
+        * runtime/StringConstructor.h:
+        (JSC):
+
 2013-04-08  Benjamin Poulain  <[email protected]>
 
         Remove HTML Notification

Modified: trunk/Source/_javascript_Core/dfg/DFGAbstractState.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGAbstractState.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGAbstractState.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -861,6 +861,10 @@
         forNode(node).set(SpecInt32);
         break;
         
+    case StringFromCharCode:
+        forNode(node).set(SpecString);
+        break;
+
     case StringCharAt:
         node->setCanExit(true);
         forNode(node).set(m_graph.m_globalData.stringStructure.get());

Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -1564,7 +1564,19 @@
             set(resultOperand, charCode);
         return true;
     }
+    case FromCharCodeIntrinsic: {
+        if (argumentCountIncludingThis != 2)
+            return false;
 
+        int indexOperand = registerOffset + argumentToOperand(1);
+        Node* charCode = addToGraph(StringFromCharCode, getToInt32(indexOperand));
+
+        if (usesResult)
+            set(resultOperand, charCode);
+
+        return true;
+    }
+
     case RegExpExecIntrinsic: {
         if (argumentCountIncludingThis != 2)
             return false;

Modified: trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -356,6 +356,10 @@
             break;
         }
 
+        case StringFromCharCode:
+            setUseKindAndUnboxIfProfitable<Int32Use>(node->child1());
+            break;
+
         case StringCharAt:
         case StringCharCodeAt: {
             // Currently we have no good way of refining these.

Modified: trunk/Source/_javascript_Core/dfg/DFGNodeType.h (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGNodeType.h	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGNodeType.h	2013-04-09 06:45:16 UTC (rev 147985)
@@ -181,6 +181,7 @@
     /* Optimizations for string access */ \
     macro(StringCharCodeAt, NodeResultInt32) \
     macro(StringCharAt, NodeResultJS) \
+    macro(StringFromCharCode, NodeResultJS) \
     \
     /* Nodes for comparison operations. */\
     macro(CompareLess, NodeResultBoolean | NodeMustGenerate | NodeMightClobber) \

Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -44,6 +44,7 @@
 #include "NameInstance.h"
 #include "ObjectConstructor.h"
 #include "Operations.h"
+#include "StringConstructor.h"
 #include <wtf/InlineASM.h>
 
 #if ENABLE(JIT)
@@ -1601,6 +1602,13 @@
     return fmod(a, b);
 }
 
+JSCell* DFG_OPERATION operationStringFromCharCode(ExecState* exec, int32_t op1)
+{
+    JSGlobalData* globalData = &exec->globalData();
+    NativeCallFrameTracer tracer(globalData, exec);
+    return JSC::stringFromCharCode(exec, op1);
+}
+
 DFGHandlerEncoded DFG_OPERATION lookupExceptionHandler(ExecState* exec, uint32_t callIndex)
 {
     JSGlobalData* globalData = &exec->globalData();

Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.h (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGOperations.h	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.h	2013-04-09 06:45:16 UTC (rev 147985)
@@ -82,6 +82,7 @@
 typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_EZIcfZ)(ExecState*, int32_t, InlineCallFrame*, int32_t);
 typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_EZZ)(ExecState*, int32_t, int32_t);
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_E)(ExecState*);
+typedef JSCell* DFG_OPERATION (*C_DFGOperation_EZ)(ExecState*, int32_t);
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_EC)(ExecState*, JSCell*);
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_ECC)(ExecState*, JSCell*, JSCell*);
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_EIcf)(ExecState*, InlineCallFrame*);
@@ -91,6 +92,7 @@
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_EJssJssJss)(ExecState*, JSString*, JSString*, JSString*);
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_EOZ)(ExecState*, JSObject*, int32_t);
 typedef JSCell* DFG_OPERATION (*C_DFGOperation_ESt)(ExecState*, Structure*);
+typedef JSCell* DFG_OPERATION (*C_DFGOperation_EZ)(ExecState*, int32_t);
 typedef double DFG_OPERATION (*D_DFGOperation_DD)(double, double);
 typedef double DFG_OPERATION (*D_DFGOperation_ZZ)(int32_t, int32_t);
 typedef double DFG_OPERATION (*D_DFGOperation_EJ)(ExecState*, EncodedJSValue);
@@ -124,6 +126,7 @@
 typedef char* DFG_OPERATION (*P_DFGOperation_EStSS)(ExecState*, Structure*, size_t, size_t);
 typedef char* DFG_OPERATION (*P_DFGOperation_EStZ)(ExecState*, Structure*, int32_t);
 typedef StringImpl* DFG_OPERATION (*Str_DFGOperation_EJss)(ExecState*, JSString*);
+JSCell* DFG_OPERATION operationStringFromCharCode(ExecState*, int32_t)  WTF_INTERNAL; 
 
 // These routines are provide callbacks out to C++ implementations of operations too complex to JIT.
 JSCell* DFG_OPERATION operationNewObject(ExecState*, Structure*) WTF_INTERNAL;

Modified: trunk/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -423,6 +423,11 @@
             break;
         }
         
+        case StringFromCharCode: {
+            changed |= setPrediction(SpecString);
+            changed |= node->child1()->mergeFlags(NodeUsedAsNumber | NodeUsedAsInt);            
+            break;
+        }
         case StringCharAt:
         case ToString:
         case MakeRope: {

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -2088,6 +2088,25 @@
     cellResult(scratchReg, m_currentNode);
 }
 
+void SpeculativeJIT::compileFromCharCode(Node* node)
+{
+    SpeculateStrictInt32Operand property(this, node->child1());
+    GPRReg propertyReg = property.gpr();
+    GPRTemporary smallStrings(this);
+    GPRTemporary scratch(this);
+    GPRReg scratchReg = scratch.gpr();
+    GPRReg smallStringsReg = smallStrings.gpr();
+
+    JITCompiler::JumpList slowCases;
+    slowCases.append(m_jit.branch32(MacroAssembler::AboveOrEqual, propertyReg, TrustedImm32(0xff)));
+    m_jit.move(MacroAssembler::TrustedImmPtr(m_jit.globalData()->smallStrings.singleCharacterStrings()), smallStringsReg);
+    m_jit.loadPtr(MacroAssembler::BaseIndex(smallStringsReg, propertyReg, MacroAssembler::ScalePtr, 0), scratchReg);
+
+    slowCases.append(m_jit.branchTest32(MacroAssembler::Zero, scratchReg));
+    addSlowPathGenerator(slowPathCall(slowCases, this, operationStringFromCharCode, scratchReg, propertyReg));
+    cellResult(scratchReg, m_currentNode);
+}
+
 GeneratedOperandType SpeculativeJIT::checkGeneratedTypeForToInt32(Node* node)
 {
 #if DFG_ENABLE(DEBUG_VERBOSE)

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h	2013-04-09 06:45:16 UTC (rev 147985)
@@ -1263,6 +1263,11 @@
         m_jit.setupArgumentsWithExecState(arg1);
         return appendCallWithExceptionCheckSetResult(operation, result);
     }
+    JITCompiler::Call callOperation(C_DFGOperation_EZ operation, GPRReg result, GPRReg arg1)
+    {
+        m_jit.setupArgumentsWithExecState(arg1);
+        return appendCallWithExceptionCheckSetResult(operation, result);
+    }
 #else
 
 // EncodedJSValue in JSVALUE32_64 is a 64-bit integer. When being compiled in ARM EABI, it must be aligned even-numbered register (r0, r2 or [sp]).
@@ -1686,7 +1691,13 @@
         m_jit.setupArgumentsWithExecState(arg1);
         return appendCallWithExceptionCheckSetResult(operation, result);
     }
+    JITCompiler::Call callOperation(C_DFGOperation_EZ operation, GPRReg result, GPRReg arg1)
+    {
+        m_jit.setupArgumentsWithExecState(arg1);
+        return appendCallWithExceptionCheckSetResult(operation, result);
+    }
 
+
 #undef EABI_32BIT_DUMMY_ARG
     
     template<typename FunctionType>
@@ -2105,6 +2116,7 @@
     
     void compileGetCharCodeAt(Node*);
     void compileGetByValOnString(Node*);
+    void compileFromCharCode(Node*); 
 
     void compileGetByValOnArguments(Node*);
     void compileGetArgumentsLength(Node*);

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -2451,6 +2451,11 @@
         compileGetByValOnString(node);
         break;
     }
+
+    case StringFromCharCode: {
+        compileFromCharCode(node);
+        break;
+    }
         
     case CheckArray: {
         checkArray(node);

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -2378,6 +2378,11 @@
         compileGetByValOnString(node);
         break;
     }
+
+    case StringFromCharCode: {
+        compileFromCharCode(node);
+        break;
+    }
         
     case CheckArray: {
         checkArray(node);

Modified: trunk/Source/_javascript_Core/runtime/StringConstructor.cpp (147984 => 147985)


--- trunk/Source/_javascript_Core/runtime/StringConstructor.cpp	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/runtime/StringConstructor.cpp	2013-04-09 06:45:16 UTC (rev 147985)
@@ -89,6 +89,11 @@
     return JSValue::encode(stringFromCharCodeSlowCase(exec));
 }
 
+JSCell* JSC_HOST_CALL stringFromCharCode(ExecState* exec, int32_t arg)
+{
+    return jsSingleCharacterString(exec, arg);
+}
+
 static EncodedJSValue JSC_HOST_CALL constructWithStringConstructor(ExecState* exec)
 {
     JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();

Modified: trunk/Source/_javascript_Core/runtime/StringConstructor.h (147984 => 147985)


--- trunk/Source/_javascript_Core/runtime/StringConstructor.h	2013-04-09 06:44:56 UTC (rev 147984)
+++ trunk/Source/_javascript_Core/runtime/StringConstructor.h	2013-04-09 06:45:16 UTC (rev 147985)
@@ -57,6 +57,8 @@
         static bool getOwnPropertySlot(JSCell*, ExecState*, PropertyName, PropertySlot&);
         static bool getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&);
     };
+    
+    JSCell* JSC_HOST_CALL stringFromCharCode(ExecState*, int32_t);
 
 } // namespace JSC
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to