| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 // Generic RegExp methods. Dispatches to implementation specific methods. | 166 // Generic RegExp methods. Dispatches to implementation specific methods. |
| 167 | 167 |
| 168 | 168 |
| 169 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, | 169 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, |
| 170 Handle<String> pattern, | 170 Handle<String> pattern, |
| 171 Handle<String> flag_str, | 171 Handle<String> flag_str, |
| 172 Zone* zone) { | 172 Zone* zone) { |
| 173 ZoneScope zone_scope(zone, DELETE_ON_EXIT); | 173 ZoneScope zone_scope(zone); |
| 174 Isolate* isolate = re->GetIsolate(); | 174 Isolate* isolate = re->GetIsolate(); |
| 175 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str); | 175 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str); |
| 176 CompilationCache* compilation_cache = isolate->compilation_cache(); | 176 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 177 Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags); | 177 Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags); |
| 178 bool in_cache = !cached.is_null(); | 178 bool in_cache = !cached.is_null(); |
| 179 LOG(isolate, RegExpCompileEvent(re, in_cache)); | 179 LOG(isolate, RegExpCompileEvent(re, in_cache)); |
| 180 | 180 |
| 181 Handle<Object> result; | 181 Handle<Object> result; |
| 182 if (in_cache) { | 182 if (in_cache) { |
| 183 re->set_data(*cached); | 183 re->set_data(*cached); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 isolate->Throw(*regexp_err); | 403 isolate->Throw(*regexp_err); |
| 404 return false; | 404 return false; |
| 405 } | 405 } |
| 406 | 406 |
| 407 | 407 |
| 408 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, | 408 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, |
| 409 Handle<String> sample_subject, | 409 Handle<String> sample_subject, |
| 410 bool is_ascii) { | 410 bool is_ascii) { |
| 411 // Compile the RegExp. | 411 // Compile the RegExp. |
| 412 Isolate* isolate = re->GetIsolate(); | 412 Isolate* isolate = re->GetIsolate(); |
| 413 ZoneScope zone_scope(isolate->runtime_zone(), DELETE_ON_EXIT); | 413 ZoneScope zone_scope(isolate->runtime_zone()); |
| 414 PostponeInterruptsScope postpone(isolate); | 414 PostponeInterruptsScope postpone(isolate); |
| 415 // If we had a compilation error the last time this is saved at the | 415 // If we had a compilation error the last time this is saved at the |
| 416 // saved code index. | 416 // saved code index. |
| 417 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); | 417 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); |
| 418 // When arriving here entry can only be a smi, either representing an | 418 // When arriving here entry can only be a smi, either representing an |
| 419 // uncompiled regexp, a previous compilation error, or code that has | 419 // uncompiled regexp, a previous compilation error, or code that has |
| 420 // been flushed. | 420 // been flushed. |
| 421 ASSERT(entry->IsSmi()); | 421 ASSERT(entry->IsSmi()); |
| 422 int entry_value = Smi::cast(entry)->value(); | 422 int entry_value = Smi::cast(entry)->value(); |
| 423 ASSERT(entry_value == JSRegExp::kUninitializedValue || | 423 ASSERT(entry_value == JSRegExp::kUninitializedValue || |
| (...skipping 5699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6123 } | 6123 } |
| 6124 | 6124 |
| 6125 return compiler.Assemble(¯o_assembler, | 6125 return compiler.Assemble(¯o_assembler, |
| 6126 node, | 6126 node, |
| 6127 data->capture_count, | 6127 data->capture_count, |
| 6128 pattern); | 6128 pattern); |
| 6129 } | 6129 } |
| 6130 | 6130 |
| 6131 | 6131 |
| 6132 }} // namespace v8::internal | 6132 }} // namespace v8::internal |
| OLD | NEW |