SelectorCompiler.h [plain text]
#pragma once
#if ENABLE(CSS_SELECTOR_JIT)
#include "SelectorChecker.h"
#include <JavaScriptCore/MacroAssemblerCodeRef.h>
#define CSS_SELECTOR_JIT_PROFILING 0
namespace JSC {
class MacroAssemblerCodeRef;
class VM;
}
namespace WebCore {
class CSSSelector;
class Element;
class RenderStyle;
class SelectorCompilationStatus {
public:
enum Status {
NotCompiled,
CannotCompile,
SimpleSelectorChecker,
SelectorCheckerWithCheckingContext
};
SelectorCompilationStatus()
: m_status(NotCompiled)
{ }
SelectorCompilationStatus(Status status)
: m_status(status)
{ }
operator Status() const { return m_status; }
private:
Status m_status;
};
namespace SelectorCompiler {
enum class SelectorContext {
RuleCollector,
QuerySelector
};
typedef unsigned (*RuleCollectorSimpleSelectorChecker)(const Element*, unsigned*);
typedef unsigned (*QuerySelectorSimpleSelectorChecker)(const Element*);
typedef unsigned (*RuleCollectorSelectorCheckerWithCheckingContext)(const Element*, SelectorChecker::CheckingContext*, unsigned*);
typedef unsigned (*QuerySelectorSelectorCheckerWithCheckingContext)(const Element*, const SelectorChecker::CheckingContext*);
SelectorCompilationStatus compileSelector(const CSSSelector*, JSC::VM*, SelectorContext, JSC::MacroAssemblerCodeRef& outputCodeRef);
inline RuleCollectorSimpleSelectorChecker ruleCollectorSimpleSelectorCheckerFunction(void* executableAddress, SelectorCompilationStatus compilationStatus)
{
ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker);
return reinterpret_cast<RuleCollectorSimpleSelectorChecker>(executableAddress);
}
inline QuerySelectorSimpleSelectorChecker querySelectorSimpleSelectorCheckerFunction(void* executableAddress, SelectorCompilationStatus compilationStatus)
{
ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker);
return reinterpret_cast<QuerySelectorSimpleSelectorChecker>(executableAddress);
}
inline RuleCollectorSelectorCheckerWithCheckingContext ruleCollectorSelectorCheckerFunctionWithCheckingContext(void* executableAddress, SelectorCompilationStatus compilationStatus)
{
ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
return reinterpret_cast<RuleCollectorSelectorCheckerWithCheckingContext>(executableAddress);
}
inline QuerySelectorSelectorCheckerWithCheckingContext querySelectorSelectorCheckerFunctionWithCheckingContext(void* executableAddress, SelectorCompilationStatus compilationStatus)
{
ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
return reinterpret_cast<QuerySelectorSelectorCheckerWithCheckingContext>(executableAddress);
}
} }
#endif // ENABLE(CSS_SELECTOR_JIT)