diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/ftl/FTLJITCode.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/ftl/FTLJITCode.cpp')
-rw-r--r-- | Source/JavaScriptCore/ftl/FTLJITCode.cpp | 96 |
1 files changed, 69 insertions, 27 deletions
diff --git a/Source/JavaScriptCore/ftl/FTLJITCode.cpp b/Source/JavaScriptCore/ftl/FTLJITCode.cpp index cdc7de0c3..1cdb50957 100644 --- a/Source/JavaScriptCore/ftl/FTLJITCode.cpp +++ b/Source/JavaScriptCore/ftl/FTLJITCode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,8 +28,12 @@ #if ENABLE(FTL_JIT) +#include "FTLState.h" + namespace JSC { namespace FTL { +using namespace B3; + JITCode::JITCode() : JSC::JITCode(FTLJIT) { @@ -37,44 +41,54 @@ JITCode::JITCode() JITCode::~JITCode() { + if (FTL::shouldDumpDisassembly()) { + dataLog("Destroying FTL JIT code at "); + CommaPrinter comma; + dataLog(comma, m_b3Code); + dataLog(comma, m_arityCheckEntrypoint); + dataLog("\n"); + } } -void JITCode::initializeExitThunks(CodeRef exitThunks) +void JITCode::initializeB3Code(CodeRef b3Code) { - m_exitThunks = exitThunks; + m_b3Code = b3Code; } -void JITCode::addHandle(PassRefPtr<ExecutableMemoryHandle> handle) +void JITCode::initializeB3Byproducts(std::unique_ptr<OpaqueByproducts> byproducts) { - m_handles.append(handle); + m_b3Byproducts = WTFMove(byproducts); } -void JITCode::addDataSection(RefCountedArray<LSectionWord> dataSection) +void JITCode::initializeAddressForCall(CodePtr address) { - m_dataSections.append(dataSection); + m_addressForCall = address; } -void JITCode::initializeCode(CodeRef entrypoint) +void JITCode::initializeArityCheckEntrypoint(CodeRef entrypoint) { - m_entrypoint = entrypoint; + m_arityCheckEntrypoint = entrypoint; } -JITCode::CodePtr JITCode::addressForCall() +JITCode::CodePtr JITCode::addressForCall(ArityCheckMode arityCheck) { - RELEASE_ASSERT(m_entrypoint); - return m_entrypoint.code(); + switch (arityCheck) { + case ArityCheckNotRequired: + return m_addressForCall; + case MustCheckArity: + return m_arityCheckEntrypoint.code(); + } + RELEASE_ASSERT_NOT_REACHED(); + return CodePtr(); } void* JITCode::executableAddressAtOffset(size_t offset) { - RELEASE_ASSERT(m_entrypoint); - return reinterpret_cast<char*>(m_entrypoint.code().executableAddress()) + offset; + return reinterpret_cast<char*>(m_addressForCall.executableAddress()) + offset; } void* JITCode::dataAddressAtOffset(size_t) { - RELEASE_ASSERT(m_entrypoint); - // We can't patch FTL code, yet. Even if we did, it's not clear that we would do so // through this API. RELEASE_ASSERT_NOT_REACHED(); @@ -83,8 +97,6 @@ void* JITCode::dataAddressAtOffset(size_t) unsigned JITCode::offsetOf(void*) { - RELEASE_ASSERT(m_entrypoint); - // We currently don't have visibility into the FTL code. RELEASE_ASSERT_NOT_REACHED(); return 0; @@ -92,8 +104,6 @@ unsigned JITCode::offsetOf(void*) size_t JITCode::size() { - RELEASE_ASSERT(m_entrypoint); - // We don't know the size of FTL code, yet. Make a wild guess. This is mostly used for // GC load estimates. return 1000; @@ -101,18 +111,11 @@ size_t JITCode::size() bool JITCode::contains(void*) { - RELEASE_ASSERT(m_entrypoint); - // We have no idea what addresses the FTL code contains, yet. RELEASE_ASSERT_NOT_REACHED(); return false; } -JITCode::CodePtr JITCode::exitThunks() -{ - return m_exitThunks.code(); -} - JITCode* JITCode::ftl() { return this; @@ -123,6 +126,45 @@ DFG::CommonData* JITCode::dfgCommon() return &common; } +void JITCode::validateReferences(const TrackedReferences& trackedReferences) +{ + common.validateReferences(trackedReferences); + + for (OSRExit& exit : osrExit) + exit.m_descriptor->validateReferences(trackedReferences); +} + +RegisterSet JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock*, CallSiteIndex callSiteIndex) +{ + for (OSRExit& exit : osrExit) { + if (exit.m_exceptionHandlerCallSiteIndex.bits() == callSiteIndex.bits()) { + RELEASE_ASSERT(exit.isExceptionHandler()); + RELEASE_ASSERT(exit.isGenericUnwindHandler()); + return ValueRep::usedRegisters(exit.m_valueReps); + } + } + return RegisterSet(); +} + +std::optional<CodeOrigin> JITCode::findPC(CodeBlock* codeBlock, void* pc) +{ + for (OSRExit& exit : osrExit) { + if (ExecutableMemoryHandle* handle = exit.m_code.executableMemory()) { + if (handle->start() <= pc && pc < handle->end()) + return std::optional<CodeOrigin>(exit.m_codeOriginForExitProfile); + } + } + + for (std::unique_ptr<LazySlowPath>& lazySlowPath : lazySlowPaths) { + if (ExecutableMemoryHandle* handle = lazySlowPath->stub().executableMemory()) { + if (handle->start() <= pc && pc < handle->end()) + return std::optional<CodeOrigin>(codeBlock->codeOrigin(lazySlowPath->callSiteIndex())); + } + } + + return std::nullopt; +} + } } // namespace JSC::FTL #endif // ENABLE(FTL_JIT) |