Ignore:
Timestamp:
Nov 7, 2007, 9:18:39 AM (18 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Darin Adler.


Fixed part of http://bugs.webkit.org/show_bug.cgi?id=15861
15% of string-validate-input.js is spent compiling the same regular expression.

Put RegExpImp properties into a static hashtable to avoid a slew of
PropertyMap churn when creating a RegExpImp.


Factored important bits of regular expression implementation out of
RegExpImp (the JS object) and into RegExp (the PCRE wrapper class),
making RegExp a ref-counted class. (This will help later.)

Removed PCRE_POSIX support because I didn't quite know how to test it
and keep it working with these changes.


1.1% SunSpider speedup. 5.8% speedup on string-validate-input.js.

  • kjs/regexp.h: A few interface changes:
  1. Renamed "subpatterns()" => "numSubpatterns()"
  2. Made flag enumeration private and replaced it with public getters for specific flags.
  3. Made RegExp ref-counted so RegExps can be shared by RegExpImps.
  4. Made RegExp take a string of flags instead of an int, eliminating duplicated flag parsing code elsewhere.
  • kjs/regexp_object.cpp: (KJS::RegExpProtoFunc::callAsFunction): For RegExp.compile:
  • Fixed a bug where compile(undefined) would throw an exception.
  • Removed some now-redundant code.
  • Used RegExp sharing to eliminate an allocation and a bunch of PropertyMap thrash. (Not a big win since compile is a deprecated function. I mainly did this to test the plubming.)

LayoutTests:

Reviewed by Darin Adler.


Beefed up the RegExp.compile testcase to cover a mistake in the
original check-in and a mistake I made while developing my new patch.

  • fast/js/resources/regexp-compile.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/regexp_object.h

    r27405 r27571  
    4949    class RegExpImp : public JSObject {
    5050    public:
    51         RegExpImp(RegExpPrototype*, RegExp*);
     51        enum { Global, IgnoreCase, Multiline, Source, LastIndex };
     52
     53        RegExpImp(RegExpPrototype*, PassRefPtr<RegExp>);
    5254        virtual ~RegExpImp();
    5355
    54         void setRegExp(RegExp* r) { m_regExp.set(r); }
     56        void setRegExp(PassRefPtr<RegExp> r) { m_regExp = r; }
    5557        RegExp* regExp() const { return m_regExp.get(); }
    5658
     
    6062        virtual bool implementsCall() const;
    6163        virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&);
     64        bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     65        JSValue* getValueProperty(ExecState*, int token) const;
     66        void put(ExecState*, const Identifier&, JSValue*, int attributes = None);
     67        void putValueProperty(ExecState*, int token, JSValue*, int attributes);
     68
    6269        virtual const ClassInfo* classInfo() const { return &info; }
    6370        static const ClassInfo info;
     
    6673        bool match(ExecState*, const List& args);
    6774
    68         OwnPtr<RegExp> m_regExp;
     75        RefPtr<RegExp> m_regExp;
     76        double m_lastIndex;
    6977    };
    7078
Note: See TracChangeset for help on using the changeset viewer.