Changeset 38311 in webkit for trunk/JavaScriptCore/VM/CodeBlock.h


Ignore:
Timestamp:
Nov 11, 2008, 12:06:11 PM (17 years ago)
Author:
[email protected]
Message:

2008-11-11 Cameron Zwarich <[email protected]>

Rubber-stamped by Sam Weinig.

Bug 22179: Move EvalCodeCache from CodeBlock.h into its own file
<https://bugs.webkit.org/show_bug.cgi?id=22179>

  • GNUmakefile.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • VM/CodeBlock.h:
  • VM/EvalCodeCache.h: Copied from VM/CodeBlock.h.
  • VM/Machine.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeBlock.h

    r38291 r38311  
    3131#define CodeBlock_h
    3232
     33#include "EvalCodeCache.h"
    3334#include "Instruction.h"
    3435#include "JSGlobalObject.h"
    3536#include "Nodes.h"
    36 #include "Parser.h"
    3737#include "RegExp.h"
    38 #include "SourceCode.h"
    3938#include "UString.h"
    4039#include <wtf/RefPtr.h>
     
    212211    };
    213212
    214     class EvalCodeCache {
    215     public:
    216         PassRefPtr<EvalNode> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue*& exceptionValue)
    217         {
    218             RefPtr<EvalNode> evalNode;
    219 
    220             if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())
    221                 evalNode = cacheMap.get(evalSource.rep());
    222 
    223             if (!evalNode) {
    224                 int errLine;
    225                 UString errMsg;
    226                
    227                 SourceCode source = makeSource(evalSource);
    228                 evalNode = exec->globalData().parser->parse<EvalNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
    229                 if (evalNode) {
    230                     if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && cacheMap.size() < maxCacheEntries)
    231                         cacheMap.set(evalSource.rep(), evalNode);
    232                 } else {
    233                     exceptionValue = Error::create(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), NULL);
    234                     return 0;
    235                 }
    236             }
    237 
    238             return evalNode.release();
    239         }
    240 
    241     private:
    242         static const int maxCacheableSourceLength = 256;
    243         static const int maxCacheEntries = 64;
    244 
    245         HashMap<RefPtr<UString::Rep>, RefPtr<EvalNode> > cacheMap;
    246     };
    247 
    248213    struct CodeBlock {
    249214        CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
Note: See TracChangeset for help on using the changeset viewer.