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/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
953 VMState<EXTERNAL> state(this); | 953 VMState<EXTERNAL> state(this); |
954 return callback(v8::Utils::ToLocal(accessing_context), | 954 return callback(v8::Utils::ToLocal(accessing_context), |
955 v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(data)); | 955 v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(data)); |
956 } | 956 } |
957 } | 957 } |
958 | 958 |
959 | 959 |
960 Object* Isolate::StackOverflow() { | 960 Object* Isolate::StackOverflow() { |
961 DisallowJavascriptExecution no_js(this); | 961 DisallowJavascriptExecution no_js(this); |
962 HandleScope scope(this); | 962 HandleScope scope(this); |
963 // At this point we cannot create an Error object using its javascript | |
964 // constructor. Instead, we copy the pre-constructed boilerplate and | |
965 // attach the stack trace as a hidden property. | |
966 Handle<Object> exception; | 963 Handle<Object> exception; |
967 if (bootstrapper()->IsActive()) { | 964 if (bootstrapper()->IsActive()) { |
968 // There is no boilerplate to use during bootstrapping. | |
969 exception = factory()->NewStringFromAsciiChecked( | 965 exception = factory()->NewStringFromAsciiChecked( |
Yang
2016/07/19 15:06:46
I wonder whether we could remove this special case
jgruber
2016/07/20 14:48:39
Done. Will update the other sites that check for b
| |
970 MessageTemplate::TemplateString(MessageTemplate::kStackOverflow)); | 966 MessageTemplate::TemplateString(MessageTemplate::kStackOverflow)); |
971 } else { | 967 } else { |
972 Handle<JSObject> boilerplate = stack_overflow_boilerplate(); | 968 // Disable detailed stack trace collection while generating the stack |
973 Handle<JSObject> copy = factory()->CopyJSObject(boilerplate); | 969 // overflow error. |
974 CaptureAndSetSimpleStackTrace(copy, factory()->undefined_value()); | 970 bool old_detailed_enabled = capture_stack_trace_for_uncaught_exceptions_; |
975 exception = copy; | 971 capture_stack_trace_for_uncaught_exceptions_ = false; |
972 | |
973 Handle<JSFunction> fun = range_error_function(); | |
974 Handle<Object> msg = factory()->NewStringFromAsciiChecked( | |
975 MessageTemplate::TemplateString(MessageTemplate::kStackOverflow)); | |
976 exception = handle(ConstructError(this, fun, fun, msg), this); | |
Yang
2016/07/19 15:06:46
What if we have an exception in ConstructError? We
jgruber
2016/07/20 14:48:39
Good catch. Done.
| |
977 | |
978 capture_stack_trace_for_uncaught_exceptions_ = old_detailed_enabled; | |
976 } | 979 } |
977 Throw(*exception, nullptr); | 980 Throw(*exception, nullptr); |
978 | 981 |
979 #ifdef VERIFY_HEAP | 982 #ifdef VERIFY_HEAP |
980 if (FLAG_verify_heap && FLAG_stress_compaction) { | 983 if (FLAG_verify_heap && FLAG_stress_compaction) { |
981 heap()->CollectAllGarbage(Heap::kNoGCFlags, "trigger compaction"); | 984 heap()->CollectAllGarbage(Heap::kNoGCFlags, "trigger compaction"); |
982 } | 985 } |
983 #endif // VERIFY_HEAP | 986 #endif // VERIFY_HEAP |
984 | 987 |
985 return heap()->exception(); | 988 return heap()->exception(); |
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3129 // Then check whether this scope intercepts. | 3132 // Then check whether this scope intercepts. |
3130 if ((flag & intercept_mask_)) { | 3133 if ((flag & intercept_mask_)) { |
3131 intercepted_flags_ |= flag; | 3134 intercepted_flags_ |= flag; |
3132 return true; | 3135 return true; |
3133 } | 3136 } |
3134 return false; | 3137 return false; |
3135 } | 3138 } |
3136 | 3139 |
3137 } // namespace internal | 3140 } // namespace internal |
3138 } // namespace v8 | 3141 } // namespace v8 |
OLD | NEW |