OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 unsigned number_of_captures; | 273 unsigned number_of_captures; |
274 const char* error_message = NULL; | 274 const char* error_message = NULL; |
275 | 275 |
276 malloc_failure = Failure::Exception(); | 276 malloc_failure = Failure::Exception(); |
277 JscreRegExp* code = jsRegExpCompile(two_byte_pattern->GetTwoByteData(), | 277 JscreRegExp* code = jsRegExpCompile(two_byte_pattern->GetTwoByteData(), |
278 pattern->length(), case_option, | 278 pattern->length(), case_option, |
279 multiline_option, &number_of_captures, | 279 multiline_option, &number_of_captures, |
280 &error_message, &JSREMalloc, &JSREFree); | 280 &error_message, &JSREMalloc, &JSREFree); |
281 | 281 |
282 if (code == NULL && malloc_failure->IsRetryAfterGC()) { | 282 if (code == NULL) { |
283 // Performs a GC, then retries. | 283 if (malloc_failure->IsRetryAfterGC()) { |
284 if (!Heap::CollectGarbage(malloc_failure->requested(), | 284 // Performs a GC, then retries. |
285 malloc_failure->allocation_space())) { | 285 if (!Heap::CollectGarbage(malloc_failure->requested(), |
| 286 malloc_failure->allocation_space())) { |
| 287 // TODO(1181417): Fix this. |
| 288 V8::FatalProcessOutOfMemory("RegExpImpl::JsreCompile"); |
| 289 } |
| 290 malloc_failure = Failure::Exception(); |
| 291 code = jsRegExpCompile(two_byte_pattern->GetTwoByteData(), |
| 292 pattern->length(), case_option, |
| 293 multiline_option, &number_of_captures, |
| 294 &error_message, &JSREMalloc, &JSREFree); |
| 295 } |
| 296 if (code == NULL && |
| 297 (malloc_failure->IsRetryAfterGC() || |
| 298 malloc_failure->IsOutOfMemoryFailure())) { |
286 // TODO(1181417): Fix this. | 299 // TODO(1181417): Fix this. |
287 V8::FatalProcessOutOfMemory("RegExpImpl::JsreCompile"); | 300 V8::FatalProcessOutOfMemory("RegExpImpl::JsreCompile"); |
288 } | 301 } |
289 malloc_failure = Failure::Exception(); | |
290 code = jsRegExpCompile(two_byte_pattern->GetTwoByteData(), | |
291 pattern->length(), case_option, | |
292 multiline_option, &number_of_captures, | |
293 &error_message, &JSREMalloc, &JSREFree); | |
294 if (code == NULL && malloc_failure->IsRetryAfterGC()) { | |
295 // TODO(1181417): Fix this. | |
296 V8::FatalProcessOutOfMemory("RegExpImpl::JsreCompile"); | |
297 } | |
298 } | 302 } |
299 | 303 |
300 if (error_message != NULL) { | 304 if (error_message != NULL) { |
301 // Throw an exception. | 305 // Throw an exception. |
302 SmartPointer<char> char_pattern = | 306 SmartPointer<char> char_pattern = |
303 two_byte_pattern->ToCString(DISALLOW_NULLS); | 307 two_byte_pattern->ToCString(DISALLOW_NULLS); |
304 Handle<JSArray> array = Factory::NewJSArray(2); | 308 Handle<JSArray> array = Factory::NewJSArray(2); |
305 SetElement(array, 0, Factory::NewStringFromUtf8(CStrVector(*char_pattern))); | 309 SetElement(array, 0, Factory::NewStringFromUtf8(CStrVector(*char_pattern))); |
306 SetElement(array, 1, Factory::NewStringFromUtf8(CStrVector(error_message))); | 310 SetElement(array, 1, Factory::NewStringFromUtf8(CStrVector(error_message))); |
307 Handle<Object> regexp_err = | 311 Handle<Object> regexp_err = |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 495 } |
492 | 496 |
493 | 497 |
494 ByteArray* RegExpImpl::JsreInternal(Handle<JSRegExp> re) { | 498 ByteArray* RegExpImpl::JsreInternal(Handle<JSRegExp> re) { |
495 Object* value = re->data(); | 499 Object* value = re->data(); |
496 ASSERT(value->IsFixedArray()); | 500 ASSERT(value->IsFixedArray()); |
497 return ByteArray::cast(FixedArray::cast(value)->get(INTERNAL_INDEX)); | 501 return ByteArray::cast(FixedArray::cast(value)->get(INTERNAL_INDEX)); |
498 } | 502 } |
499 | 503 |
500 }} // namespace v8::internal | 504 }} // namespace v8::internal |
OLD | NEW |