diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-05-24 08:28:08 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-05-24 08:28:08 +0000 |
| commit | a4e969f4965059196ca948db781e52f7cfebf19e (patch) | |
| tree | 6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp | |
| parent | 41386e9cb918eed93b3f13648cbef387e371e451 (diff) | |
| download | WebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz | |
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp')
| -rw-r--r-- | Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp b/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp index f6587f47f..48d77c3e1 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 @@ -65,9 +88,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]; + auto rep = m_addedIdentifiers[i]; ASSERT(rep->hasAtLeastOneRef()); - commonData->dfgIdentifiers.append(Identifier(&vm, rep)); + commonData->dfgIdentifiers.append(Identifier::fromUid(&vm, rep)); } } |
