| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 Top::Throw(*regexp_err); | 200 Top::Throw(*regexp_err); |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, | 204 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, |
| 205 Handle<String> pattern, | 205 Handle<String> pattern, |
| 206 Handle<String> flag_str) { | 206 Handle<String> flag_str) { |
| 207 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str); | 207 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str); |
| 208 Handle<FixedArray> cached = CompilationCache::LookupRegExp(pattern, flags); | 208 Handle<FixedArray> cached = CompilationCache::LookupRegExp(pattern, flags); |
| 209 bool in_cache = !cached.is_null(); | 209 bool in_cache = !cached.is_null(); |
| 210 LOG(RegExpCompileEvent(re, in_cache)); |
| 211 |
| 210 Handle<Object> result; | 212 Handle<Object> result; |
| 211 if (in_cache) { | 213 if (in_cache) { |
| 212 re->set_data(*cached); | 214 re->set_data(*cached); |
| 213 result = re; | 215 result = re; |
| 214 } else { | 216 } else { |
| 215 FlattenString(pattern); | 217 FlattenString(pattern); |
| 218 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 216 RegExpParseResult parse_result; | 219 RegExpParseResult parse_result; |
| 217 FlatStringReader reader(pattern); | 220 FlatStringReader reader(pattern); |
| 218 if (!ParseRegExp(&reader, flags.is_multiline(), &parse_result)) { | 221 if (!ParseRegExp(&reader, flags.is_multiline(), &parse_result)) { |
| 219 // Throw an exception if we fail to parse the pattern. | 222 // Throw an exception if we fail to parse the pattern. |
| 220 ThrowRegExpException(re, | 223 ThrowRegExpException(re, |
| 221 pattern, | 224 pattern, |
| 222 parse_result.error, | 225 parse_result.error, |
| 223 "malformed_regexp"); | 226 "malformed_regexp"); |
| 224 return Handle<Object>(); | 227 return Handle<Object>(); |
| 225 } | 228 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 251 } | 254 } |
| 252 Object* data = re->data(); | 255 Object* data = re->data(); |
| 253 if (data->IsFixedArray()) { | 256 if (data->IsFixedArray()) { |
| 254 // If compilation succeeded then the data is set on the regexp | 257 // If compilation succeeded then the data is set on the regexp |
| 255 // and we can store it in the cache. | 258 // and we can store it in the cache. |
| 256 Handle<FixedArray> data(FixedArray::cast(re->data())); | 259 Handle<FixedArray> data(FixedArray::cast(re->data())); |
| 257 CompilationCache::PutRegExp(pattern, flags, data); | 260 CompilationCache::PutRegExp(pattern, flags, data); |
| 258 } | 261 } |
| 259 } | 262 } |
| 260 | 263 |
| 261 LOG(RegExpCompileEvent(re, in_cache)); | |
| 262 return result; | 264 return result; |
| 263 } | 265 } |
| 264 | 266 |
| 265 | 267 |
| 266 Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp, | 268 Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp, |
| 267 Handle<String> subject, | 269 Handle<String> subject, |
| 268 Handle<Object> index) { | 270 Handle<Object> index) { |
| 269 switch (regexp->TypeTag()) { | 271 switch (regexp->TypeTag()) { |
| 270 case JSRegExp::JSCRE: | 272 case JSRegExp::JSCRE: |
| 271 if (FLAG_disable_jscre) { | 273 if (FLAG_disable_jscre) { |
| (...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3031 } | 3033 } |
| 3032 EmbeddedVector<byte, 1024> codes; | 3034 EmbeddedVector<byte, 1024> codes; |
| 3033 RegExpMacroAssemblerIrregexp macro_assembler(codes); | 3035 RegExpMacroAssemblerIrregexp macro_assembler(codes); |
| 3034 return compiler.Assemble(¯o_assembler, | 3036 return compiler.Assemble(¯o_assembler, |
| 3035 node, | 3037 node, |
| 3036 input->capture_count); | 3038 input->capture_count); |
| 3037 } | 3039 } |
| 3038 | 3040 |
| 3039 | 3041 |
| 3040 }} // namespace v8::internal | 3042 }} // namespace v8::internal |
| OLD | NEW |