WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
work in progress
blah.patch (text/plain), 11.52 KB, created by
Filip Pizlo
on 2015-11-17 17:57:26 PST
(
hide
)
Description:
work in progress
Filename:
MIME Type:
Creator:
Filip Pizlo
Created:
2015-11-17 17:57:26 PST
Size:
11.52 KB
patch
obsolete
>Index: Source/JavaScriptCore/b3/B3Procedure.cpp >=================================================================== >--- Source/JavaScriptCore/b3/B3Procedure.cpp (revision 192559) >+++ Source/JavaScriptCore/b3/B3Procedure.cpp (working copy) >@@ -148,6 +148,11 @@ void* Procedure::addDataSection(size_t s > return result; > } > >+RegisterAtOffsetList& Procedure::calleeSaveRegisters() >+{ >+ return code().calleeSaveRegisters(); >+} >+ > size_t Procedure::addValueIndex() > { > if (m_valueIndexFreeList.isEmpty()) { >Index: Source/JavaScriptCore/b3/B3Procedure.h >=================================================================== >--- Source/JavaScriptCore/b3/B3Procedure.h (revision 192559) >+++ Source/JavaScriptCore/b3/B3Procedure.h (working copy) >@@ -31,6 +31,7 @@ > #include "B3Origin.h" > #include "B3Type.h" > #include "PureNaN.h" >+#include "RegisterAtOffsetList.h" > #include <wtf/Bag.h> > #include <wtf/FastMalloc.h> > #include <wtf/Noncopyable.h> >@@ -222,6 +223,8 @@ public: > > Air::Code& code() { return *m_code; } > >+ RegisterAtOffsetList& calleeSaveRegisters(); >+ > private: > friend class BlockInsertionSet; > >Index: Source/JavaScriptCore/ftl/FTLB3Compile.cpp >=================================================================== >--- Source/JavaScriptCore/ftl/FTLB3Compile.cpp (revision 0) >+++ Source/JavaScriptCore/ftl/FTLB3Compile.cpp (working copy) >@@ -0,0 +1,96 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "FTLCompile.h" >+ >+#if ENABLE(FTL_JIT) && FTL_USES_B3 >+ >+#include "B3Generate.h" >+#include "B3ProcedureInlines.h" >+#include "CodeBlockWithJITType.h" >+#include "CCallHelpers.h" >+#include "DFGCommon.h" >+#include "DFGGraphSafepoint.h" >+#include "DFGOperations.h" >+#include "DataView.h" >+#include "Disassembler.h" >+#include "FTLExceptionHandlerManager.h" >+#include "FTLExitThunkGenerator.h" >+#include "FTLInlineCacheSize.h" >+#include "FTLJITCode.h" >+#include "FTLThunks.h" >+#include "FTLUnwindInfo.h" >+#include "JITSubGenerator.h" >+#include "LinkBuffer.h" >+#include "ScratchRegisterAllocator.h" >+ >+namespace JSC { namespace FTL { >+ >+using namespace DFG; >+ >+void compile(State& state, Safepoint::Result& safepointResult) >+{ >+ Graph& graph = state.graph; >+ CodeBlock* codeBlock = graph.m_codeBlock; >+ VM& vm = graph.m_vm; >+ >+ { >+ GraphSafepoint safepoint(state.graph, safepointResult); >+ >+ B3::prepareForGeneration(*state.proc); >+ } >+ >+ if (safepointResult.didGetCancelled()) >+ return; >+ RELEASE_ASSERT(!state.graph.m_vm.heap.isCollecting()); >+ >+ if (state.allocationFailed) >+ return; >+ >+ std::unique_ptr<RegisterAtOffsetList> registerOffsets = state.proc->calleeSaveRegisters(); >+ if (shouldDumpDisassembly()) { >+ dataLog("Unwind info for ", CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT), ":\n"); >+ dataLog(" ", *registerOffsets, "\n"); >+ } >+ state.graph.m_codeBlock->setCalleeSaveRegisters(WTF::move(registerOffsets)); >+ >+ CCallHelpers jit(&vm, codeBlock); >+ B3::generate(*state.proc, jit); >+ >+ state.finalizer->b3CodeLinkBuffer = std::make_unique<LinkBuffer>( >+ vm, jit, codeBlock, JITCompilationCanFail); >+ if (state.finalizer->b3CodeLinkBuffer->didFailToAllocate()) { >+ state.allocationFailed = true; >+ return; >+ } >+ >+ state.generatedFunction = state.finalizer->b3CodeLinkBuffer->entrypoint().executableAddress(); >+} >+ >+} } // namespace JSC::FTL >+ >+#endif // ENABLE(FTL_JIT) && FTL_USES_B3 >+ >Index: Source/JavaScriptCore/ftl/FTLJITCode.cpp >=================================================================== >--- Source/JavaScriptCore/ftl/FTLJITCode.cpp (revision 192559) >+++ Source/JavaScriptCore/ftl/FTLJITCode.cpp (working copy) >@@ -42,14 +42,25 @@ JITCode::~JITCode() > if (FTL::shouldDumpDisassembly()) { > dataLog("Destroying FTL JIT code at "); > CommaPrinter comma; >+#if FTL_USES_B3 >+ dataLog(comma, m_b3Code); >+ dataLog(comma, m_arityCheckEntrypoint); >+#else > for (auto& handle : m_handles) > dataLog(comma, pointerDump(handle.get())); > dataLog(comma, pointerDump(m_arityCheckEntrypoint.executableMemory())); > dataLog(comma, pointerDump(m_exitThunks.executableMemory())); > dataLog("\n"); >+#endif > } > } > >+#if FTL_USES_B3 >+void JITCode::initializeB3Code(CodeRef b3Code) >+{ >+ m_b3Code = b3Code; >+} >+#else // FTL_USES_B3 > void JITCode::initializeExitThunks(CodeRef exitThunks) > { > m_exitThunks = exitThunks; >@@ -65,21 +76,26 @@ void JITCode::addDataSection(PassRefPtr< > m_dataSections.append(dataSection); > } > >-void JITCode::initializeArityCheckEntrypoint(CodeRef entrypoint) >+void JITCode::initializeAddressForCall(CodePtr address) > { >- m_arityCheckEntrypoint = entrypoint; >+ m_addressForCall = address; > } >+#endif // FTL_USES_B3 > >-void JITCode::initializeAddressForCall(CodePtr address) >+void JITCode::initializeArityCheckEntrypoint(CodeRef entrypoint) > { >- m_addressForCall = address; >+ m_arityCheckEntrypoint = entrypoint; > } > > JITCode::CodePtr JITCode::addressForCall(ArityCheckMode arityCheck) > { > switch (arityCheck) { > case ArityCheckNotRequired: >+#if FTL_USES_B3 >+ return m_b3Code.code(); >+#else > return m_addressForCall; >+#endif > case MustCheckArity: > return m_arityCheckEntrypoint.code(); > } >@@ -89,7 +105,7 @@ JITCode::CodePtr JITCode::addressForCall > > void* JITCode::executableAddressAtOffset(size_t offset) > { >- return reinterpret_cast<char*>(m_addressForCall.executableAddress()) + offset; >+ return reinterpret_cast<char*>(addressForCall(ArityCheckNotRequired)) + offset; > } > > void* JITCode::dataAddressAtOffset(size_t) >@@ -121,10 +137,12 @@ bool JITCode::contains(void*) > return false; > } > >+#if !FTL_USES_B3 > JITCode::CodePtr JITCode::exitThunks() > { > return m_exitThunks.code(); > } >+#endif > > JITCode* JITCode::ftl() > { >Index: Source/JavaScriptCore/ftl/FTLJITCode.h >=================================================================== >--- Source/JavaScriptCore/ftl/FTLJITCode.h (revision 192559) >+++ Source/JavaScriptCore/ftl/FTLJITCode.h (working copy) >@@ -58,28 +58,36 @@ class JITCode : public JSC::JITCode { > public: > JITCode(); > ~JITCode(); >- >+ > CodePtr addressForCall(ArityCheckMode) override; > void* executableAddressAtOffset(size_t offset) override; > void* dataAddressAtOffset(size_t offset) override; > unsigned offsetOf(void* pointerIntoCode) override; > size_t size() override; > bool contains(void*) override; >- >+ >+#if FTL_USES_B3 >+ void initializeB3Code(CodeRef); >+#else > void initializeExitThunks(CodeRef); > void addHandle(PassRefPtr<ExecutableMemoryHandle>); > void addDataSection(PassRefPtr<DataSection>); >- void initializeArityCheckEntrypoint(CodeRef); > void initializeAddressForCall(CodePtr); >+#endif >+ void initializeArityCheckEntrypoint(CodeRef); > > void validateReferences(const TrackedReferences&) override; > > RegisterSet liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock*, CallSiteIndex) override; >- >+ >+#if FTL_USES_B3 >+ CodeRef b3Code() const { return m_b3Code; } >+#else > const Vector<RefPtr<ExecutableMemoryHandle>>& handles() const { return m_handles; } > const Vector<RefPtr<DataSection>>& dataSections() const { return m_dataSections; } > > CodePtr exitThunks(); >+#endif > > JITCode* ftl() override; > DFG::CommonData* dfgCommon() override; >@@ -91,11 +99,17 @@ public: > Vector<std::unique_ptr<LazySlowPath>> lazySlowPaths; > > private: >+#if FTL_USES_B3 >+ CodeRef m_b3Code; >+#else > Vector<RefPtr<DataSection>> m_dataSections; > Vector<RefPtr<ExecutableMemoryHandle>> m_handles; > CodePtr m_addressForCall; >+#endif > CodeRef m_arityCheckEntrypoint; >+#if !FTL_USES_B3 > CodeRef m_exitThunks; >+#endif > }; > > } } // namespace JSC::FTL >Index: Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp >=================================================================== >--- Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp (revision 192559) >+++ Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp (working copy) >@@ -73,11 +73,25 @@ bool JITFinalizer::finalize() > > bool JITFinalizer::finalizeFunction() > { >+#if FTL_USES_B3 >+ for (OSRExitCompilationInfo& info : osrExit) { >+ b3CodeLinkBuffer->link( >+ info.m_thunkJump, >+ CodeLocationLabel( >+ m_plan.vm.getCTIStub(osrExitGenerationThunkGenerator).code())); >+ } >+ >+ jitCode->initializeB3Code( >+ FINALIZE_DFG_CODE( >+ *b3CodeLinkBuffer, >+ ("FTL B3 code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data()))); >+ >+#else // FTL_USES_B3 > for (unsigned i = jitCode->handles().size(); i--;) { > MacroAssembler::cacheFlush( > jitCode->handles()[i]->start(), jitCode->handles()[i]->sizeInBytes()); > } >- >+ > if (exitThunksLinkBuffer) { > for (unsigned i = 0; i < osrExit.size(); ++i) { > OSRExitCompilationInfo& info = osrExit[i]; >@@ -124,6 +138,7 @@ bool JITFinalizer::finalizeFunction() > *outOfLineCodeInfos[i].m_linkBuffer, > ("FTL out of line code for %s", outOfLineCodeInfos[i].m_codeDescription)).executableMemory()); > } >+#endif // FTL_USES_B3 > > jitCode->initializeArityCheckEntrypoint( > FINALIZE_DFG_CODE( >Index: Source/JavaScriptCore/ftl/FTLJITFinalizer.h >=================================================================== >--- Source/JavaScriptCore/ftl/FTLJITFinalizer.h (revision 192559) >+++ Source/JavaScriptCore/ftl/FTLJITFinalizer.h (working copy) >@@ -60,11 +60,21 @@ public: > bool finalize() override; > bool finalizeFunction() override; > >- std::unique_ptr<LinkBuffer> exitThunksLinkBuffer; >+#if FTL_USES_B3 >+ std::unique_ptr<LinkBuffer> b3CodeLinkBuffer; >+#endif >+ >+ // Eventually, we can get rid of this with B3. > std::unique_ptr<LinkBuffer> entrypointLinkBuffer; >+ >+#if !FTL_USES_B3 >+ // In B3, we can do all of this directly in the B3 code. That includes slow paths and exception handlers. >+ std::unique_ptr<LinkBuffer> exitThunksLinkBuffer; > std::unique_ptr<LinkBuffer> sideCodeLinkBuffer; > std::unique_ptr<LinkBuffer> handleExceptionsLinkBuffer; > Vector<OutOfLineCodeInfo> outOfLineCodeInfos; >+#endif >+ > Vector<OSRExitCompilationInfo> osrExit; > Vector<CCallHelpers::Jump> lazySlowPathGeneratorJumps; > GeneratedFunction function;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 151370
:
265724
|
265784