|
| 1 | +2016-12-11 Saam Barati <sbarati@apple.com> |
| 2 | + |
| 3 | + We should be able to throw exceptions from Wasm code and when Wasm frames are on the stack |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=165429 |
| 5 | + |
| 6 | + Reviewed by Keith Miller. |
| 7 | + |
| 8 | + This patch teaches the stack walking runtime about wasm. |
| 9 | + To do this, I taught StackVisitor that a callee is not |
| 10 | + always an object. |
| 11 | + |
| 12 | + To be able to unwind callee save registers properly, I've given |
| 13 | + JSWebAssemblyCallee a list of RegisterAtOffsetList for the callee |
| 14 | + saves that B3 saved in the prologue. Also, because we have two |
| 15 | + B3Compilations per wasm function, one for wasm entrypoint, and |
| 16 | + one for the JS entrypoint, I needed to create a callee for each |
| 17 | + because they each might spill callee save registers. |
| 18 | + |
| 19 | + I also fixed a bug inside the Wasm::Memory constructor where we |
| 20 | + were trying to mmap the same number of bytes even after the first |
| 21 | + mmap failed. We should start by trying to mmap the maximum bytes, |
| 22 | + and if that fails, fall back to the specified initial bytes. However, |
| 23 | + the code was just mmapping the maximum twice. I've fixed that and |
| 24 | + also added a RELEASE_ASSERT_NOT_REACHED() for when the second mmap |
| 25 | + fails along with a FIXME to throw an OOM error. |
| 26 | + |
| 27 | + There was a second bug I fixed where JSModuleRecord was calling |
| 28 | + visitWeak on its CallLinkInfos inside ::visitChldren(). It needs |
| 29 | + to do this after marking. I changed JSModuleRecord to do what |
| 30 | + CodeBlock does and call visitWeak on its CallLinkInfos inside |
| 31 | + an UnconditionalFinalizer. |
| 32 | + |
| 33 | + * API/JSContextRef.cpp: |
| 34 | + (BacktraceFunctor::operator()): |
| 35 | + * inspector/ScriptCallStackFactory.cpp: |
| 36 | + (Inspector::createScriptCallStackFromException): |
| 37 | + * interpreter/CallFrame.cpp: |
| 38 | + (JSC::CallFrame::vmEntryGlobalObject): |
| 39 | + * interpreter/CallFrame.h: |
| 40 | + (JSC::ExecState::callee): |
| 41 | + * interpreter/Interpreter.cpp: |
| 42 | + (JSC::GetStackTraceFunctor::operator()): |
| 43 | + (JSC::UnwindFunctor::operator()): |
| 44 | + (JSC::UnwindFunctor::copyCalleeSavesToVMEntryFrameCalleeSavesBuffer): |
| 45 | + * interpreter/Interpreter.h: |
| 46 | + * interpreter/ShadowChicken.cpp: |
| 47 | + (JSC::ShadowChicken::update): |
| 48 | + * interpreter/StackVisitor.cpp: |
| 49 | + (JSC::StackVisitor::StackVisitor): |
| 50 | + (JSC::StackVisitor::readFrame): |
| 51 | + (JSC::StackVisitor::readNonInlinedFrame): |
| 52 | + (JSC::StackVisitor::readInlinedFrame): |
| 53 | + (JSC::StackVisitor::Frame::isWasmFrame): |
| 54 | + (JSC::StackVisitor::Frame::codeType): |
| 55 | + (JSC::StackVisitor::Frame::calleeSaveRegisters): |
| 56 | + (JSC::StackVisitor::Frame::functionName): |
| 57 | + (JSC::StackVisitor::Frame::sourceURL): |
| 58 | + (JSC::StackVisitor::Frame::toString): |
| 59 | + (JSC::StackVisitor::Frame::hasLineAndColumnInfo): |
| 60 | + (JSC::StackVisitor::Frame::setToEnd): |
| 61 | + * interpreter/StackVisitor.h: |
| 62 | + (JSC::StackVisitor::Frame::callee): |
| 63 | + (JSC::StackVisitor::Frame::isNativeFrame): |
| 64 | + (JSC::StackVisitor::Frame::isJSFrame): Deleted. |
| 65 | + * jsc.cpp: |
| 66 | + (callWasmFunction): |
| 67 | + (functionTestWasmModuleFunctions): |
| 68 | + * runtime/Error.cpp: |
| 69 | + (JSC::addErrorInfoAndGetBytecodeOffset): |
| 70 | + * runtime/JSCell.cpp: |
| 71 | + (JSC::JSCell::isAnyWasmCallee): |
| 72 | + * runtime/JSCell.h: |
| 73 | + * runtime/JSFunction.cpp: |
| 74 | + (JSC::RetrieveArgumentsFunctor::operator()): |
| 75 | + (JSC::RetrieveCallerFunctionFunctor::operator()): |
| 76 | + * runtime/StackFrame.cpp: |
| 77 | + (JSC::StackFrame::sourceID): |
| 78 | + (JSC::StackFrame::sourceURL): |
| 79 | + (JSC::StackFrame::functionName): |
| 80 | + (JSC::StackFrame::computeLineAndColumn): |
| 81 | + (JSC::StackFrame::toString): |
| 82 | + * runtime/StackFrame.h: |
| 83 | + (JSC::StackFrame::StackFrame): |
| 84 | + (JSC::StackFrame::hasLineAndColumnInfo): |
| 85 | + (JSC::StackFrame::hasBytecodeOffset): |
| 86 | + (JSC::StackFrame::bytecodeOffset): |
| 87 | + (JSC::StackFrame::isNative): Deleted. |
| 88 | + * runtime/VM.h: |
| 89 | + * wasm/WasmB3IRGenerator.cpp: |
| 90 | + (JSC::Wasm::B3IRGenerator::B3IRGenerator): |
| 91 | + (JSC::Wasm::createJSToWasmWrapper): |
| 92 | + (JSC::Wasm::parseAndCompile): |
| 93 | + * wasm/WasmCallingConvention.h: |
| 94 | + (JSC::Wasm::CallingConvention::setupFrameInPrologue): |
| 95 | + * wasm/WasmFormat.h: |
| 96 | + * wasm/WasmMemory.cpp: |
| 97 | + (JSC::Wasm::Memory::Memory): |
| 98 | + * wasm/WasmMemory.h: |
| 99 | + (JSC::Wasm::Memory::isValid): |
| 100 | + * wasm/WasmPlan.cpp: |
| 101 | + (JSC::Wasm::Plan::run): |
| 102 | + (JSC::Wasm::Plan::initializeCallees): |
| 103 | + * wasm/WasmPlan.h: |
| 104 | + (JSC::Wasm::Plan::jsToWasmEntryPointForFunction): Deleted. |
| 105 | + * wasm/js/JSWebAssemblyCallee.cpp: |
| 106 | + (JSC::JSWebAssemblyCallee::finishCreation): |
| 107 | + * wasm/js/JSWebAssemblyCallee.h: |
| 108 | + (JSC::JSWebAssemblyCallee::create): |
| 109 | + (JSC::JSWebAssemblyCallee::entrypoint): |
| 110 | + (JSC::JSWebAssemblyCallee::calleeSaveRegisters): |
| 111 | + (JSC::JSWebAssemblyCallee::jsToWasmEntryPoint): Deleted. |
| 112 | + * wasm/js/JSWebAssemblyModule.cpp: |
| 113 | + (JSC::JSWebAssemblyModule::JSWebAssemblyModule): |
| 114 | + (JSC::JSWebAssemblyModule::visitChildren): |
| 115 | + (JSC::JSWebAssemblyModule::UnconditionalFinalizer::finalizeUnconditionally): |
| 116 | + * wasm/js/JSWebAssemblyModule.h: |
| 117 | + (JSC::JSWebAssemblyModule::jsEntrypointCalleeFromFunctionIndexSpace): |
| 118 | + (JSC::JSWebAssemblyModule::wasmEntrypointCalleeFromFunctionIndexSpace): |
| 119 | + (JSC::JSWebAssemblyModule::setJSEntrypointCallee): |
| 120 | + (JSC::JSWebAssemblyModule::setWasmEntrypointCallee): |
| 121 | + (JSC::JSWebAssemblyModule::allocationSize): |
| 122 | + (JSC::JSWebAssemblyModule::calleeFromFunctionIndexSpace): Deleted. |
| 123 | + * wasm/js/JSWebAssemblyRuntimeError.h: |
| 124 | + * wasm/js/WebAssemblyFunction.cpp: |
| 125 | + (JSC::WebAssemblyFunction::call): |
| 126 | + * wasm/js/WebAssemblyInstanceConstructor.cpp: |
| 127 | + (JSC::constructJSWebAssemblyInstance): |
| 128 | + * wasm/js/WebAssemblyMemoryConstructor.cpp: |
| 129 | + (JSC::constructJSWebAssemblyMemory): |
| 130 | + * wasm/js/WebAssemblyModuleConstructor.cpp: |
| 131 | + (JSC::constructJSWebAssemblyModule): |
| 132 | + * wasm/js/WebAssemblyModuleRecord.cpp: |
| 133 | + (JSC::WebAssemblyModuleRecord::link): |
| 134 | + |
1 | 135 | 2016-12-11 Filip Pizlo <fpizlo@apple.com> |
2 | 136 |
|
3 | 137 | Re-enable concurrent GC. |
|
0 commit comments