Changeset 267371 in webkit


Ignore:
Timestamp:
Sep 21, 2020 3:01:12 PM (4 years ago)
Author:
mark.lam@apple.com
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/JavaScriptCore:

  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

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

Note: arm64.rb already does this right.

  1. 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.
  1. 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:
Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r267370 r267371  
     12020-09-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Move some LLInt globals into JSC::Config.
     4        https://bugs.webkit.org/show_bug.cgi?id=216685
     5        rdar://68964544
     6
     7        Reviewed by Keith Miller.
     8
     9        1. Moved the following into g_jscConfig:
     10
     11           Data::s_exceptionInstructions ==> g_jscConfig.llint.exceptionInstructions
     12           Data::s_wasmExceptionInstructions ==> g_jscConfig.llint.wasmExceptionInstructions
     13           g_opcodeMap ==> g_jscConfig.llint.opcodeMap
     14           g_opcodeMapWide16 ==> g_jscConfig.llint.opcodeMapWide16
     15           g_opcodeMapWide32 ==> g_jscConfig.llint.opcodeMapWide32
     16
     17        2. Fixed cloop.rb so that it can take an offset for the leap offlineasm instruction.
     18        3. Fixed x86.rb so that it can take an offset for the leap offlineasm instruction.
     19        4. Fixed arm.rb so that it can take an offset for the leap offlineasm instruction.
     20
     21           Note: arm64.rb already does this right.
     22
     23        5. Added JSC::Config::singleton() to return a reference to g_jscConfig.
     24           This is useful when debugging with lldb since g_jscConfig is not an actual
     25           label, but is a macro that computes the address of the Config record.
     26
     27        This patch has been smoke tested on arm64e, x86_64, and cloop (on x86_64 and armv7k).
     28
     29        * llint/LLIntData.cpp:
     30        (JSC::LLInt::LLIntInitializeAssertScope::LLIntInitializeAssertScope):
     31        (JSC::LLInt::LLIntInitializeAssertScope::~LLIntInitializeAssertScope):
     32        (JSC::LLInt::LLIntInitializeAssertScope::assertInitializationIsAllowed):
     33        (JSC::LLInt::initialize):
     34        * llint/LLIntData.h:
     35        (JSC::LLInt::exceptionInstructions):
     36        (JSC::LLInt::wasmExceptionInstructions):
     37        (JSC::LLInt::opcodeMap):
     38        (JSC::LLInt::opcodeMapWide16):
     39        (JSC::LLInt::opcodeMapWide32):
     40        (JSC::LLInt::getOpcode):
     41        (JSC::LLInt::getOpcodeWide16):
     42        (JSC::LLInt::getOpcodeWide32):
     43        * llint/LowLevelInterpreter.asm:
     44        * llint/LowLevelInterpreter.cpp:
     45        * llint/LowLevelInterpreter64.asm:
     46        * llint/WebAssembly.asm:
     47        * offlineasm/arm.rb:
     48        * offlineasm/cloop.rb:
     49        * offlineasm/x86.rb:
     50        * runtime/JSCConfig.cpp:
     51        (JSC::Config::singleton):
     52        * runtime/JSCConfig.h:
     53
    1542020-09-21  Basuke Suzuki  <basuke.suzuki@sony.com>
    255
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r262054 r267371  
    11/*
    2  * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#include "ArithProfile.h"
    3030#include "CodeBlock.h"
     31#include "JSCConfig.h"
    3132#include "LLIntCLoop.h"
    3233#include "Opcode.h"
     
    3940
    4041namespace LLInt {
    41 
    42 
    43 uint8_t Data::s_exceptionInstructions[maxOpcodeLength + 1] = { };
    44 uint8_t Data::s_wasmExceptionInstructions[maxOpcodeLength + 1] = { };
    45 Opcode g_opcodeMap[numOpcodeIDs + numWasmOpcodeIDs] = { };
    46 Opcode g_opcodeMapWide16[numOpcodeIDs + numWasmOpcodeIDs] = { };
    47 Opcode g_opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs] = { };
    4842
    4943#if !ENABLE(C_LOOP)
     
    6256
    6357#else // !ENABLE(C_LOOP)
    64     llint_entry(&g_opcodeMap, &g_opcodeMapWide16, &g_opcodeMapWide32);
     58    llint_entry(&g_jscConfig.llint.opcodeMap, &g_jscConfig.llint.opcodeMapWide16, &g_jscConfig.llint.opcodeMapWide32);
    6559
    6660#if ENABLE(WEBASSEMBLY)
    67     wasm_entry(&g_opcodeMap[numOpcodeIDs], &g_opcodeMapWide16[numOpcodeIDs], &g_opcodeMapWide32[numOpcodeIDs]);
     61    wasm_entry(&g_jscConfig.llint.opcodeMap[numOpcodeIDs], &g_jscConfig.llint.opcodeMapWide16[numOpcodeIDs], &g_jscConfig.llint.opcodeMapWide32[numOpcodeIDs]);
    6862#endif // ENABLE(WEBASSEMBLY)
    6963
    7064    for (int i = 0; i < numOpcodeIDs + numWasmOpcodeIDs; ++i) {
    71         g_opcodeMap[i] = tagCodePtr(g_opcodeMap[i], BytecodePtrTag);
    72         g_opcodeMapWide16[i] = tagCodePtr(g_opcodeMapWide16[i], BytecodePtrTag);
    73         g_opcodeMapWide32[i] = tagCodePtr(g_opcodeMapWide32[i], BytecodePtrTag);
     65        g_jscConfig.llint.opcodeMap[i] = tagCodePtr(g_jscConfig.llint.opcodeMap[i], BytecodePtrTag);
     66        g_jscConfig.llint.opcodeMapWide16[i] = tagCodePtr(g_jscConfig.llint.opcodeMapWide16[i], BytecodePtrTag);
     67        g_jscConfig.llint.opcodeMapWide32[i] = tagCodePtr(g_jscConfig.llint.opcodeMapWide32[i], BytecodePtrTag);
    7468    }
    7569
    7670    ASSERT(llint_throw_from_slow_path_trampoline < UINT8_MAX);
    7771    for (unsigned i = 0; i < maxOpcodeLength + 1; ++i) {
    78         Data::s_exceptionInstructions[i] = llint_throw_from_slow_path_trampoline;
    79         Data::s_wasmExceptionInstructions[i] = wasm_throw_from_slow_path_trampoline;
     72        g_jscConfig.llint.exceptionInstructions[i] = llint_throw_from_slow_path_trampoline;
     73        g_jscConfig.llint.wasmExceptionInstructions[i] = wasm_throw_from_slow_path_trampoline;
    8074    }
    8175#endif // ENABLE(C_LOOP)
  • trunk/Source/JavaScriptCore/llint/LLIntData.h

    r254674 r267371  
    11/*
    2  * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444namespace LLInt {
    4545
    46 extern "C" JS_EXPORT_PRIVATE Opcode g_opcodeMap[numOpcodeIDs + numWasmOpcodeIDs];
    47 extern "C" JS_EXPORT_PRIVATE Opcode g_opcodeMapWide16[numOpcodeIDs + numWasmOpcodeIDs];
    48 extern "C" JS_EXPORT_PRIVATE Opcode g_opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs];
    49 
    5046class Data {
    5147
     
    5450
    5551private:
    56     static uint8_t s_exceptionInstructions[maxOpcodeLength + 1];
    57     static uint8_t s_wasmExceptionInstructions[maxOpcodeLength + 1];
    58 
    5952    friend void initialize();
    6053
     
    7770inline Instruction* exceptionInstructions()
    7871{
    79     return reinterpret_cast<Instruction*>(Data::s_exceptionInstructions);
     72    return reinterpret_cast<Instruction*>(g_jscConfig.llint.exceptionInstructions);
    8073}
    8174   
    8275inline Instruction* wasmExceptionInstructions()
    8376{
    84     return bitwise_cast<Instruction*>(Data::s_wasmExceptionInstructions);
     77    return bitwise_cast<Instruction*>(g_jscConfig.llint.wasmExceptionInstructions);
    8578}
    8679
    8780inline Opcode* opcodeMap()
    8881{
    89     return g_opcodeMap;
     82    return g_jscConfig.llint.opcodeMap;
    9083}
    9184
    9285inline Opcode* opcodeMapWide16()
    9386{
    94     return g_opcodeMapWide16;
     87    return g_jscConfig.llint.opcodeMapWide16;
    9588}
    9689
    9790inline Opcode* opcodeMapWide32()
    9891{
    99     return g_opcodeMapWide32;
     92    return g_jscConfig.llint.opcodeMapWide32;
    10093}
    10194
     
    10396{
    10497#if ENABLE(COMPUTED_GOTO_OPCODES)
    105     return g_opcodeMap[id];
     98    return g_jscConfig.llint.opcodeMap[id];
    10699#else
    107100    return static_cast<Opcode>(id);
     
    112105{
    113106#if ENABLE(COMPUTED_GOTO_OPCODES)
    114     return g_opcodeMapWide16[id];
     107    return g_jscConfig.llint.opcodeMapWide16[id];
    115108#else
    116109    UNUSED_PARAM(id);
     
    122115{
    123116#if ENABLE(COMPUTED_GOTO_OPCODES)
    124     return g_opcodeMapWide32[id];
     117    return g_jscConfig.llint.opcodeMapWide32[id];
    125118#else
    126119    UNUSED_PARAM(id);
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r265907 r267371  
    1 # Copyright (C) 2011-2019 Apple Inc. All rights reserved.
     1# Copyright (C) 2011-2020 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    316316const OpcodeIDWide32Size = 2 # Wide32 Prefix + OpcodeID
    317317
     318if X86_64_WIN or C_LOOP_WIN
     319    const GigacageConfig = _g_gigacageConfig
     320    const JSCConfig = _g_jscConfig
     321else
     322    const GigacageConfig = _g_config + constexpr Gigacage::startOffsetOfGigacageConfig
     323    const JSCConfig = _g_config + constexpr WTF::offsetOfWTFConfigExtension
     324end
    318325
    319326macro nextInstruction()
    320327    loadb [PB, PC, 1], t0
    321     leap _g_opcodeMap, t1
     328    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMap, t1
    322329    jmp [t1, t0, PtrSize], BytecodePtrTag
    323330end
     
    325332macro nextInstructionWide16()
    326333    loadb OpcodeIDNarrowSize[PB, PC, 1], t0
    327     leap _g_opcodeMapWide16, t1
     334    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide16, t1
    328335    jmp [t1, t0, PtrSize], BytecodePtrTag
    329336end
     
    331338macro nextInstructionWide32()
    332339    loadb OpcodeIDNarrowSize[PB, PC, 1], t0
    333     leap _g_opcodeMapWide32, t1
     340    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide32, t1
    334341    jmp [t1, t0, PtrSize], BytecodePtrTag
    335342end
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.cpp

    r259734 r267371  
    11/*
    2  * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8787// Define the opcode dispatch mechanism when using the C loop:
    8888//
     89
     90using WebConfig::g_config;
    8991
    9092// These are for building a C Loop interpreter:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r266770 r267371  
    441441macro cagePrimitive(basePtr, mask, ptr, scratch)
    442442    if GIGACAGE_ENABLED and not (C_LOOP or C_LOOP_WIN)
    443         loadb _g_config + (constexpr Gigacage::startOffsetOfGigacageConfig) + Gigacage::Config::disablingPrimitiveGigacageIsForbidden, scratch
     443        loadb GigacageConfig + Gigacage::Config::disablingPrimitiveGigacageIsForbidden, scratch
    444444        btbnz scratch, .doCaging
    445445
     
    461461    end
    462462    if GIGACAGE_ENABLED
    463         cagePrimitive(_g_config + (constexpr Gigacage::startOffsetOfGigacageConfig) + Gigacage::Config::basePtrs + GigacagePrimitiveBasePtrOffset, constexpr Gigacage::primitiveGigacageMask, source, scratch)
     463        cagePrimitive(GigacageConfig + Gigacage::Config::basePtrs + GigacagePrimitiveBasePtrOffset, constexpr Gigacage::primitiveGigacageMask, source, scratch)
    464464        if ARM64E
    465465            const numberOfPACBits = constexpr MacroAssembler::numberOfPACBits
     
    475475    loadp source, dest
    476476    if GIGACAGE_ENABLED
    477         cage(_g_config + (constexpr Gigacage::startOffsetOfGigacageConfig) + Gigacage::Config::basePtrs + GigacageJSValueBasePtrOffset, constexpr Gigacage::jsValueGigacageMask, dest, scratchOrLength)
     477        cage(GigacageConfig + Gigacage::Config::basePtrs + GigacageJSValueBasePtrOffset, constexpr Gigacage::jsValueGigacageMask, dest, scratchOrLength)
    478478    end
    479479end
  • trunk/Source/JavaScriptCore/llint/WebAssembly.asm

    r264995 r267371  
    1 # Copyright (C) 2019 Apple Inc. All rights reserved.
     1# Copyright (C) 2019-2020 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    9696macro wasmNextInstruction()
    9797    loadb [PB, PC, 1], t0
    98     leap _g_opcodeMap, t1
     98    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMap, t1
    9999    jmp NumberOfJSOpcodeIDs * PtrSize[t1, t0, PtrSize], BytecodePtrTag
    100100end
     
    102102macro wasmNextInstructionWide16()
    103103    loadb OpcodeIDNarrowSize[PB, PC, 1], t0
    104     leap _g_opcodeMapWide16, t1
     104    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide16, t1
    105105    jmp NumberOfJSOpcodeIDs * PtrSize[t1, t0, PtrSize], BytecodePtrTag
    106106end
     
    108108macro wasmNextInstructionWide32()
    109109    loadb OpcodeIDNarrowSize[PB, PC, 1], t0
    110     leap _g_opcodeMapWide32, t1
     110    leap JSCConfig + constexpr JSC::offsetOfJSCConfigOpcodeMapWide32, t1
    111111    jmp NumberOfJSOpcodeIDs * PtrSize[t1, t0, PtrSize], BytecodePtrTag
    112112end
  • trunk/Source/JavaScriptCore/offlineasm/arm.rb

    r259996 r267371  
    263263                labelRef = node.operands[0]
    264264                if labelRef.is_a? LabelReference
    265                     raise unless labelRef.offset == 0
    266265                    tmp = Tmp.new(node.codeOrigin, :gpr)
    267266                    newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), node.operands[1], tmp])
     267                    # FIXME: This check against 255 is just the simplest check we can do. ARM is capable of encoding some larger constants using
     268                    # rotation (subject to some special rules). Perhaps we can add the more comprehensive encoding check here.
     269                    if labelRef.offset > 255
     270                        newList << Instruction.new(codeOrigin, "move", [Immediate.new(node.codeOrigin, labelRef.offset), tmp])
     271                        newList << Instruction.new(codeOrigin, "addp", [tmp, node.operands[1]])
     272                    elsif labelRef.offset > 0
     273                        newList << Instruction.new(codeOrigin, "addp", [Immediate.new(node.codeOrigin, labelRef.offset), node.operands[1]])
     274                    end
    268275                else
    269276                    newList << node
  • trunk/Source/JavaScriptCore/offlineasm/cloop.rb

    r252422 r267371  
    1 # Copyright (C) 2012-2019 Apple Inc. All rights reserved.
     1# Copyright (C) 2012-2020 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    334334    def cloopEmitLea(destination, type)
    335335        $asm.putc "#{destination.clLValue(:voidPtr)} = CAST<void*>(&#{cLabel});"
     336        if offset != 0
     337            $asm.putc "#{destination.clLValue(:int8Ptr)} = #{destination.clValue(:int8Ptr)} + #{offset};"
     338        end
    336339    end
    337340end
     
    345348    def cloopEmitLea(destination, type)
    346349        if destination == base
    347             $asm.putc "#{destination.clLValue(:int8Ptr)} += #{offset.clValue(type)};"
     350            $asm.putc "#{destination.clLValue(:int8Ptr)} = #{destination.clValue(:int8Ptr)} + #{offset.clValue(type)};"
    348351        else
    349352            $asm.putc "#{destination.clLValue(:int8Ptr)} = #{base.clValue(:int8Ptr)} + #{offset.clValue(type)};"
  • trunk/Source/JavaScriptCore/offlineasm/x86.rb

    r262389 r267371  
    575575            else
    576576                $asm.puts "lea #{dst.x86Operand(:ptr)}, #{src.asmLabel}"
     577            end
     578            if src.offset != 0
     579                $asm.puts "add#{x86Suffix(kind)} #{orderOperands(const(src.offset), dst.x86Operand(kind))}"
    577580            end
    578581        else
  • trunk/Source/JavaScriptCore/runtime/JSCConfig.cpp

    r262356 r267371  
    2929namespace JSC {
    3030
     31#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     32Config g_jscConfig;
     33#endif
     34
     35Config& Config::singleton()
     36{
     37    return g_jscConfig;
     38}
     39
    3140void Config::disableFreezingForTesting()
    3241{
  • trunk/Source/JavaScriptCore/runtime/JSCConfig.h

    r263635 r267371  
    2626#pragma once
    2727
     28#include "Opcode.h"
    2829#include "OptionsList.h"
    2930#include <wtf/WTFConfig.h>
     
    3536class VM;
    3637
    37 constexpr size_t ConfigSizeToProtect = CeilingOnPageSize;
    38 
    3938#if ENABLE(SEPARATED_WX_HEAP)
    4039using JITWriteSeparateHeapsFunction = void (*)(off_t, const void*, size_t);
     
    4241
    4342struct Config {
     43    static Config& singleton();
     44
    4445    JS_EXPORT_PRIVATE static void disableFreezingForTesting();
    4546    JS_EXPORT_PRIVATE static void enableRestrictedOptions();
     
    8687    void (*shellTimeoutCheckCallback)(VM&);
    8788
     89    struct {
     90        uint8_t exceptionInstructions[maxOpcodeLength + 1];
     91        uint8_t wasmExceptionInstructions[maxOpcodeLength + 1];
     92        Opcode opcodeMap[numOpcodeIDs + numWasmOpcodeIDs];
     93        Opcode opcodeMapWide16[numOpcodeIDs + numWasmOpcodeIDs];
     94        Opcode opcodeMapWide32[numOpcodeIDs + numWasmOpcodeIDs];
     95    } llint;
     96
     97#if CPU(ARM64E) && ENABLE(PTRTAG_DEBUGGING)
    8898    WTF::PtrTagLookup ptrTagLookupRecord;
     99#endif
    89100};
     101
     102#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    90103
    91104constexpr size_t alignmentOfJSCConfig = std::alignment_of<JSC::Config>::value;
     
    96109#define g_jscConfig (*bitwise_cast<JSC::Config*>(&g_wtfConfig.spaceForExtensions))
    97110
     111#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     112
     113extern "C" JS_EXPORT_PRIVATE Config g_jscConfig;
     114
     115#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     116
     117constexpr size_t offsetOfJSCConfigOpcodeMap = offsetof(JSC::Config, llint.opcodeMap);
     118constexpr size_t offsetOfJSCConfigOpcodeMapWide16 = offsetof(JSC::Config, llint.opcodeMapWide16);
     119constexpr size_t offsetOfJSCConfigOpcodeMapWide32 = offsetof(JSC::Config, llint.opcodeMapWide32);
     120
    98121} // namespace JSC
     122
     123#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     124using JSC::g_jscConfig;
     125#endif
  • trunk/Source/WTF/ChangeLog

    r267288 r267371  
     12020-09-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Move some LLInt globals into JSC::Config.
     4        https://bugs.webkit.org/show_bug.cgi?id=216685
     5        rdar://68964544
     6
     7        Reviewed by Keith Miller.
     8
     9        1. Introduce ConfigAlignment as a distinct value from ConfigSizeToProtect.
     10           This is because ConfigSizeToProtect is now larger than 1 CeilingOnPageSize on
     11           some platforms, but ConfigAlignment only needs to match CeilingOnPageSize.
     12
     13        2. Introduced ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD) to disable using the
     14           unified g_config record for Windows ports.
     15
     16           This is needed because WTF is built as a DLL on Windows.  offlineasm does not
     17           know how to resolve a DLL exported variable.  Additionally, the Windows ports
     18           have never supported freezing of the Config record to begin with.  So, we're
     19           working around this by disabling ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     20           for Windows.  This allows JSC to have its own g_jscConfig record, which solves
     21           this issue for now.
     22
     23        * wtf/PlatformEnable.h:
     24        * wtf/WTFConfig.cpp:
     25        (WTF::Config::permanentlyFreeze):
     26        * wtf/WTFConfig.h:
     27
    1282020-09-18  Don Olmstead  <don.olmstead@sony.com>
    229
  • trunk/Source/WTF/wtf/PlatformEnable.h

    r267288 r267371  
    772772#endif
    773773
     774/* The unified Config record feature is not available for Windows because the
     775   Windows port puts WTF in a separate DLL, and the offlineasm code accessing
     776   the config record expects the config record to be directly accessible like
     777   a global variable (and not have to go thru DLL shenanigans). C++ code would
     778   resolve these DLL bindings automatically, but offlineasm does not.
     779
     780   The permanently freezing feature also currently relies on the Config records
     781   being unified, and the Windows port also does not currently have an
     782   implementation for the freezing mechanism anyway. For simplicity, we just
     783   disable both the use of unified Config record and config freezing for the
     784   Windows port.
     785*/
     786#if OS(WINDOWS)
     787#define ENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 0
     788#else
     789#define ENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 1
     790#endif
     791
    774792/* CSS Selector JIT Compiler */
    775793#if !defined(ENABLE_CSS_SELECTOR_JIT) && ((CPU(X86_64) || CPU(ARM64) || (CPU(ARM_THUMB2) && OS(DARWIN))) && ENABLE(JIT) && (OS(DARWIN) || PLATFORM(GTK) || PLATFORM(WPE)))
  • trunk/Source/WTF/wtf/WTFConfig.cpp

    r262434 r267371  
    3737#endif
    3838
     39#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     40
    3941namespace WebConfig {
    4042
    41 alignas(WTF::ConfigSizeToProtect) Slot g_config[WTF::ConfigSizeToProtect / sizeof(Slot)];
     43alignas(WTF::ConfigAlignment) Slot g_config[WTF::ConfigSizeToProtect / sizeof(Slot)];
    4244
    4345} // namespace WebConfig
     46
     47#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     48
     49namespace WTF {
     50
     51Config g_wtfConfig;
     52
     53} // namespace WTF
     54
     55#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    4456
    4557namespace WTF {
     
    6072
    6173    int result = 0;
     74
     75#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    6276#if OS(DARWIN)
    6377    enum {
     
    7387    // FIXME: Implement equivalent, maybe with VirtualProtect.
    7488    // Also need to fix WebKitTestRunner.
     89
     90    // Note: the Windows port also currently does not support a unified Config
     91    // record, which is needed for the current form of the freezing feature to
     92    // work. See comments in PlatformEnable.h for UNIFIED_AND_FREEZABLE_CONFIG_RECORD.
    7593#endif
     94#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     95
    7696    RELEASE_ASSERT(!result);
    7797    RELEASE_ASSERT(g_wtfConfig.isPermanentlyFrozen);
  • trunk/Source/WTF/wtf/WTFConfig.h

    r263074 r267371  
    4343#endif
    4444
     45#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    4546namespace WebConfig {
    4647
     
    4950
    5051} // namespace WebConfig
     52#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    5153
    5254namespace WTF {
    5355
    54 constexpr size_t ConfigSizeToProtect = CeilingOnPageSize;
     56constexpr size_t ConfigAlignment = CeilingOnPageSize;
     57constexpr size_t ConfigSizeToProtect = std::max(CeilingOnPageSize, 16 * KB);
    5558
    5659struct Config {
     
    7679};
    7780
     81#if ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     82
    7883constexpr size_t startSlotOfWTFConfig = Gigacage::reservedSlotsForGigacageConfig;
    7984constexpr size_t startOffsetOfWTFConfig = startSlotOfWTFConfig * sizeof(WebConfig::Slot);
     
    8792
    8893#define g_wtfConfig (*bitwise_cast<WTF::Config*>(&WebConfig::g_config[WTF::startSlotOfWTFConfig]))
     94
     95#else // not ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     96
     97extern "C" WTF_EXPORT_PRIVATE Config g_wtfConfig;
     98
     99#endif // ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    89100
    90101ALWAYS_INLINE Config::AssertNotFrozenScope::AssertNotFrozenScope()
     
    101112
    102113} // namespace WTF
     114
     115#if !ENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     116using WTF::g_wtfConfig;
     117#endif
  • trunk/Source/bmalloc/ChangeLog

    r265383 r267371  
     12020-09-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Move some LLInt globals into JSC::Config.
     4        https://bugs.webkit.org/show_bug.cgi?id=216685
     5        rdar://68964544
     6
     7        Reviewed by Keith Miller.
     8
     9        Introduce ConfigAlignment to match WTFConfig.h.
     10        Added BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD) support to match WTF.
     11
     12        * bmalloc/BPlatform.h:
     13        * bmalloc/Gigacage.cpp:
     14        (Gigacage::ensureGigacage):
     15        * bmalloc/GigacageConfig.h:
     16        * bmalloc/mbmalloc.cpp:
     17
    1182020-08-07  Saam Barati  <sbarati@apple.com>
    219
  • trunk/Source/bmalloc/bmalloc/BPlatform.h

    r261207 r267371  
    11/*
    2  * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9797#endif
    9898
     99/* ==== Feature decision macros: these define feature choices for a particular port. ==== */
     100
     101#define BENABLE(WTF_FEATURE) (defined BENABLE_##WTF_FEATURE && BENABLE_##WTF_FEATURE)
     102
    99103/* ==== Policy decision macros: these define policy choices for a particular port. ==== */
    100104
     
    319323#define BUSE_PRECOMPUTED_CONSTANTS_VMPAGE16K 1
    320324#endif
     325
     326/* The unified Config record feature is not available for Windows because the
     327   Windows port puts WTF in a separate DLL, and the offlineasm code accessing
     328   the config record expects the config record to be directly accessible like
     329   a global variable (and not have to go thru DLL shenanigans). C++ code would
     330   resolve these DLL bindings automatically, but offlineasm does not.
     331
     332   The permanently freezing feature also currently relies on the Config records
     333   being unified, and the Windows port also does not currently have an
     334   implementation for the freezing mechanism anyway. For simplicity, we just
     335   disable both the use of unified Config record and config freezing for the
     336   Windows port.
     337*/
     338#if BOS(WINDOWS)
     339#define BENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 0
     340#else
     341#define BENABLE_UNIFIED_AND_FREEZABLE_CONFIG_RECORD 1
     342#endif
  • trunk/Source/bmalloc/bmalloc/Gigacage.cpp

    r263316 r267371  
    4444namespace Gigacage {
    4545
     46#if !BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     47Config g_gigacageConfig;
     48#endif
     49
    4650struct Callback {
    4751    Callback() { }
     
    112116            if (!shouldBeEnabled())
    113117                return;
    114            
     118
     119#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    115120            // We might only get page size alignment, but that's also the minimum
    116121            // alignment we need for freezing the Config.
    117122            RELEASE_BASSERT(!(reinterpret_cast<size_t>(&g_gigacageConfig) & (vmPageSize() - 1)));
     123#endif
    118124
    119125            Kind shuffledKinds[NumberOfKinds];
  • trunk/Source/bmalloc/bmalloc/GigacageConfig.h

    r262434 r267371  
    3131#include <inttypes.h>
    3232
     33#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     34
    3335namespace WebConfig {
    3436
     
    3739
    3840} // namespace WebConfig
     41
     42#endif // BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    3943
    4044namespace Gigacage {
     
    7377};
    7478
     79#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     80
    7581constexpr size_t startSlotOfGigacageConfig = 0;
    7682constexpr size_t startOffsetOfGigacageConfig = startSlotOfGigacageConfig * sizeof(WebConfig::Slot);
     
    8692#define g_gigacageConfig (*bmalloc::bitwise_cast<Gigacage::Config*>(&WebConfig::g_config[Gigacage::startSlotOfGigacageConfig]))
    8793
     94#else // not BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     95
     96extern "C" BEXPORT Config g_gigacageConfig;
     97
     98#endif // BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     99
    88100} // namespace Gigacage
     101
     102#if !BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     103using Gigacage::g_gigacageConfig;
     104#endif
  • trunk/Source/bmalloc/bmalloc/mbmalloc.cpp

    r262434 r267371  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#include "GigacageConfig.h"
    3030
     31#if BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     32
    3133namespace WebConfig {
    3234
     35// FIXME: Other than OS(DARWIN) || PLATFORM(PLAYSTATION), CeilingOnPageSize is
     36// not 16K. ConfigAlignment should match that.
     37constexpr size_t ConfigAlignment = 16 * bmalloc::Sizes::kB;
    3338constexpr size_t ConfigSizeToProtect = 16 * bmalloc::Sizes::kB;
    3439
    35 alignas(ConfigSizeToProtect) BEXPORT Slot g_config[ConfigSizeToProtect / sizeof(Slot)];
     40alignas(ConfigAlignment) BEXPORT Slot g_config[ConfigSizeToProtect / sizeof(Slot)];
    3641
    3742} // namespace WebConfig
     43
     44#else // !BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
     45
     46namespace Gigacage {
     47
     48Config g_gigacageConfig;
     49
     50} // namespace Gigacage
     51
     52#endif // BENABLE(UNIFIED_AND_FREEZABLE_CONFIG_RECORD)
    3853
    3954extern "C" {
Note: See TracChangeset for help on using the changeset viewer.