Index: src/regexp/regexp-macro-assembler.cc |
diff --git a/src/regexp/regexp-macro-assembler.cc b/src/regexp/regexp-macro-assembler.cc |
index 2e3a8a2f76877eb90bac9dd699ae03ba1e86a505..755b604f8c02fd52b2b43bd529f94d1fd451b13f 100644 |
--- a/src/regexp/regexp-macro-assembler.cc |
+++ b/src/regexp/regexp-macro-assembler.cc |
@@ -170,15 +170,18 @@ int NativeRegExpMacroAssembler::CheckStackGuardState( |
bool is_one_byte = subject_handle->IsOneByteRepresentationUnderneath(); |
StackLimitCheck check(isolate); |
- if (check.JsHasOverflowed()) { |
+ bool js_has_overflowed = check.JsHasOverflowed(); |
+ |
+ if (is_direct_call) { |
+ // Direct calls from JavaScript can be interrupted in two ways: |
+ // 1. A real stack overflow, in which case we let the caller throw the |
+ // exception. |
+ // 2. The stack guard was used to interrupt execution for another purpose, |
+ // forcing the call through the runtime system. |
+ return_value = js_has_overflowed ? EXCEPTION : RETRY; |
+ } else if (js_has_overflowed) { |
isolate->StackOverflow(); |
return_value = EXCEPTION; |
- } else if (is_direct_call) { |
- // If not real stack overflow the stack guard was used to interrupt |
- // execution for another purpose. If this is a direct call from JavaScript |
- // retry the RegExp forcing the call through the runtime system. |
- // Currently the direct call cannot handle a GC. |
- return_value = RETRY; |
} else { |
Object* result = isolate->stack_guard()->HandleInterrupts(); |
if (result->IsException(isolate)) return_value = EXCEPTION; |