Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/jsregexp.cc

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/jsregexp.h ('k') | src/lithium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
163 } 163 }
164 return true; 164 return true;
165 } 165 }
166 166
167 167
168 // Generic RegExp methods. Dispatches to implementation specific methods. 168 // Generic RegExp methods. Dispatches to implementation specific methods.
169 169
170 170
171 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, 171 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
172 Handle<String> pattern, 172 Handle<String> pattern,
173 Handle<String> flag_str, 173 Handle<String> flag_str) {
174 Zone* zone) {
175 ZoneScope zone_scope(zone, DELETE_ON_EXIT);
176 Isolate* isolate = re->GetIsolate(); 174 Isolate* isolate = re->GetIsolate();
175 Zone zone(isolate);
177 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str); 176 JSRegExp::Flags flags = RegExpFlagsFromString(flag_str);
178 CompilationCache* compilation_cache = isolate->compilation_cache(); 177 CompilationCache* compilation_cache = isolate->compilation_cache();
179 Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags); 178 Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags);
180 bool in_cache = !cached.is_null(); 179 bool in_cache = !cached.is_null();
181 LOG(isolate, RegExpCompileEvent(re, in_cache)); 180 LOG(isolate, RegExpCompileEvent(re, in_cache));
182 181
183 Handle<Object> result; 182 Handle<Object> result;
184 if (in_cache) { 183 if (in_cache) {
185 re->set_data(*cached); 184 re->set_data(*cached);
186 return re; 185 return re;
187 } 186 }
188 pattern = FlattenGetString(pattern); 187 pattern = FlattenGetString(pattern);
189 PostponeInterruptsScope postpone(isolate); 188 PostponeInterruptsScope postpone(isolate);
190 RegExpCompileData parse_result; 189 RegExpCompileData parse_result;
191 FlatStringReader reader(isolate, pattern); 190 FlatStringReader reader(isolate, pattern);
192 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), 191 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(),
193 &parse_result, zone)) { 192 &parse_result, &zone)) {
194 // Throw an exception if we fail to parse the pattern. 193 // Throw an exception if we fail to parse the pattern.
195 ThrowRegExpException(re, 194 ThrowRegExpException(re,
196 pattern, 195 pattern,
197 parse_result.error, 196 parse_result.error,
198 "malformed_regexp"); 197 "malformed_regexp");
199 return Handle<Object>::null(); 198 return Handle<Object>::null();
200 } 199 }
201 200
202 bool has_been_compiled = false; 201 bool has_been_compiled = false;
203 202
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 isolate->Throw(*regexp_err); 404 isolate->Throw(*regexp_err);
406 return false; 405 return false;
407 } 406 }
408 407
409 408
410 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, 409 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
411 Handle<String> sample_subject, 410 Handle<String> sample_subject,
412 bool is_ascii) { 411 bool is_ascii) {
413 // Compile the RegExp. 412 // Compile the RegExp.
414 Isolate* isolate = re->GetIsolate(); 413 Isolate* isolate = re->GetIsolate();
415 ZoneScope zone_scope(isolate->runtime_zone(), DELETE_ON_EXIT); 414 Zone zone(isolate);
416 PostponeInterruptsScope postpone(isolate); 415 PostponeInterruptsScope postpone(isolate);
417 // If we had a compilation error the last time this is saved at the 416 // If we had a compilation error the last time this is saved at the
418 // saved code index. 417 // saved code index.
419 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); 418 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii));
420 // When arriving here entry can only be a smi, either representing an 419 // When arriving here entry can only be a smi, either representing an
421 // uncompiled regexp, a previous compilation error, or code that has 420 // uncompiled regexp, a previous compilation error, or code that has
422 // been flushed. 421 // been flushed.
423 ASSERT(entry->IsSmi()); 422 ASSERT(entry->IsSmi());
424 int entry_value = Smi::cast(entry)->value(); 423 int entry_value = Smi::cast(entry)->value();
425 ASSERT(entry_value == JSRegExp::kUninitializedValue || 424 ASSERT(entry_value == JSRegExp::kUninitializedValue ||
(...skipping 10 matching lines...) Expand all
436 CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate); 435 CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate);
437 return false; 436 return false;
438 } 437 }
439 438
440 JSRegExp::Flags flags = re->GetFlags(); 439 JSRegExp::Flags flags = re->GetFlags();
441 440
442 Handle<String> pattern(re->Pattern()); 441 Handle<String> pattern(re->Pattern());
443 if (!pattern->IsFlat()) FlattenString(pattern); 442 if (!pattern->IsFlat()) FlattenString(pattern);
444 RegExpCompileData compile_data; 443 RegExpCompileData compile_data;
445 FlatStringReader reader(isolate, pattern); 444 FlatStringReader reader(isolate, pattern);
446 Zone* zone = isolate->runtime_zone();
447 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), 445 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(),
448 &compile_data, 446 &compile_data,
449 zone)) { 447 &zone)) {
450 // Throw an exception if we fail to parse the pattern. 448 // Throw an exception if we fail to parse the pattern.
451 // THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once. 449 // THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once.
452 ThrowRegExpException(re, 450 ThrowRegExpException(re,
453 pattern, 451 pattern,
454 compile_data.error, 452 compile_data.error,
455 "malformed_regexp"); 453 "malformed_regexp");
456 return false; 454 return false;
457 } 455 }
458 RegExpEngine::CompilationResult result = 456 RegExpEngine::CompilationResult result =
459 RegExpEngine::Compile(&compile_data, 457 RegExpEngine::Compile(&compile_data,
460 flags.is_ignore_case(), 458 flags.is_ignore_case(),
461 flags.is_global(), 459 flags.is_global(),
462 flags.is_multiline(), 460 flags.is_multiline(),
463 pattern, 461 pattern,
464 sample_subject, 462 sample_subject,
465 is_ascii, 463 is_ascii,
466 zone); 464 &zone);
467 if (result.error_message != NULL) { 465 if (result.error_message != NULL) {
468 // Unable to compile regexp. 466 // Unable to compile regexp.
469 Handle<String> error_message = 467 Handle<String> error_message =
470 isolate->factory()->NewStringFromUtf8(CStrVector(result.error_message)); 468 isolate->factory()->NewStringFromUtf8(CStrVector(result.error_message));
471 CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate); 469 CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate);
472 return false; 470 return false;
473 } 471 }
474 472
475 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data())); 473 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data()));
476 data->set(JSRegExp::code_index(is_ascii), result.code); 474 data->set(JSRegExp::code_index(is_ascii), result.code);
(...skipping 5653 matching lines...) Expand 10 before | Expand all | Expand 10 after
6130 } 6128 }
6131 6129
6132 return compiler.Assemble(&macro_assembler, 6130 return compiler.Assemble(&macro_assembler,
6133 node, 6131 node,
6134 data->capture_count, 6132 data->capture_count,
6135 pattern); 6133 pattern);
6136 } 6134 }
6137 6135
6138 6136
6139 }} // namespace v8::internal 6137 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.h ('k') | src/lithium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698