| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/regexp/regexp-macro-assembler.h" | 5 #include "src/regexp/regexp-macro-assembler.h" |
| 6 | 6 |
| 7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
| 8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
| 9 #include "src/regexp/regexp-stack.h" | 9 #include "src/regexp/regexp-stack.h" |
| 10 #include "src/simulator.h" | 10 #include "src/simulator.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 DCHECK(re_code->instruction_start() <= *return_address); | 163 DCHECK(re_code->instruction_start() <= *return_address); |
| 164 DCHECK(*return_address <= re_code->instruction_end()); | 164 DCHECK(*return_address <= re_code->instruction_end()); |
| 165 int return_value = 0; | 165 int return_value = 0; |
| 166 // Prepare for possible GC. | 166 // Prepare for possible GC. |
| 167 HandleScope handles(isolate); | 167 HandleScope handles(isolate); |
| 168 Handle<Code> code_handle(re_code); | 168 Handle<Code> code_handle(re_code); |
| 169 Handle<String> subject_handle(*subject); | 169 Handle<String> subject_handle(*subject); |
| 170 bool is_one_byte = subject_handle->IsOneByteRepresentationUnderneath(); | 170 bool is_one_byte = subject_handle->IsOneByteRepresentationUnderneath(); |
| 171 | 171 |
| 172 StackLimitCheck check(isolate); | 172 StackLimitCheck check(isolate); |
| 173 bool js_has_overflowed = check.JsHasOverflowed(); | 173 if (check.JsHasOverflowed()) { |
| 174 | |
| 175 if (is_direct_call) { | |
| 176 // Direct calls from JavaScript can be interrupted in two ways: | |
| 177 // 1. A real stack overflow, in which case we let the caller throw the | |
| 178 // exception. | |
| 179 // 2. The stack guard was used to interrupt execution for another purpose, | |
| 180 // forcing the call through the runtime system. | |
| 181 return_value = js_has_overflowed ? EXCEPTION : RETRY; | |
| 182 } else if (js_has_overflowed) { | |
| 183 isolate->StackOverflow(); | 174 isolate->StackOverflow(); |
| 184 return_value = EXCEPTION; | 175 return_value = EXCEPTION; |
| 176 } else if (is_direct_call) { |
| 177 // If not real stack overflow the stack guard was used to interrupt |
| 178 // execution for another purpose. If this is a direct call from JavaScript |
| 179 // retry the RegExp forcing the call through the runtime system. |
| 180 // Currently the direct call cannot handle a GC. |
| 181 return_value = RETRY; |
| 185 } else { | 182 } else { |
| 186 Object* result = isolate->stack_guard()->HandleInterrupts(); | 183 Object* result = isolate->stack_guard()->HandleInterrupts(); |
| 187 if (result->IsException(isolate)) return_value = EXCEPTION; | 184 if (result->IsException(isolate)) return_value = EXCEPTION; |
| 188 } | 185 } |
| 189 | 186 |
| 190 DisallowHeapAllocation no_gc; | 187 DisallowHeapAllocation no_gc; |
| 191 | 188 |
| 192 if (*code_handle != re_code) { // Return address no longer valid | 189 if (*code_handle != re_code) { // Return address no longer valid |
| 193 intptr_t delta = code_handle->address() - re_code->address(); | 190 intptr_t delta = code_handle->address() - re_code->address(); |
| 194 // Overwrite the return address on the stack. | 191 // Overwrite the return address on the stack. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 354 } |
| 358 *stack_base = new_stack_base; | 355 *stack_base = new_stack_base; |
| 359 intptr_t stack_content_size = old_stack_base - stack_pointer; | 356 intptr_t stack_content_size = old_stack_base - stack_pointer; |
| 360 return new_stack_base - stack_content_size; | 357 return new_stack_base - stack_content_size; |
| 361 } | 358 } |
| 362 | 359 |
| 363 #endif // V8_INTERPRETED_REGEXP | 360 #endif // V8_INTERPRETED_REGEXP |
| 364 | 361 |
| 365 } // namespace internal | 362 } // namespace internal |
| 366 } // namespace v8 | 363 } // namespace v8 |
| OLD | NEW |