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

Side by Side Diff: src/jsregexp.cc

Issue 15691017: Make assertion scopes thread safe. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 pattern, 263 pattern,
264 flags, 264 flags,
265 match_pattern); 265 match_pattern);
266 } 266 }
267 267
268 268
269 static void SetAtomLastCapture(FixedArray* array, 269 static void SetAtomLastCapture(FixedArray* array,
270 String* subject, 270 String* subject,
271 int from, 271 int from,
272 int to) { 272 int to) {
273 NoHandleAllocation no_handles(array->GetIsolate()); 273 SealHandleScope shs(array->GetIsolate());
274 RegExpImpl::SetLastCaptureCount(array, 2); 274 RegExpImpl::SetLastCaptureCount(array, 2);
275 RegExpImpl::SetLastSubject(array, subject); 275 RegExpImpl::SetLastSubject(array, subject);
276 RegExpImpl::SetLastInput(array, subject); 276 RegExpImpl::SetLastInput(array, subject);
277 RegExpImpl::SetCapture(array, 0, from); 277 RegExpImpl::SetCapture(array, 0, from);
278 RegExpImpl::SetCapture(array, 1, to); 278 RegExpImpl::SetCapture(array, 1, to);
279 } 279 }
280 280
281 281
282 int RegExpImpl::AtomExecRaw(Handle<JSRegExp> regexp, 282 int RegExpImpl::AtomExecRaw(Handle<JSRegExp> regexp,
283 Handle<String> subject, 283 Handle<String> subject,
284 int index, 284 int index,
285 int32_t* output, 285 int32_t* output,
286 int output_size) { 286 int output_size) {
287 Isolate* isolate = regexp->GetIsolate(); 287 Isolate* isolate = regexp->GetIsolate();
288 288
289 ASSERT(0 <= index); 289 ASSERT(0 <= index);
290 ASSERT(index <= subject->length()); 290 ASSERT(index <= subject->length());
291 291
292 if (!subject->IsFlat()) FlattenString(subject); 292 if (!subject->IsFlat()) FlattenString(subject);
293 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid 293 DisallowHeapAllocation no_gc; // ensure vectors stay valid
294 294
295 String* needle = String::cast(regexp->DataAt(JSRegExp::kAtomPatternIndex)); 295 String* needle = String::cast(regexp->DataAt(JSRegExp::kAtomPatternIndex));
296 int needle_len = needle->length(); 296 int needle_len = needle->length();
297 ASSERT(needle->IsFlat()); 297 ASSERT(needle->IsFlat());
298 ASSERT_LT(0, needle_len); 298 ASSERT_LT(0, needle_len);
299 299
300 if (index + needle_len > subject->length()) { 300 if (index + needle_len > subject->length()) {
301 return RegExpImpl::RE_FAILURE; 301 return RegExpImpl::RE_FAILURE;
302 } 302 }
303 303
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 static const int kNumRegisters = 2; 347 static const int kNumRegisters = 2;
348 STATIC_ASSERT(kNumRegisters <= Isolate::kJSRegexpStaticOffsetsVectorSize); 348 STATIC_ASSERT(kNumRegisters <= Isolate::kJSRegexpStaticOffsetsVectorSize);
349 int32_t* output_registers = isolate->jsregexp_static_offsets_vector(); 349 int32_t* output_registers = isolate->jsregexp_static_offsets_vector();
350 350
351 int res = AtomExecRaw(re, subject, index, output_registers, kNumRegisters); 351 int res = AtomExecRaw(re, subject, index, output_registers, kNumRegisters);
352 352
353 if (res == RegExpImpl::RE_FAILURE) return isolate->factory()->null_value(); 353 if (res == RegExpImpl::RE_FAILURE) return isolate->factory()->null_value();
354 354
355 ASSERT_EQ(res, RegExpImpl::RE_SUCCESS); 355 ASSERT_EQ(res, RegExpImpl::RE_SUCCESS);
356 NoHandleAllocation no_handles(isolate); 356 SealHandleScope shs(isolate);
357 FixedArray* array = FixedArray::cast(last_match_info->elements()); 357 FixedArray* array = FixedArray::cast(last_match_info->elements());
358 SetAtomLastCapture(array, *subject, output_registers[0], output_registers[1]); 358 SetAtomLastCapture(array, *subject, output_registers[0], output_registers[1]);
359 return last_match_info; 359 return last_match_info;
360 } 360 }
361 361
362 362
363 // Irregexp implementation. 363 // Irregexp implementation.
364 364
365 // Ensures that the regexp object contains a compiled version of the 365 // Ensures that the regexp object contains a compiled version of the
366 // source for either ASCII or non-ASCII strings. 366 // source for either ASCII or non-ASCII strings.
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 684 }
685 685
686 686
687 Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info, 687 Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info,
688 Handle<String> subject, 688 Handle<String> subject,
689 int capture_count, 689 int capture_count,
690 int32_t* match) { 690 int32_t* match) {
691 ASSERT(last_match_info->HasFastObjectElements()); 691 ASSERT(last_match_info->HasFastObjectElements());
692 int capture_register_count = (capture_count + 1) * 2; 692 int capture_register_count = (capture_count + 1) * 2;
693 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); 693 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead);
694 AssertNoAllocation no_gc; 694 DisallowHeapAllocation no_allocation;
695 FixedArray* array = FixedArray::cast(last_match_info->elements()); 695 FixedArray* array = FixedArray::cast(last_match_info->elements());
696 if (match != NULL) { 696 if (match != NULL) {
697 for (int i = 0; i < capture_register_count; i += 2) { 697 for (int i = 0; i < capture_register_count; i += 2) {
698 SetCapture(array, i, match[i]); 698 SetCapture(array, i, match[i]);
699 SetCapture(array, i + 1, match[i + 1]); 699 SetCapture(array, i + 1, match[i + 1]);
700 } 700 }
701 } 701 }
702 SetLastCaptureCount(array, capture_register_count); 702 SetLastCaptureCount(array, capture_register_count);
703 SetLastSubject(array, *subject); 703 SetLastSubject(array, *subject);
704 SetLastInput(array, *subject); 704 SetLastInput(array, *subject);
(...skipping 5417 matching lines...) Expand 10 before | Expand all | Expand 10 after
6122 } 6122 }
6123 6123
6124 return compiler.Assemble(&macro_assembler, 6124 return compiler.Assemble(&macro_assembler,
6125 node, 6125 node,
6126 data->capture_count, 6126 data->capture_count,
6127 pattern); 6127 pattern);
6128 } 6128 }
6129 6129
6130 6130
6131 }} // namespace v8::internal 6131 }} // namespace v8::internal
OLDNEW
« src/api.cc ('K') | « src/json-stringifier.h ('k') | src/lithium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698