Ignore:
Timestamp:
Dec 4, 2016, 1:23:56 PM (8 years ago)
Author:
[email protected]
Message:

We should have a Wasm callee
https://bugs.webkit.org/show_bug.cgi?id=165163

Reviewed by Keith Miller.

This patch adds JSWebAssemblyCallee and stores it into the
callee slot in the call frame as part of the prologue of a
wasm function. This is the first step in implementing
unwinding from/through wasm frames. We will use the callee
to identify that a machine frame belongs to wasm code.

(callWasmFunction):
(functionTestWasmModuleFunctions):

  • llint/LowLevelInterpreter64.asm:
  • runtime/JSGlobalObject.cpp:
  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:
  • wasm/JSWebAssembly.h:
  • wasm/WasmB3IRGenerator.cpp:

(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::parseAndCompile):

  • wasm/WasmCallingConvention.h:

(JSC::Wasm::CallingConvention::setupFrameInPrologue):

  • wasm/WasmFormat.h:
  • wasm/WasmPlan.cpp:

(JSC::Wasm::Plan::initializeCallees):

  • wasm/WasmPlan.h:

(JSC::Wasm::Plan::compiledFunction):
(JSC::Wasm::Plan::getCompiledFunctions): Deleted.

  • wasm/js/JSWebAssemblyCallee.cpp: Added.

(JSC::JSWebAssemblyCallee::JSWebAssemblyCallee):
(JSC::JSWebAssemblyCallee::finishCreation):
(JSC::JSWebAssemblyCallee::destroy):

  • wasm/js/JSWebAssemblyCallee.h: Added.

(JSC::JSWebAssemblyCallee::create):
(JSC::JSWebAssemblyCallee::createStructure):
(JSC::JSWebAssemblyCallee::jsEntryPoint):

  • wasm/js/JSWebAssemblyModule.cpp:

(JSC::JSWebAssemblyModule::create):
(JSC::JSWebAssemblyModule::JSWebAssemblyModule):
(JSC::JSWebAssemblyModule::visitChildren):

  • wasm/js/JSWebAssemblyModule.h:

(JSC::JSWebAssemblyModule::moduleInformation):
(JSC::JSWebAssemblyModule::callee):
(JSC::JSWebAssemblyModule::callees):
(JSC::JSWebAssemblyModule::offsetOfCallees):
(JSC::JSWebAssemblyModule::allocationSize):
(JSC::JSWebAssemblyModule::compiledFunctions): Deleted.

  • wasm/js/WebAssemblyFunction.cpp:

(JSC::callWebAssemblyFunction):
(JSC::WebAssemblyFunction::create):
(JSC::WebAssemblyFunction::visitChildren):
(JSC::WebAssemblyFunction::finishCreation):

  • wasm/js/WebAssemblyFunction.h:

(JSC::WebAssemblyFunction::webAssemblyCallee):
(JSC::WebAssemblyFunction::instance):
(JSC::WebAssemblyFunction::signature):
(JSC::CallableWebAssemblyFunction::CallableWebAssemblyFunction): Deleted.
(JSC::WebAssemblyFunction::webAssemblyFunctionCell): Deleted.

  • wasm/js/WebAssemblyFunctionCell.cpp:

(JSC::WebAssemblyFunctionCell::create): Deleted.
(JSC::WebAssemblyFunctionCell::WebAssemblyFunctionCell): Deleted.
(JSC::WebAssemblyFunctionCell::destroy): Deleted.
(JSC::WebAssemblyFunctionCell::createStructure): Deleted.

  • wasm/js/WebAssemblyFunctionCell.h:

(JSC::WebAssemblyFunctionCell::function): Deleted.

  • wasm/js/WebAssemblyModuleConstructor.cpp:

(JSC::constructJSWebAssemblyModule):

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::link):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r209296 r209312  
    5454#include "JSString.h"
    5555#include "JSTypedArrays.h"
     56#include "JSWebAssemblyCallee.h"
    5657#include "LLIntData.h"
    5758#include "LLIntThunks.h"
     
    25672568}
    25682569
    2569 static JSValue callWasmFunction(VM* vm, const B3::Compilation& code, Vector<JSValue>& boxedArgs)
     2570static JSValue callWasmFunction(VM* vm, JSGlobalObject* globalObject, JSWebAssemblyCallee* wasmCallee, Vector<JSValue>& boxedArgs)
    25702571{
    25712572    JSValue firstArgument;
     
    25802581
    25812582    ProtoCallFrame protoCallFrame;
    2582     protoCallFrame.init(nullptr, nullptr, firstArgument, argCount, remainingArgs);
    2583 
    2584     return JSValue::decode(vmEntryToWasm(code.code().executableAddress(), vm, &protoCallFrame));
     2583    protoCallFrame.init(nullptr, globalObject->globalExec()->jsCallee(), firstArgument, argCount, remainingArgs);
     2584
     2585    return JSValue::decode(vmEntryToWasm(wasmCallee->jsEntryPoint(), vm, &protoCallFrame));
    25852586}
    25862587
     
    26112612        CRASH();
    26122613
     2614    MarkedArgumentBuffer callees;
     2615    {
     2616        unsigned lastIndex = UINT_MAX;
     2617        plan.initializeCallees(exec->lexicalGlobalObject(),
     2618            [&] (unsigned calleeIndex, JSWebAssemblyCallee* callee) {
     2619                RELEASE_ASSERT(!calleeIndex || (calleeIndex - 1 == lastIndex));
     2620                callees.append(callee);
     2621                lastIndex = calleeIndex;
     2622            });
     2623    }
     2624
    26132625    for (uint32_t i = 0; i < functionCount; ++i) {
    2614         if (!plan.compiledFunction(i))
    2615             dataLogLn("failed to compile function at index", i);
    2616 
    26172626        JSArray* testCases = jsCast<JSArray*>(exec->argument(i + 2));
    26182627        for (unsigned testIndex = 0; testIndex < testCases->length(); ++testIndex) {
     
    26252634                boxedArgs.append(box(exec, vm, arguments->getIndexQuickly(argIndex)));
    26262635
    2627             JSValue callResult = callWasmFunction(&vm, *plan.compiledFunction(i)->jsEntryPoint, boxedArgs);
     2636            JSValue callResult = callWasmFunction(&vm, exec->lexicalGlobalObject(), jsCast<JSWebAssemblyCallee*>(callees.at(i)), boxedArgs);
    26282637            JSValue expected = box(exec, vm, result);
    26292638            if (callResult != expected) {
Note: See TracChangeset for help on using the changeset viewer.