+2015-08-27 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r189079.
+ https://bugs.webkit.org/show_bug.cgi?id=148555
+
+ broke the build (Requested by jessieberlin on #webkit).
+
+ Reverted changeset:
+
+ "Create WebAssembly functions"
+ https://bugs.webkit.org/show_bug.cgi?id=148373
+ http://trac.webkit.org/changeset/189079
+
2015-08-27 Sukolsak Sakshuwong <sukolsak@gmail.com>
Create WebAssembly functions
{
if (!m_hash) {
RELEASE_ASSERT(isSafeToComputeHash());
- m_hash = CodeBlockHash(ownerScriptExecutable()->source(), specializationKind());
+ m_hash = CodeBlockHash(ownerExecutable()->source(), specializationKind());
}
return m_hash;
}
CString CodeBlock::sourceCodeForTools() const
{
if (codeType() != FunctionCode)
- return ownerScriptExecutable()->source().toUTF8();
+ return ownerExecutable()->source().toUTF8();
SourceProvider* provider = source();
FunctionExecutable* executable = jsCast<FunctionExecutable*>(ownerExecutable());
out.print(", ", instructionCount());
if (this->jitType() == JITCode::BaselineJIT && m_shouldAlwaysBeInlined)
out.print(" (ShouldAlwaysBeInlined)");
- if (ownerScriptExecutable()->neverInline())
+ if (ownerExecutable()->neverInline())
out.print(" (NeverInline)");
- if (ownerScriptExecutable()->didTryToEnterInLoop())
+ if (ownerExecutable()->didTryToEnterInLoop())
out.print(" (DidTryToEnterInLoop)");
- if (ownerScriptExecutable()->isStrictMode())
+ if (ownerExecutable()->isStrictMode())
out.print(" (StrictMode)");
if (this->jitType() == JITCode::BaselineJIT && m_didFailFTLCompilation)
out.print(" (FTLFail)");
void CodeBlock::dumpSource(PrintStream& out)
{
- ScriptExecutable* executable = ownerScriptExecutable();
+ ScriptExecutable* executable = ownerExecutable();
if (executable->isFunctionExecutable()) {
FunctionExecutable* functionExecutable = reinterpret_cast<FunctionExecutable*>(executable);
String source = functionExecutable->source().provider()->getRange(
setNumParameters(unlinkedCodeBlock->numParameters());
if (vm()->typeProfiler() || vm()->controlFlowProfiler())
- vm()->functionHasExecutedCache()->removeUnexecutedRange(ownerExecutable->sourceID(), ownerExecutable->typeProfilingStartOffset(), ownerExecutable->typeProfilingEndOffset());
+ vm()->functionHasExecutedCache()->removeUnexecutedRange(m_ownerExecutable->sourceID(), m_ownerExecutable->typeProfilingStartOffset(), m_ownerExecutable->typeProfilingEndOffset());
setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation());
if (unlinkedCodeBlock->usesGlobalObject())
for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) {
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
if (vm()->typeProfiler() || vm()->controlFlowProfiler())
- vm()->functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
+ vm()->functionHasExecutedCache()->insertUnexecutedRange(m_ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
}
for (size_t count = unlinkedCodeBlock->numberOfFunctionExprs(), i = 0; i < count; ++i) {
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i);
if (vm()->typeProfiler() || vm()->controlFlowProfiler())
- vm()->functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
+ vm()->functionHasExecutedCache()->insertUnexecutedRange(m_ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
}
instructions[i + opLength - 1] = objectAllocationProfile;
objectAllocationProfile->initialize(*vm(),
- ownerExecutable, m_globalObject->objectPrototype(), inferredInlineCapacity);
+ m_ownerExecutable.get(), m_globalObject->objectPrototype(), inferredInlineCapacity);
break;
}
// the user's program, give the type profiler some range to identify these return statements.
// Currently, the text offset that is used as identification is "f" in the function keyword
// and is stored on TypeLocation's m_divotForFunctionOffsetIfReturnStatement member variable.
- divotStart = divotEnd = ownerExecutable->typeProfilingStartOffset();
+ divotStart = divotEnd = m_ownerExecutable->typeProfilingStartOffset();
shouldAnalyze = true;
}
break;
}
std::pair<TypeLocation*, bool> locationPair = vm()->typeProfiler()->typeLocationCache()->getTypeLocation(globalVariableID,
- ownerExecutable->sourceID(), divotStart, divotEnd, globalTypeSet, vm());
+ m_ownerExecutable->sourceID(), divotStart, divotEnd, globalTypeSet, vm());
TypeLocation* location = locationPair.first;
bool isNewLocation = locationPair.second;
if (flag == ProfileTypeBytecodeFunctionReturnStatement)
- location->m_divotForFunctionOffsetIfReturnStatement = ownerExecutable->typeProfilingStartOffset();
+ location->m_divotForFunctionOffsetIfReturnStatement = m_ownerExecutable->typeProfilingStartOffset();
if (shouldAnalyze && isNewLocation)
vm()->typeProfiler()->insertNewLocation(location);
m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock) + m_instructions.size() * sizeof(Instruction));
}
-#if ENABLE(WEBASSEMBLY)
-CodeBlock::CodeBlock(WebAssemblyExecutable* ownerExecutable, VM& vm, JSGlobalObject* globalObject)
- : m_globalObject(globalObject->vm(), ownerExecutable, globalObject)
- , m_heap(&m_globalObject->vm().heap)
- , m_numCalleeRegisters(0)
- , m_numVars(0)
- , m_isConstructor(false)
- , m_shouldAlwaysBeInlined(false)
- , m_didFailFTLCompilation(false)
- , m_hasBeenCompiledWithFTL(false)
- , m_hasDebuggerStatement(false)
- , m_steppingMode(SteppingModeDisabled)
- , m_numBreakpoints(0)
- , m_ownerExecutable(m_globalObject->vm(), ownerExecutable, ownerExecutable)
- , m_vm(&vm)
- , m_isStrictMode(false)
- , m_needsActivation(false)
- , m_mayBeExecuting(false)
- , m_codeType(FunctionCode)
- , m_osrExitCounter(0)
- , m_optimizationDelayCounter(0)
- , m_reoptimizationRetryCounter(0)
-#if ENABLE(JIT)
- , m_capabilityLevelState(DFG::CannotCompile)
-#endif
-{
- ASSERT(m_heap->isDeferred());
-
- m_heap->m_codeBlocks.add(this);
- m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock));
-}
-#endif
-
CodeBlock::~CodeBlock()
{
if (m_vm->m_perBytecodeProfiler)
void CodeBlock::finalizeUnconditionally()
{
Interpreter* interpreter = m_vm->interpreter;
- bool ownedByWebAssemblyExecutable = false;
-#if ENABLE(WEBASSEMBLY)
- ownedByWebAssemblyExecutable = m_ownerExecutable->isWebAssemblyExecutable();
-#endif
- if (JITCode::couldBeInterpreted(jitType()) && !ownedByWebAssemblyExecutable) {
+ if (JITCode::couldBeInterpreted(jitType())) {
const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) {
Instruction* curInstruction = &instructions()[propertyAccessInstructions[i]];
unsigned CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
{
RELEASE_ASSERT(bytecodeOffset < instructions().size());
- return ownerScriptExecutable()->firstLine() + m_unlinkedCode->lineNumberForBytecodeOffset(bytecodeOffset);
+ return m_ownerExecutable->firstLine() + m_unlinkedCode->lineNumberForBytecodeOffset(bytecodeOffset);
}
unsigned CodeBlock::columnNumberForBytecodeOffset(unsigned bytecodeOffset)
m_unlinkedCode->expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column);
divot += m_sourceOffset;
column += line ? 1 : firstLineColumnOffset();
- line += ownerScriptExecutable()->firstLine();
+ line += m_ownerExecutable->firstLine();
}
bool CodeBlock::hasOpDebugForLineAndColumn(unsigned line, unsigned column)
void CodeBlock::install()
{
- ownerScriptExecutable()->installCode(this);
+ ownerExecutable()->installCode(this);
}
PassRefPtr<CodeBlock> CodeBlock::newReplacement()
{
- return ownerScriptExecutable()->newReplacementCodeBlockFor(specializationKind());
+ return ownerExecutable()->newReplacementCodeBlockFor(specializationKind());
}
#if ENABLE(JIT)
return DFG::functionForConstructCapabilityLevel(this);
return DFG::functionForCallCapabilityLevel(this);
}
-
-#if ENABLE(WEBASSEMBLY)
-CodeBlock* WebAssemblyCodeBlock::replacement()
-{
- return nullptr;
-}
-
-DFG::CapabilityLevel WebAssemblyCodeBlock::capabilityLevelInternal()
-{
- return DFG::CannotCompile;
-}
-#endif
#endif
void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mode, const FireDetail* detail)
void CodeBlock::updateAllPredictions()
{
-#if ENABLE(WEBASSEMBLY)
- if (m_ownerExecutable->isWebAssemblyExecutable())
- return;
-#endif
updateAllValueProfilePredictions();
updateAllArrayPredictions();
}
RELEASE_ASSERT(vm()->interpreter->getOpcodeID(instructions[endIdx].u.opcode) == op_profile_control_flow);
basicBlockEndOffset = instructions[endIdx + 1].u.operand - 1;
} else {
- basicBlockEndOffset = m_sourceOffset + ownerScriptExecutable()->source().length() - 1; // Offset before the closing brace.
+ basicBlockEndOffset = m_sourceOffset + m_ownerExecutable->source().length() - 1; // Offset before the closing brace.
basicBlockStartOffset = std::min(basicBlockStartOffset, basicBlockEndOffset); // Some start offsets may be at the closing brace, ensure it is the offset before.
}
continue;
}
- BasicBlockLocation* basicBlockLocation = vm()->controlFlowProfiler()->getBasicBlockLocation(ownerScriptExecutable()->sourceID(), basicBlockStartOffset, basicBlockEndOffset);
+ BasicBlockLocation* basicBlockLocation = vm()->controlFlowProfiler()->getBasicBlockLocation(m_ownerExecutable->sourceID(), basicBlockStartOffset, basicBlockEndOffset);
// Find all functions that are enclosed within the range: [basicBlockStartOffset, basicBlockEndOffset]
// and insert these functions' start/end offsets as gaps in the current BasicBlockLocation.
CodeBlock(CopyParsedBlockTag, CodeBlock& other);
CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSScope*, PassRefPtr<SourceProvider>, unsigned sourceOffset, unsigned firstLineColumnOffset);
-#if ENABLE(WEBASSEMBLY)
- CodeBlock(WebAssemblyExecutable* ownerExecutable, VM&, JSGlobalObject*);
-#endif
WriteBarrier<JSGlobalObject> m_globalObject;
Heap* m_heap;
void jettison(Profiler::JettisonReason, ReoptimizationMode = DontCountReoptimization, const FireDetail* = nullptr);
- ExecutableBase* ownerExecutable() const { return m_ownerExecutable.get(); }
- ScriptExecutable* ownerScriptExecutable() const { return jsCast<ScriptExecutable*>(m_ownerExecutable.get()); }
+ ScriptExecutable* ownerExecutable() const { return m_ownerExecutable.get(); }
void setVM(VM* vm) { m_vm = vm; }
VM* vm() { return m_vm; }
return m_needsActivation;
}
- CodeType codeType() const
- {
-#if ENABLE(WEBASSEMBLY)
- if (m_ownerExecutable->isWebAssemblyExecutable())
- return FunctionCode;
-#endif
- return m_unlinkedCode->codeType();
- }
-
+ CodeType codeType() const { return m_unlinkedCode->codeType(); }
PutPropertySlot::Context putByIdContext() const
{
if (codeType() == EvalCode)
unsigned m_numBreakpoints : 30;
};
};
- WriteBarrier<ExecutableBase> m_ownerExecutable;
+ WriteBarrier<ScriptExecutable> m_ownerExecutable;
VM* m_vm;
RefCountedArray<Instruction> m_instructions;
#endif
};
-#if ENABLE(WEBASSEMBLY)
-class WebAssemblyCodeBlock : public CodeBlock {
-public:
- WebAssemblyCodeBlock(CopyParsedBlockTag, WebAssemblyCodeBlock& other)
- : CodeBlock(CopyParsedBlock, other)
- {
- }
-
- WebAssemblyCodeBlock(WebAssemblyExecutable* ownerExecutable, VM& vm, JSGlobalObject* globalObject)
- : CodeBlock(ownerExecutable, vm, globalObject)
- {
- }
-
-#if ENABLE(JIT)
-protected:
- virtual CodeBlock* replacement() override;
- virtual DFG::CapabilityLevel capabilityLevelInternal() override;
-#endif
-};
-#endif
-
inline Register& ExecState::r(int index)
{
CodeBlock* codeBlock = this->codeBlock();
void Debugger::toggleBreakpoint(CodeBlock* codeBlock, Breakpoint& breakpoint, BreakpointState enabledOrNot)
{
- ScriptExecutable* executable = codeBlock->ownerScriptExecutable();
+ ScriptExecutable* executable = codeBlock->ownerExecutable();
SourceID sourceID = static_cast<SourceID>(executable->sourceID());
if (breakpoint.sourceID != sourceID)
CodeBlock* codeBlock = callFrame->codeBlock();
if (!codeBlock)
return noSourceID;
- return codeBlock->ownerScriptExecutable()->sourceID();
+ return codeBlock->ownerExecutable()->sourceID();
}
JSValue DebuggerCallFrame::thisValueForCallFrame(CallFrame* callFrame)
CodeBlock* m_profiledBlock;
InlineCallFrame* m_inlineCallFrame;
- ScriptExecutable* executable() { return m_codeBlock->ownerScriptExecutable(); }
+ ScriptExecutable* executable() { return m_codeBlock->ownerExecutable(); }
QueryableExitProfile m_exitProfile;
dataLog(" Might inline function: ", mightInlineFunctionFor(codeBlock, kind), "\n");
dataLog(" Might compile function: ", mightCompileFunctionFor(codeBlock, kind), "\n");
dataLog(" Is supported for inlining: ", isSupportedForInlining(codeBlock), "\n");
- dataLog(" Needs activation: ", codeBlock->ownerScriptExecutable()->needsActivation(), "\n");
- dataLog(" Is inlining candidate: ", codeBlock->ownerScriptExecutable()->isInliningCandidate(), "\n");
+ dataLog(" Needs activation: ", codeBlock->ownerExecutable()->needsActivation(), "\n");
+ dataLog(" Is inlining candidate: ", codeBlock->ownerExecutable()->isInliningCandidate(), "\n");
}
if (!canInline(capabilityLevel)) {
if (verbose)
byteCodeParser->m_graph.freeze(codeBlock->ownerExecutable());
// The owner is the machine code block, and we already have a barrier on that when the
// plan finishes.
- m_inlineCallFrame->executable.setWithoutWriteBarrier(codeBlock->ownerScriptExecutable());
+ m_inlineCallFrame->executable.setWithoutWriteBarrier(codeBlock->ownerExecutable());
m_inlineCallFrame->setStackOffset(inlineCallFrameStart.offset() - JSStack::CallFrameHeaderSize);
if (callee) {
m_inlineCallFrame->calleeRecovery = ValueRecovery::constant(callee);
}
dataLog(
": needsActivation = ", codeBlock->needsActivation(),
- ", isStrictMode = ", codeBlock->ownerScriptExecutable()->isStrictMode(), "\n");
+ ", isStrictMode = ", codeBlock->ownerExecutable()->isStrictMode(), "\n");
codeBlock->baselineVersion()->dumpBytecode();
}
bool isSupportedForInlining(CodeBlock* codeBlock)
{
-#if ENABLE(WEBASSEMBLY)
- if (codeBlock->ownerExecutable()->isWebAssemblyExecutable())
- return false;
-#endif
- return codeBlock->ownerScriptExecutable()->isInliningCandidate();
+ return codeBlock->ownerExecutable()->isInliningCandidate();
}
bool mightCompileEval(CodeBlock* codeBlock)
ScriptExecutable* executableFor(InlineCallFrame* inlineCallFrame)
{
if (!inlineCallFrame)
- return m_codeBlock->ownerScriptExecutable();
+ return m_codeBlock->ownerExecutable();
return inlineCallFrame->executable.get();
}
sanitizeStackForVM(vm);
if (bytecodeIndex)
- codeBlock->ownerScriptExecutable()->setDidTryToEnterInLoop(true);
+ codeBlock->ownerExecutable()->setDidTryToEnterInLoop(true);
if (codeBlock->jitType() != JITCode::DFGJIT) {
RELEASE_ASSERT(codeBlock->jitType() == JITCode::FTLJIT);
}
if (m_remainingCapacityForFrameCapture) {
-#if ENABLE(WEBASSEMBLY)
- if (visitor->codeBlock()->ownerExecutable()->isWebAssemblyExecutable())
- return StackVisitor::Continue;
-#endif
unsigned line;
unsigned column;
visitor->computeLineAndColumn(line, column);
ASSERT(!callFrame->vm().exception());
ThisTDZMode thisTDZMode = callerCodeBlock->unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded;
- eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock->ownerScriptExecutable(), callerCodeBlock->isStrictMode(), thisTDZMode, programSource, callerScopeChain);
+ eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock->ownerExecutable(), callerCodeBlock->isStrictMode(), thisTDZMode, programSource, callerScopeChain);
if (!eval)
return jsUndefined();
}
return traceBuild.toString().impl();
}
-static inline bool isWebAssemblyExecutable(ExecutableBase* executable)
-{
-#if !ENABLE(WEBASSEMBLY)
- UNUSED_PARAM(executable);
- return false;
-#else
- return executable->isWebAssemblyExecutable();
-#endif
-}
-
class GetStackTraceFunctor {
public:
GetStackTraceFunctor(VM& vm, Vector<StackFrame>& results, size_t remainingCapacity)
{
VM& vm = m_vm;
if (m_remainingCapacityForFrameCapture) {
- if (visitor->isJSFrame()
- && !isWebAssemblyExecutable(visitor->codeBlock()->ownerExecutable())
- && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
+ if (visitor->isJSFrame() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
CodeBlock* codeBlock = visitor->codeBlock();
StackFrame s = {
Strong<JSObject>(vm, visitor->callee()),
getStackFrameCodeType(visitor),
- Strong<ScriptExecutable>(vm, codeBlock->ownerScriptExecutable()),
+ Strong<ScriptExecutable>(vm, codeBlock->ownerExecutable()),
Strong<UnlinkedCodeBlock>(vm, codeBlock->unlinkedCodeBlock()),
codeBlock->source(),
- codeBlock->ownerScriptExecutable()->firstLine(),
+ codeBlock->ownerExecutable()->firstLine(),
codeBlock->firstLineColumnOffset(),
codeBlock->sourceOffset(),
visitor->bytecodeOffset(),
m_codeBlock = visitor->codeBlock();
unsigned bytecodeOffset = visitor->bytecodeOffset();
- if (m_isTermination || !(m_handler = (m_codeBlock && !isWebAssemblyExecutable(m_codeBlock->ownerExecutable())) ? m_codeBlock->handlerForBytecodeOffset(bytecodeOffset) : nullptr)) {
+ if (m_isTermination || !(m_handler = m_codeBlock ? m_codeBlock->handlerForBytecodeOffset(bytecodeOffset) : nullptr)) {
if (!unwindCallFrame(visitor)) {
if (LegacyProfiler* profiler = vm.enabledProfiler())
profiler->exceptionUnwind(m_callFrame);
case CodeType::Eval:
case CodeType::Function:
case CodeType::Global: {
- String sourceURL = codeBlock()->ownerScriptExecutable()->sourceURL();
+ String sourceURL = codeBlock()->ownerExecutable()->sourceURL();
if (!sourceURL.isEmpty())
traceLine = sourceURL.impl();
break;
unsigned divotColumn = 0;
retrieveExpressionInfo(divot, unusedStartOffset, unusedEndOffset, divotLine, divotColumn);
- line = divotLine + codeBlock->ownerScriptExecutable()->firstLine();
+ line = divotLine + codeBlock->ownerExecutable()->firstLine();
column = divotColumn + (divotLine ? 1 : codeBlock->firstLineColumnOffset());
- if (codeBlock->ownerScriptExecutable()->hasOverrideLineNumber())
- line = codeBlock->ownerScriptExecutable()->overrideLineNumber();
+ if (codeBlock->ownerExecutable()->hasOverrideLineNumber())
+ line = codeBlock->ownerExecutable()->overrideLineNumber();
}
void StackVisitor::Frame::retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)
MacroAssemblerCodePtr codePtr;
CodeBlock* codeBlock = 0;
- if (executable->isHostFunction()) {
+ if (executable->isHostFunction())
codePtr = executable->entrypointFor(*vm, kind, MustCheckArity, callLinkInfo->registerPreservationMode());
-#if ENABLE(WEBASSEMBLY)
- } else if (executable->isWebAssemblyExecutable()) {
- WebAssemblyExecutable* webAssemblyExecutable = static_cast<WebAssemblyExecutable*>(executable);
- webAssemblyExecutable->prepareForExecution(execCallee);
- codeBlock = webAssemblyExecutable->codeBlockForCall();
- ASSERT(codeBlock);
- ArityCheckMode arity;
- if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
- arity = MustCheckArity;
- else
- arity = ArityCheckNotRequired;
- codePtr = webAssemblyExecutable->entrypointFor(*vm, kind, arity, callLinkInfo->registerPreservationMode());
-#endif
- } else {
+ else {
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
if (!isCall(kind) && functionExecutable->constructAbility() == ConstructAbility::CannotConstruct) {
JSScope* scope = function->scopeUnchecked();
ExecutableBase* executable = function->executable();
if (UNLIKELY(!executable->hasJITCodeFor(kind))) {
- bool isWebAssemblyExecutable = false;
-#if ENABLE(WEBASSEMBLY)
- isWebAssemblyExecutable = executable->isWebAssemblyExecutable();
-#endif
- if (!isWebAssemblyExecutable) {
- FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
-
- if (!isCall(kind) && functionExecutable->constructAbility() == ConstructAbility::CannotConstruct) {
- exec->vm().throwException(exec, createNotAConstructorError(exec, function));
- return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
- }
+ FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
- JSObject* error = functionExecutable->prepareForExecution(execCallee, function, scope, kind);
- if (error) {
- exec->vm().throwException(exec, error);
- return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
- }
- } else {
-#if ENABLE(WEBASSEMBLY)
- if (!isCall(kind)) {
- exec->vm().throwException(exec, createNotAConstructorError(exec, function));
- return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
- }
+ if (!isCall(kind) && functionExecutable->constructAbility() == ConstructAbility::CannotConstruct) {
+ exec->vm().throwException(exec, createNotAConstructorError(exec, function));
+ return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
+ }
- WebAssemblyExecutable* webAssemblyExecutable = static_cast<WebAssemblyExecutable*>(executable);
- webAssemblyExecutable->prepareForExecution(execCallee);
-#endif
+ JSObject* error = functionExecutable->prepareForExecution(execCallee, function, scope, kind);
+ if (error) {
+ exec->vm().throwException(exec, error);
+ return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
}
}
return reinterpret_cast<char*>(executable->entrypointFor(
if (variant.executable()->isHostFunction())
codeBlock = nullptr;
else {
- ExecutableBase* executable = variant.executable();
-#if ENABLE(WEBASSEMBLY)
- if (executable->isWebAssemblyExecutable())
- codeBlock = jsCast<WebAssemblyExecutable*>(executable)->codeBlockForCall();
- else
-#endif
- codeBlock = jsCast<FunctionExecutable*>(executable)->codeBlockForCall();
+ codeBlock = jsCast<FunctionExecutable*>(variant.executable())->codeBlockForCall();
+
// If we cannot handle a callee, assume that it's better for this whole thing to be a
// virtual call.
if (exec->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()) || callLinkInfo.callType() == CallLinkInfo::CallVarargs || callLinkInfo.callType() == CallLinkInfo::ConstructVarargs) {
ASSERT(maxFrameExtentForSlowPathCall == 64);
#endif
ASSERT(StringType == 6);
- ASSERT(ObjectType == 19);
- ASSERT(FinalObjectType == 20);
+ ASSERT(ObjectType == 18);
+ ASSERT(FinalObjectType == 19);
ASSERT(MasqueradesAsUndefined == 1);
ASSERT(ImplementsHasInstance == 2);
ASSERT(ImplementsDefaultHasInstance == 8);
MacroAssemblerCodePtr codePtr;
CodeBlock* codeBlock = 0;
- bool isWebAssemblyExecutable = false;
-#if ENABLE(WEBASSEMBLY)
- isWebAssemblyExecutable = executable->isWebAssemblyExecutable();
-#endif
-
- if (executable->isHostFunction()) {
+ if (executable->isHostFunction())
codePtr = executable->entrypointFor(vm, kind, MustCheckArity, RegisterPreservationNotRequired);
- } else if (!isWebAssemblyExecutable) {
+ else {
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
if (!isCall(kind) && functionExecutable->constructAbility() == ConstructAbility::CannotConstruct)
else
arity = ArityCheckNotRequired;
codePtr = functionExecutable->entrypointFor(vm, kind, arity, RegisterPreservationNotRequired);
- } else {
-#if ENABLE(WEBASSEMBLY)
- WebAssemblyExecutable* webAssemblyExecutable = static_cast<WebAssemblyExecutable*>(executable);
- webAssemblyExecutable->prepareForExecution(execCallee);
- codeBlock = webAssemblyExecutable->codeBlockForCall();
- ASSERT(codeBlock);
- ArityCheckMode arity;
- if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
- arity = MustCheckArity;
- else
- arity = ArityCheckNotRequired;
- codePtr = webAssemblyExecutable->entrypointFor(vm, kind, arity, RegisterPreservationNotRequired);
-#endif
}
ASSERT(!!codePtr);
# Type constants.
const StringType = 6
-const ObjectType = 19
-const FinalObjectType = 20
+const ObjectType = 18
+const FinalObjectType = 19
# Type flags constants.
const MasqueradesAsUndefined = 1
SLOW_PATH_DECL(slow_path_enter)
{
BEGIN();
- ExecutableBase* ownerExecutable = exec->codeBlock()->ownerExecutable();
+ ScriptExecutable* ownerExecutable = exec->codeBlock()->ownerExecutable();
Heap::heap(ownerExecutable)->writeBarrier(ownerExecutable);
END();
}
#include "DFGDriver.h"
#include "JIT.h"
#include "JSCInlines.h"
-#include "JSWASMModule.h"
#include "LLIntEntrypoint.h"
#include "Parser.h"
#include "ProfilerDatabase.h"
#include "TypeProfiler.h"
-#include "WASMFunctionParser.h"
#include <wtf/CommaPrinter.h>
#include <wtf/Vector.h>
#include <wtf/text/StringBuilder.h>
return unlinkedExecutable->link(exec.vm(), source, overrideLineNumber);
}
-#if ENABLE(WEBASSEMBLY)
-const ClassInfo WebAssemblyExecutable::s_info = { "WebAssemblyExecutable", &ExecutableBase::s_info, 0, CREATE_METHOD_TABLE(WebAssemblyExecutable) };
-
-WebAssemblyExecutable::WebAssemblyExecutable(VM& vm, const SourceCode& source, JSWASMModule* module, unsigned functionIndex)
- : ExecutableBase(vm, vm.webAssemblyExecutableStructure.get(), NUM_PARAMETERS_NOT_COMPILED)
- , m_source(source)
- , m_module(vm, this, module)
- , m_functionIndex(functionIndex)
-{
-}
-
-void WebAssemblyExecutable::destroy(JSCell* cell)
-{
- static_cast<WebAssemblyExecutable*>(cell)->WebAssemblyExecutable::~WebAssemblyExecutable();
-}
-
-void WebAssemblyExecutable::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
- WebAssemblyExecutable* thisObject = jsCast<WebAssemblyExecutable*>(cell);
- ASSERT_GC_OBJECT_INHERITS(thisObject, info());
- ExecutableBase::visitChildren(thisObject, visitor);
- if (thisObject->m_codeBlockForCall)
- thisObject->m_codeBlockForCall->visitAggregate(visitor);
- visitor.append(&thisObject->m_module);
-}
-
-void WebAssemblyExecutable::clearCode()
-{
- m_codeBlockForCall = nullptr;
- Base::clearCode();
-}
-
-void WebAssemblyExecutable::prepareForExecution(ExecState* exec)
-{
- if (hasJITCodeForCall())
- return;
-
- VM& vm = exec->vm();
- DeferGC deferGC(vm.heap);
-
- RefPtr<WebAssemblyCodeBlock> codeBlock = adoptRef(new WebAssemblyCodeBlock(
- this, vm, exec->lexicalGlobalObject()));
-
- WASMFunctionParser::compile(vm, codeBlock.get(), m_module.get(), m_source, m_functionIndex);
-
- m_jitCodeForCall = codeBlock->jitCode();
- m_jitCodeForCallWithArityCheck = MacroAssemblerCodePtr();
- m_jitCodeForCallWithArityCheckAndPreserveRegs = MacroAssemblerCodePtr();
- m_numParametersForCall = codeBlock->numParameters();
-
- m_codeBlockForCall = codeBlock;
-
- Heap::heap(this)->writeBarrier(this);
-}
-#endif
-
void ExecutableBase::dump(PrintStream& out) const
{
ExecutableBase* realThis = const_cast<ExecutableBase*>(this);
class Debugger;
class EvalCodeBlock;
class FunctionCodeBlock;
-class JSScope;
-class JSWASMModule;
class LLIntOffsetsExtractor;
class ProgramCodeBlock;
-class WebAssemblyCodeBlock;
+class JSScope;
enum CompilationKind { FirstCompilation, OptimizingCompilation };
CodeBlockHash hashFor(CodeSpecializationKind) const;
- bool isEvalExecutable() const
+ bool isEvalExecutable()
{
return type() == EvalExecutableType;
}
- bool isFunctionExecutable() const
+ bool isFunctionExecutable()
{
return type() == FunctionExecutableType;
}
- bool isProgramExecutable() const
+ bool isProgramExecutable()
{
return type() == ProgramExecutableType;
}
return m_numParametersForCall == NUM_PARAMETERS_IS_HOST;
}
-#if ENABLE(WEBASSEMBLY)
- bool isWebAssemblyExecutable() const
- {
- return type() == WebAssemblyExecutableType;
- }
-#endif
-
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(vm, globalObject, proto, TypeInfo(CellType, StructureFlags), info()); }
void clearCode();
static void destroy(JSCell*);
- UnlinkedFunctionExecutable* unlinkedExecutable() const
+ UnlinkedFunctionExecutable* unlinkedExecutable()
{
return m_unlinkedExecutable.get();
}
WriteBarrier<InferredValue> m_singletonFunction;
};
-#if ENABLE(WEBASSEMBLY)
-class WebAssemblyExecutable final : public ExecutableBase {
-public:
- typedef ExecutableBase Base;
- static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
-
- static WebAssemblyExecutable* create(VM& vm, const SourceCode& source, JSWASMModule* module, unsigned functionIndex)
- {
- WebAssemblyExecutable* executable = new (NotNull, allocateCell<WebAssemblyExecutable>(vm.heap)) WebAssemblyExecutable(vm, source, module, functionIndex);
- executable->finishCreation(vm);
- return executable;
- }
-
- static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
- {
- return Structure::create(vm, globalObject, proto, TypeInfo(WebAssemblyExecutableType, StructureFlags), info());
- }
-
- static void destroy(JSCell*);
-
- DECLARE_INFO;
-
- void clearCode();
-
- void prepareForExecution(ExecState*);
-
- WebAssemblyCodeBlock* codeBlockForCall()
- {
- return m_codeBlockForCall.get();
- }
-
-private:
- WebAssemblyExecutable(VM&, const SourceCode&, JSWASMModule*, unsigned functionIndex);
-
- static void visitChildren(JSCell*, SlotVisitor&);
-
- SourceCode m_source;
- WriteBarrier<JSWASMModule> m_module;
- unsigned m_functionIndex;
-
- RefPtr<WebAssemblyCodeBlock> m_codeBlockForCall;
-};
-#endif
-
inline void ExecutableBase::clearCodeVirtual(ExecutableBase* executable)
{
switch (executable->type()) {
return jsCast<ProgramExecutable*>(executable)->clearCode();
case FunctionExecutableType:
return jsCast<FunctionExecutable*>(executable)->clearCode();
-#if ENABLE(WEBASSEMBLY)
- case WebAssemblyExecutableType:
- return jsCast<WebAssemblyExecutable*>(executable)->clearCode();
-#endif
default:
return jsCast<NativeExecutable*>(executable)->clearCode();
}
return result;
}
-#if ENABLE(WEBASSEMBLY)
-JSFunction* JSFunction::create(VM& vm, WebAssemblyExecutable* executable, JSScope* scope)
-{
- JSFunction* function = new (NotNull, allocateCell<JSFunction>(vm.heap)) JSFunction(vm, executable, scope);
- ASSERT(function->structure()->globalObject());
- function->finishCreation(vm);
- return function;
-}
-#endif
-
static inline NativeExecutable* getNativeExecutable(VM& vm, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
{
#if !ENABLE(JIT)
class LLIntOffsetsExtractor;
class NativeExecutable;
class SourceCode;
-class WebAssemblyExecutable;
namespace DFG {
class SpeculativeJIT;
class JITCompiler;
JS_EXPORT_PRIVATE static JSFunction* create(VM&, JSGlobalObject*, int length, const String& name, NativeStdFunction&&, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
static JSFunction* create(VM&, FunctionExecutable*, JSScope*);
-#if ENABLE(WEBASSEMBLY)
- static JSFunction* create(VM&, WebAssemblyExecutable*, JSScope*);
-#endif
static JSFunction* createBuiltinFunction(VM&, FunctionExecutable*, JSGlobalObject*);
static JSFunction* createBuiltinFunction(VM&, FunctionExecutable*, JSGlobalObject*, const String& name);
JSFunction(VM&, FunctionExecutable*, JSScope*);
JSFunction(VM&, FunctionExecutable*, JSScope*, Structure*);
-#if ENABLE(WEBASSEMBLY)
- JSFunction(VM&, WebAssemblyExecutable*, JSScope*);
-#endif
-
void finishCreation(VM&, NativeExecutable*, int length, const String& name);
using Base::finishCreation;
{
}
-#if ENABLE(WEBASSEMBLY)
-inline JSFunction::JSFunction(VM& vm, WebAssemblyExecutable* executable, JSScope* scope)
- : Base(vm, scope, scope->globalObject()->functionStructure())
- , m_executable(vm, this, executable)
- , m_rareData()
-{
-}
-#endif
-
inline FunctionExecutable* JSFunction::jsExecutable() const
{
ASSERT(!isHostFunctionNonInline());
inline bool JSFunction::isBuiltinFunction() const
{
-#if ENABLE(WEBASSEMBLY)
- if (m_executable->isWebAssemblyExecutable())
- return false;
-#endif
return !isHostFunction() && jsExecutable()->isBuiltinFunction();
}
EvalExecutableType,
ProgramExecutableType,
FunctionExecutableType,
- WebAssemblyExecutableType,
UnlinkedFunctionExecutableType,
UnlinkedProgramCodeBlockType,
evalExecutableStructure.set(*this, EvalExecutable::createStructure(*this, 0, jsNull()));
programExecutableStructure.set(*this, ProgramExecutable::createStructure(*this, 0, jsNull()));
functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, 0, jsNull()));
-#if ENABLE(WEBASSEMBLY)
- webAssemblyExecutableStructure.set(*this, WebAssemblyExecutable::createStructure(*this, 0, jsNull()));
-#endif
regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull()));
symbolStructure.set(*this, Symbol::createStructure(*this, 0, jsNull()));
symbolTableStructure.set(*this, SymbolTable::createStructure(*this, 0, jsNull()));
Strong<Structure> evalExecutableStructure;
Strong<Structure> programExecutableStructure;
Strong<Structure> functionExecutableStructure;
-#if ENABLE(WEBASSEMBLY)
- Strong<Structure> webAssemblyExecutableStructure;
-#endif
Strong<Structure> regExpStructure;
Strong<Structure> symbolStructure;
Strong<Structure> symbolTableStructure;
Vector<WASMFunctionDeclaration>& functionDeclarations() { return m_functionDeclarations; }
Vector<WASMFunctionPointerTable>& functionPointerTables() { return m_functionPointerTables; }
- Vector<WriteBarrier<JSFunction>>& functions() { return m_functions; }
-
private:
JSWASMModule(VM& vm, Structure* structure)
: Base(vm, structure)
#if ENABLE(WEBASSEMBLY)
-#include "CCallHelpers.h"
#include "JSWASMModule.h"
-#include "LinkBuffer.h"
#include "WASMFunctionSyntaxChecker.h"
#define PROPAGATE_ERROR() do { if (!m_errorMessage.isNull()) return 0; } while (0)
return true;
}
-void WASMFunctionParser::compile(VM& vm, CodeBlock* codeBlock, JSWASMModule* module, const SourceCode&, size_t functionIndex)
-{
- // FIXME: Actually compile the code.
- CCallHelpers jit(&vm, codeBlock);
- MacroAssembler::Label beginLabel = jit.label();
- jit.move(MacroAssembler::TrustedImm64(JSValue::encode(jsNumber(0))), GPRInfo::returnValueGPR);
- jit.ret();
- MacroAssembler::Label arityCheck = jit.label();
- jit.jump(beginLabel);
-
- LinkBuffer patchBuffer(vm, jit, codeBlock, JITCompilationMustSucceed);
- MacroAssemblerCodePtr withArityCheck = patchBuffer.locationOf(arityCheck);
- MacroAssembler::CodeRef result = FINALIZE_CODE(patchBuffer, ("Baseline JIT code for WebAssembly"));
- codeBlock->setJITCode(adoptRef(new DirectJITCode(result, withArityCheck, JITCode::BaselineJIT)));
- codeBlock->capabilityLevel();
-
- uint32_t signatureIndex = module->functionDeclarations()[functionIndex].signatureIndex;
- const WASMSignature& signature = module->signatures()[signatureIndex];
- codeBlock->setNumParameters(1 + signature.arguments.size());
-}
-
template <class Context>
bool WASMFunctionParser::parseFunction(Context& context)
{
namespace JSC {
-class CodeBlock;
class JSWASMModule;
-class VM;
class WASMFunctionParser {
public:
static bool checkSyntax(JSWASMModule*, const SourceCode&, size_t functionIndex, unsigned startOffsetInSource, unsigned& endOffsetInSource, String& errorMessage);
- static void compile(VM&, CodeBlock*, JSWASMModule*, const SourceCode&, size_t functionIndex);
private:
WASMFunctionParser(JSWASMModule* module, const SourceCode& source, size_t functionIndex)
namespace JSC {
-WASMModuleParser::WASMModuleParser(VM& vm, JSGlobalObject* globalObject, const SourceCode& source)
- : m_vm(vm)
- , m_globalObject(vm, globalObject)
- , m_source(source)
+WASMModuleParser::WASMModuleParser(const SourceCode& source)
+ : m_source(source)
, m_reader(static_cast<WebAssemblySourceProvider*>(source.provider())->data())
{
}
-JSWASMModule* WASMModuleParser::parse(String& errorMessage)
+JSWASMModule* WASMModuleParser::parse(VM& vm, JSGlobalObject* globalObject, String& errorMessage)
{
- m_module.set(m_vm, JSWASMModule::create(m_vm, m_globalObject->wasmModuleStructure()));
+ m_module.set(vm, JSWASMModule::create(vm, globalObject->wasmModuleStructure()));
parseModule();
if (!m_errorMessage.isNull()) {
errorMessage = m_errorMessage;
uint32_t numberOfFunctionDeclarations;
READ_COMPACT_UINT32_OR_FAIL(numberOfFunctionDeclarations, "Cannot read the number of function declarations.");
m_module->functionDeclarations().reserveInitialCapacity(numberOfFunctionDeclarations);
- m_module->functions().reserveInitialCapacity(numberOfFunctionDeclarations);
for (uint32_t i = 0; i < numberOfFunctionDeclarations; ++i) {
WASMFunctionDeclaration functionDeclaration;
READ_COMPACT_UINT32_OR_FAIL(functionDeclaration.signatureIndex, "Cannot read the signature index.");
return;
}
m_reader.setOffset(endOffsetInSource);
-
- WebAssemblyExecutable* webAssemblyExecutable = WebAssemblyExecutable::create(m_vm, m_source, m_module.get(), functionIndex);
- JSFunction* function = JSFunction::create(m_vm, webAssemblyExecutable, m_globalObject.get());
- m_module->functions().uncheckedAppend(WriteBarrier<JSFunction>(m_vm, m_module.get(), function));
}
void WASMModuleParser::parseExportSection()
for (uint32_t exportIndex = 0; exportIndex < numberOfExports; ++exportIndex) {
String exportName;
READ_STRING_OR_FAIL(exportName, "Cannot read the function export name.");
+ // FIXME: Check that exportName is legal.
uint32_t functionIndex;
READ_COMPACT_UINT32_OR_FAIL(functionIndex, "Cannot read the function index.");
FAIL_IF_FALSE(functionIndex < m_module->functionDeclarations().size(), "The function index is incorrect.");
- Identifier identifier = Identifier::fromString(&m_vm, exportName);
- m_module->putDirect(m_vm, identifier, m_module->functions()[functionIndex].get());
+ // FIXME: Export the function.
}
break;
}
JSWASMModule* parseWebAssembly(ExecState* exec, const SourceCode& source, String& errorMessage)
{
- WASMModuleParser moduleParser(exec->vm(), exec->lexicalGlobalObject(), source);
- return moduleParser.parse(errorMessage);
+ WASMModuleParser WASMModuleParser(source);
+ return WASMModuleParser.parse(exec->vm(), exec->lexicalGlobalObject(), errorMessage);
}
} // namespace JSC
class WASMModuleParser {
public:
- WASMModuleParser(VM&, JSGlobalObject*, const SourceCode&);
- JSWASMModule* parse(String& errorMessage);
+ WASMModuleParser(const SourceCode&);
+ JSWASMModule* parse(VM&, JSGlobalObject*, String& errorMessage);
private:
void parseModule();
void parseFunctionDefinition(size_t functionIndex);
void parseExportSection();
- VM& m_vm;
- Strong<JSGlobalObject> m_globalObject;
const SourceCode& m_source;
WASMReader m_reader;
Strong<JSWASMModule> m_module;
+2015-08-27 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r189079.
+ https://bugs.webkit.org/show_bug.cgi?id=148555
+
+ broke the build (Requested by jessieberlin on #webkit).
+
+ Reverted changeset:
+
+ "Create WebAssembly functions"
+ https://bugs.webkit.org/show_bug.cgi?id=148373
+ http://trac.webkit.org/changeset/189079
+
2015-08-27 Sukolsak Sakshuwong <sukolsak@gmail.com>
Create WebAssembly functions
GetCallerCodeBlockFunctor iter;
exec->iterate(iter);
CodeBlock* codeBlock = iter.codeBlock();
- executable = codeBlock->ownerScriptExecutable();
+ executable = codeBlock->ownerExecutable();
} else if (code.isFunction()) {
JSFunction* funcObj = JSC::jsCast<JSFunction*>(code.toObject(exec));
executable = funcObj->jsExecutable();