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/dfg/DFGDesiredIdentifiers.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp b/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp index f6587f47f..b4cec6b4e 100644 --- a/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp +++ b/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-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 @@ -29,11 +29,20 @@ #if ENABLE(DFG_JIT) #include "CodeBlock.h" +#include "DFGCommonData.h" +#include "JSCInlines.h" namespace JSC { namespace DFG { +DesiredIdentifiers::DesiredIdentifiers() + : m_codeBlock(nullptr) + , m_didProcessIdentifiers(false) +{ +} + DesiredIdentifiers::DesiredIdentifiers(CodeBlock* codeBlock) : m_codeBlock(codeBlock) + , m_didProcessIdentifiers(false) { } @@ -46,14 +55,28 @@ unsigned DesiredIdentifiers::numberOfIdentifiers() return m_codeBlock->numberOfIdentifiers() + m_addedIdentifiers.size(); } -void DesiredIdentifiers::addLazily(StringImpl* rep) +unsigned DesiredIdentifiers::ensure(UniquedStringImpl* rep) { - m_addedIdentifiers.append(rep); + if (!m_didProcessIdentifiers) { + // Do this now instead of the constructor so that we don't pay the price on the main + // thread. Also, not all compilations need to call ensure(). + for (unsigned index = m_codeBlock->numberOfIdentifiers(); index--;) + m_identifierNumberForName.add(m_codeBlock->identifier(index).impl(), index); + m_didProcessIdentifiers = true; + } + + auto addResult = m_identifierNumberForName.add(rep, numberOfIdentifiers()); + unsigned result = addResult.iterator->value; + if (addResult.isNewEntry) { + m_addedIdentifiers.append(rep); + ASSERT(at(result) == rep); + } + return result; } -StringImpl* DesiredIdentifiers::at(unsigned index) const +UniquedStringImpl* DesiredIdentifiers::at(unsigned index) const { - StringImpl* result; + UniquedStringImpl* result; if (index < m_codeBlock->numberOfIdentifiers()) result = m_codeBlock->identifier(index).impl(); else @@ -64,10 +87,9 @@ StringImpl* DesiredIdentifiers::at(unsigned index) const void DesiredIdentifiers::reallyAdd(VM& vm, CommonData* commonData) { - for (unsigned i = 0; i < m_addedIdentifiers.size(); ++i) { - StringImpl* rep = m_addedIdentifiers[i]; + for (auto rep : m_addedIdentifiers) { ASSERT(rep->hasAtLeastOneRef()); - commonData->dfgIdentifiers.append(Identifier(&vm, rep)); + commonData->dfgIdentifiers.append(Identifier::fromUid(&vm, rep)); } } |