Title: [267371] trunk/Source
Revision
267371
Author
[email protected]
Date
2020-09-21 15:01:12 -0700 (Mon, 21 Sep 2020)

Log Message

Move some LLInt globals into JSC::Config.
https://bugs.webkit.org/show_bug.cgi?id=216685
rdar://68964544

Reviewed by Keith Miller.

Source/bmalloc:

Introduce ConfigAlignment to match WTFConfig.h.
Added BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD) support to match WTF.

* bmalloc/BPlatform.h:
* bmalloc/Gigacage.cpp:
(Gigacage::ensureGigacage):
* bmalloc/GigacageConfig.h:
* bmalloc/mbmalloc.cpp:

Source/_javascript_Core:

1. Moved the following into g_jscConfig:

   Data::s_exceptionInstructions ==> g_jscConfig.llint.exceptionInstructions
   Data::s_wasmExceptionInstructions ==> g_jscConfig.llint.wasmExceptionInstructions
   g_opcodeMap ==> g_jscConfig.llint.opcodeMap
   g_opcodeMapWide16 ==> g_jscConfig.llint.opcodeMapWide16
   g_opcodeMapWide32 ==> g_jscConfig.llint.opcodeMapWide32

2. Fixed cloop.rb so that it can take an offset for the leap offlineasm instruction.
3. Fixed x86.rb so that it can take an offset for the leap offlineasm instruction.
4. Fixed arm.rb so that it can take an offset for the leap offlineasm instruction.

   Note: arm64.rb already does this right.

5. Added JSC::Config::singleton() to return a reference to g_jscConfig.
   This is useful when debugging with lldb since g_jscConfig is not an actual
   label, but is a macro that computes the address of the Config record.

This patch has been smoke tested on arm64e, x86_64, and cloop (on x86_64 and armv7k).

* llint/LLIntData.cpp:
(JSC::LLInt::LLIntInitializeAssertScope::LLIntInitializeAssertScope):
(JSC::LLInt::LLIntInitializeAssertScope::~LLIntInitializeAssertScope):
(JSC::LLInt::LLIntInitializeAssertScope::assertInitializationIsAllowed):
(JSC::LLInt::initialize):
* llint/LLIntData.h:
(JSC::LLInt::exceptionInstructions):
(JSC::LLInt::wasmExceptionInstructions):
(JSC::LLInt::opcodeMap):
(JSC::LLInt::opcodeMapWide16):
(JSC::LLInt::opcodeMapWide32):
(JSC::LLInt::getOpcode):
(JSC::LLInt::getOpcodeWide16):
(JSC::LLInt::getOpcodeWide32):
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter.cpp:
* llint/LowLevelInterpreter64.asm:
* llint/WebAssembly.asm:
* offlineasm/arm.rb:
* offlineasm/cloop.rb:
* offlineasm/x86.rb:
* runtime/JSCConfig.cpp:
(JSC::Config::singleton):
* runtime/JSCConfig.h:

Source/WTF:

1. Introduce ConfigAlignment as a distinct value from ConfigSizeToProtect.
   This is because ConfigSizeToProtect is now larger than 1 CeilingOnPageSize on
   some platforms, but ConfigAlignment only needs to match CeilingOnPageSize.

2. Introduced ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD) to disable using the
   unified g_config record for Windows ports.

   This is needed because WTF is built as a DLL on Windows.  offlineasm does not
   know how to resolve a DLL exported variable.  Additionally, the Windows ports
   have never supported freezing of the Config record to begin with.  So, we're
   working around this by disabling ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
   for Windows.  This allows JSC to have its own g_jscConfig record, which solves
   this issue for now.

* wtf/PlatformEnable.h:
* wtf/WTFConfig.cpp:
(WTF::Config::permanentlyFreeze):
* wtf/WTFConfig.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (267370 => 267371)


--- trunk/Source/_javascript_Core/ChangeLog	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,3 +1,56 @@
+2020-09-21  Mark Lam  <[email protected]>
+
+        Move some LLInt globals into JSC::Config.
+        https://bugs.webkit.org/show_bug.cgi?id=216685
+        rdar://68964544
+
+        Reviewed by Keith Miller.
+
+        1. Moved the following into g_jscConfig:
+
+           Data::s_exceptionInstructions ==> g_jscConfig.llint.exceptionInstructions
+           Data::s_wasmExceptionInstructions ==> g_jscConfig.llint.wasmExceptionInstructions
+           g_opcodeMap ==> g_jscConfig.llint.opcodeMap
+           g_opcodeMapWide16 ==> g_jscConfig.llint.opcodeMapWide16
+           g_opcodeMapWide32 ==> g_jscConfig.llint.opcodeMapWide32
+
+        2. Fixed cloop.rb so that it can take an offset for the leap offlineasm instruction.
+        3. Fixed x86.rb so that it can take an offset for the leap offlineasm instruction.
+        4. Fixed arm.rb so that it can take an offset for the leap offlineasm instruction.
+
+           Note: arm64.rb already does this right.
+
+        5. Added JSC::Config::singleton() to return a reference to g_jscConfig.
+           This is useful when debugging with lldb since g_jscConfig is not an actual
+           label, but is a macro that computes the address of the Config record.
+
+        This patch has been smoke tested on arm64e, x86_64, and cloop (on x86_64 and armv7k).
+
+        * llint/LLIntData.cpp:
+        (JSC::LLInt::LLIntInitializeAssertScope::LLIntInitializeAssertScope):
+        (JSC::LLInt::LLIntInitializeAssertScope::~LLIntInitializeAssertScope):
+        (JSC::LLInt::LLIntInitializeAssertScope::assertInitializationIsAllowed):
+        (JSC::LLInt::initialize):
+        * llint/LLIntData.h:
+        (JSC::LLInt::exceptionInstructions):
+        (JSC::LLInt::wasmExceptionInstructions):
+        (JSC::LLInt::opcodeMap):
+        (JSC::LLInt::opcodeMapWide16):
+        (JSC::LLInt::opcodeMapWide32):
+        (JSC::LLInt::getOpcode):
+        (JSC::LLInt::getOpcodeWide16):
+        (JSC::LLInt::getOpcodeWide32):
+        * llint/LowLevelInterpreter.asm:
+        * llint/LowLevelInterpreter.cpp:
+        * llint/LowLevelInterpreter64.asm:
+        * llint/WebAssembly.asm:
+        * offlineasm/arm.rb:
+        * offlineasm/cloop.rb:
+        * offlineasm/x86.rb:
+        * runtime/JSCConfig.cpp:
+        (JSC::Config::singleton):
+        * runtime/JSCConfig.h:
+
 2020-09-21  Basuke Suzuki  <[email protected]>
 
         [WinCairo][PlayStation] Support different instances of listener client.

Modified: trunk/Source/_javascript_Core/llint/LLIntData.cpp (267370 => 267371)


--- trunk/Source/_javascript_Core/llint/LLIntData.cpp	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/llint/LLIntData.cpp	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,6 +28,7 @@
 
 #include "ArithProfile.h"
 #include "CodeBlock.h"
+#include "JSCConfig.h"
 #include "LLIntCLoop.h"
 #include "Opcode.h"
 #include "WriteBarrier.h"
@@ -39,13 +40,6 @@
 
 namespace LLInt {
 
-
-uint8_t Data::s_exceptionInstructions[maxOpcodeLength + 1] = { };
-uint8_t Data::s_wasmExceptionInstructions[maxOpcodeLength + 1] = { };
-Opcode g_opcodeMap[numOpcodeIDs + numWasmOpcodeIDs] = { };
-Opcode g_opcodeMapWide16[numOpcodeIDs + numWasmOpcodeIDs] = { };
-Opcode g_opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs] = { };
-
 #if !ENABLE(C_LOOP)
 extern "C" void llint_entry(void*, void*, void*);
 
@@ -61,22 +55,22 @@
     CLoop::initialize();
 
 #else // !ENABLE(C_LOOP)
-    llint_entry(&g_opcodeMap, &g_opcodeMapWide16, &g_opcodeMapWide32);
+    llint_entry(&g_jscConfig.llint.opcodeMap, &g_jscConfig.llint.opcodeMapWide16, &g_jscConfig.llint.opcodeMapWide32);
 
 #if ENABLE(WEBASSEMBLY)
-    wasm_entry(&g_opcodeMap[numOpcodeIDs], &g_opcodeMapWide16[numOpcodeIDs], &g_opcodeMapWide32[numOpcodeIDs]);
+    wasm_entry(&g_jscConfig.llint.opcodeMap[numOpcodeIDs], &g_jscConfig.llint.opcodeMapWide16[numOpcodeIDs], &g_jscConfig.llint.opcodeMapWide32[numOpcodeIDs]);
 #endif // ENABLE(WEBASSEMBLY)
 
     for (int i = 0; i < numOpcodeIDs + numWasmOpcodeIDs; ++i) {
-        g_opcodeMap[i] = tagCodePtr(g_opcodeMap[i], BytecodePtrTag);
-        g_opcodeMapWide16[i] = tagCodePtr(g_opcodeMapWide16[i], BytecodePtrTag);
-        g_opcodeMapWide32[i] = tagCodePtr(g_opcodeMapWide32[i], BytecodePtrTag);
+        g_jscConfig.llint.opcodeMap[i] = tagCodePtr(g_jscConfig.llint.opcodeMap[i], BytecodePtrTag);
+        g_jscConfig.llint.opcodeMapWide16[i] = tagCodePtr(g_jscConfig.llint.opcodeMapWide16[i], BytecodePtrTag);
+        g_jscConfig.llint.opcodeMapWide32[i] = tagCodePtr(g_jscConfig.llint.opcodeMapWide32[i], BytecodePtrTag);
     }
 
     ASSERT(llint_throw_from_slow_path_trampoline < UINT8_MAX);
     for (unsigned i = 0; i < maxOpcodeLength + 1; ++i) {
-        Data::s_exceptionInstructions[i] = llint_throw_from_slow_path_trampoline;
-        Data::s_wasmExceptionInstructions[i] = wasm_throw_from_slow_path_trampoline;
+        g_jscConfig.llint.exceptionInstructions[i] = llint_throw_from_slow_path_trampoline;
+        g_jscConfig.llint.wasmExceptionInstructions[i] = wasm_throw_from_slow_path_trampoline;
     }
 #endif // ENABLE(C_LOOP)
 }

Modified: trunk/Source/_javascript_Core/llint/LLIntData.h (267370 => 267371)


--- trunk/Source/_javascript_Core/llint/LLIntData.h	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/llint/LLIntData.h	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,10 +43,6 @@
 
 namespace LLInt {
 
-extern "C" JS_EXPORT_PRIVATE Opcode g_opcodeMap[numOpcodeIDs + numWasmOpcodeIDs];
-extern "C" JS_EXPORT_PRIVATE Opcode g_opcodeMapWide16[numOpcodeIDs + numWasmOpcodeIDs];
-extern "C" JS_EXPORT_PRIVATE Opcode g_opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs];
-
 class Data {
 
 public:
@@ -53,9 +49,6 @@
     static void performAssertions(VM&);
 
 private:
-    static uint8_t s_exceptionInstructions[maxOpcodeLength + 1];
-    static uint8_t s_wasmExceptionInstructions[maxOpcodeLength + 1];
-
     friend void initialize();
 
     friend Instruction* exceptionInstructions();
@@ -76,33 +69,33 @@
 
 inline Instruction* exceptionInstructions()
 {
-    return reinterpret_cast<Instruction*>(Data::s_exceptionInstructions);
+    return reinterpret_cast<Instruction*>(g_jscConfig.llint.exceptionInstructions);
 }
     
 inline Instruction* wasmExceptionInstructions()
 {
-    return bitwise_cast<Instruction*>(Data::s_wasmExceptionInstructions);
+    return bitwise_cast<Instruction*>(g_jscConfig.llint.wasmExceptionInstructions);
 }
 
 inline Opcode* opcodeMap()
 {
-    return g_opcodeMap;
+    return g_jscConfig.llint.opcodeMap;
 }
 
 inline Opcode* opcodeMapWide16()
 {
-    return g_opcodeMapWide16;
+    return g_jscConfig.llint.opcodeMapWide16;
 }
 
 inline Opcode* opcodeMapWide32()
 {
-    return g_opcodeMapWide32;
+    return g_jscConfig.llint.opcodeMapWide32;
 }
 
 inline Opcode getOpcode(OpcodeID id)
 {
 #if ENABLE(COMPUTED_GOTO_OPCODES)
-    return g_opcodeMap[id];
+    return g_jscConfig.llint.opcodeMap[id];
 #else
     return static_cast<Opcode>(id);
 #endif
@@ -111,7 +104,7 @@
 inline Opcode getOpcodeWide16(OpcodeID id)
 {
 #if ENABLE(COMPUTED_GOTO_OPCODES)
-    return g_opcodeMapWide16[id];
+    return g_jscConfig.llint.opcodeMapWide16[id];
 #else
     UNUSED_PARAM(id);
     RELEASE_ASSERT_NOT_REACHED();
@@ -121,7 +114,7 @@
 inline Opcode getOpcodeWide32(OpcodeID id)
 {
 #if ENABLE(COMPUTED_GOTO_OPCODES)
-    return g_opcodeMapWide32[id];
+    return g_jscConfig.llint.opcodeMapWide32[id];
 #else
     UNUSED_PARAM(id);
     RELEASE_ASSERT_NOT_REACHED();

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (267370 => 267371)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2019 Apple Inc. All rights reserved.
+# Copyright (C) 2011-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -315,22 +315,29 @@
 const OpcodeIDWide16Size = 2 # Wide16 Prefix + OpcodeID
 const OpcodeIDWide32Size = 2 # Wide32 Prefix + OpcodeID
 
+if X86_64_WIN or C_LOOP_WIN
+    const GigacageConfig = _g_gigacageConfig
+    const JSCConfig = _g_jscConfig
+else
+    const GigacageConfig = _g_config + constexpr Gigacage::startOffsetOfGigacageConfig
+    const JSCConfig = _g_config + constexpr WTF::offsetOfWTFConfigExtension
+end
 
 macro nextInstruction()
     loadb [PB, PC, 1], t0
-    leap _g_opcodeMap, t1
+    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMap, t1
     jmp [t1, t0, PtrSize], BytecodePtrTag
 end
 
 macro nextInstructionWide16()
     loadb OpcodeIDNarrowSize[PB, PC, 1], t0
-    leap _g_opcodeMapWide16, t1
+    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide16, t1
     jmp [t1, t0, PtrSize], BytecodePtrTag
 end
 
 macro nextInstructionWide32()
     loadb OpcodeIDNarrowSize[PB, PC, 1], t0
-    leap _g_opcodeMapWide32, t1
+    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide32, t1
     jmp [t1, t0, PtrSize], BytecodePtrTag
 end
 

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp (267370 => 267371)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.cpp	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -87,6 +87,8 @@
 // Define the opcode dispatch mechanism when using the C loop:
 //
 
+using WebConfig::g_config;
+
 // These are for building a C Loop interpreter:
 #define OFFLINE_ASM_BEGIN
 #define OFFLINE_ASM_END

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (267370 => 267371)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2020-09-21 22:01:12 UTC (rev 267371)
@@ -440,7 +440,7 @@
 
 macro cagePrimitive(basePtr, mask, ptr, scratch)
     if GIGACAGE_ENABLED and not (C_LOOP or C_LOOP_WIN)
-        loadb _g_config + (constexpr Gigacage::startOffsetOfGigacageConfig) + Gigacage::Config::disablingPrimitiveGigacageIsForbidden, scratch
+        loadb GigacageConfig + Gigacage::Config::disablingPrimitiveGigacageIsForbidden, scratch
         btbnz scratch, .doCaging
 
         loadb _disablePrimitiveGigacageRequested, scratch
@@ -460,7 +460,7 @@
         const source = ptr
     end
     if GIGACAGE_ENABLED
-        cagePrimitive(_g_config + (constexpr Gigacage::startOffsetOfGigacageConfig) + Gigacage::Config::basePtrs + GigacagePrimitiveBasePtrOffset, constexpr Gigacage::primitiveGigacageMask, source, scratch)
+        cagePrimitive(GigacageConfig + Gigacage::Config::basePtrs + GigacagePrimitiveBasePtrOffset, constexpr Gigacage::primitiveGigacageMask, source, scratch)
         if ARM64E
             const numberOfPACBits = constexpr MacroAssembler::numberOfPACBits
             bfiq scratch2, 0, 64 - numberOfPACBits, ptr
@@ -474,7 +474,7 @@
 macro loadCagedJSValue(source, dest, scratchOrLength)
     loadp source, dest
     if GIGACAGE_ENABLED
-        cage(_g_config + (constexpr Gigacage::startOffsetOfGigacageConfig) + Gigacage::Config::basePtrs + GigacageJSValueBasePtrOffset, constexpr Gigacage::jsValueGigacageMask, dest, scratchOrLength)
+        cage(GigacageConfig + Gigacage::Config::basePtrs + GigacageJSValueBasePtrOffset, constexpr Gigacage::jsValueGigacageMask, dest, scratchOrLength)
     end
 end
 

Modified: trunk/Source/_javascript_Core/llint/WebAssembly.asm (267370 => 267371)


--- trunk/Source/_javascript_Core/llint/WebAssembly.asm	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/llint/WebAssembly.asm	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,4 +1,4 @@
-# Copyright (C) 2019 Apple Inc. All rights reserved.
+# Copyright (C) 2019-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -95,19 +95,19 @@
 
 macro wasmNextInstruction()
     loadb [PB, PC, 1], t0
-    leap _g_opcodeMap, t1
+    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMap, t1
     jmp NumberOfJSOpcodeIDs * PtrSize[t1, t0, PtrSize], BytecodePtrTag
 end
 
 macro wasmNextInstructionWide16()
     loadb OpcodeIDNarrowSize[PB, PC, 1], t0
-    leap _g_opcodeMapWide16, t1
+    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide16, t1
     jmp NumberOfJSOpcodeIDs * PtrSize[t1, t0, PtrSize], BytecodePtrTag
 end
 
 macro wasmNextInstructionWide32()
     loadb OpcodeIDNarrowSize[PB, PC, 1], t0
-    leap _g_opcodeMapWide32, t1
+    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide32, t1
     jmp NumberOfJSOpcodeIDs * PtrSize[t1, t0, PtrSize], BytecodePtrTag
 end
 

Modified: trunk/Source/_javascript_Core/offlineasm/arm.rb (267370 => 267371)


--- trunk/Source/_javascript_Core/offlineasm/arm.rb	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/offlineasm/arm.rb	2020-09-21 22:01:12 UTC (rev 267371)
@@ -262,9 +262,16 @@
             when "leai", "leap", "leaq"
                 labelRef = node.operands[0]
                 if labelRef.is_a? LabelReference
-                    raise unless labelRef.offset == 0
                     tmp = Tmp.new(node.codeOrigin, :gpr)
                     newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), node.operands[1], tmp])
+                    # FIXME: This check against 255 is just the simplest check we can do. ARM is capable of encoding some larger constants using
+                    # rotation (subject to some special rules). Perhaps we can add the more comprehensive encoding check here.
+                    if labelRef.offset > 255
+                        newList << Instruction.new(codeOrigin, "move", [Immediate.new(node.codeOrigin, labelRef.offset), tmp])
+                        newList << Instruction.new(codeOrigin, "addp", [tmp, node.operands[1]])
+                    elsif labelRef.offset > 0
+                        newList << Instruction.new(codeOrigin, "addp", [Immediate.new(node.codeOrigin, labelRef.offset), node.operands[1]])
+                    end
                 else
                     newList << node
                 end

Modified: trunk/Source/_javascript_Core/offlineasm/cloop.rb (267370 => 267371)


--- trunk/Source/_javascript_Core/offlineasm/cloop.rb	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/offlineasm/cloop.rb	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2019 Apple Inc. All rights reserved.
+# Copyright (C) 2012-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -333,6 +333,9 @@
     end
     def cloopEmitLea(destination, type)
         $asm.putc "#{destination.clLValue(:voidPtr)} = CAST<void*>(&#{cLabel});"
+        if offset != 0
+            $asm.putc "#{destination.clLValue(:int8Ptr)} = #{destination.clValue(:int8Ptr)} + #{offset};"
+        end
     end
 end
 
@@ -344,7 +347,7 @@
 class Address
     def cloopEmitLea(destination, type)
         if destination == base
-            $asm.putc "#{destination.clLValue(:int8Ptr)} += #{offset.clValue(type)};"
+            $asm.putc "#{destination.clLValue(:int8Ptr)} = #{destination.clValue(:int8Ptr)} + #{offset.clValue(type)};"
         else
             $asm.putc "#{destination.clLValue(:int8Ptr)} = #{base.clValue(:int8Ptr)} + #{offset.clValue(type)};"
         end

Modified: trunk/Source/_javascript_Core/offlineasm/x86.rb (267370 => 267371)


--- trunk/Source/_javascript_Core/offlineasm/x86.rb	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/offlineasm/x86.rb	2020-09-21 22:01:12 UTC (rev 267371)
@@ -575,6 +575,9 @@
             else
                 $asm.puts "lea #{dst.x86Operand(:ptr)}, #{src.asmLabel}"
             end
+            if src.offset != 0
+                $asm.puts "add#{x86Suffix(kind)} #{orderOperands(const(src.offset), dst.x86Operand(kind))}"
+            end
         else
             $asm.puts "lea#{x86Suffix(kind)} #{orderOperands(src.x86AddressOperand(kind), dst.x86Operand(kind))}"
         end

Modified: trunk/Source/_javascript_Core/runtime/JSCConfig.cpp (267370 => 267371)


--- trunk/Source/_javascript_Core/runtime/JSCConfig.cpp	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.cpp	2020-09-21 22:01:12 UTC (rev 267371)
@@ -28,6 +28,15 @@
 
 namespace JSC {
 
+#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+Config g_jscConfig;
+#endif
+
+Config& Config::singleton()
+{
+    return g_jscConfig;
+}
+
 void Config::disableFreezingForTesting()
 {
     RELEASE_ASSERT(!g_jscConfig.isPermanentlyFrozen());

Modified: trunk/Source/_javascript_Core/runtime/JSCConfig.h (267370 => 267371)


--- trunk/Source/_javascript_Core/runtime/JSCConfig.h	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.h	2020-09-21 22:01:12 UTC (rev 267371)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "Opcode.h"
 #include "OptionsList.h"
 #include <wtf/WTFConfig.h>
 
@@ -34,13 +35,13 @@
 class FixedVMPoolExecutableAllocator;
 class VM;
 
-constexpr size_t ConfigSizeToProtect = CeilingOnPageSize;
-
 #if ENABLE(SEPARATED_WX_HEAP)
 using JITWriteSeparateHeapsFunction = void (*)(off_t, const void*, size_t);
 #endif
 
 struct Config {
+    static Config& singleton();
+
     JS_EXPORT_PRIVATE static void disableFreezingForTesting();
     JS_EXPORT_PRIVATE static void enableRestrictedOptions();
     static void permanentlyFreeze() { WTF::Config::permanentlyFreeze(); }
@@ -85,9 +86,21 @@
 
     void (*shellTimeoutCheckCallback)(VM&);
 
+    struct {
+        uint8_t exceptionInstructions[maxOpcodeLength + 1];
+        uint8_t wasmExceptionInstructions[maxOpcodeLength + 1];
+        Opcode opcodeMap[numOpcodeIDs + numWasmOpcodeIDs];
+        Opcode opcodeMapWide16[numOpcodeIDs + numWasmOpcodeIDs];
+        Opcode opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs];
+    } llint;
+
+#if CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)
     WTF::PtrTagLookup ptrTagLookupRecord;
+#endif
 };
 
+#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 constexpr size_t alignmentOfJSCConfig = std::alignment_of<JSC::Config>::value;
 
 static_assert(WTF::offsetOfWTFConfigExtension + sizeof(JSC::Config) <= WTF::ConfigSizeToProtect);
@@ -95,4 +108,18 @@
 
 #define g_jscConfig (*bitwise_cast<JSC::Config*>(&g_wtfConfig.spaceForExtensions))
 
+#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
+extern "C" JS_EXPORT_PRIVATE Config g_jscConfig;
+
+#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
+constexpr size_t offsetOfJSCConfigOpcodeMap = offsetof(JSC::Config, llint.opcodeMap);
+constexpr size_t offsetOfJSCConfigOpcodeMapWide16 = offsetof(JSC::Config, llint.opcodeMapWide16);
+constexpr size_t offsetOfJSCConfigOpcodeMapWide32 = offsetof(JSC::Config, llint.opcodeMapWide32);
+
 } // namespace JSC
+
+#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+using JSC::g_jscConfig;
+#endif

Modified: trunk/Source/WTF/ChangeLog (267370 => 267371)


--- trunk/Source/WTF/ChangeLog	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/WTF/ChangeLog	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,3 +1,30 @@
+2020-09-21  Mark Lam  <[email protected]>
+
+        Move some LLInt globals into JSC::Config.
+        https://bugs.webkit.org/show_bug.cgi?id=216685
+        rdar://68964544
+
+        Reviewed by Keith Miller.
+
+        1. Introduce ConfigAlignment as a distinct value from ConfigSizeToProtect.
+           This is because ConfigSizeToProtect is now larger than 1 CeilingOnPageSize on
+           some platforms, but ConfigAlignment only needs to match CeilingOnPageSize.
+
+        2. Introduced ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD) to disable using the
+           unified g_config record for Windows ports.
+
+           This is needed because WTF is built as a DLL on Windows.  offlineasm does not
+           know how to resolve a DLL exported variable.  Additionally, the Windows ports
+           have never supported freezing of the Config record to begin with.  So, we're
+           working around this by disabling ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+           for Windows.  This allows JSC to have its own g_jscConfig record, which solves
+           this issue for now.
+
+        * wtf/PlatformEnable.h:
+        * wtf/WTFConfig.cpp:
+        (WTF::Config::permanentlyFreeze):
+        * wtf/WTFConfig.h:
+
 2020-09-18  Don Olmstead  <[email protected]>
 
         [WebGPU] Add ENABLE(WHLSL_COMPILER) guard

Modified: trunk/Source/WTF/wtf/PlatformEnable.h (267370 => 267371)


--- trunk/Source/WTF/wtf/PlatformEnable.h	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/WTF/wtf/PlatformEnable.h	2020-09-21 22:01:12 UTC (rev 267371)
@@ -771,6 +771,24 @@
 #define ENABLE_SIGNAL_BASED_VM_TRAPS 1
 #endif
 
+/* The unified Config record feature is not available for Windows because the
+   Windows port puts WTF in a separate DLL, and the offlineasm code accessing
+   the config record expects the config record to be directly accessible like
+   a global variable (and not have to go thru DLL shenanigans). C++ code would
+   resolve these DLL bindings automatically, but offlineasm does not.
+
+   The permanently freezing feature also currently relies on the Config records
+   being unified, and the Windows port also does not currently have an
+   implementation for the freezing mechanism anyway. For simplicity, we just
+   disable both the use of unified Config record and config freezing for the
+   Windows port.
+*/
+#if OS(WINDOWS)
+#define ENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 0
+#else
+#define ENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 1
+#endif
+
 /* CSS Selector JIT Compiler */
 #if !defined(ENABLE_CSS_SELECTOR_JIT) && ((CPU(X86_64) || CPU(ARM64) || (CPU(ARM_THUMB2) && OS(DARWIN))) && ENABLE(JIT) && (OS(DARWIN) || PLATFORM(GTK) || PLATFORM(WPE)))
 #define ENABLE_CSS_SELECTOR_JIT 1

Modified: trunk/Source/WTF/wtf/WTFConfig.cpp (267370 => 267371)


--- trunk/Source/WTF/wtf/WTFConfig.cpp	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/WTF/wtf/WTFConfig.cpp	2020-09-21 22:01:12 UTC (rev 267371)
@@ -36,14 +36,26 @@
 #include <sys/mman.h>
 #endif
 
+#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 namespace WebConfig {
 
-alignas(WTF::ConfigSizeToProtect) Slot g_config[WTF::ConfigSizeToProtect / sizeof(Slot)];
+alignas(WTF::ConfigAlignment) Slot g_config[WTF::ConfigSizeToProtect / sizeof(Slot)];
 
 } // namespace WebConfig
 
+#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 namespace WTF {
 
+Config g_wtfConfig;
+
+} // namespace WTF
+
+#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
+namespace WTF {
+
 void Config::permanentlyFreeze()
 {
     static Lock configLock;
@@ -59,6 +71,8 @@
     }
 
     int result = 0;
+
+#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
 #if OS(DARWIN)
     enum {
         AllowPermissionChangesAfterThis = false,
@@ -72,7 +86,13 @@
 #elif OS(WINDOWS)
     // FIXME: Implement equivalent, maybe with VirtualProtect.
     // Also need to fix WebKitTestRunner.
+
+    // Note: the Windows port also currently does not support a unified Config
+    // record, which is needed for the current form of the freezing feature to
+    // work. See comments in PlatformEnable.h for UNIFIED_AND_FREEZABLE_CONFIG_RECORD.
 #endif
+#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
     RELEASE_ASSERT(!result);
     RELEASE_ASSERT(g_wtfConfig.isPermanentlyFrozen);
 }

Modified: trunk/Source/WTF/wtf/WTFConfig.h (267370 => 267371)


--- trunk/Source/WTF/wtf/WTFConfig.h	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/WTF/wtf/WTFConfig.h	2020-09-21 22:01:12 UTC (rev 267371)
@@ -42,6 +42,7 @@
 #include <bmalloc/GigacageConfig.h>
 #endif
 
+#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
 namespace WebConfig {
 
 using Slot = uint64_t;
@@ -48,10 +49,12 @@
 extern "C" WTF_EXPORT_PRIVATE Slot g_config[];
 
 } // namespace WebConfig
+#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
 
 namespace WTF {
 
-constexpr size_t ConfigSizeToProtect = CeilingOnPageSize;
+constexpr size_t ConfigAlignment = CeilingOnPageSize;
+constexpr size_t ConfigSizeToProtect = std::max(CeilingOnPageSize, 16 * KB);
 
 struct Config {
     WTF_EXPORT_PRIVATE static void permanentlyFreeze();
@@ -75,6 +78,8 @@
     uint64_t spaceForExtensions[1];
 };
 
+#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 constexpr size_t startSlotOfWTFConfig = Gigacage::reservedSlotsForGigacageConfig;
 constexpr size_t startOffsetOfWTFConfig = startSlotOfWTFConfig * sizeof(WebConfig::Slot);
 
@@ -87,6 +92,12 @@
 
 #define g_wtfConfig (*bitwise_cast<WTF::Config*>(&WebConfig::g_config[WTF::startSlotOfWTFConfig]))
 
+#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
+extern "C" WTF_EXPORT_PRIVATE Config g_wtfConfig;
+
+#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 ALWAYS_INLINE Config::AssertNotFrozenScope::AssertNotFrozenScope()
 {
     RELEASE_ASSERT(!g_wtfConfig.isPermanentlyFrozen);
@@ -100,3 +111,7 @@
 };
 
 } // namespace WTF
+
+#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+using WTF::g_wtfConfig;
+#endif

Modified: trunk/Source/bmalloc/ChangeLog (267370 => 267371)


--- trunk/Source/bmalloc/ChangeLog	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/bmalloc/ChangeLog	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,3 +1,20 @@
+2020-09-21  Mark Lam  <[email protected]>
+
+        Move some LLInt globals into JSC::Config.
+        https://bugs.webkit.org/show_bug.cgi?id=216685
+        rdar://68964544
+
+        Reviewed by Keith Miller.
+
+        Introduce ConfigAlignment to match WTFConfig.h.
+        Added BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD) support to match WTF.
+
+        * bmalloc/BPlatform.h:
+        * bmalloc/Gigacage.cpp:
+        (Gigacage::ensureGigacage):
+        * bmalloc/GigacageConfig.h:
+        * bmalloc/mbmalloc.cpp:
+
 2020-08-07  Saam Barati  <[email protected]>
 
         Use thread_switch instead of switch_pri to drop priority to zero for 1ms instead of 10

Modified: trunk/Source/bmalloc/bmalloc/BPlatform.h (267370 => 267371)


--- trunk/Source/bmalloc/bmalloc/BPlatform.h	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/bmalloc/bmalloc/BPlatform.h	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -96,6 +96,10 @@
 #define BPLATORM_PLAYSTATION 1
 #endif
 
+/* ==== Feature decision macros: these define feature choices for a particular port. ==== */
+
+#define BENABLE(WTF_FEATURE) (defined BENABLE_##WTF_FEATURE && BENABLE_##WTF_FEATURE)
+
 /* ==== Policy decision macros: these define policy choices for a particular port. ==== */
 
 /* BUSE() - use a particular third-party library or optional OS service */
@@ -318,3 +322,21 @@
 #if !defined(BUSE_PRECOMPUTED_CONSTANTS_VMPAGE16K)
 #define BUSE_PRECOMPUTED_CONSTANTS_VMPAGE16K 1
 #endif
+
+/* The unified Config record feature is not available for Windows because the
+   Windows port puts WTF in a separate DLL, and the offlineasm code accessing
+   the config record expects the config record to be directly accessible like
+   a global variable (and not have to go thru DLL shenanigans). C++ code would
+   resolve these DLL bindings automatically, but offlineasm does not.
+
+   The permanently freezing feature also currently relies on the Config records
+   being unified, and the Windows port also does not currently have an
+   implementation for the freezing mechanism anyway. For simplicity, we just
+   disable both the use of unified Config record and config freezing for the
+   Windows port.
+*/
+#if BOS(WINDOWS)
+#define BENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 0
+#else
+#define BENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 1
+#endif

Modified: trunk/Source/bmalloc/bmalloc/Gigacage.cpp (267370 => 267371)


--- trunk/Source/bmalloc/bmalloc/Gigacage.cpp	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/bmalloc/bmalloc/Gigacage.cpp	2020-09-21 22:01:12 UTC (rev 267371)
@@ -43,6 +43,10 @@
 
 namespace Gigacage {
 
+#if !BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+Config g_gigacageConfig;
+#endif
+
 struct Callback {
     Callback() { }
     
@@ -111,10 +115,12 @@
 
             if (!shouldBeEnabled())
                 return;
-            
+
+#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
             // We might only get page size alignment, but that's also the minimum
             // alignment we need for freezing the Config.
             RELEASE_BASSERT(!(reinterpret_cast<size_t>(&g_gigacageConfig) & (vmPageSize() - 1)));
+#endif
 
             Kind shuffledKinds[NumberOfKinds];
             for (unsigned i = 0; i < NumberOfKinds; ++i)

Modified: trunk/Source/bmalloc/bmalloc/GigacageConfig.h (267370 => 267371)


--- trunk/Source/bmalloc/bmalloc/GigacageConfig.h	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/bmalloc/bmalloc/GigacageConfig.h	2020-09-21 22:01:12 UTC (rev 267371)
@@ -30,6 +30,8 @@
 #include "StdLibExtras.h"
 #include <inttypes.h>
 
+#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 namespace WebConfig {
 
 using Slot = uint64_t;
@@ -37,6 +39,8 @@
 
 } // namespace WebConfig
 
+#endif // BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 namespace Gigacage {
 
 struct Config {
@@ -72,6 +76,8 @@
     void* basePtrs[NumberOfKinds];
 };
 
+#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 constexpr size_t startSlotOfGigacageConfig = 0;
 constexpr size_t startOffsetOfGigacageConfig = startSlotOfGigacageConfig * sizeof(WebConfig::Slot);
 
@@ -85,4 +91,14 @@
 
 #define g_gigacageConfig (*bmalloc::bitwise_cast<Gigacage::Config*>(&WebConfig::g_config[Gigacage::startSlotOfGigacageConfig]))
 
+#else // not BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
+extern "C" BEXPORT Config g_gigacageConfig;
+
+#endif // BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 } // namespace Gigacage
+
+#if !BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+using Gigacage::g_gigacageConfig;
+#endif

Modified: trunk/Source/bmalloc/bmalloc/mbmalloc.cpp (267370 => 267371)


--- trunk/Source/bmalloc/bmalloc/mbmalloc.cpp	2020-09-21 21:45:23 UTC (rev 267370)
+++ trunk/Source/bmalloc/bmalloc/mbmalloc.cpp	2020-09-21 22:01:12 UTC (rev 267371)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,14 +28,29 @@
 #include "BExport.h"
 #include "GigacageConfig.h"
 
+#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 namespace WebConfig {
 
+// FIXME: Other than OS(DARWIN) || PLATFORM(PLAYSTATION), CeilingOnPageSize is
+// not 16K. ConfigAlignment should match that.
+constexpr size_t ConfigAlignment = 16 * bmalloc::Sizes::kB;
 constexpr size_t ConfigSizeToProtect = 16 * bmalloc::Sizes::kB;
 
-alignas(ConfigSizeToProtect) BEXPORT Slot g_config[ConfigSizeToProtect / sizeof(Slot)];
+alignas(ConfigAlignment) BEXPORT Slot g_config[ConfigSizeToProtect / sizeof(Slot)];
 
 } // namespace WebConfig
 
+#else // !BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
+namespace Gigacage {
+
+Config g_gigacageConfig;
+
+} // namespace Gigacage
+
+#endif // BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
+
 extern "C" {
 
 BEXPORT void* mbmalloc(size_t);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to