Changeset 39083 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Dec 7, 2008, 3:55:04 PM (16 years ago)
Author:
[email protected]
Message:

<rdar://problem/6309878> Need more granular control over allocation of executable memory (21783)
<https://bugs.webkit.org/show_bug.cgi?id=21783>

Reviewed by Cameron Zwarich and Sam Weinig

Add a new allocator for use by the JIT that provides executable pages, so
we can get rid of the current hack that makes the entire heap executable.

1-2% progression on SunSpider-v8, 1% on SunSpider. Reduces memory usage as well!

Location:
trunk/JavaScriptCore/runtime
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSGlobalData.h

    r38622 r39083  
    3434#include <wtf/RefCounted.h>
    3535#include "Collector.h"
     36#include "ExecutableAllocator.h"
    3637#include "SmallStrings.h"
    3738
     
    121122        Heap heap;
    122123
     124        PassRefPtr<ExecutablePool> poolForSize(size_t n) { return m_executableAllocator.poolForSize(n); }
    123125    private:
    124126        JSGlobalData(bool isShared = false);
     127        ExecutableAllocator m_executableAllocator;
    125128
    126129        static JSGlobalData*& sharedInstanceInternal();
  • trunk/JavaScriptCore/runtime/RegExp.cpp

    r38975 r39083  
    3838#endif
    3939
    40 inline RegExp::RegExp(const UString& pattern)
     40inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern)
    4141    : m_pattern(pattern)
    4242    , m_flagBits(0)
     
    4646{
    4747#if ENABLE(WREC)
    48     m_wrecFunction = Generator::compileRegExp(pattern, &m_numSubpatterns, &m_constructionError);
     48    m_wrecFunction = Generator::compileRegExp(globalData, pattern, &m_numSubpatterns, &m_constructionError, m_executablePool);
    4949    if (m_wrecFunction)
    5050        return;
     
    5555}
    5656
    57 PassRefPtr<RegExp> RegExp::create(const UString& pattern)
     57PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern)
    5858{
    59     return adoptRef(new RegExp(pattern));
     59    return adoptRef(new RegExp(globalData, pattern));
    6060}
    6161
    62 inline RegExp::RegExp(const UString& pattern, const UString& flags)
     62inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags)
    6363    : m_pattern(pattern)
    6464    , m_flags(flags)
     
    8787
    8888#if ENABLE(WREC)
    89     m_wrecFunction = Generator::compileRegExp(pattern, &m_numSubpatterns, &m_constructionError, (m_flagBits & IgnoreCase), (m_flagBits & Multiline));
     89    m_wrecFunction = Generator::compileRegExp(globalData, pattern, &m_numSubpatterns, &m_constructionError, m_executablePool, (m_flagBits & IgnoreCase), (m_flagBits & Multiline));
    9090    if (m_wrecFunction)
    9191        return;
     
    9696}
    9797
    98 PassRefPtr<RegExp> RegExp::create(const UString& pattern, const UString& flags)
     98PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
    9999{
    100     return adoptRef(new RegExp(pattern, flags));
     100    return adoptRef(new RegExp(globalData, pattern, flags));
    101101}
    102102
     
    104104{
    105105    jsRegExpFree(m_regExp);
    106 #if ENABLE(WREC)
    107     if (m_wrecFunction)
    108         WTF::fastFreeExecutable(reinterpret_cast<void*>(m_wrecFunction));
    109 #endif
    110106}
    111107
  • trunk/JavaScriptCore/runtime/RegExp.h

    r38975 r39083  
    2424#include "UString.h"
    2525#include "WREC.h"
     26#include "ExecutableAllocator.h"
    2627#include <wtf/Forward.h>
    2728#include <wtf/RefCounted.h>
     
    3536    class RegExp : public RefCounted<RegExp> {
    3637    public:
    37         static PassRefPtr<RegExp> create(const UString& pattern);
    38         static PassRefPtr<RegExp> create(const UString& pattern, const UString& flags);
     38        static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern);
     39        static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern, const UString& flags);
    3940        ~RegExp();
    4041
     
    5354
    5455    private:
    55         RegExp(const UString& pattern);
    56         RegExp(const UString& pattern, const UString& flags);
     56        RegExp(JSGlobalData* globalData, const UString& pattern);
     57        RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags);
    5758
    5859        void compile();
     
    6970#if ENABLE(WREC)
    7071        WREC::CompiledRegExp m_wrecFunction;
     72        RefPtr<ExecutablePool> m_executablePool;
    7173#endif
    7274    };
  • trunk/JavaScriptCore/runtime/RegExpConstructor.cpp

    r38975 r39083  
    332332    UString flags = arg1->isUndefined() ? UString("") : arg1->toString(exec);
    333333
    334     RefPtr<RegExp> regExp = RegExp::create(pattern, flags);
     334    RefPtr<RegExp> regExp = RegExp::create(&exec->globalData(), pattern, flags);
    335335    if (!regExp->isValid())
    336336        return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage()));
  • trunk/JavaScriptCore/runtime/RegExpPrototype.cpp

    r38975 r39083  
    8686        UString pattern = args.isEmpty() ? UString("") : arg0->toString(exec);
    8787        UString flags = arg1->isUndefined() ? UString("") : arg1->toString(exec);
    88         regExp = RegExp::create(pattern, flags);
     88        regExp = RegExp::create(&exec->globalData(), pattern, flags);
    8989    }
    9090
  • trunk/JavaScriptCore/runtime/StringPrototype.cpp

    r38975 r39083  
    413413         *  replaced with the result of the expression new RegExp(regexp).
    414414         */
    415         reg = RegExp::create(a0->toString(exec));
     415        reg = RegExp::create(&exec->globalData(), a0->toString(exec));
    416416    }
    417417    RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
     
    463463         *  replaced with the result of the expression new RegExp(regexp).
    464464         */
    465         reg = RegExp::create(a0->toString(exec));
     465        reg = RegExp::create(&exec->globalData(), a0->toString(exec));
    466466    }
    467467    RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
Note: See TracChangeset for help on using the changeset viewer.