Make more things LLInt constexprs
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jul 2017 22:47:04 +0000 (22:47 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jul 2017 22:47:04 +0000 (22:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174994

Reviewed by Saam Barati.

This patch makes more const values in the LLInt constexprs.
It also deletes all of the no longer necessary static_asserts in
LLIntData.cpp. Finally, it fixes a typo in parser.rb.

* interpreter/ShadowChicken.h:
(JSC::ShadowChicken::Packet::tailMarker):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LowLevelInterpreter.asm:
* offlineasm/generate_offset_extractor.rb:
* offlineasm/parser.rb:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/interpreter/ShadowChicken.h
Source/JavaScriptCore/llint/LLIntData.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/offlineasm/generate_offset_extractor.rb
Source/JavaScriptCore/offlineasm/parser.rb

index b026c19..73912ab 100644 (file)
@@ -1,3 +1,22 @@
+2017-07-31  Keith Miller  <keith_miller@apple.com>
+
+        Make more things LLInt constexprs
+        https://bugs.webkit.org/show_bug.cgi?id=174994
+
+        Reviewed by Saam Barati.
+
+        This patch makes more const values in the LLInt constexprs.
+        It also deletes all of the no longer necessary static_asserts in
+        LLIntData.cpp. Finally, it fixes a typo in parser.rb.
+
+        * interpreter/ShadowChicken.h:
+        (JSC::ShadowChicken::Packet::tailMarker):
+        * llint/LLIntData.cpp:
+        (JSC::LLInt::Data::performAssertions):
+        * llint/LowLevelInterpreter.asm:
+        * offlineasm/generate_offset_extractor.rb:
+        * offlineasm/parser.rb:
+
 2017-07-31  Matt Lewis  <jlewis3@apple.com>
 
         Unreviewed, rolling out r220060.
index d7455a6..84b52e8 100644 (file)
@@ -77,11 +77,12 @@ public:
         {
         }
         
-        static const unsigned unlikelyValue = 0x7a11;
-        
+        static const constexpr unsigned unlikelyValue = 0x7a11;
+
+        static const constexpr intptr_t tailMarkerValue = static_cast<intptr_t>(unlikelyValue);
         static JSObject* tailMarker()
         {
-            return bitwise_cast<JSObject*>(static_cast<intptr_t>(unlikelyValue));
+            return bitwise_cast<JSObject*>(tailMarkerValue);
         }
         
         static JSObject* throwMarker()
index 8b615a1..1e49f2f 100644 (file)
@@ -153,79 +153,8 @@ void Data::performAssertions(VM& vm)
 #elif (CPU(X86_64) && OS(WINDOWS))
     ASSERT(CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() == 3);
 #endif
-    
-    STATIC_ASSERT(StringType == 6);
-    STATIC_ASSERT(SymbolType == 7);
-    STATIC_ASSERT(ObjectType == 23);
-    STATIC_ASSERT(FinalObjectType == 24);
-    STATIC_ASSERT(JSFunctionType == 26);
-    STATIC_ASSERT(ArrayType == 34);
-    STATIC_ASSERT(DerivedArrayType == 35);
-    STATIC_ASSERT(ProxyObjectType == 53);
-    STATIC_ASSERT(Int8ArrayType == 36);
-    STATIC_ASSERT(Int16ArrayType == 37);
-    STATIC_ASSERT(Int32ArrayType == 38);
-    STATIC_ASSERT(Uint8ArrayType == 39);
-    STATIC_ASSERT(Uint8ClampedArrayType == 40);
-    STATIC_ASSERT(Uint16ArrayType == 41);
-    STATIC_ASSERT(Uint32ArrayType == 42);
-    STATIC_ASSERT(Float32ArrayType == 43);
-    STATIC_ASSERT(Float64ArrayType == 44);
-    STATIC_ASSERT(MasqueradesAsUndefined == 1);
-    STATIC_ASSERT(ImplementsDefaultHasInstance == 2);
-    STATIC_ASSERT(FirstConstantRegisterIndex == 0x40000000);
-    STATIC_ASSERT(GlobalCode == 0);
-    STATIC_ASSERT(EvalCode == 1);
-    STATIC_ASSERT(FunctionCode == 2);
-    STATIC_ASSERT(ModuleCode == 3);
-    
-    STATIC_ASSERT(IsArray == 0x01);
-    STATIC_ASSERT(IndexingShapeMask == 0x0E);
-    STATIC_ASSERT(NoIndexingShape == 0x00);
-    STATIC_ASSERT(Int32Shape == 0x04);
-    STATIC_ASSERT(DoubleShape == 0x06);
-    STATIC_ASSERT(ContiguousShape == 0x08);
-    STATIC_ASSERT(ArrayStorageShape == 0x0A);
-    STATIC_ASSERT(SlowPutArrayStorageShape == 0x0C);
 
     ASSERT(!(reinterpret_cast<ptrdiff_t>((reinterpret_cast<WriteBarrier<JSCell>*>(0x4000)->slot())) - 0x4000));
-    static_assert(PutByIdPrimaryTypeMask == 0x6, "LLInt assumes PutByIdPrimaryTypeMask is == 0x6");
-    static_assert(PutByIdPrimaryTypeSecondary == 0x0, "LLInt assumes PutByIdPrimaryTypeSecondary is == 0x0");
-    static_assert(PutByIdPrimaryTypeObjectWithStructure == 0x2, "LLInt assumes PutByIdPrimaryTypeObjectWithStructure is == 0x2");
-    static_assert(PutByIdPrimaryTypeObjectWithStructureOrOther == 0x4, "LLInt assumes PutByIdPrimaryTypeObjectWithStructureOrOther is == 0x4");
-    static_assert(PutByIdSecondaryTypeMask == -0x8, "LLInt assumes PutByIdSecondaryTypeMask is == -0x8");
-    static_assert(PutByIdSecondaryTypeBottom == 0x0, "LLInt assumes PutByIdSecondaryTypeBottom is == 0x0");
-    static_assert(PutByIdSecondaryTypeBoolean == 0x8, "LLInt assumes PutByIdSecondaryTypeBoolean is == 0x8");
-    static_assert(PutByIdSecondaryTypeOther == 0x10, "LLInt assumes PutByIdSecondaryTypeOther is == 0x10");
-    static_assert(PutByIdSecondaryTypeInt32 == 0x18, "LLInt assumes PutByIdSecondaryTypeInt32 is == 0x18");
-    static_assert(PutByIdSecondaryTypeNumber == 0x20, "LLInt assumes PutByIdSecondaryTypeNumber is == 0x20");
-    static_assert(PutByIdSecondaryTypeString == 0x28, "LLInt assumes PutByIdSecondaryTypeString is == 0x28");
-    static_assert(PutByIdSecondaryTypeSymbol == 0x30, "LLInt assumes PutByIdSecondaryTypeSymbol is == 0x30");
-    static_assert(PutByIdSecondaryTypeObject == 0x38, "LLInt assumes PutByIdSecondaryTypeObject is == 0x38");
-    static_assert(PutByIdSecondaryTypeObjectOrOther == 0x40, "LLInt assumes PutByIdSecondaryTypeObjectOrOther is == 0x40");
-    static_assert(PutByIdSecondaryTypeTop == 0x48, "LLInt assumes PutByIdSecondaryTypeTop is == 0x48");
-
-    static_assert(GlobalProperty == 0, "LLInt assumes GlobalProperty ResultType is == 0");
-    static_assert(GlobalVar == 1, "LLInt assumes GlobalVar ResultType is == 1");
-    static_assert(GlobalLexicalVar == 2, "LLInt assumes GlobalLexicalVar ResultType is == 2");
-    static_assert(ClosureVar == 3, "LLInt assumes ClosureVar ResultType is == 3");
-    static_assert(LocalClosureVar == 4, "LLInt assumes LocalClosureVar ResultType is == 4");
-    static_assert(ModuleVar == 5, "LLInt assumes ModuleVar ResultType is == 5");
-    static_assert(GlobalPropertyWithVarInjectionChecks == 6, "LLInt assumes GlobalPropertyWithVarInjectionChecks ResultType is == 6");
-    static_assert(GlobalVarWithVarInjectionChecks == 7, "LLInt assumes GlobalVarWithVarInjectionChecks ResultType is == 7");
-    static_assert(GlobalLexicalVarWithVarInjectionChecks == 8, "LLInt assumes GlobalLexicalVarWithVarInjectionChecks ResultType is == 8");
-    static_assert(ClosureVarWithVarInjectionChecks == 9, "LLInt assumes ClosureVarWithVarInjectionChecks ResultType is == 9");
-
-    static_assert(static_cast<unsigned>(InitializationMode::NotInitialization) == 2, "LLInt assumes that InitializationMode::NotInitialization is 0");
-    
-    STATIC_ASSERT(GetPutInfo::typeBits == 0x3ff);
-    STATIC_ASSERT(GetPutInfo::initializationShift == 10);
-    STATIC_ASSERT(GetPutInfo::initializationBits == 0xffc00);
-
-    STATIC_ASSERT(MarkedBlock::blockSize == 16 * 1024);
-    STATIC_ASSERT(blackThreshold == 0);
-
-    ASSERT(bitwise_cast<uintptr_t>(ShadowChicken::Packet::tailMarker()) == static_cast<uintptr_t>(0x7a11));
 
     // FIXME: make these assertions less horrible.
 #if !ASSERT_DISABLED
index 9167f85..f540cb9 100644 (file)
@@ -204,7 +204,7 @@ else
     const LowestTag = DeletedValueTag
 end
 
-# NOTE: The values below must be in sync with what is in PutByIdFlags.h.
+# PutByIdFlags data
 const PutByIdPrimaryTypeMask = constexpr PutByIdPrimaryTypeMask
 const PutByIdPrimaryTypeSecondary = constexpr PutByIdPrimaryTypeSecondary
 const PutByIdPrimaryTypeObjectWithStructure = constexpr PutByIdPrimaryTypeObjectWithStructure
@@ -250,7 +250,7 @@ const IsWatched = constexpr IsWatched
 const IsInvalidated = constexpr IsInvalidated
 
 # ShadowChicken data
-const ShadowChickenTailMarker = 0x7a11
+const ShadowChickenTailMarker = constexpr ShadowChicken::Packet::tailMarkerValue
 
 # ArithProfile data
 const ArithProfileInt = 0x100000
@@ -401,15 +401,15 @@ const GlobalVarWithVarInjectionChecks = constexpr GlobalVarWithVarInjectionCheck
 const GlobalLexicalVarWithVarInjectionChecks = constexpr GlobalLexicalVarWithVarInjectionChecks
 const ClosureVarWithVarInjectionChecks = constexpr ClosureVarWithVarInjectionChecks
 
-const ResolveTypeMask = 0x3ff
-const InitializationModeMask = 0xffc00
-const InitializationModeShift = 10
-const NotInitialization = 2
+const ResolveTypeMask = constexpr GetPutInfo::typeBits
+const InitializationModeMask = constexpr GetPutInfo::initializationBits
+const InitializationModeShift = constexpr GetPutInfo::initializationShift
+const NotInitialization = constexpr InitializationMode::NotInitialization
 
-const MarkedBlockSize = 16 * 1024
+const MarkedBlockSize = constexpr MarkedBlock::blockSize
 const MarkedBlockMask = ~(MarkedBlockSize - 1)
 
-const BlackThreshold = 0
+const BlackThreshold = constexpr blackThreshold
 
 # Allocation constants
 if JSVALUE64
index 160b94c..84bb2d9 100644 (file)
@@ -121,6 +121,17 @@ File.open(outputFlnm, "w") {
     $output = outp
     outp.puts inputHash
     length = 0
+
+    emitCodeInAllConfigurations(prunedAST) {
+        | settings, ast, backend, index |
+        constsList = ast.filter(ConstExpr).uniq.sort
+
+        constsList.each_with_index {
+            | const, index |
+            outp.puts "constexpr int64_t constValue#{index} = static_cast<int64_t>(#{const.value});"
+        }
+    }
+
     emitCodeInAllConfigurations(prunedAST) {
         | settings, ast, backend, index |
         offsetsList = ast.filter(StructOffset).uniq.sort
@@ -152,24 +163,12 @@ File.open(outputFlnm, "w") {
             emitMagicNumber
             outp.puts "sizeof(#{sizeof.struct}),"
         }
-        constsList.each {
-            | const |
+        constsList.each_index {
+            | index |
             emitMagicNumber
-            outp.puts "static_cast<int64_t>(#{const.value}),"
+            outp.puts "constValue#{index},"
         }
     }
     outp.puts "};"
 
-    emitCodeInAllConfigurations(prunedAST) {
-        | settings, ast, backend, index |
-        constsList = ast.filter(ConstExpr).uniq.sort
-
-        constsList.each_with_index {
-            | const, index |
-            outp.puts "constexpr int64_t isConst#{index} = static_cast<int64_t>(#{const.value});"
-            # Make a trivally true static assert that uses the last value...
-            outp.puts "static_assert(isConst#{index} || true, \"\");"
-        }
-    }
-
 }
index 907021d..9f4eb1e 100644 (file)
@@ -3,7 +3,7 @@
 # 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 copyrighht
+# 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