OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags); | 120 Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags); |
121 bool in_cache = !cached.is_null(); | 121 bool in_cache = !cached.is_null(); |
122 LOG(isolate, RegExpCompileEvent(re, in_cache)); | 122 LOG(isolate, RegExpCompileEvent(re, in_cache)); |
123 | 123 |
124 Handle<Object> result; | 124 Handle<Object> result; |
125 if (in_cache) { | 125 if (in_cache) { |
126 re->set_data(*cached); | 126 re->set_data(*cached); |
127 return re; | 127 return re; |
128 } | 128 } |
129 pattern = FlattenGetString(pattern); | 129 pattern = FlattenGetString(pattern); |
130 CompilationZoneScope zone_scope(isolate, DELETE_ON_EXIT); | 130 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
131 PostponeInterruptsScope postpone(isolate); | 131 PostponeInterruptsScope postpone(isolate); |
132 RegExpCompileData parse_result; | 132 RegExpCompileData parse_result; |
133 FlatStringReader reader(isolate, pattern); | 133 FlatStringReader reader(isolate, pattern); |
134 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), | 134 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), |
135 &parse_result)) { | 135 &parse_result)) { |
136 // Throw an exception if we fail to parse the pattern. | 136 // Throw an exception if we fail to parse the pattern. |
137 ThrowRegExpException(re, | 137 ThrowRegExpException(re, |
138 pattern, | 138 pattern, |
139 parse_result.error, | 139 parse_result.error, |
140 "malformed_regexp"); | 140 "malformed_regexp"); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 #else // V8_INTERPRETED_REGEXP (RegExp native code) | 295 #else // V8_INTERPRETED_REGEXP (RegExp native code) |
296 if (compiled_code->IsCode()) return true; | 296 if (compiled_code->IsCode()) return true; |
297 #endif | 297 #endif |
298 return CompileIrregexp(re, is_ascii); | 298 return CompileIrregexp(re, is_ascii); |
299 } | 299 } |
300 | 300 |
301 | 301 |
302 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, bool is_ascii) { | 302 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, bool is_ascii) { |
303 // Compile the RegExp. | 303 // Compile the RegExp. |
304 Isolate* isolate = re->GetIsolate(); | 304 Isolate* isolate = re->GetIsolate(); |
305 CompilationZoneScope zone_scope(isolate, DELETE_ON_EXIT); | 305 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
306 PostponeInterruptsScope postpone(isolate); | 306 PostponeInterruptsScope postpone(isolate); |
307 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); | 307 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); |
308 if (entry->IsJSObject()) { | 308 if (entry->IsJSObject()) { |
309 // If it's a JSObject, a previous compilation failed and threw this object. | 309 // If it's a JSObject, a previous compilation failed and threw this object. |
310 // Re-throw the object without trying again. | 310 // Re-throw the object without trying again. |
311 isolate->Throw(entry); | 311 isolate->Throw(entry); |
312 return false; | 312 return false; |
313 } | 313 } |
314 ASSERT(entry->IsTheHole()); | 314 ASSERT(entry->IsTheHole()); |
315 | 315 |
(...skipping 5060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5376 } | 5376 } |
5377 | 5377 |
5378 return compiler.Assemble(¯o_assembler, | 5378 return compiler.Assemble(¯o_assembler, |
5379 node, | 5379 node, |
5380 data->capture_count, | 5380 data->capture_count, |
5381 pattern); | 5381 pattern); |
5382 } | 5382 } |
5383 | 5383 |
5384 | 5384 |
5385 }} // namespace v8::internal | 5385 }} // namespace v8::internal |
OLD | NEW |