Changeset 253314 in webkit


Ignore:
Timestamp:
Dec 9, 2019 5:54:07 PM (4 years ago)
Author:
Tadeu Zagallo
Message:

[WebAssembly] Remove WasmValidate
https://bugs.webkit.org/show_bug.cgi?id=205037

Reviewed by Saam Barati.

It's currently only used when JSC_useWasmLLInt is false and it creates an additional instantiation
of Wasm::FunctionParser, which adds about 100kb to the binary size. This does not introduce any
behavior changes with the default options, but it means that we'll generate bytecode when calling
WebAssembly.validate/new WebAssembly.Module even when the WasmLLInt is disabled.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • wasm/WasmBBQPlan.cpp:

(JSC::Wasm::BBQPlan::didReceiveFunctionData):

  • wasm/WasmEntryPlan.cpp:
  • wasm/WasmLLIntPlan.cpp:
  • wasm/WasmModule.cpp:

(JSC::Wasm::makeValidationResult):
(JSC::Wasm::makeValidationCallback):
(JSC::Wasm::Module::validateSync):
(JSC::Wasm::Module::validateAsync):

  • wasm/WasmModule.h:
  • wasm/WasmOMGForOSREntryPlan.cpp:

(JSC::Wasm::OMGForOSREntryPlan::work):

  • wasm/WasmOMGPlan.cpp:

(JSC::Wasm::OMGPlan::work):

  • wasm/WasmPlan.cpp:
  • wasm/WasmValidate.cpp: Removed.
  • wasm/WasmValidate.h: Removed.
Location:
trunk/Source/JavaScriptCore
Files:
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r253303 r253314  
     12019-12-09  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        [WebAssembly] Remove WasmValidate
     4        https://bugs.webkit.org/show_bug.cgi?id=205037
     5
     6        Reviewed by Saam Barati.
     7
     8        It's currently only used when JSC_useWasmLLInt is false and it creates an additional instantiation
     9        of Wasm::FunctionParser, which adds about 100kb to the binary size. This does not introduce any
     10        behavior changes with the default options, but it means that we'll generate bytecode when calling
     11        WebAssembly.validate/new WebAssembly.Module even when the WasmLLInt is disabled.
     12
     13        * JavaScriptCore.xcodeproj/project.pbxproj:
     14        * Sources.txt:
     15        * wasm/WasmBBQPlan.cpp:
     16        (JSC::Wasm::BBQPlan::didReceiveFunctionData):
     17        * wasm/WasmEntryPlan.cpp:
     18        * wasm/WasmLLIntPlan.cpp:
     19        * wasm/WasmModule.cpp:
     20        (JSC::Wasm::makeValidationResult):
     21        (JSC::Wasm::makeValidationCallback):
     22        (JSC::Wasm::Module::validateSync):
     23        (JSC::Wasm::Module::validateAsync):
     24        * wasm/WasmModule.h:
     25        * wasm/WasmOMGForOSREntryPlan.cpp:
     26        (JSC::Wasm::OMGForOSREntryPlan::work):
     27        * wasm/WasmOMGPlan.cpp:
     28        (JSC::Wasm::OMGPlan::work):
     29        * wasm/WasmPlan.cpp:
     30        * wasm/WasmValidate.cpp: Removed.
     31        * wasm/WasmValidate.h: Removed.
     32
    1332019-12-09  Tadeu Zagallo  <tzagallo@apple.com>
    234
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r253263 r253314  
    11161116                53FA2AE11CF37F3F0022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FA2AE01CF37F3F0022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11171117                53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1118                 53FF7F991DBFCD9000A26CCC /* WasmValidate.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FF7F981DBFCD9000A26CCC /* WasmValidate.h */; };
    11191118                5B70CFDE1DB69E6600EC23F9 /* JSAsyncFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */; };
    11201119                5B70CFE01DB69E6600EC23F9 /* AsyncFunctionPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFDA1DB69E5C00EC23F9 /* AsyncFunctionPrototype.h */; };
     
    38203819                53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmCallingConvention.cpp; sourceTree = "<group>"; };
    38213820                53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmCallingConvention.h; sourceTree = "<group>"; };
    3822                 53FF7F981DBFCD9000A26CCC /* WasmValidate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmValidate.h; sourceTree = "<group>"; };
    3823                 53FF7F9A1DBFD2B900A26CCC /* WasmValidate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmValidate.cpp; sourceTree = "<group>"; };
    38243821                5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAsyncFunction.h; sourceTree = "<group>"; };
    38253822                5B70CFD91DB69E5C00EC23F9 /* JSAsyncFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAsyncFunction.cpp; sourceTree = "<group>"; };
     
    68696866                                E3C694B223026874006FBE42 /* WasmTierUpCount.cpp */,
    68706867                                53E9E0AE1EAEC45700FEE251 /* WasmTierUpCount.h */,
    6871                                 53FF7F9A1DBFD2B900A26CCC /* WasmValidate.cpp */,
    6872                                 53FF7F981DBFCD9000A26CCC /* WasmValidate.h */,
    68736868                                530FB3031E7A1146003C19DD /* WasmWorklist.cpp */,
    68746869                                530FB3011E7A0B6E003C19DD /* WasmWorklist.h */,
     
    1029910294                                53E9E0AF1EAEC45700FEE251 /* WasmTierUpCount.h in Headers */,
    1030010295                                AD5C36EC1F75AD7C000BCAAF /* WasmToJS.h in Headers */,
    10301                                 53FF7F991DBFCD9000A26CCC /* WasmValidate.h in Headers */,
    1030210296                                530FB3021E7A0B6E003C19DD /* WasmWorklist.h in Headers */,
    1030310297                                FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r253097 r253314  
    10391039wasm/WasmThunks.cpp
    10401040wasm/WasmTierUpCount.cpp
    1041 wasm/WasmValidate.cpp
    10421041wasm/WasmWorklist.cpp
    10431042
  • trunk/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp

    r253188 r253314  
    4141#include "WasmSignatureInlines.h"
    4242#include "WasmTierUpCount.h"
    43 #include "WasmValidate.h"
    4443#include <wtf/DataLog.h>
    4544#include <wtf/Locker.h>
     
    223222    unsigned functionIndexSpace = m_moduleInformation->importFunctionCount() + functionIndex;
    224223    ASSERT_UNUSED(functionIndexSpace, m_moduleInformation->signatureIndexFromFunctionIndexSpace(functionIndexSpace) == signatureIndex);
    225     ASSERT(validateFunction(function, signature, m_moduleInformation.get()));
    226224    Expected<std::unique_ptr<InternalFunction>, String> parseAndCompileResult;
    227225    unsigned osrEntryScratchBufferSize = 0;
     
    318316}
    319317
    320 bool BBQPlan::didReceiveFunctionData(unsigned functionIndex, const FunctionData& function)
    321 {
    322     dataLogLnIf(WasmBBQPlanInternal::verbose, "Processing function starting at: ", function.start, " and ending at: ", function.end);
    323     size_t functionLength = function.end - function.start;
    324     ASSERT(functionLength == function.data.size());
    325     SignatureIndex signatureIndex = m_moduleInformation->internalFunctionSignatureIndices[functionIndex];
    326     const Signature& signature = SignatureInformation::get(signatureIndex);
    327 
    328     auto validationResult = validateFunction(function, signature, m_moduleInformation.get());
    329     if (!validationResult) {
    330         if (WasmBBQPlanInternal::verbose) {
    331             for (unsigned i = 0; i < functionLength; ++i)
    332                 dataLog(RawPointer(reinterpret_cast<void*>(function.data[i])), ", ");
    333             dataLogLn();
    334         }
    335         fail(holdLock(m_lock), makeString(validationResult.error(), ", in function at index ", String::number(functionIndex))); // FIXME make this an Expected.
    336     }
    337     return !!validationResult;
     318bool BBQPlan::didReceiveFunctionData(unsigned, const FunctionData&)
     319{
     320    return true;
    338321}
    339322
  • trunk/Source/JavaScriptCore/wasm/WasmEntryPlan.cpp

    r253140 r253314  
    3131#include "WasmMemory.h"
    3232#include "WasmSignatureInlines.h"
    33 #include "WasmValidate.h"
    3433#include <wtf/CrossThreadCopier.h>
    3534#include <wtf/DataLog.h>
  • trunk/Source/JavaScriptCore/wasm/WasmLLIntPlan.cpp

    r253168 r253314  
    3838#include "WasmLLIntGenerator.h"
    3939#include "WasmSignatureInlines.h"
    40 #include "WasmValidate.h"
    4140
    4241namespace JSC { namespace Wasm {
  • trunk/Source/JavaScriptCore/wasm/WasmModule.cpp

    r253188 r253314  
    4343}
    4444
    45 Module::Module(BBQPlan& plan)
    46     : m_moduleInformation(plan.takeModuleInformation())
    47 {
    48 }
    49 
    5045Module::~Module() { }
    5146
     
    5550}
    5651
    57 template<typename Plan>
    58 static Module::ValidationResult makeValidationResult(Plan& plan)
     52static Module::ValidationResult makeValidationResult(LLIntPlan& plan)
    5953{
    6054    ASSERT(!plan.hasWork());
     
    6458}
    6559
    66 template<typename PlanT>
    6760static Plan::CompletionTask makeValidationCallback(Module::AsyncValidationCallback&& callback)
    6861{
    6962    return createSharedTask<Plan::CallbackType>([callback = WTFMove(callback)] (Plan& plan) {
    7063        ASSERT(!plan.hasWork());
    71         callback->run(makeValidationResult(static_cast<PlanT&>(plan)));
     64        callback->run(makeValidationResult(static_cast<LLIntPlan&>(plan)));
    7265    });
    7366}
     
    7568Module::ValidationResult Module::validateSync(Context* context, Vector<uint8_t>&& source)
    7669{
    77     if (Options::useWasmLLInt()) {
    78         Ref<LLIntPlan> plan = adoptRef(*new LLIntPlan(context, WTFMove(source), EntryPlan::Validation, Plan::dontFinalize()));
    79         Wasm::ensureWorklist().enqueue(plan.get());
    80         plan->waitForCompletion();
    81         return makeValidationResult(plan.get());
    82     }
    83 
    84     Ref<BBQPlan> plan = adoptRef(*new BBQPlan(context, WTFMove(source), EntryPlan::Validation, Plan::dontFinalize()));
    85     plan->parseAndValidateModule();
     70    Ref<LLIntPlan> plan = adoptRef(*new LLIntPlan(context, WTFMove(source), EntryPlan::Validation, Plan::dontFinalize()));
     71    Wasm::ensureWorklist().enqueue(plan.get());
     72    plan->waitForCompletion();
    8673    return makeValidationResult(plan.get());
    8774}
     
    8976void Module::validateAsync(Context* context, Vector<uint8_t>&& source, Module::AsyncValidationCallback&& callback)
    9077{
    91     if (Options::useWasmLLInt()) {
    92         Ref<Plan> plan = adoptRef(*new LLIntPlan(context, WTFMove(source), EntryPlan::Validation, makeValidationCallback<LLIntPlan>(WTFMove(callback))));
    93         Wasm::ensureWorklist().enqueue(WTFMove(plan));
    94     } else {
    95         Ref<Plan> plan = adoptRef(*new BBQPlan(context, WTFMove(source), EntryPlan::Validation, makeValidationCallback<BBQPlan>(WTFMove(callback))));
    96         Wasm::ensureWorklist().enqueue(WTFMove(plan));
    97     }
     78    Ref<Plan> plan = adoptRef(*new LLIntPlan(context, WTFMove(source), EntryPlan::Validation, makeValidationCallback(WTFMove(callback))));
     79    Wasm::ensureWorklist().enqueue(WTFMove(plan));
    9880}
    9981
  • trunk/Source/JavaScriptCore/wasm/WasmModule.h

    r253188 r253314  
    3838namespace JSC { namespace Wasm {
    3939
    40 class BBQPlan;
    4140class LLIntPlan;
    4241struct Context;
     
    5352    static ValidationResult validateSync(Context*, Vector<uint8_t>&& source);
    5453    static void validateAsync(Context*, Vector<uint8_t>&& source, Module::AsyncValidationCallback&&);
    55 
    56     static Ref<Module> create(BBQPlan& plan)
    57     {
    58         return adoptRef(*new Module(plan));
    59     }
    6054
    6155    static Ref<Module> create(LLIntPlan& plan)
     
    7670    Ref<CodeBlock> getOrCreateCodeBlock(Context*, MemoryMode);
    7771
    78     Module(BBQPlan&);
    7972    Module(LLIntPlan&);
    8073    Ref<ModuleInformation> m_moduleInformation;
  • trunk/Source/JavaScriptCore/wasm/WasmOMGForOSREntryPlan.cpp

    r251886 r253314  
    4141#include "WasmNameSection.h"
    4242#include "WasmSignatureInlines.h"
    43 #include "WasmValidate.h"
    4443#include "WasmWorklist.h"
    4544#include <wtf/DataLog.h>
     
    8079    SignatureIndex signatureIndex = m_moduleInformation->internalFunctionSignatureIndices[m_functionIndex];
    8180    const Signature& signature = SignatureInformation::get(signatureIndex);
    82     ASSERT(validateFunction(function, signature, m_moduleInformation.get()));
    8381
    8482    Vector<UnlinkedWasmToWasmCall> unlinkedCalls;
  • trunk/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp

    r253188 r253314  
    4141#include "WasmNameSection.h"
    4242#include "WasmSignatureInlines.h"
    43 #include "WasmValidate.h"
    4443#include "WasmWorklist.h"
    4544#include <wtf/DataLog.h>
     
    7877    SignatureIndex signatureIndex = m_moduleInformation->internalFunctionSignatureIndices[m_functionIndex];
    7978    const Signature& signature = SignatureInformation::get(signatureIndex);
    80     ASSERT(validateFunction(function, signature, m_moduleInformation.get()));
    8179
    8280    Vector<UnlinkedWasmToWasmCall> unlinkedCalls;
  • trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp

    r253140 r253314  
    3636#include "WasmFaultSignalHandler.h"
    3737#include "WasmMemory.h"
    38 #include "WasmValidate.h"
    3938#include <wtf/DataLog.h>
    4039#include <wtf/Locker.h>
Note: See TracChangeset for help on using the changeset viewer.