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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 Isolate* isolate_; | 396 Isolate* isolate_; |
397 Handle<Object> caller_; | 397 Handle<Object> caller_; |
398 | 398 |
399 bool seen_caller_; | 399 bool seen_caller_; |
400 int sloppy_frames_; | 400 int sloppy_frames_; |
401 bool encountered_strict_function_; | 401 bool encountered_strict_function_; |
402 }; | 402 }; |
403 | 403 |
404 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, | 404 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, |
405 Handle<Object> caller) { | 405 Handle<Object> caller) { |
| 406 DisallowJavascriptExecution no_js(this); |
| 407 |
406 // Get stack trace limit. | 408 // Get stack trace limit. |
407 Handle<JSObject> error = error_function(); | 409 Handle<JSObject> error = error_function(); |
408 Handle<String> stackTraceLimit = | 410 Handle<String> stackTraceLimit = |
409 factory()->InternalizeUtf8String("stackTraceLimit"); | 411 factory()->InternalizeUtf8String("stackTraceLimit"); |
410 DCHECK(!stackTraceLimit.is_null()); | 412 DCHECK(!stackTraceLimit.is_null()); |
411 Handle<Object> stack_trace_limit = | 413 Handle<Object> stack_trace_limit = |
412 JSReceiver::GetDataProperty(error, stackTraceLimit); | 414 JSReceiver::GetDataProperty(error, stackTraceLimit); |
413 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); | 415 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); |
414 int limit = FastD2IChecked(stack_trace_limit->Number()); | 416 int limit = FastD2IChecked(stack_trace_limit->Number()); |
415 limit = Max(limit, 0); // Ensure that limit is not negative. | 417 limit = Max(limit, 0); // Ensure that limit is not negative. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 return Smi::cast(maybe_code)->value(); | 733 return Smi::cast(maybe_code)->value(); |
732 } else { | 734 } else { |
733 AbstractCode* abstract_code = AbstractCode::cast(maybe_code); | 735 AbstractCode* abstract_code = AbstractCode::cast(maybe_code); |
734 int code_offset = Smi::cast(elements->get(index + 3))->value(); | 736 int code_offset = Smi::cast(elements->get(index + 3))->value(); |
735 return abstract_code->SourcePosition(code_offset); | 737 return abstract_code->SourcePosition(code_offset); |
736 } | 738 } |
737 } | 739 } |
738 | 740 |
739 Handle<JSArray> Isolate::CaptureCurrentStackTrace( | 741 Handle<JSArray> Isolate::CaptureCurrentStackTrace( |
740 int frame_limit, StackTrace::StackTraceOptions options) { | 742 int frame_limit, StackTrace::StackTraceOptions options) { |
| 743 DisallowJavascriptExecution no_js(this); |
741 CaptureStackTraceHelper helper(this, options); | 744 CaptureStackTraceHelper helper(this, options); |
742 | 745 |
743 // Ensure no negative values. | 746 // Ensure no negative values. |
744 int limit = Max(frame_limit, 0); | 747 int limit = Max(frame_limit, 0); |
745 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 748 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
746 Handle<FixedArray> stack_trace_elems( | 749 Handle<FixedArray> stack_trace_elems( |
747 FixedArray::cast(stack_trace->elements()), this); | 750 FixedArray::cast(stack_trace->elements()), this); |
748 | 751 |
749 int frames_seen = 0; | 752 int frames_seen = 0; |
750 for (StackTraceFrameIterator it(this); !it.done() && (frames_seen < limit); | 753 for (StackTraceFrameIterator it(this); !it.done() && (frames_seen < limit); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 { | 917 { |
915 // Leaving JavaScript. | 918 // Leaving JavaScript. |
916 VMState<EXTERNAL> state(this); | 919 VMState<EXTERNAL> state(this); |
917 return callback(v8::Utils::ToLocal(accessing_context), | 920 return callback(v8::Utils::ToLocal(accessing_context), |
918 v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(data)); | 921 v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(data)); |
919 } | 922 } |
920 } | 923 } |
921 | 924 |
922 | 925 |
923 Object* Isolate::StackOverflow() { | 926 Object* Isolate::StackOverflow() { |
| 927 DisallowJavascriptExecution no_js(this); |
924 HandleScope scope(this); | 928 HandleScope scope(this); |
925 // At this point we cannot create an Error object using its javascript | 929 // At this point we cannot create an Error object using its javascript |
926 // constructor. Instead, we copy the pre-constructed boilerplate and | 930 // constructor. Instead, we copy the pre-constructed boilerplate and |
927 // attach the stack trace as a hidden property. | 931 // attach the stack trace as a hidden property. |
928 Handle<Object> exception; | 932 Handle<Object> exception; |
929 if (bootstrapper()->IsActive()) { | 933 if (bootstrapper()->IsActive()) { |
930 // There is no boilerplate to use during bootstrapping. | 934 // There is no boilerplate to use during bootstrapping. |
931 exception = factory()->NewStringFromAsciiChecked( | 935 exception = factory()->NewStringFromAsciiChecked( |
932 MessageTemplate::TemplateString(MessageTemplate::kStackOverflow)); | 936 MessageTemplate::TemplateString(MessageTemplate::kStackOverflow)); |
933 } else { | 937 } else { |
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3085 // Then check whether this scope intercepts. | 3089 // Then check whether this scope intercepts. |
3086 if ((flag & intercept_mask_)) { | 3090 if ((flag & intercept_mask_)) { |
3087 intercepted_flags_ |= flag; | 3091 intercepted_flags_ |= flag; |
3088 return true; | 3092 return true; |
3089 } | 3093 } |
3090 return false; | 3094 return false; |
3091 } | 3095 } |
3092 | 3096 |
3093 } // namespace internal | 3097 } // namespace internal |
3094 } // namespace v8 | 3098 } // namespace v8 |
OLD | NEW |