Chromium Code Reviews| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 // from the source pattern. | 288 // from the source pattern. |
| 289 // If compilation fails, an exception is thrown and this function | 289 // If compilation fails, an exception is thrown and this function |
| 290 // returns false. | 290 // returns false. |
| 291 bool RegExpImpl::EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii) { | 291 bool RegExpImpl::EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii) { |
| 292 Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii)); | 292 Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii)); |
| 293 #ifdef V8_INTERPRETED_REGEXP | 293 #ifdef V8_INTERPRETED_REGEXP |
| 294 if (compiled_code->IsByteArray()) return true; | 294 if (compiled_code->IsByteArray()) return true; |
| 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 // We could potentially have marked this as flushable, but have keept | |
|
Erik Corry
2011/06/30 18:48:25
keept -> kept
Rico
2011/07/01 05:58:09
Done.
| |
| 299 // a saved version if we did not flush it yet. | |
| 300 Object* saved_code = re->DataAt(JSRegExp::saved_code_index(is_ascii)); | |
| 301 if (saved_code->IsCode()) { | |
| 302 // Reinstate the code in the original place. | |
| 303 re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code); | |
| 304 ASSERT(compiled_code->IsSmi()); | |
| 305 return true; | |
| 306 } | |
| 298 return CompileIrregexp(re, is_ascii); | 307 return CompileIrregexp(re, is_ascii); |
| 299 } | 308 } |
| 300 | 309 |
| 301 | 310 |
| 302 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, bool is_ascii) { | 311 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, bool is_ascii) { |
| 303 // Compile the RegExp. | 312 // Compile the RegExp. |
| 304 Isolate* isolate = re->GetIsolate(); | 313 Isolate* isolate = re->GetIsolate(); |
| 305 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); | 314 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
| 306 PostponeInterruptsScope postpone(isolate); | 315 PostponeInterruptsScope postpone(isolate); |
| 307 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); | 316 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); |
| 308 if (entry->IsJSObject()) { | 317 if (entry->IsJSObject()) { |
| 309 // If it's a JSObject, a previous compilation failed and threw this object. | 318 // If it's a JSObject, a previous compilation failed and threw this object. |
| 310 // Re-throw the object without trying again. | 319 // Re-throw the object without trying again. |
| 311 isolate->Throw(entry); | 320 isolate->Throw(entry); |
| 312 return false; | 321 return false; |
| 313 } | 322 } |
| 314 ASSERT(entry->IsTheHole()); | 323 ASSERT(entry->IsSmi()); |
| 315 | 324 |
| 316 JSRegExp::Flags flags = re->GetFlags(); | 325 JSRegExp::Flags flags = re->GetFlags(); |
| 317 | 326 |
| 318 Handle<String> pattern(re->Pattern()); | 327 Handle<String> pattern(re->Pattern()); |
| 319 if (!pattern->IsFlat()) { | 328 if (!pattern->IsFlat()) { |
| 320 FlattenString(pattern); | 329 FlattenString(pattern); |
| 321 } | 330 } |
| 322 | 331 |
| 323 RegExpCompileData compile_data; | 332 RegExpCompileData compile_data; |
| 324 FlatStringReader reader(isolate, pattern); | 333 FlatStringReader reader(isolate, pattern); |
| (...skipping 5006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5331 } | 5340 } |
| 5332 | 5341 |
| 5333 return compiler.Assemble(¯o_assembler, | 5342 return compiler.Assemble(¯o_assembler, |
| 5334 node, | 5343 node, |
| 5335 data->capture_count, | 5344 data->capture_count, |
| 5336 pattern); | 5345 pattern); |
| 5337 } | 5346 } |
| 5338 | 5347 |
| 5339 | 5348 |
| 5340 }} // namespace v8::internal | 5349 }} // namespace v8::internal |
| OLD | NEW |