Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/bytecode/EvalCodeCache.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef EvalCodeCache_h
30 #define EvalCodeCache_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/bytecode/EvalCodeCache.h:30:9`!
31
32 #include "Executable.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Executable.h`/
33 #include "JSGlobalObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h`/
34 #include "Nodes.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h`/
35 #include "Parser.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/parser/Parser.h`/
36 #include "SourceCode.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/parser/SourceCode.h`/
37 #include "UString.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UString.h`/
38 #include <wtf/HashMap.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashMap.h`/
39 #include <wtf/RefPtr.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RefPtr.h`/
40
41 namespace JSCcxx . . $ `<built-in>:463:9`! {
42
43 class EvalCodeCachecxx . . $ QTJSC/EvalCodeCache# {
44 public:
45 PassRefPtrcxx . . $ PassRefPtr#<EvalExecutablecxx . . $ QTJSC/EvalExecutable#> getcxx . . $ QTJSC/EvalCodeCache#get(23018e8ca9988d0f).(ExecStatecxx . . $ QTJSC/ExecState#* exec, const UStringcxx . . $ QTJSC/UString#& evalSource, ScopeChainNodecxx . . $ QTJSC/ScopeChainNode#* scopeChain, JSValuecxx . . $ QTJSC/JSValue#& exceptionValue)
46 {
47 RefPtrcxx . . $ RefPtr#<EvalExecutablecxx . . $ QTJSC/EvalExecutable#> evalExecutable;
48
49 if (evalSource.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).() < maxCacheableSourceLengthcxx . . $ QTJSC/EvalCodeCache#maxCacheableSourceLength. && (*cxx . . $ QTJSC/ScopeChainIterator#`operator*`(99d346b5a13496d5).scopeChain->begincxx . . $ QTJSC/ScopeChainNode#begin(96529fad815ce745).())->isVariableObjectcxx . . $ QTJSC/JSObject#isVariableObject(50ce9a9e25b4a850).())
50 evalExecutable = m_cacheMapcxx . . $ QTJSC/EvalCodeCache#m_cacheMap..get(evalSource.repcxx . . $ QTJSC/UString#rep(eff8ac5d0836371c).());
51
52 if (!evalExecutable) {
53 evalExecutable = EvalExecutable::create(exec, makeSourcecxx . . $ QTJSC/makeSource(2886e7d8f5479a73).(evalSource));
54 exceptionValue = evalExecutable->compile(exec, scopeChain);
55 if (exceptionValue)
56 return 0;
57
58 if (evalSource.sizecxx . . $ QTJSC/UString#size(455f465bc33b4cdf).() < maxCacheableSourceLengthcxx . . $ QTJSC/EvalCodeCache#maxCacheableSourceLength. && (*cxx . . $ QTJSC/ScopeChainIterator#`operator*`(99d346b5a13496d5).scopeChain->begincxx . . $ QTJSC/ScopeChainNode#begin(96529fad815ce745).())->isVariableObjectcxx . . $ QTJSC/JSObject#isVariableObject(50ce9a9e25b4a850).() && m_cacheMapcxx . . $ QTJSC/EvalCodeCache#m_cacheMap..size() <cxx . . $ QTJSC/`operator<`(11610d830df66bbf). maxCacheEntriescxx . . $ QTJSC/EvalCodeCache#maxCacheEntries.)
59 m_cacheMapcxx . . $ QTJSC/EvalCodeCache#m_cacheMap..set(evalSource.repcxx . . $ QTJSC/UString#rep(eff8ac5d0836371c).(), evalExecutable);
60 }
61
62 return evalExecutable.release();
63 }
64
65 bool isEmptycxx . . $ QTJSC/EvalCodeCache#isEmpty(50ce9a9e25b4a850).() const { return m_cacheMapcxx . . $ QTJSC/EvalCodeCache#m_cacheMap..isEmpty(); }
66
67 private:
68 static const int maxCacheableSourceLengthcxx . . $ QTJSC/EvalCodeCache#maxCacheableSourceLength. = 256;
69 static const int maxCacheEntriescxx . . $ QTJSC/EvalCodeCache#maxCacheEntries. = 64;
70
71 typedef HashMap<RefPtr<UString::Rep>, RefPtr<EvalExecutable> > EvalCacheMapcxx . . $ QTJSC/EvalCodeCache#EvalCacheMap#;
72 EvalCacheMapcxx . . $ QTJSC/EvalCodeCache#EvalCacheMap# m_cacheMapcxx . . $ QTJSC/EvalCodeCache#m_cacheMap.;
73 };
74
75 } // namespace JSC
76
77 #endif // EvalCodeCache_h