Changeset 205309 in webkit


Ignore:
Timestamp:
Sep 1, 2016 1:04:02 PM (8 years ago)
Author:
keith_miller@apple.com
Message:

Rename WASM classes dropping the WASM prefix
https://bugs.webkit.org/show_bug.cgi?id=161500

Reviewed by Mark Lam.

Having to write WASM::WASMModule seems silly. Also, this patch
merges WASMFunctionReturnType and WASMValueType into one type
that is a typedef of B3::Type. Using B3::Type as the WASM
primitive type makes it trivial to convert a Vector of WASM
types into a Vector of B3 types.

  • b3/B3Type.h:
  • wasm/JSWASMModule.h:

(JSC::JSWASMModule::signatures):
(JSC::JSWASMModule::functionImports):
(JSC::JSWASMModule::functionImportSignatures):
(JSC::JSWASMModule::globalVariableTypes):
(JSC::JSWASMModule::functionDeclarations):
(JSC::JSWASMModule::functionPointerTables):

  • wasm/WASMB3IRGenerator.cpp:

(JSC::WASM::toB3Op):
(JSC::WASM::B3IRGenerator::addLocal):
(JSC::WASM::B3IRGenerator::unaryOp):
(JSC::WASM::B3IRGenerator::binaryOp):
(JSC::WASM::B3IRGenerator::addConstant):
(JSC::WASM::parseAndCompile):

  • wasm/WASMB3IRGenerator.h:
  • wasm/WASMFormat.h:
  • wasm/WASMFunctionParser.h:

(JSC::WASM::FunctionParser<Context>::FunctionParser):
(JSC::WASM::FunctionParser<Context>::parse):
(JSC::WASM::FunctionParser<Context>::parseBlock):
(JSC::WASM::FunctionParser<Context>::parseExpression):
(JSC::WASM::WASMFunctionParser<Context>::WASMFunctionParser): Deleted.
(JSC::WASM::WASMFunctionParser<Context>::parse): Deleted.
(JSC::WASM::WASMFunctionParser<Context>::parseBlock): Deleted.
(JSC::WASM::WASMFunctionParser<Context>::parseExpression): Deleted.

  • wasm/WASMModuleParser.cpp:

(JSC::WASM::ModuleParser::parse):
(JSC::WASM::ModuleParser::parseFunctionTypes):
(JSC::WASM::ModuleParser::parseFunctionSignatures):
(JSC::WASM::ModuleParser::parseFunctionDefinitions):
(JSC::WASM::WASMModuleParser::parse): Deleted.
(JSC::WASM::WASMModuleParser::parseFunctionTypes): Deleted.
(JSC::WASM::WASMModuleParser::parseFunctionSignatures): Deleted.
(JSC::WASM::WASMModuleParser::parseFunctionDefinitions): Deleted.

  • wasm/WASMModuleParser.h:

(JSC::WASM::ModuleParser::ModuleParser):
(JSC::WASM::ModuleParser::functionInformation):
(JSC::WASM::WASMModuleParser::WASMModuleParser): Deleted.
(JSC::WASM::WASMModuleParser::functionInformation): Deleted.

  • wasm/WASMOps.h:
  • wasm/WASMParser.h:

(JSC::WASM::Parser::Parser):
(JSC::WASM::Parser::consumeCharacter):
(JSC::WASM::Parser::consumeString):
(JSC::WASM::Parser::parseUInt32):
(JSC::WASM::Parser::parseUInt7):
(JSC::WASM::Parser::parseVarUInt1):
(JSC::WASM::Parser::parseValueType):
(JSC::WASM::WASMParser::WASMParser): Deleted.
(JSC::WASM::WASMParser::consumeCharacter): Deleted.
(JSC::WASM::WASMParser::consumeString): Deleted.
(JSC::WASM::WASMParser::parseUInt32): Deleted.
(JSC::WASM::WASMParser::parseUInt7): Deleted.
(JSC::WASM::WASMParser::parseVarUInt1): Deleted.
(JSC::WASM::WASMParser::parseValueType): Deleted.

  • wasm/WASMPlan.cpp:

(JSC::WASM::Plan::Plan):

  • wasm/WASMSections.cpp:

(JSC::WASM::Sections::lookup):
(JSC::WASM::WASMSections::lookup): Deleted.

  • wasm/WASMSections.h:

(JSC::WASM::Sections::validateOrder):
(JSC::WASM::WASMSections::validateOrder): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r205304 r205309  
     12016-09-01  Keith Miller  <keith_miller@apple.com>
     2
     3        Rename WASM classes dropping the WASM prefix
     4        https://bugs.webkit.org/show_bug.cgi?id=161500
     5
     6        Reviewed by Mark Lam.
     7
     8        Having to write WASM::WASMModule seems silly. Also, this patch
     9        merges WASMFunctionReturnType and WASMValueType into one type
     10        that is a typedef of B3::Type. Using B3::Type as the WASM
     11        primitive type makes it trivial to convert a Vector of WASM
     12        types into a Vector of B3 types.
     13
     14        * b3/B3Type.h:
     15        * wasm/JSWASMModule.h:
     16        (JSC::JSWASMModule::signatures):
     17        (JSC::JSWASMModule::functionImports):
     18        (JSC::JSWASMModule::functionImportSignatures):
     19        (JSC::JSWASMModule::globalVariableTypes):
     20        (JSC::JSWASMModule::functionDeclarations):
     21        (JSC::JSWASMModule::functionPointerTables):
     22        * wasm/WASMB3IRGenerator.cpp:
     23        (JSC::WASM::toB3Op):
     24        (JSC::WASM::B3IRGenerator::addLocal):
     25        (JSC::WASM::B3IRGenerator::unaryOp):
     26        (JSC::WASM::B3IRGenerator::binaryOp):
     27        (JSC::WASM::B3IRGenerator::addConstant):
     28        (JSC::WASM::parseAndCompile):
     29        * wasm/WASMB3IRGenerator.h:
     30        * wasm/WASMFormat.h:
     31        * wasm/WASMFunctionParser.h:
     32        (JSC::WASM::FunctionParser<Context>::FunctionParser):
     33        (JSC::WASM::FunctionParser<Context>::parse):
     34        (JSC::WASM::FunctionParser<Context>::parseBlock):
     35        (JSC::WASM::FunctionParser<Context>::parseExpression):
     36        (JSC::WASM::WASMFunctionParser<Context>::WASMFunctionParser): Deleted.
     37        (JSC::WASM::WASMFunctionParser<Context>::parse): Deleted.
     38        (JSC::WASM::WASMFunctionParser<Context>::parseBlock): Deleted.
     39        (JSC::WASM::WASMFunctionParser<Context>::parseExpression): Deleted.
     40        * wasm/WASMModuleParser.cpp:
     41        (JSC::WASM::ModuleParser::parse):
     42        (JSC::WASM::ModuleParser::parseFunctionTypes):
     43        (JSC::WASM::ModuleParser::parseFunctionSignatures):
     44        (JSC::WASM::ModuleParser::parseFunctionDefinitions):
     45        (JSC::WASM::WASMModuleParser::parse): Deleted.
     46        (JSC::WASM::WASMModuleParser::parseFunctionTypes): Deleted.
     47        (JSC::WASM::WASMModuleParser::parseFunctionSignatures): Deleted.
     48        (JSC::WASM::WASMModuleParser::parseFunctionDefinitions): Deleted.
     49        * wasm/WASMModuleParser.h:
     50        (JSC::WASM::ModuleParser::ModuleParser):
     51        (JSC::WASM::ModuleParser::functionInformation):
     52        (JSC::WASM::WASMModuleParser::WASMModuleParser): Deleted.
     53        (JSC::WASM::WASMModuleParser::functionInformation): Deleted.
     54        * wasm/WASMOps.h:
     55        * wasm/WASMParser.h:
     56        (JSC::WASM::Parser::Parser):
     57        (JSC::WASM::Parser::consumeCharacter):
     58        (JSC::WASM::Parser::consumeString):
     59        (JSC::WASM::Parser::parseUInt32):
     60        (JSC::WASM::Parser::parseUInt7):
     61        (JSC::WASM::Parser::parseVarUInt1):
     62        (JSC::WASM::Parser::parseValueType):
     63        (JSC::WASM::WASMParser::WASMParser): Deleted.
     64        (JSC::WASM::WASMParser::consumeCharacter): Deleted.
     65        (JSC::WASM::WASMParser::consumeString): Deleted.
     66        (JSC::WASM::WASMParser::parseUInt32): Deleted.
     67        (JSC::WASM::WASMParser::parseUInt7): Deleted.
     68        (JSC::WASM::WASMParser::parseVarUInt1): Deleted.
     69        (JSC::WASM::WASMParser::parseValueType): Deleted.
     70        * wasm/WASMPlan.cpp:
     71        (JSC::WASM::Plan::Plan):
     72        * wasm/WASMSections.cpp:
     73        (JSC::WASM::Sections::lookup):
     74        (JSC::WASM::WASMSections::lookup): Deleted.
     75        * wasm/WASMSections.h:
     76        (JSC::WASM::Sections::validateOrder):
     77        (JSC::WASM::WASMSections::validateOrder): Deleted.
     78
    1792016-09-01  Filip Pizlo  <fpizlo@apple.com>
    280
  • trunk/Source/JavaScriptCore/b3/B3Type.h

    r194858 r205309  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040
    4141enum Type : int8_t {
    42     Void,
    4342    Int32,
    4443    Int64,
    4544    Float,
    46     Double
     45    Double,
     46    LastValueType = Double,
     47    Void
    4748};
    4849
  • trunk/Source/JavaScriptCore/wasm/JSWASMModule.h

    r205021 r205309  
    7676    Vector<float>& f32Constants() { return m_f32Constants; }
    7777    Vector<double>& f64Constants() { return m_f64Constants; }
    78     Vector<WASMSignature>& signatures() { return m_signatures; }
    79     Vector<WASMFunctionImport>& functionImports() { return m_functionImports; }
    80     Vector<WASMFunctionImportSignature>& functionImportSignatures() { return m_functionImportSignatures; }
    81     Vector<WASMValueType>& globalVariableTypes() { return m_globalVariableTypes; }
    82     Vector<WASMFunctionDeclaration>& functionDeclarations() { return m_functionDeclarations; }
    83     Vector<WASMFunctionPointerTable>& functionPointerTables() { return m_functionPointerTables; }
     78    Vector<WASM::Signature>& signatures() { return m_signatures; }
     79    Vector<WASM::FunctionImport>& functionImports() { return m_functionImports; }
     80    Vector<WASM::FunctionImportSignature>& functionImportSignatures() { return m_functionImportSignatures; }
     81    Vector<WASM::Type>& globalVariableTypes() { return m_globalVariableTypes; }
     82    Vector<WASM::FunctionDeclaration>& functionDeclarations() { return m_functionDeclarations; }
     83    Vector<WASM::FunctionPointerTable>& functionPointerTables() { return m_functionPointerTables; }
    8484
    8585    const JSArrayBuffer* arrayBuffer() const { return m_arrayBuffer.get(); }
     
    9696    Vector<float> m_f32Constants;
    9797    Vector<double> m_f64Constants;
    98     Vector<WASMSignature> m_signatures;
    99     Vector<WASMFunctionImport> m_functionImports;
    100     Vector<WASMFunctionImportSignature> m_functionImportSignatures;
    101     Vector<WASMValueType> m_globalVariableTypes;
    102     Vector<WASMFunctionDeclaration> m_functionDeclarations;
    103     Vector<WASMFunctionPointerTable> m_functionPointerTables;
     98    Vector<WASM::Signature> m_signatures;
     99    Vector<WASM::FunctionImport> m_functionImports;
     100    Vector<WASM::FunctionImportSignature> m_functionImportSignatures;
     101    Vector<WASM::Type> m_globalVariableTypes;
     102    Vector<WASM::FunctionDeclaration> m_functionDeclarations;
     103    Vector<WASM::FunctionPointerTable> m_functionPointerTables;
    104104
    105105    WriteBarrier<JSArrayBuffer> m_arrayBuffer;
  • trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp

    r205021 r205309  
    4242using namespace B3;
    4343
    44 inline B3::Opcode toB3Op(WASMBinaryOpType op)
     44inline B3::Opcode toB3Op(BinaryOpType op)
    4545{
    4646    switch (op) {
    47 #define CREATE_CASE(name, op, b3op) case WASMBinaryOpType::name: return b3op;
     47#define CREATE_CASE(name, op, b3op) case BinaryOpType::name: return b3op;
    4848    FOR_EACH_WASM_BINARY_OP(CREATE_CASE)
    4949#undef CREATE_CASE
     
    5252}
    5353
    54 inline B3::Opcode toB3Op(WASMUnaryOpType op)
     54inline B3::Opcode toB3Op(UnaryOpType op)
    5555{
    5656    switch (op) {
    57 #define CREATE_CASE(name, op, b3op) case WASMUnaryOpType::name: return b3op;
     57#define CREATE_CASE(name, op, b3op) case UnaryOpType::name: return b3op;
    5858    FOR_EACH_WASM_UNARY_OP(CREATE_CASE)
    5959#undef CREATE_CASE
     
    6868    B3IRGenerator(Procedure&);
    6969
    70     void addLocal(WASMValueType, uint32_t);
    71     ExpressionType addConstant(WASMValueType, uint64_t);
    72 
    73     bool WARN_UNUSED_RETURN binaryOp(WASMBinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result);
    74     bool WARN_UNUSED_RETURN unaryOp(WASMUnaryOpType, ExpressionType arg, ExpressionType& result);
     70    void addLocal(Type, uint32_t);
     71    ExpressionType addConstant(Type, uint64_t);
     72
     73    bool WARN_UNUSED_RETURN binaryOp(BinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result);
     74    bool WARN_UNUSED_RETURN unaryOp(UnaryOpType, ExpressionType arg, ExpressionType& result);
    7575
    7676    bool WARN_UNUSED_RETURN addBlock();
     
    9797}
    9898
    99 void B3IRGenerator::addLocal(WASMValueType, uint32_t)
     99void B3IRGenerator::addLocal(Type, uint32_t)
    100100{
    101101    // TODO: Add locals.
    102102}
    103103
    104 bool B3IRGenerator::unaryOp(WASMUnaryOpType op, ExpressionType arg, ExpressionType& result)
     104bool B3IRGenerator::unaryOp(UnaryOpType op, ExpressionType arg, ExpressionType& result)
    105105{
    106106    result = m_currentBlock->appendNew<Value>(m_proc, toB3Op(op), Origin(), arg);
     
    108108}
    109109
    110 bool B3IRGenerator::binaryOp(WASMBinaryOpType op, ExpressionType left, ExpressionType right, ExpressionType& result)
     110bool B3IRGenerator::binaryOp(BinaryOpType op, ExpressionType left, ExpressionType right, ExpressionType& result)
    111111{
    112112    result = m_currentBlock->appendNew<Value>(m_proc, toB3Op(op), Origin(), left, right);
     
    114114}
    115115
    116 B3IRGenerator::ExpressionType B3IRGenerator::addConstant(WASMValueType type, uint64_t value)
     116B3IRGenerator::ExpressionType B3IRGenerator::addConstant(Type type, uint64_t value)
    117117{
    118118    switch (type) {
    119     case WASMValueType::I32:
     119    case Int32:
    120120        return m_currentBlock->appendNew<Const32Value>(m_proc, Origin(), static_cast<int32_t>(value));
    121     case WASMValueType::I64:
     121    case Int64:
    122122        return m_currentBlock->appendNew<Const64Value>(m_proc, Origin(), value);
    123     case WASMValueType::F32:
     123    case Float:
    124124        return m_currentBlock->appendNew<ConstFloatValue>(m_proc, Origin(), bitwise_cast<float>(static_cast<int32_t>(value)));
    125     case WASMValueType::F64:
     125    case Double:
    126126        return m_currentBlock->appendNew<ConstDoubleValue>(m_proc, Origin(), bitwise_cast<double>(value));
    127127    default:
     
    206206}
    207207
    208 std::unique_ptr<Compilation> parseAndCompile(VM& vm, Vector<uint8_t>& source, WASMFunctionInformation info, unsigned optLevel)
     208std::unique_ptr<Compilation> parseAndCompile(VM& vm, Vector<uint8_t>& source, FunctionInformation info, unsigned optLevel)
    209209{
    210210    Procedure procedure;
    211211    B3IRGenerator context(procedure);
    212     WASMFunctionParser<B3IRGenerator> parser(context, source, info);
     212    FunctionParser<B3IRGenerator> parser(context, source, info);
    213213    if (!parser.parse())
    214214        RELEASE_ASSERT_NOT_REACHED();
  • trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.h

    r205021 r205309  
    3636namespace WASM {
    3737
    38 std::unique_ptr<B3::Compilation> parseAndCompile(VM&, Vector<uint8_t>&, WASMFunctionInformation, unsigned optLevel = 1);
     38std::unique_ptr<B3::Compilation> parseAndCompile(VM&, Vector<uint8_t>&, FunctionInformation, unsigned optLevel = 1);
    3939
    4040} // namespace WASM
  • trunk/Source/JavaScriptCore/wasm/WASMFormat.h

    r205021 r205309  
    4545#if ENABLE(WEBASSEMBLY)
    4646
     47#include "B3Type.h"
    4748#include <wtf/Vector.h>
    4849#include <wtf/text/WTFString.h>
     
    5253class JSFunction;
    5354
    54 enum class WASMValueType : uint8_t {
    55     I32,
    56     I64,
    57     F32,
    58     F64,
    59     NumberOfTypes
     55namespace WASM {
     56
     57using B3::Type;
     58using B3::Int32;
     59using B3::Int64;
     60using B3::Float;
     61using B3::Double;
     62
     63static_assert(Int32 == 0, "WASM needs B3::Type::Int32 to have the value 0");
     64static_assert(Int64 == 1, "WASM needs B3::Type::Int64 to have the value 1");
     65static_assert(Float == 2, "WASM needs B3::Type::Float to have the value 2");
     66static_assert(Double == 3, "WASM needs B3::Type::Double to have the value 3");
     67
     68struct Signature {
     69    Type returnType;
     70    Vector<Type> arguments;
    6071};
    6172
    62 enum class WASMFunctionReturnType : uint8_t {
    63     I32,
    64     I64,
    65     F32,
    66     F64,
    67     Void,
    68     NumberOfExpressionTypes
    69 };
    70 
    71 struct WASMSignature {
    72     WASMFunctionReturnType returnType;
    73     Vector<WASMValueType> arguments;
    74 };
    75 
    76 struct WASMFunctionImport {
     73struct FunctionImport {
    7774    String functionName;
    7875};
    7976
    80 struct WASMFunctionImportSignature {
     77struct FunctionImportSignature {
    8178    uint32_t signatureIndex;
    8279    uint32_t functionImportIndex;
    8380};
    8481
    85 struct WASMFunctionDeclaration {
     82struct FunctionDeclaration {
    8683    uint32_t signatureIndex;
    8784};
    8885
    89 struct WASMFunctionPointerTable {
     86struct FunctionPointerTable {
    9087    uint32_t signatureIndex;
    9188    Vector<uint32_t> functionIndices;
     
    9390};
    9491
    95 struct WASMFunctionInformation {
     92struct FunctionInformation {
    9693    size_t start;
    9794    size_t end;
    9895};
    9996
     97} // namespace WASM
     98
    10099} // namespace JSC
    101100
  • trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h

    r205021 r205309  
    3636
    3737template<typename Context>
    38 class WASMFunctionParser : public WASMParser {
     38class FunctionParser : public Parser {
    3939public:
    4040    typedef typename Context::ExpressionType ExpressionType;
    4141
    42     WASMFunctionParser(Context&, const Vector<uint8_t>& sourceBuffer, const WASMFunctionInformation&);
     42    FunctionParser(Context&, const Vector<uint8_t>& sourceBuffer, const FunctionInformation&);
    4343
    4444    bool WARN_UNUSED_RETURN parse();
     
    4848
    4949    bool WARN_UNUSED_RETURN parseBlock();
    50     bool WARN_UNUSED_RETURN parseExpression(WASMOpType);
     50    bool WARN_UNUSED_RETURN parseExpression(OpType);
    5151    bool WARN_UNUSED_RETURN unifyControl(Vector<ExpressionType>&, unsigned level);
    5252
     
    5858
    5959template<typename Context>
    60 WASMFunctionParser<Context>::WASMFunctionParser(Context& context, const Vector<uint8_t>& sourceBuffer, const WASMFunctionInformation& info)
    61     : WASMParser(sourceBuffer, info.start, info.end)
     60FunctionParser<Context>::FunctionParser(Context& context, const Vector<uint8_t>& sourceBuffer, const FunctionInformation& info)
     61    : Parser(sourceBuffer, info.start, info.end)
    6262    , m_context(context)
    6363{
     
    6565
    6666template<typename Context>
    67 bool WASMFunctionParser<Context>::parse()
     67bool FunctionParser<Context>::parse()
    6868{
    6969    uint32_t localCount;
     
    7676            return false;
    7777
    78         WASMValueType typeOfLocal;
     78        Type typeOfLocal;
    7979        if (!parseValueType(typeOfLocal))
    8080            return false;
    8181
    82         m_context.addLocal(typeOfLocal, numberOfLocalsWithType);
    8382    }
    8483
     
    8786
    8887template<typename Context>
    89 bool WASMFunctionParser<Context>::parseBlock()
     88bool FunctionParser<Context>::parseBlock()
    9089{
    9190    while (true) {
     
    9493            return false;
    9594
    96         if (!parseExpression(static_cast<WASMOpType>(op))) {
     95        if (!parseExpression(static_cast<OpType>(op))) {
    9796            if (verbose)
    9897                dataLogLn("failed to process op:", op);
     
    10099        }
    101100
    102         if (op == WASMOpType::End)
     101        if (op == OpType::End)
    103102            break;
    104103    }
     
    108107
    109108template<typename Context>
    110 bool WASMFunctionParser<Context>::parseExpression(WASMOpType op)
     109bool FunctionParser<Context>::parseExpression(OpType op)
    111110{
    112111    switch (op) {
     
    116115        ExpressionType right = m_expressionStack.takeLast();
    117116        ExpressionType result;
    118         if (!m_context.binaryOp(static_cast<WASMBinaryOpType>(op), left, right, result))
     117        if (!m_context.binaryOp(static_cast<BinaryOpType>(op), left, right, result))
    119118            return false;
    120119        m_expressionStack.append(result);
     
    125124        ExpressionType arg = m_expressionStack.takeLast();
    126125        ExpressionType result;
    127         if (!m_context.unaryOp(static_cast<WASMUnaryOpType>(op), arg, result))
     126        if (!m_context.unaryOp(static_cast<UnaryOpType>(op), arg, result))
    128127            return false;
    129128        m_expressionStack.append(result);
     
    132131#undef CREATE_CASE
    133132
    134     case WASMOpType::I32Const: {
     133    case OpType::I32Const: {
    135134        uint32_t constant;
    136135        if (!parseVarUInt32(constant))
    137136            return false;
    138         m_expressionStack.append(m_context.addConstant(WASMValueType::I32, constant));
     137        m_expressionStack.append(m_context.addConstant(Int32, constant));
    139138        return true;
    140139    }
    141140
    142     case WASMOpType::Block: {
     141    case OpType::Block: {
    143142        if (!m_context.addBlock())
    144143            return false;
     
    146145    }
    147146
    148     case WASMOpType::Return: {
     147    case OpType::Return: {
    149148        uint8_t returnCount;
    150149        if (!parseVarUInt1(returnCount))
     
    157156    }
    158157
    159     case WASMOpType::End:
     158    case OpType::End:
    160159        return m_context.endBlock(m_expressionStack);
    161160
  • trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp

    r205021 r205309  
    3939static const bool verbose = false;
    4040
    41 bool WASMModuleParser::parse()
     41bool ModuleParser::parse()
    4242{
    4343    if (m_sourceLength < 8)
     
    6060        dataLogLn("Passed processing header.");
    6161
    62     WASMSections::Section previousSection = WASMSections::Section::Unknown;
     62    Sections::Section previousSection = Sections::Unknown;
    6363    while (m_offset < m_sourceLength) {
    6464        if (verbose)
     
    7272            return false;
    7373
    74         WASMSections::Section section = WASMSections::lookup(m_source.data() + m_offset, sectionNameLength);
    75         if (!WASMSections::validateOrder(previousSection, section))
     74        Sections::Section section = Sections::lookup(m_source.data() + m_offset, sectionNameLength);
     75        if (!Sections::validateOrder(previousSection, section))
    7676            return false;
    7777        m_offset += sectionNameLength;
     
    8484
    8585        switch (section) {
    86         case WASMSections::Section::End:
     86        case Sections::End:
    8787            return true;
    8888
    89         case WASMSections::Section::FunctionTypes: {
     89        case Sections::FunctionTypes: {
    9090            if (verbose)
    9191                dataLogLn("Parsing types.");
     
    9595        }
    9696
    97         case WASMSections::Section::Signatures: {
     97        case Sections::Signatures: {
    9898            if (verbose)
    9999                dataLogLn("Parsing function signatures.");
     
    103103        }
    104104
    105         case WASMSections::Section::Definitions: {
     105        case Sections::Definitions: {
    106106            if (verbose)
    107107                dataLogLn("Parsing function definitions.");
     
    111111        }
    112112
    113         case WASMSections::Section::Unknown: {
     113        case Sections::Unknown: {
    114114            if (verbose)
    115115                dataLogLn("Unknown section, skipping.");
     
    132132}
    133133
    134 bool WASMModuleParser::parseFunctionTypes()
     134bool ModuleParser::parseFunctionTypes()
    135135{
    136136    uint32_t count;
     
    158158            dataLogLn("argumentCount: ", argumentCount);
    159159
    160         Vector<WASMValueType> argumentTypes;
     160        Vector<Type> argumentTypes;
     161        argumentTypes.resize(argumentCount);
     162
    161163        for (unsigned i = 0; i < argumentCount; ++i) {
    162             if (!parseUInt7(type) || type >= static_cast<uint8_t>(WASMValueType::NumberOfTypes))
    163                 return false;
    164             argumentTypes.append(static_cast<WASMValueType>(type));
     164            if (!parseUInt7(type) || type >= static_cast<uint8_t>(Type::LastValueType))
     165                return false;
     166            argumentTypes.append(static_cast<Type>(type));
    165167        }
    166168
    167169        if (!parseVarUInt1(type))
    168170            return false;
    169         WASMFunctionReturnType returnType;
     171        Type returnType;
    170172
    171173        if (verbose)
     
    173175
    174176        if (type) {
    175             WASMValueType value;
     177            Type value;
    176178            if (!parseValueType(value))
    177179                return false;
    178             returnType = static_cast<WASMFunctionReturnType>(value);
     180            returnType = static_cast<Type>(value);
    179181        } else
    180             returnType = WASMFunctionReturnType::Void;
     182            returnType = Type::Void;
    181183
    182184        // TODO: Actually do something with this data...
     
    186188}
    187189
    188 bool WASMModuleParser::parseFunctionSignatures()
     190bool ModuleParser::parseFunctionSignatures()
    189191{
    190192    uint32_t count;
     
    203205}
    204206
    205 bool WASMModuleParser::parseFunctionDefinitions()
     207bool ModuleParser::parseFunctionDefinitions()
    206208{
    207209    uint32_t count;
     
    217219            return false;
    218220
    219         WASMFunctionInformation& info = m_functions[i];
     221        FunctionInformation& info = m_functions[i];
    220222        info.start = m_offset;
    221223        info.end = m_offset + functionSize;
  • trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h

    r205021 r205309  
    3636namespace WASM {
    3737
    38 class WASMModuleParser : public WASMParser {
     38class ModuleParser : public Parser {
    3939public:
    4040
    4141    static const unsigned magicNumber = 0xc;
    4242
    43     WASMModuleParser(const Vector<uint8_t>& sourceBuffer)
    44         : WASMParser(sourceBuffer, 0, sourceBuffer.size())
     43    ModuleParser(const Vector<uint8_t>& sourceBuffer)
     44        : Parser(sourceBuffer, 0, sourceBuffer.size())
    4545    {
    4646    }
     
    4848    bool WARN_UNUSED_RETURN parse();
    4949
    50     const Vector<WASMFunctionInformation>& functionInformation() { return m_functions; }
     50    const Vector<FunctionInformation>& functionInformation() { return m_functions; }
    5151
    5252private:
     
    5656    bool WARN_UNUSED_RETURN parseFunctionDefinition(uint32_t number);
    5757    bool WARN_UNUSED_RETURN parseBlock();
    58     bool WARN_UNUSED_RETURN parseExpression(WASMOpType);
     58    bool WARN_UNUSED_RETURN parseExpression(OpType);
    5959
    60     Vector<WASMFunctionInformation> m_functions;
     60    Vector<FunctionInformation> m_functions;
    6161};
    6262
  • trunk/Source/JavaScriptCore/wasm/WASMOps.h

    r204588 r205309  
    107107#define CREATE_ENUM_VALUE(name, id, b3op) name = id,
    108108
    109 enum WASMOpType : uint8_t {
     109enum OpType : uint8_t {
    110110    FOR_EACH_WASM_OP(CREATE_ENUM_VALUE)
    111111};
    112112
    113 enum class WASMBinaryOpType : uint8_t {
     113enum class BinaryOpType : uint8_t {
    114114    FOR_EACH_WASM_BINARY_OP(CREATE_ENUM_VALUE)
    115115};
    116116
    117 enum class WASMUnaryOpType : uint8_t {
     117enum class UnaryOpType : uint8_t {
    118118    FOR_EACH_WASM_UNARY_OP(CREATE_ENUM_VALUE)
    119119};
  • trunk/Source/JavaScriptCore/wasm/WASMParser.h

    r205021 r205309  
    3939namespace WASM {
    4040
    41 class WASMParser {
     41class Parser {
    4242protected:
    43     WASMParser(const Vector<uint8_t>&, size_t start, size_t end);
     43    Parser(const Vector<uint8_t>&, size_t start, size_t end);
    4444
    4545    bool WARN_UNUSED_RETURN consumeCharacter(char);
     
    5252
    5353
    54     bool WARN_UNUSED_RETURN parseValueType(WASMValueType& result);
     54    bool WARN_UNUSED_RETURN parseValueType(Type& result);
    5555
    5656    const Vector<uint8_t>& m_source;
     
    5959};
    6060
    61 ALWAYS_INLINE WASMParser::WASMParser(const Vector<uint8_t>& sourceBuffer, size_t start, size_t end)
     61ALWAYS_INLINE Parser::Parser(const Vector<uint8_t>& sourceBuffer, size_t start, size_t end)
    6262    : m_source(sourceBuffer)
    6363    , m_sourceLength(end)
     
    6868}
    6969
    70 ALWAYS_INLINE bool WASMParser::consumeCharacter(char c)
     70ALWAYS_INLINE bool Parser::consumeCharacter(char c)
    7171{
    7272    if (m_offset >= m_sourceLength)
     
    7979}
    8080
    81 ALWAYS_INLINE bool WASMParser::consumeString(const char* str)
     81ALWAYS_INLINE bool Parser::consumeString(const char* str)
    8282{
    8383    unsigned start = m_offset;
     
    9191}
    9292
    93 ALWAYS_INLINE bool WASMParser::parseUInt32(uint32_t& result)
     93ALWAYS_INLINE bool Parser::parseUInt32(uint32_t& result)
    9494{
    9595    if (m_offset + 4 >= m_sourceLength)
     
    100100}
    101101
    102 ALWAYS_INLINE bool WASMParser::parseUInt7(uint8_t& result)
     102ALWAYS_INLINE bool Parser::parseUInt7(uint8_t& result)
    103103{
    104104    if (m_offset >= m_sourceLength)
     
    108108}
    109109
    110 ALWAYS_INLINE bool WASMParser::parseVarUInt1(uint8_t& result)
     110ALWAYS_INLINE bool Parser::parseVarUInt1(uint8_t& result)
    111111{
    112112    uint32_t temp;
     
    117117}
    118118
    119 ALWAYS_INLINE bool WASMParser::parseValueType(WASMValueType& result)
     119ALWAYS_INLINE bool Parser::parseValueType(Type& result)
    120120{
    121121    uint8_t value;
    122122    if (!parseUInt7(value))
    123123        return false;
    124     if (value >= static_cast<uint8_t>(WASMValueType::NumberOfTypes))
     124    if (value >= static_cast<uint8_t>(Type::LastValueType))
    125125        return false;
    126     result = static_cast<WASMValueType>(value);
     126    result = static_cast<Type>(value);
    127127    return true;
    128128}
  • trunk/Source/JavaScriptCore/wasm/WASMPlan.cpp

    r205021 r205309  
    4444    if (verbose)
    4545        dataLogLn("Starting plan.");
    46     WASMModuleParser moduleParser(source);
     46    ModuleParser moduleParser(source);
    4747    if (!moduleParser.parse()) {
    4848        dataLogLn("Parsing module failed.");
     
    5353        dataLogLn("Parsed module.");
    5454
    55     for (const WASMFunctionInformation& info : moduleParser.functionInformation()) {
     55    for (const FunctionInformation& info : moduleParser.functionInformation()) {
    5656        if (verbose)
    5757            dataLogLn("Processing funcion starting at: ", info.start, " and ending at: ", info.end);
  • trunk/Source/JavaScriptCore/wasm/WASMSections.cpp

    r205021 r205309  
    4343static const bool verbose = false;
    4444
    45 static const unsigned sectionDataLength = static_cast<unsigned>(WASMSections::Section::Unknown);
     45static const unsigned sectionDataLength = static_cast<unsigned>(Sections::Unknown);
    4646static const SectionData sectionData[sectionDataLength] {
    4747#define CREATE_SECTION_DATA(name, str) { sizeof(str) - 1, str },
     
    5050};
    5151
    52 WASMSections::Section WASMSections::lookup(const uint8_t* name, unsigned length)
     52Sections::Section Sections::lookup(const uint8_t* name, unsigned length)
    5353{
    5454    if (verbose)
     
    5858            continue;
    5959        if (!memcmp(name, sectionData[i].name, length))
    60             return static_cast<WASMSections::Section>(i);
     60            return static_cast<Sections::Section>(i);
    6161    }
    62     return WASMSections::Section::Unknown;
     62    return Sections::Unknown;
    6363}
    6464
  • trunk/Source/JavaScriptCore/wasm/WASMSections.h

    r204484 r205309  
    3939    macro(End, "end")
    4040
    41 struct WASMSections {
    42     enum class Section {
     41struct Sections {
     42    enum Section {
    4343#define CREATE_SECTION_ENUM(name, str) name,
    4444        FOR_EACH_WASM_SECTION_TYPE(CREATE_SECTION_ENUM)
     
    5151        // This allows unknown sections after End, which I doubt will ever be supported but
    5252        // there is no reason to potentially break backwards compatability.
    53         if (previous == Section::Unknown)
     53        if (previous == Unknown)
    5454            return true;
    5555        return previous < next;
Note: See TracChangeset for help on using the changeset viewer.