https://bugs.webkit.org/show_bug.cgi?id=68328
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Dec 2011 20:46:07 +0000 (20:46 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Dec 2011 20:46:07 +0000 (20:46 +0000)
The generator and intrinsic fields in HashTableValue/HashEntry and associated structures and methods are redundant

Reviewed by Geoff Garen.

../JavaScriptCore:

Move the instrinsic enum out of the DFG, into runtime. Add entires for all host functions
that have an intrinsic in the form of a generated thunk. Remove the thunk pointer from the
hashtable, and make Intrinsic field no longer ifdef on JIT/DFG. In getHostFunction select
a thunk genertaor to use based on the Intrinsic.

* JavaScriptCore.xcodeproj/project.pbxproj:
* create_hash_table:
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::handleIntrinsic):
* dfg/DFGCapabilities.h:
* dfg/DFGIntrinsic.h: Removed.
* jit/JITStubs.cpp:
(JSC::JITThunks::hostFunctionStub):
* jit/JITStubs.h:
* runtime/Executable.cpp:
(JSC::ExecutableBase::intrinsic):
(JSC::NativeExecutable::intrinsic):
* runtime/Executable.h:
(JSC::ExecutableBase::intrinsicFor):
(JSC::NativeExecutable::create):
(JSC::NativeExecutable::finishCreation):
* runtime/Intrinsic.h: Copied from Source/JavaScriptCore/dfg/DFGIntrinsic.h.
* runtime/JSGlobalData.cpp:
(JSC::thunkGeneratorForIntrinsic):
(JSC::JSGlobalData::getHostFunction):
* runtime/JSGlobalData.h:
* runtime/Lookup.cpp:
(JSC::HashTable::createTable):
(JSC::setUpStaticFunctionSlot):
* runtime/Lookup.h:
(JSC::HashEntry::initialize):
(JSC::HashEntry::intrinsic):

../WebCore:

Intrinsic is no longer in the DFG namespace, is always in the
hash table. Removed ThunkGenerator.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHashTable):

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

16 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/create_hash_table
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGCapabilities.h
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/jit/JITStubs.h
Source/JavaScriptCore/runtime/Executable.cpp
Source/JavaScriptCore/runtime/Executable.h
Source/JavaScriptCore/runtime/Intrinsic.h [moved from Source/JavaScriptCore/dfg/DFGIntrinsic.h with 85% similarity]
Source/JavaScriptCore/runtime/JSGlobalData.cpp
Source/JavaScriptCore/runtime/JSGlobalData.h
Source/JavaScriptCore/runtime/Lookup.cpp
Source/JavaScriptCore/runtime/Lookup.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

index 520e2bf..d4a2f4a 100644 (file)
@@ -1,3 +1,44 @@
+2011-12-06  Gavin Barraclough  <barraclough@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=68328
+        The generator and intrinsic fields in HashTableValue/HashEntry and associated structures and methods are redundant
+
+        Reviewed by Geoff Garen.
+
+        Move the instrinsic enum out of the DFG, into runtime. Add entires for all host functions
+        that have an intrinsic in the form of a generated thunk. Remove the thunk pointer from the
+        hashtable, and make Intrinsic field no longer ifdef on JIT/DFG. In getHostFunction select
+        a thunk genertaor to use based on the Intrinsic.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * create_hash_table:
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::handleCall):
+        (JSC::DFG::ByteCodeParser::handleIntrinsic):
+        * dfg/DFGCapabilities.h:
+        * dfg/DFGIntrinsic.h: Removed.
+        * jit/JITStubs.cpp:
+        (JSC::JITThunks::hostFunctionStub):
+        * jit/JITStubs.h:
+        * runtime/Executable.cpp:
+        (JSC::ExecutableBase::intrinsic):
+        (JSC::NativeExecutable::intrinsic):
+        * runtime/Executable.h:
+        (JSC::ExecutableBase::intrinsicFor):
+        (JSC::NativeExecutable::create):
+        (JSC::NativeExecutable::finishCreation):
+        * runtime/Intrinsic.h: Copied from Source/JavaScriptCore/dfg/DFGIntrinsic.h.
+        * runtime/JSGlobalData.cpp:
+        (JSC::thunkGeneratorForIntrinsic):
+        (JSC::JSGlobalData::getHostFunction):
+        * runtime/JSGlobalData.h:
+        * runtime/Lookup.cpp:
+        (JSC::HashTable::createTable):
+        (JSC::setUpStaticFunctionSlot):
+        * runtime/Lookup.h:
+        (JSC::HashEntry::initialize):
+        (JSC::HashEntry::intrinsic):
+
 2011-12-06  Michael Saboff  <msaboff@apple.com>
 
         Add 8 bit paths to global object functions
index 1aa4ef1..5b512d3 100644 (file)
                0FD82E85141F3FE300179C94 /* BoundsCheckedPointer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E82141F3FC900179C94 /* BoundsCheckedPointer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FD82E86141F3FF100179C94 /* PredictedType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E84141F3FDA00179C94 /* PredictedType.cpp */; };
                0FD82E9014207A5F00179C94 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E8E14207A5100179C94 /* ValueProfile.cpp */; };
-               0FD82EF51423075B00179C94 /* DFGIntrinsic.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82EF31423073900179C94 /* DFGIntrinsic.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FD82F4B142806A100179C94 /* BitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82F491428069200179C94 /* BitVector.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FE228ED1436AB2700196C48 /* Heuristics.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE228EB1436AB2300196C48 /* Heuristics.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FE228EE1436AB2C00196C48 /* Heuristics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE228EA1436AB2300196C48 /* Heuristics.cpp */; };
                860161E50F3A83C100F84710 /* MacroAssemblerX86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */; };
                860161E60F3A83C100F84710 /* MacroAssemblerX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */; };
                8604F505143CE1C200B295F5 /* JSGlobalThis.h in Headers */ = {isa = PBXBuildFile; fileRef = 8604F503143CE1C100B295F5 /* JSGlobalThis.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               860BD801148EA6F200112B2F /* Intrinsic.h in Headers */ = {isa = PBXBuildFile; fileRef = 86BF642A148DB2B5004DE36A /* Intrinsic.h */; settings = {ATTRIBUTES = (Private, ); }; };
                8626BECF11928E3900782FAB /* StringStatics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8626BECE11928E3900782FAB /* StringStatics.cpp */; };
                8627E5EC11F1281900A313B5 /* PageAllocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8627E5EA11F1281900A313B5 /* PageAllocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                863B23E00FC6118900703AA4 /* MacroAssemblerCodeRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0FD82E82141F3FC900179C94 /* BoundsCheckedPointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundsCheckedPointer.h; sourceTree = "<group>"; };
                0FD82E84141F3FDA00179C94 /* PredictedType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PredictedType.cpp; sourceTree = "<group>"; };
                0FD82E8E14207A5100179C94 /* ValueProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValueProfile.cpp; sourceTree = "<group>"; };
-               0FD82EF31423073900179C94 /* DFGIntrinsic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGIntrinsic.h; path = dfg/DFGIntrinsic.h; sourceTree = "<group>"; };
                0FD82F491428069200179C94 /* BitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitVector.h; sourceTree = "<group>"; };
                0FE228EA1436AB2300196C48 /* Heuristics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Heuristics.cpp; sourceTree = "<group>"; };
                0FE228EB1436AB2300196C48 /* Heuristics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Heuristics.h; sourceTree = "<group>"; };
                1A082777142168D70090CCAC /* BinarySemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySemaphore.cpp; sourceTree = "<group>"; };
                1A082778142168D70090CCAC /* BinarySemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySemaphore.h; sourceTree = "<group>"; };
                1C9051420BA9E8A70081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
-               1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = JavaScriptCore.xcconfig; sourceTree = "<group>"; };
+               1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = JavaScriptCore.xcconfig; path = ../Configurations/JavaScriptCore.xcconfig; sourceTree = "<group>"; };
                1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
                1C9051450BA9E8A70081E9D0 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
                1CAA8B4A0D32C39A0041BCFF /* JavaScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScript.h; sourceTree = "<group>"; };
                86B99AE1117E578100DF5A90 /* StringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringBuffer.h; path = text/StringBuffer.h; sourceTree = "<group>"; };
                86BB09BE138E381B0056702F /* DFGRepatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGRepatch.cpp; path = dfg/DFGRepatch.cpp; sourceTree = "<group>"; };
                86BB09BF138E381B0056702F /* DFGRepatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGRepatch.h; path = dfg/DFGRepatch.h; sourceTree = "<group>"; };
+               86BF642A148DB2B5004DE36A /* Intrinsic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Intrinsic.h; sourceTree = "<group>"; };
                86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssembler.h; sourceTree = "<group>"; };
                86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM.cpp; sourceTree = "<group>"; };
                86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerMIPS.h; sourceTree = "<group>"; };
                1432EBD70A34CAD400717B9F /* API */ = {
                        isa = PBXGroup;
                        children = (
+                               1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */,
                                1482B78A0A4305AB00517CFC /* APICast.h */,
                                865F408710E7D56300947361 /* APIShims.h */,
                                1CAA8B4A0D32C39A0041BCFF /* JavaScript.h */,
                                1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */,
                                449097EE0F8F81B50076A327 /* FeatureDefines.xcconfig */,
                                5DAFD6CB146B686300FBEFB4 /* JSC.xcconfig */,
-                               1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */,
                                BC021BF2136900C300FC5467 /* TestAPI.xcconfig */,
                                5DAFD6CC146B68B900FBEFB4 /* TestRegExp.xcconfig */,
                                1C9051420BA9E8A70081E9D0 /* Version.xcconfig */,
                7EF6E0BB0EB7A1EC0079AFAF /* runtime */ = {
                        isa = PBXGroup;
                        children = (
-                               0FE228EA1436AB2300196C48 /* Heuristics.cpp */,
-                               0FE228EB1436AB2300196C48 /* Heuristics.h */,
-                               0F7700911402FF280078EB39 /* SamplingCounter.cpp */,
-                               0F77008E1402FDD60078EB39 /* SamplingCounter.h */,
                                BCF605110E203EF800B9A64D /* ArgList.cpp */,
                                BCF605120E203EF800B9A64D /* ArgList.h */,
                                BC257DE50E1F51C50016B6C9 /* Arguments.cpp */,
                                DDF7ABD311F60ED200108E36 /* GCActivityCallbackCF.cpp */,
                                BC02E9B80E184545000F9297 /* GetterSetter.cpp */,
                                BC337BDE0E1AF0B80076918A /* GetterSetter.h */,
+                               0FE228EA1436AB2300196C48 /* Heuristics.cpp */,
+                               0FE228EB1436AB2300196C48 /* Heuristics.h */,
                                933A349D038AE80F008635CE /* Identifier.cpp */,
                                933A349A038AE7C6008635CE /* Identifier.h */,
                                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */,
                                E178633F0D9BEC0000D74E75 /* InitializeThreading.h */,
                                BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */,
                                BC11667A0E199C05008066DD /* InternalFunction.h */,
+                               86BF642A148DB2B5004DE36A /* Intrinsic.h */,
                                14DA818F0D99FD2000B0A4FB /* JSActivation.cpp */,
                                14DA818E0D99FD2000B0A4FB /* JSActivation.h */,
                                93ADFCE60CCBD7AC00D30B08 /* JSArray.cpp */,
                                F692A87C0255597D01FF60F7 /* RegExpObject.h */,
                                BCD202BF0E1706A7002C7E82 /* RegExpPrototype.cpp */,
                                BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */,
+                               0F7700911402FF280078EB39 /* SamplingCounter.cpp */,
+                               0F77008E1402FDD60078EB39 /* SamplingCounter.h */,
                                9374D3A8038D9D74008635CE /* ScopeChain.cpp */,
                                9374D3A7038D9D74008635CE /* ScopeChain.h */,
                                7E2C6C980D31C6B6002D44E2 /* ScopeChainMark.h */,
                                86AE6C4C136A11E400963012 /* DFGGPRInfo.h */,
                                86EC9DB71328DF82002B2AD7 /* DFGGraph.cpp */,
                                86EC9DB81328DF82002B2AD7 /* DFGGraph.h */,
-                               0FD82EF31423073900179C94 /* DFGIntrinsic.h */,
                                86EC9DBB1328DF82002B2AD7 /* DFGJITCompiler.cpp */,
                                86EC9DBC1328DF82002B2AD7 /* DFGJITCompiler.h */,
                                86ECA3E9132DEF1C002B2AD7 /* DFGNode.h */,
                                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
                                145722861437E140005FDE26 /* StrongInlines.h in Headers */,
                                0FD82F4B142806A100179C94 /* BitVector.h in Headers */,
-                               0FD82EF51423075B00179C94 /* DFGIntrinsic.h in Headers */,
                                0FD82E85141F3FE300179C94 /* BoundsCheckedPointer.h in Headers */,
                                0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */,
                                0FD82E55141DAEEE00179C94 /* PredictionTracker.h in Headers */,
                                A73BE17B148420520091204B /* Uint32Array.h in Headers */,
                                A73BE17E148420840091204B /* TypedArrayBase.h in Headers */,
                                A73BE180148420A80091204B /* IntegralTypedArrayBase.h in Headers */,
+                               860BD801148EA6F200112B2F /* Intrinsic.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index b21424e..ae49ce4 100755 (executable)
@@ -250,16 +250,6 @@ sub output() {
         print "\nnamespace JSC {\n";
     }
     my $count = scalar @keys + 1;
-    print "#if ENABLE(JIT)\n";
-    print "#define THUNK_GENERATOR(generator) , generator\n";
-    print "#else\n";
-    print "#define THUNK_GENERATOR(generator)\n";
-    print "#endif\n";
-    print "#if ENABLE(DFG_JIT)\n";
-    print "#define INTRINSIC(intrinsic) , intrinsic\n";
-    print "#else\n";
-    print "#define INTRINSIC(intrinsic)\n";
-    print "#endif\n";
     print "\nstatic const struct HashTableValue ${nameEntries}\[$count\] = {\n";
     my $i = 0;
     foreach my $key (@keys) {
@@ -279,67 +269,33 @@ sub output() {
             $firstValue = $values[$i]{"value"};
             $secondValue = "0";
         }
-        my $thunkGenerator = "0";
-        my $intrinsic = "DFG::NoIntrinsic";
-        if ($key eq "charCodeAt") {
-            $thunkGenerator = "charCodeAtThunkGenerator";
-            $intrinsic = "DFG::CharCodeAtIntrinsic";
-        }
-        if ($key eq "charAt") {
-            $thunkGenerator = "charAtThunkGenerator";
-            $intrinsic = "DFG::CharAtIntrinsic";
-        }
-        if ($key eq "fromCharCode") {
-            $thunkGenerator = "fromCharCodeThunkGenerator";
-        }
+
+        my $intrinsic = "NoIntrinsic";
+        $intrinsic = "CharCodeAtIntrinsic" if ($key eq "charCodeAt");
+        $intrinsic = "CharAtIntrinsic" if ($key eq "charAt");
+        $intrinsic = "FromCharCodeIntrinsic" if ($key eq "fromCharCode");
         if ($name eq "mathTable") {
-            if ($key eq "min") {
-                $intrinsic = "DFG::MinIntrinsic";
-            }
-            if ($key eq "max") {
-                $intrinsic = "DFG::MaxIntrinsic";
-            }
-            if ($key eq "sqrt") {
-                $thunkGenerator = "sqrtThunkGenerator";
-                $intrinsic = "DFG::SqrtIntrinsic";
-            }
-            if ($key eq "pow") {
-                $thunkGenerator = "powThunkGenerator";
-            }
-            if ($key eq "abs") {
-                $thunkGenerator = "absThunkGenerator";
-                $intrinsic = "DFG::AbsIntrinsic";
-            }
-            if ($key eq "floor") {
-                $thunkGenerator = "floorThunkGenerator";
-            }
-            if ($key eq "ceil") {
-                $thunkGenerator = "ceilThunkGenerator";
-            }
-            if ($key eq "round") {
-                $thunkGenerator = "roundThunkGenerator";
-            }
-            if ($key eq "exp") {
-                $thunkGenerator = "expThunkGenerator";
-            }
-            if ($key eq "log") {
-                $thunkGenerator = "logThunkGenerator";
-            }
+            $intrinsic = "MinIntrinsic" if ($key eq "min");
+            $intrinsic = "MaxIntrinsic" if ($key eq "max");
+            $intrinsic = "SqrtIntrinsic" if ($key eq "sqrt");
+            $intrinsic = "PowIntrinsic" if ($key eq "pow");
+            $intrinsic = "AbsIntrinsic" if ($key eq "abs");
+            $intrinsic = "FloorIntrinsic" if ($key eq "floor");
+            $intrinsic = "CeilIntrinsic" if ($key eq "ceil");
+            $intrinsic = "RoundIntrinsic" if ($key eq "round");
+            $intrinsic = "ExpIntrinsic" if ($key eq "exp");
+            $intrinsic = "LogIntrinsic" if ($key eq "log");
         }
         if ($name eq "arrayPrototypeTable") {
-            if ($key eq "push") {
-                $intrinsic = "DFG::ArrayPushIntrinsic";
-            }
-            if ($key eq "pop") {
-                $intrinsic = "DFG::ArrayPopIntrinsic";
-            }
+            $intrinsic = "ArrayPushIntrinsic" if ($key eq "push");
+            $intrinsic = "ArrayPopIntrinsic" if ($key eq "pop");
         }
-        print "   { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue THUNK_GENERATOR($thunkGenerator) INTRINSIC($intrinsic) },\n";
+
+        print "   { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue, $intrinsic },\n";
         $i++;
     }
-    print "   { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }\n";
+    print "   { 0, 0, 0, 0, NoIntrinsic }\n";
     print "};\n\n";
-    print "#undef THUNK_GENERATOR\n";
     print "extern const struct HashTable $name =\n";
     print "    \{ $compactSize, $compactHashSizeMask, $nameEntries, 0 \};\n";
     print "} // namespace\n";
index a09a1a3..47287fb 100644 (file)
@@ -902,7 +902,7 @@ void ByteCodeParser::handleCall(Interpreter* interpreter, Instruction* currentIn
             nextOffset += OPCODE_LENGTH(op_call_put_result);
         }
         JSFunction* expectedFunction;
-        DFG::Intrinsic intrinsic;
+        Intrinsic intrinsic;
         bool certainAboutExpectedFunction;
         if (callType == ConstantFunction) {
             expectedFunction = m_graph.valueOfFunctionConstant(m_codeBlock, callTarget);
@@ -1225,7 +1225,6 @@ bool ByteCodeParser::handleIntrinsic(bool usesResult, int resultOperand, Intrins
     }
 
     default:
-        ASSERT(intrinsic == NoIntrinsic);
         return false;
     }
 }
index ff3dc30..0f70aa4 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef DFGCapabilities_h
 #define DFGCapabilities_h
 
-#include "DFGIntrinsic.h"
+#include "Intrinsic.h"
 #include "DFGNode.h"
 #include "Executable.h"
 #include "Heuristics.h"
index 422c7be..976d1d3 100644 (file)
@@ -3742,11 +3742,11 @@ NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFu
 {
     std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, Weak<NativeExecutable>());
     if (!*entry.first->second)
-        entry.first->second.set(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), constructor, DFG::NoIntrinsic));
+        entry.first->second.set(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), constructor, NoIntrinsic));
     return entry.first->second.get();
 }
 
-NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator, DFG::Intrinsic intrinsic)
+NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator, Intrinsic intrinsic)
 {
     std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, Weak<NativeExecutable>());
     if (!*entry.first->second) {
index c587381..728da0f 100644 (file)
@@ -31,7 +31,7 @@
 #define JITStubs_h
 
 #include "CallData.h"
-#include "DFGIntrinsic.h"
+#include "Intrinsic.h"
 #include "MacroAssemblerCodeRef.h"
 #include "Register.h"
 #include "ThunkGenerators.h"
@@ -300,7 +300,7 @@ namespace JSC {
         MacroAssemblerCodeRef ctiStub(JSGlobalData*, ThunkGenerator);
 
         NativeExecutable* hostFunctionStub(JSGlobalData*, NativeFunction, NativeFunction constructor);
-        NativeExecutable* hostFunctionStub(JSGlobalData*, NativeFunction, ThunkGenerator, DFG::Intrinsic);
+        NativeExecutable* hostFunctionStub(JSGlobalData*, NativeFunction, ThunkGenerator, Intrinsic);
 
         void clearHostFunctionStubs();
 
index bfd8a23..64e92e8 100644 (file)
@@ -51,11 +51,11 @@ inline void ExecutableBase::clearCode()
 }
 
 #if ENABLE(DFG_JIT)
-DFG::Intrinsic ExecutableBase::intrinsic() const
+Intrinsic ExecutableBase::intrinsic() const
 {
     if (const NativeExecutable* nativeExecutable = jsDynamicCast<const NativeExecutable*>(this))
         return nativeExecutable->intrinsic();
-    return DFG::NoIntrinsic;
+    return NoIntrinsic;
 }
 #endif
 
@@ -66,7 +66,7 @@ NativeExecutable::~NativeExecutable()
 }
 
 #if ENABLE(DFG_JIT)
-DFG::Intrinsic NativeExecutable::intrinsic() const
+Intrinsic NativeExecutable::intrinsic() const
 {
     return m_intrinsic;
 }
index 1b8b461..6395843 100644 (file)
@@ -154,17 +154,15 @@ namespace JSC {
             return hasJITCodeForConstruct();
         }
 
-#if ENABLE(DFG_JIT)
         // Intrinsics are only for calls, currently.
-        DFG::Intrinsic intrinsic() const;
+        Intrinsic intrinsic() const;
         
-        DFG::Intrinsic intrinsicFor(CodeSpecializationKind kind) const
+        Intrinsic intrinsicFor(CodeSpecializationKind kind) const
         {
             if (isCall(kind))
                 return intrinsic();
-            return DFG::NoIntrinsic;
+            return NoIntrinsic;
         }
-#endif
 
     protected:
         JITCode m_jitCodeForCall;
@@ -181,7 +179,7 @@ namespace JSC {
         typedef ExecutableBase Base;
 
 #if ENABLE(JIT)
-        static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodeRef callThunk, NativeFunction function, MacroAssemblerCodeRef constructThunk, NativeFunction constructor, DFG::Intrinsic intrinsic)
+        static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodeRef callThunk, NativeFunction function, MacroAssemblerCodeRef constructThunk, NativeFunction constructor, Intrinsic intrinsic)
         {
             ASSERT(globalData.canUseJIT());
             NativeExecutable* executable;
@@ -217,13 +215,11 @@ namespace JSC {
         
         static const ClassInfo s_info;
 
-#if ENABLE(DFG_JIT)
-        DFG::Intrinsic intrinsic() const;
-#endif
+        Intrinsic intrinsic() const;
 
     protected:
 #if ENABLE(JIT)
-        void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk, DFG::Intrinsic intrinsic)
+        void finishCreation(JSGlobalData& globalData, JITCode callThunk, JITCode constructThunk, Intrinsic intrinsic)
         {
             ASSERT(globalData.canUseJIT());
             Base::finishCreation(globalData);
@@ -231,11 +227,7 @@ namespace JSC {
             m_jitCodeForConstruct = constructThunk;
             m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
             m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
-#if ENABLE(DFG_JIT)
             m_intrinsic = intrinsic;
-#else
-            UNUSED_PARAM(intrinsic);
-#endif
         }
 #endif
 
@@ -244,6 +236,7 @@ namespace JSC {
         {
             ASSERT(!globalData.canUseJIT());
             Base::finishCreation(globalData);
+            m_intrinsic = NoIntrinsic;
         }
 #endif
 
@@ -260,7 +253,7 @@ namespace JSC {
         NativeFunction m_function;
         NativeFunction m_constructor;
         
-        DFG::Intrinsic m_intrinsic;
+        Intrinsic m_intrinsic;
     };
 
     class ScriptExecutable : public ExecutableBase {
similarity index 85%
rename from Source/JavaScriptCore/dfg/DFGIntrinsic.h
rename to Source/JavaScriptCore/runtime/Intrinsic.h
index ca72884..5cc0068 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef DFGIntrinsic_h
-#define DFGIntrinsic_h
+#ifndef Intrinsic_h
+#define Intrinsic_h
 
-namespace JSC { namespace DFG {
+namespace JSC {
 
 enum Intrinsic {
     NoIntrinsic,
@@ -37,9 +37,16 @@ enum Intrinsic {
     ArrayPushIntrinsic,
     ArrayPopIntrinsic,
     CharCodeAtIntrinsic,
-    CharAtIntrinsic
+    CharAtIntrinsic,
+    FromCharCodeIntrinsic,
+    PowIntrinsic,
+    FloorIntrinsic,
+    CeilIntrinsic,
+    RoundIntrinsic,
+    ExpIntrinsic,
+    LogIntrinsic,
 };
 
-} } // namespace JSC::DFG
+} // namespace JSC
 
-#endif // DFGIntrinsic_h
+#endif // Intrinsic_h
index ed6b80c..a535fc2 100644 (file)
@@ -412,6 +412,36 @@ JSGlobalData*& JSGlobalData::sharedInstanceInternal()
 }
 
 #if ENABLE(JIT)
+static ThunkGenerator thunkGeneratorForIntrinsic(Intrinsic intrinsic)
+{
+    switch (intrinsic) {
+    case CharCodeAtIntrinsic:
+        return charCodeAtThunkGenerator;
+    case CharAtIntrinsic:
+        return charAtThunkGenerator;
+    case FromCharCodeIntrinsic:
+        return fromCharCodeThunkGenerator;
+    case SqrtIntrinsic:
+        return sqrtThunkGenerator;
+    case PowIntrinsic:
+        return powThunkGenerator;
+    case AbsIntrinsic:
+        return absThunkGenerator;
+    case FloorIntrinsic:
+        return floorThunkGenerator;
+    case CeilIntrinsic:
+        return ceilThunkGenerator;
+    case RoundIntrinsic:
+        return roundThunkGenerator;
+    case ExpIntrinsic:
+        return expThunkGenerator;
+    case LogIntrinsic:
+        return logThunkGenerator;
+    default:
+        return 0;
+    }
+}
+
 NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, NativeFunction constructor)
 {
 #if ENABLE(INTERPRETER)
@@ -420,10 +450,10 @@ NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, NativeF
 #endif
     return jitStubs->hostFunctionStub(this, function, constructor);
 }
-NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, ThunkGenerator generator, DFG::Intrinsic intrinsic)
+NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, Intrinsic intrinsic)
 {
     ASSERT(canUseJIT());
-    return jitStubs->hostFunctionStub(this, function, generator, intrinsic);
+    return jitStubs->hostFunctionStub(this, function, intrinsic != NoIntrinsic ? thunkGeneratorForIntrinsic(intrinsic) : 0, intrinsic);
 }
 #else
 NativeExecutable* JSGlobalData::getHostFunction(NativeFunction function, NativeFunction constructor)
index f0e3bb5..139dd42 100644 (file)
@@ -30,7 +30,7 @@
 #define JSGlobalData_h
 
 #include "CachedTranscendentalFunction.h"
-#include "DFGIntrinsic.h"
+#include "Intrinsic.h"
 #include "DateInstanceCache.h"
 #include "ExecutableAllocator.h"
 #include "Heap.h"
@@ -246,7 +246,7 @@ namespace JSC {
         {
             return jitStubs->ctiStub(this, generator);
         }
-        NativeExecutable* getHostFunction(NativeFunction, ThunkGenerator, DFG::Intrinsic);
+        NativeExecutable* getHostFunction(NativeFunction, Intrinsic);
 #endif
         NativeExecutable* getHostFunction(NativeFunction, NativeFunction constructor);
 
index 70419fe..55c048f 100644 (file)
@@ -46,14 +46,7 @@ void HashTable::createTable(JSGlobalData* globalData) const
             entry = entry->next();
         }
 
-        entry->initialize(identifier, values[i].attributes, values[i].value1, values[i].value2
-#if ENABLE(JIT)
-                          , values[i].generator
-#if ENABLE(DFG_JIT)
-                          , values[i].intrinsic
-#endif
-#endif
-                          );
+        entry->initialize(identifier, values[i].attributes, values[i].value1, values[i].value2, values[i].intrinsic);
     }
     table = entries;
 }
@@ -86,8 +79,8 @@ bool setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject*
         JSFunction* function;
         JSGlobalObject* globalObject = thisObj->globalObject();
 #if ENABLE(JIT)
-        if (exec->globalData().canUseJIT() && (entry->generator() || entry->intrinsic() != DFG::NoIntrinsic))
-            function = JSFunction::create(exec, globalObject, entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator(), entry->intrinsic()));
+        if (exec->globalData().canUseJIT() && entry->intrinsic() != NoIntrinsic)
+            function = JSFunction::create(exec, globalObject, entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->intrinsic()));
         else
 #endif
             function = JSFunction::create(exec, globalObject, entry->functionLength(), propertyName, entry->function());
index 1712b0d..189c6aa 100644 (file)
@@ -22,7 +22,7 @@
 #define Lookup_h
 
 #include "CallFrame.h"
-#include "DFGIntrinsic.h"
+#include "Intrinsic.h"
 #include "Identifier.h"
 #include "JSGlobalObject.h"
 #include "PropertySlot.h"
@@ -36,12 +36,7 @@ namespace JSC {
         unsigned char attributes; // JSObject attributes
         intptr_t value1;
         intptr_t value2;
-#if ENABLE(JIT)
-        ThunkGenerator generator;
-#if ENABLE(DFG_JIT)
-        DFG::Intrinsic intrinsic;
-#endif
-#endif
+        Intrinsic intrinsic;
     };
 
     // FIXME: There is no reason this get function can't be simpler.
@@ -52,25 +47,13 @@ namespace JSC {
     class HashEntry {
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        void initialize(StringImpl* key, unsigned char attributes, intptr_t v1, intptr_t v2
-#if ENABLE(JIT)
-                        , ThunkGenerator generator = 0
-#if ENABLE(DFG_JIT)
-                        , DFG::Intrinsic intrinsic = DFG::NoIntrinsic
-#endif
-#endif
-                        )
+        void initialize(StringImpl* key, unsigned char attributes, intptr_t v1, intptr_t v2, Intrinsic intrinsic)
         {
             m_key = key;
             m_attributes = attributes;
             m_u.store.value1 = v1;
             m_u.store.value2 = v2;
-#if ENABLE(JIT)
-            m_u.function.generator = generator;
-#if ENABLE(DFG_JIT)
             m_u.function.intrinsic = intrinsic;
-#endif
-#endif
             m_next = 0;
         }
 
@@ -79,18 +62,12 @@ namespace JSC {
 
         unsigned char attributes() const { return m_attributes; }
 
-#if ENABLE(JIT)
-        ThunkGenerator generator() const { ASSERT(m_attributes & Function); return m_u.function.generator; }
-        DFG::Intrinsic intrinsic() const
+        Intrinsic intrinsic() const
         {
             ASSERT(m_attributes & Function);
-#if ENABLE(DFG_JIT)
             return m_u.function.intrinsic;
-#else
-            return DFG::NoIntrinsic;
-#endif
         }
-#endif
+
         NativeFunction function() const { ASSERT(m_attributes & Function); return m_u.function.functionValue; }
         unsigned char functionLength() const { ASSERT(m_attributes & Function); return static_cast<unsigned char>(m_u.function.length); }
 
@@ -114,12 +91,7 @@ namespace JSC {
             struct {
                 NativeFunction functionValue;
                 intptr_t length; // number of arguments for function
-#if ENABLE(JIT)
-                ThunkGenerator generator;
-#if ENABLE(DFG_JIT)
-                DFG::Intrinsic intrinsic;
-#endif
-#endif
+                Intrinsic intrinsic;
             } function;
             struct {
                 GetFunction get;
index b60a4fb..829f76d 100644 (file)
@@ -1,3 +1,16 @@
+2011-12-06  Gavin Barraclough  <barraclough@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=68328
+        The generator and intrinsic fields in HashTableValue/HashEntry and associated structures and methods are redundant
+
+        Reviewed by Geoff Garen.
+
+        Intrinsic is no longer in the DFG namespace, is always in the
+        hash table. Removed ThunkGenerator.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHashTable):
+
 2011-12-06  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Unreviewed, rolling out r102091.
index eaf72fc..fb3b9be 100644 (file)
@@ -3119,16 +3119,6 @@ sub GenerateHashTable
     }
 
     # Dump the hash table
-    push(@implContent, "#if ENABLE(JIT)\n");
-    push(@implContent, "#define THUNK_GENERATOR(generator) , generator\n");
-    push(@implContent, "#else\n");
-    push(@implContent, "#define THUNK_GENERATOR(generator)\n");
-    push(@implContent, "#endif\n");
-    push(@implContent, "#if ENABLE(DFG_JIT)\n");
-    push(@implContent, "#define INTRINSIC(intrinsic) , intrinsic\n");
-    push(@implContent, "#else\n");
-    push(@implContent, "#define INTRINSIC(intrinsic)\n");
-    push(@implContent, "#endif\n");
     push(@implContent, "\nstatic const HashTableValue $nameEntries\[\] =\n\{\n");
     $i = 0;
     foreach my $key (@{$keys}) {
@@ -3148,13 +3138,12 @@ sub GenerateHashTable
         } else {
             $targetType = "static_cast<PropertySlot::GetValueFunc>";
         }
-        push(@implContent, "    { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },\n");
+        push(@implContent, "    { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i], NoIntrinsic },\n");
         push(@implContent, "#endif\n") if $conditional;
         ++$i;
     }
-    push(@implContent, "    { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }\n");
+    push(@implContent, "    { 0, 0, 0, 0, NoIntrinsic }\n");
     push(@implContent, "};\n\n");
-    push(@implContent, "#undef THUNK_GENERATOR\n");
     my $compactSizeMask = $numEntries - 1;
     push(@implContent, "static const HashTable $name = { $compactSize, $compactSizeMask, $nameEntries, 0 };\n");
 }