| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, | 65 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, |
| 66 Handle<String> subject); | 66 Handle<String> subject); |
| 67 | 67 |
| 68 // Stores an uncompiled RegExp pattern in the JSRegExp object. | 68 // Stores an uncompiled RegExp pattern in the JSRegExp object. |
| 69 // It will be compiled by JSCRE when first executed. | 69 // It will be compiled by JSCRE when first executed. |
| 70 static Handle<Object> JscrePrepare(Handle<JSRegExp> re, | 70 static Handle<Object> JscrePrepare(Handle<JSRegExp> re, |
| 71 Handle<String> pattern, | 71 Handle<String> pattern, |
| 72 JSRegExp::Flags flags); | 72 JSRegExp::Flags flags); |
| 73 | 73 |
| 74 // Stores a compiled RegExp pattern in the JSRegExp object. | 74 // Stores a compiled RegExp pattern in the JSRegExp object. |
| 75 // The pattern is compiled by Regexp2000. | 75 // The pattern is compiled by Irregexp. |
| 76 static Handle<Object> Re2kPrepare(Handle<JSRegExp> re, | 76 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re, |
| 77 Handle<String> pattern, | 77 Handle<String> pattern, |
| 78 JSRegExp::Flags flags, | 78 JSRegExp::Flags flags, |
| 79 Handle<FixedArray> re2k_data); | 79 Handle<FixedArray> irregexp_data); |
| 80 | 80 |
| 81 | 81 |
| 82 // Compile the pattern using JSCRE and store the result in the | 82 // Compile the pattern using JSCRE and store the result in the |
| 83 // JSRegExp object. | 83 // JSRegExp object. |
| 84 static Handle<Object> JscreCompile(Handle<JSRegExp> re); | 84 static Handle<Object> JscreCompile(Handle<JSRegExp> re); |
| 85 | 85 |
| 86 static Handle<Object> AtomCompile(Handle<JSRegExp> re, | 86 static Handle<Object> AtomCompile(Handle<JSRegExp> re, |
| 87 Handle<String> pattern, | 87 Handle<String> pattern, |
| 88 JSRegExp::Flags flags, | 88 JSRegExp::Flags flags, |
| 89 Handle<String> match_pattern); | 89 Handle<String> match_pattern); |
| 90 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, | 90 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, |
| 91 Handle<String> subject, | 91 Handle<String> subject, |
| 92 Handle<Object> index); | 92 Handle<Object> index); |
| 93 | 93 |
| 94 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp, | 94 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp, |
| 95 Handle<String> subject); | 95 Handle<String> subject); |
| 96 | 96 |
| 97 static Handle<Object> JscreCompile(Handle<JSRegExp> re, | 97 static Handle<Object> JscreCompile(Handle<JSRegExp> re, |
| 98 Handle<String> pattern, | 98 Handle<String> pattern, |
| 99 JSRegExp::Flags flags); | 99 JSRegExp::Flags flags); |
| 100 | 100 |
| 101 // Execute a compiled JSCRE pattern. | 101 // Execute a compiled JSCRE pattern. |
| 102 static Handle<Object> JscreExec(Handle<JSRegExp> regexp, | 102 static Handle<Object> JscreExec(Handle<JSRegExp> regexp, |
| 103 Handle<String> subject, | 103 Handle<String> subject, |
| 104 Handle<Object> index); | 104 Handle<Object> index); |
| 105 | 105 |
| 106 // Execute a Regexp2000 bytecode pattern. | 106 // Execute an Irregexp bytecode pattern. |
| 107 static Handle<Object> Re2kExec(Handle<JSRegExp> regexp, | 107 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, |
| 108 Handle<String> subject, | 108 Handle<String> subject, |
| 109 Handle<Object> index); | 109 Handle<Object> index); |
| 110 | 110 |
| 111 static Handle<Object> JscreExecGlobal(Handle<JSRegExp> regexp, | 111 static Handle<Object> JscreExecGlobal(Handle<JSRegExp> regexp, |
| 112 Handle<String> subject); | 112 Handle<String> subject); |
| 113 | 113 |
| 114 static Handle<Object> Re2kExecGlobal(Handle<JSRegExp> regexp, | 114 static Handle<Object> IrregexpExecGlobal(Handle<JSRegExp> regexp, |
| 115 Handle<String> subject); | 115 Handle<String> subject); |
| 116 | 116 |
| 117 static void NewSpaceCollectionPrologue(); | 117 static void NewSpaceCollectionPrologue(); |
| 118 static void OldSpaceCollectionPrologue(); | 118 static void OldSpaceCollectionPrologue(); |
| 119 | 119 |
| 120 // Converts a source string to a 16 bit flat string. The string | 120 // Converts a source string to a 16 bit flat string. The string |
| 121 // will be either sequential or it will be a SlicedString backed | 121 // will be either sequential or it will be a SlicedString backed |
| 122 // by a flat string. | 122 // by a flat string. |
| 123 static Handle<String> StringToTwoByte(Handle<String> pattern); | 123 static Handle<String> StringToTwoByte(Handle<String> pattern); |
| 124 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); | 124 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); |
| 125 | 125 |
| 126 static const int kRe2kImplementationIndex = 0; | 126 static const int kIrregexpImplementationIndex = 0; |
| 127 static const int kRe2kNumberOfCapturesIndex = 1; | 127 static const int kIrregexpNumberOfCapturesIndex = 1; |
| 128 static const int kRe2kNumberOfRegistersIndex = 2; | 128 static const int kIrregexpNumberOfRegistersIndex = 2; |
| 129 static const int kRe2kCodeIndex = 3; | 129 static const int kIrregexpCodeIndex = 3; |
| 130 static const int kRe2kDataLength = 4; | 130 static const int kIrregexpDataLength = 4; |
| 131 | 131 |
| 132 static const int kJscreNumberOfCapturesIndex = 0; | 132 static const int kJscreNumberOfCapturesIndex = 0; |
| 133 static const int kJscreInternalIndex = 1; | 133 static const int kJscreInternalIndex = 1; |
| 134 static const int kJscreDataLength = 2; | 134 static const int kJscreDataLength = 2; |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 static String* last_ascii_string_; | 137 static String* last_ascii_string_; |
| 138 static String* two_byte_cached_string_; | 138 static String* two_byte_cached_string_; |
| 139 | 139 |
| 140 static int JscreNumberOfCaptures(Handle<JSRegExp> re); | 140 static int JscreNumberOfCaptures(Handle<JSRegExp> re); |
| 141 static ByteArray* JscreInternal(Handle<JSRegExp> re); | 141 static ByteArray* JscreInternal(Handle<JSRegExp> re); |
| 142 | 142 |
| 143 static int Re2kNumberOfCaptures(Handle<JSRegExp> re); | 143 static int IrregexpNumberOfCaptures(Handle<JSRegExp> re); |
| 144 static int Re2kNumberOfRegisters(Handle<JSRegExp> re); | 144 static int IrregexpNumberOfRegisters(Handle<JSRegExp> re); |
| 145 static Handle<ByteArray> Re2kCode(Handle<JSRegExp> re); | 145 static Handle<ByteArray> IrregexpCode(Handle<JSRegExp> re); |
| 146 | 146 |
| 147 // Call jsRegExpExecute once | 147 // Call jsRegExpExecute once |
| 148 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp, | 148 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp, |
| 149 int num_captures, | 149 int num_captures, |
| 150 Handle<String> subject, | 150 Handle<String> subject, |
| 151 int previous_index, | 151 int previous_index, |
| 152 const uc16* utf8_subject, | 152 const uc16* utf8_subject, |
| 153 int* ovector, | 153 int* ovector, |
| 154 int ovector_length); | 154 int ovector_length); |
| 155 | 155 |
| 156 static Handle<Object> Re2kExecOnce(Handle<JSRegExp> regexp, | 156 static Handle<Object> IrregexpExecOnce(Handle<JSRegExp> regexp, |
| 157 int num_captures, | 157 int num_captures, |
| 158 Handle<String> subject16, | 158 Handle<String> subject16, |
| 159 int previous_index, | 159 int previous_index, |
| 160 int* ovector, | 160 int* ovector, |
| 161 int ovector_length); | 161 int ovector_length); |
| 162 | 162 |
| 163 // Set the subject cache. The previous string buffer is not deleted, so the | 163 // Set the subject cache. The previous string buffer is not deleted, so the |
| 164 // caller should ensure that it doesn't leak. | 164 // caller should ensure that it doesn't leak. |
| 165 static void SetSubjectCache(String* subject, | 165 static void SetSubjectCache(String* subject, |
| 166 char* utf8_subject, | 166 char* utf8_subject, |
| 167 int uft8_length, | 167 int uft8_length, |
| 168 int character_position, | 168 int character_position, |
| 169 int utf8_position); | 169 int utf8_position); |
| 170 | 170 |
| 171 // A one element cache of the last utf8_subject string and its length. The | 171 // A one element cache of the last utf8_subject string and its length. The |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 static Handle<FixedArray> Compile(RegExpParseResult* input, | 767 static Handle<FixedArray> Compile(RegExpParseResult* input, |
| 768 RegExpNode** node_return, | 768 RegExpNode** node_return, |
| 769 bool ignore_case); | 769 bool ignore_case); |
| 770 static void DotPrint(const char* label, RegExpNode* node); | 770 static void DotPrint(const char* label, RegExpNode* node); |
| 771 }; | 771 }; |
| 772 | 772 |
| 773 | 773 |
| 774 } } // namespace v8::internal | 774 } } // namespace v8::internal |
| 775 | 775 |
| 776 #endif // V8_JSREGEXP_H_ | 776 #endif // V8_JSREGEXP_H_ |
| OLD | NEW |