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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 code = frame->LookupCode(); | 1060 code = frame->LookupCode(); |
1061 handler_sp = handler->address() + StackHandlerConstants::kSize; | 1061 handler_sp = handler->address() + StackHandlerConstants::kSize; |
1062 offset = Smi::cast(code->handler_table()->get(0))->value(); | 1062 offset = Smi::cast(code->handler_table()->get(0))->value(); |
1063 break; | 1063 break; |
1064 } | 1064 } |
1065 | 1065 |
1066 // For optimized frames we perform a lookup in the handler table. | 1066 // For optimized frames we perform a lookup in the handler table. |
1067 if (frame->is_optimized() && catchable_by_js) { | 1067 if (frame->is_optimized() && catchable_by_js) { |
1068 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame); | 1068 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame); |
1069 int stack_slots = 0; // Will contain stack slot count of frame. | 1069 int stack_slots = 0; // Will contain stack slot count of frame. |
1070 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots); | 1070 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, NULL); |
1071 if (offset >= 0) { | 1071 if (offset >= 0) { |
1072 // Compute the stack pointer from the frame pointer. This ensures that | 1072 // Compute the stack pointer from the frame pointer. This ensures that |
1073 // argument slots on the stack are dropped as returning would. | 1073 // argument slots on the stack are dropped as returning would. |
1074 Address return_sp = frame->fp() - | 1074 Address return_sp = frame->fp() - |
1075 StandardFrameConstants::kFixedFrameSizeFromFp - | 1075 StandardFrameConstants::kFixedFrameSizeFromFp - |
1076 stack_slots * kPointerSize; | 1076 stack_slots * kPointerSize; |
1077 | 1077 |
1078 // Gather information from the frame. | 1078 // Gather information from the frame. |
1079 code = frame->LookupCode(); | 1079 code = frame->LookupCode(); |
1080 handler_sp = return_sp; | 1080 handler_sp = return_sp; |
1081 handler_fp = frame->fp(); | 1081 handler_fp = frame->fp(); |
1082 break; | 1082 break; |
1083 } | 1083 } |
1084 } | 1084 } |
1085 | 1085 |
1086 // For JavaScript frames we perform a range lookup in the handler table. | 1086 // For JavaScript frames we perform a range lookup in the handler table. |
1087 if (frame->is_java_script() && catchable_by_js) { | 1087 if (frame->is_java_script() && catchable_by_js) { |
1088 JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(frame); | 1088 JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(frame); |
1089 int stack_slots = 0; // Will contain operand stack depth of handler. | 1089 int stack_slots = 0; // Will contain operand stack depth of handler. |
1090 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots); | 1090 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, NULL); |
1091 if (offset >= 0) { | 1091 if (offset >= 0) { |
1092 // Compute the stack pointer from the frame pointer. This ensures that | 1092 // Compute the stack pointer from the frame pointer. This ensures that |
1093 // operand stack slots are dropped for nested statements. Also restore | 1093 // operand stack slots are dropped for nested statements. Also restore |
1094 // correct context for the handler which is pushed within the try-block. | 1094 // correct context for the handler which is pushed within the try-block. |
1095 Address return_sp = frame->fp() - | 1095 Address return_sp = frame->fp() - |
1096 StandardFrameConstants::kFixedFrameSizeFromFp - | 1096 StandardFrameConstants::kFixedFrameSizeFromFp - |
1097 stack_slots * kPointerSize; | 1097 stack_slots * kPointerSize; |
1098 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); | 1098 STATIC_ASSERT(TryBlockConstant::kElementCount == 1); |
1099 context = Context::cast(Memory::Object_at(return_sp - kPointerSize)); | 1099 context = Context::cast(Memory::Object_at(return_sp - kPointerSize)); |
1100 | 1100 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 | 1136 |
1137 // For JSEntryStub frames we update the JS_ENTRY handler. | 1137 // For JSEntryStub frames we update the JS_ENTRY handler. |
1138 if (frame->is_entry() || frame->is_entry_construct()) { | 1138 if (frame->is_entry() || frame->is_entry_construct()) { |
1139 entry_handler = frame->top_handler()->next()->address(); | 1139 entry_handler = frame->top_handler()->next()->address(); |
1140 } | 1140 } |
1141 | 1141 |
1142 // For JavaScript frames we perform a lookup in the handler table. | 1142 // For JavaScript frames we perform a lookup in the handler table. |
1143 if (frame->is_java_script()) { | 1143 if (frame->is_java_script()) { |
1144 JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(frame); | 1144 JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(frame); |
1145 int stack_slots = 0; // The computed stack slot count is not used. | 1145 int stack_slots = 0; // The computed stack slot count is not used. |
1146 if (js_frame->LookupExceptionHandlerInTable(&stack_slots) > 0) { | 1146 HandlerTable::CatchPrediction prediction; |
1147 return CAUGHT_BY_JAVASCRIPT; | 1147 if (js_frame->LookupExceptionHandlerInTable(&stack_slots, &prediction) > |
| 1148 0) { |
| 1149 // We are conservative with our prediction: try-finally is considered |
| 1150 // to always rethrow, to meet the expectation of the debugger. |
| 1151 if (prediction == HandlerTable::CAUGHT) return CAUGHT_BY_JAVASCRIPT; |
1148 } | 1152 } |
1149 } | 1153 } |
1150 | 1154 |
1151 // The exception has been externally caught if and only if there is an | 1155 // The exception has been externally caught if and only if there is an |
1152 // external handler which is on top of the top-most JS_ENTRY handler. | 1156 // external handler which is on top of the top-most JS_ENTRY handler. |
1153 if (external_handler != nullptr && !try_catch_handler()->is_verbose_) { | 1157 if (external_handler != nullptr && !try_catch_handler()->is_verbose_) { |
1154 if (entry_handler == nullptr || entry_handler > external_handler) { | 1158 if (entry_handler == nullptr || entry_handler > external_handler) { |
1155 return CAUGHT_BY_EXTERNAL; | 1159 return CAUGHT_BY_EXTERNAL; |
1156 } | 1160 } |
1157 } | 1161 } |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 Handle<Object> Isolate::GetPromiseOnStackOnThrow() { | 1570 Handle<Object> Isolate::GetPromiseOnStackOnThrow() { |
1567 Handle<Object> undefined = factory()->undefined_value(); | 1571 Handle<Object> undefined = factory()->undefined_value(); |
1568 ThreadLocalTop* tltop = thread_local_top(); | 1572 ThreadLocalTop* tltop = thread_local_top(); |
1569 if (tltop->promise_on_stack_ == NULL) return undefined; | 1573 if (tltop->promise_on_stack_ == NULL) return undefined; |
1570 Handle<JSFunction> promise_function = tltop->promise_on_stack_->function(); | 1574 Handle<JSFunction> promise_function = tltop->promise_on_stack_->function(); |
1571 // Find the top-most try-catch or try-finally handler. | 1575 // Find the top-most try-catch or try-finally handler. |
1572 if (PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) return undefined; | 1576 if (PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) return undefined; |
1573 for (JavaScriptFrameIterator it(this); !it.done(); it.Advance()) { | 1577 for (JavaScriptFrameIterator it(this); !it.done(); it.Advance()) { |
1574 JavaScriptFrame* frame = it.frame(); | 1578 JavaScriptFrame* frame = it.frame(); |
1575 int stack_slots = 0; // The computed stack slot count is not used. | 1579 int stack_slots = 0; // The computed stack slot count is not used. |
1576 if (frame->LookupExceptionHandlerInTable(&stack_slots) > 0) { | 1580 if (frame->LookupExceptionHandlerInTable(&stack_slots, NULL) > 0) { |
1577 // Throwing inside a Promise only leads to a reject if not caught by an | 1581 // Throwing inside a Promise only leads to a reject if not caught by an |
1578 // inner try-catch or try-finally. | 1582 // inner try-catch or try-finally. |
1579 if (frame->function() == *promise_function) { | 1583 if (frame->function() == *promise_function) { |
1580 return tltop->promise_on_stack_->promise(); | 1584 return tltop->promise_on_stack_->promise(); |
1581 } | 1585 } |
1582 return undefined; | 1586 return undefined; |
1583 } | 1587 } |
1584 } | 1588 } |
1585 return undefined; | 1589 return undefined; |
1586 } | 1590 } |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 if (prev_ && prev_->Intercept(flag)) return true; | 2786 if (prev_ && prev_->Intercept(flag)) return true; |
2783 // Then check whether this scope intercepts. | 2787 // Then check whether this scope intercepts. |
2784 if ((flag & intercept_mask_)) { | 2788 if ((flag & intercept_mask_)) { |
2785 intercepted_flags_ |= flag; | 2789 intercepted_flags_ |= flag; |
2786 return true; | 2790 return true; |
2787 } | 2791 } |
2788 return false; | 2792 return false; |
2789 } | 2793 } |
2790 | 2794 |
2791 } } // namespace v8::internal | 2795 } } // namespace v8::internal |
OLD | NEW |