| 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 "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/ast.h" | 9 #include "src/ast.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 446 } |
| 447 | 447 |
| 448 | 448 |
| 449 Handle<JSArray> Isolate::CaptureCurrentStackTrace( | 449 Handle<JSArray> Isolate::CaptureCurrentStackTrace( |
| 450 int frame_limit, StackTrace::StackTraceOptions options) { | 450 int frame_limit, StackTrace::StackTraceOptions options) { |
| 451 // Ensure no negative values. | 451 // Ensure no negative values. |
| 452 int limit = Max(frame_limit, 0); | 452 int limit = Max(frame_limit, 0); |
| 453 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 453 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
| 454 | 454 |
| 455 Handle<String> column_key = | 455 Handle<String> column_key = |
| 456 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("column")); | 456 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("column")); |
| 457 Handle<String> line_key = | 457 Handle<String> line_key = |
| 458 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("lineNumber")); | 458 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("lineNumber")); |
| 459 Handle<String> script_id_key = | 459 Handle<String> script_id_key = |
| 460 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("scriptId")); | 460 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptId")); |
| 461 Handle<String> script_name_key = | 461 Handle<String> script_name_key = |
| 462 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("scriptName")); | 462 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptName")); |
| 463 Handle<String> script_name_or_source_url_key = | 463 Handle<String> script_name_or_source_url_key = |
| 464 factory()->InternalizeOneByteString( | 464 factory()->InternalizeOneByteString( |
| 465 STATIC_ASCII_VECTOR("scriptNameOrSourceURL")); | 465 STATIC_CHAR_VECTOR("scriptNameOrSourceURL")); |
| 466 Handle<String> function_key = | 466 Handle<String> function_key = |
| 467 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("functionName")); | 467 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("functionName")); |
| 468 Handle<String> eval_key = | 468 Handle<String> eval_key = |
| 469 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("isEval")); | 469 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval")); |
| 470 Handle<String> constructor_key = | 470 Handle<String> constructor_key = |
| 471 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("isConstructor")); | 471 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isConstructor")); |
| 472 | 472 |
| 473 StackTraceFrameIterator it(this); | 473 StackTraceFrameIterator it(this); |
| 474 int frames_seen = 0; | 474 int frames_seen = 0; |
| 475 while (!it.done() && (frames_seen < limit)) { | 475 while (!it.done() && (frames_seen < limit)) { |
| 476 JavaScriptFrame* frame = it.frame(); | 476 JavaScriptFrame* frame = it.frame(); |
| 477 // Set initial size to the maximum inlining level + 1 for the outermost | 477 // Set initial size to the maximum inlining level + 1 for the outermost |
| 478 // function. | 478 // function. |
| 479 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 479 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 480 frame->Summarize(&frames); | 480 frame->Summarize(&frames); |
| 481 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 481 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 // Report the exception if it isn't caught by JavaScript code. | 985 // Report the exception if it isn't caught by JavaScript code. |
| 986 return handler == NULL; | 986 return handler == NULL; |
| 987 } | 987 } |
| 988 } | 988 } |
| 989 | 989 |
| 990 | 990 |
| 991 bool Isolate::IsErrorObject(Handle<Object> obj) { | 991 bool Isolate::IsErrorObject(Handle<Object> obj) { |
| 992 if (!obj->IsJSObject()) return false; | 992 if (!obj->IsJSObject()) return false; |
| 993 | 993 |
| 994 Handle<String> error_key = | 994 Handle<String> error_key = |
| 995 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error")); | 995 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("$Error")); |
| 996 Handle<Object> error_constructor = Object::GetProperty( | 996 Handle<Object> error_constructor = Object::GetProperty( |
| 997 js_builtins_object(), error_key).ToHandleChecked(); | 997 js_builtins_object(), error_key).ToHandleChecked(); |
| 998 | 998 |
| 999 DisallowHeapAllocation no_gc; | 999 DisallowHeapAllocation no_gc; |
| 1000 for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); | 1000 for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); |
| 1001 !iter.IsAtEnd(); iter.Advance()) { | 1001 !iter.IsAtEnd(); iter.Advance()) { |
| 1002 if (iter.GetCurrent()->IsJSProxy()) return false; | 1002 if (iter.GetCurrent()->IsJSProxy()) return false; |
| 1003 if (JSObject::cast(iter.GetCurrent())->map()->constructor() == | 1003 if (JSObject::cast(iter.GetCurrent())->map()->constructor() == |
| 1004 *error_constructor) { | 1004 *error_constructor) { |
| 1005 return true; | 1005 return true; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 | 1072 |
| 1073 Handle<Object> exception_arg = exception_handle; | 1073 Handle<Object> exception_arg = exception_handle; |
| 1074 // If the exception argument is a custom object, turn it into a string | 1074 // If the exception argument is a custom object, turn it into a string |
| 1075 // before throwing as uncaught exception. Note that the pending | 1075 // before throwing as uncaught exception. Note that the pending |
| 1076 // exception object to be set later must not be turned into a string. | 1076 // exception object to be set later must not be turned into a string. |
| 1077 if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) { | 1077 if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) { |
| 1078 MaybeHandle<Object> maybe_exception = | 1078 MaybeHandle<Object> maybe_exception = |
| 1079 Execution::ToDetailString(this, exception_arg); | 1079 Execution::ToDetailString(this, exception_arg); |
| 1080 if (!maybe_exception.ToHandle(&exception_arg)) { | 1080 if (!maybe_exception.ToHandle(&exception_arg)) { |
| 1081 exception_arg = factory()->InternalizeOneByteString( | 1081 exception_arg = factory()->InternalizeOneByteString( |
| 1082 STATIC_ASCII_VECTOR("exception")); | 1082 STATIC_CHAR_VECTOR("exception")); |
| 1083 } | 1083 } |
| 1084 } | 1084 } |
| 1085 Handle<Object> message_obj = MessageHandler::MakeMessageObject( | 1085 Handle<Object> message_obj = MessageHandler::MakeMessageObject( |
| 1086 this, | 1086 this, |
| 1087 "uncaught_exception", | 1087 "uncaught_exception", |
| 1088 location, | 1088 location, |
| 1089 HandleVector<Object>(&exception_arg, 1), | 1089 HandleVector<Object>(&exception_arg, 1), |
| 1090 stack_trace_object); | 1090 stack_trace_object); |
| 1091 thread_local_top()->pending_message_obj_ = *message_obj; | 1091 thread_local_top()->pending_message_obj_ = *message_obj; |
| 1092 if (location != NULL) { | 1092 if (location != NULL) { |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 if (prev_ && prev_->Intercept(flag)) return true; | 2381 if (prev_ && prev_->Intercept(flag)) return true; |
| 2382 // Then check whether this scope intercepts. | 2382 // Then check whether this scope intercepts. |
| 2383 if ((flag & intercept_mask_)) { | 2383 if ((flag & intercept_mask_)) { |
| 2384 intercepted_flags_ |= flag; | 2384 intercepted_flags_ |= flag; |
| 2385 return true; | 2385 return true; |
| 2386 } | 2386 } |
| 2387 return false; | 2387 return false; |
| 2388 } | 2388 } |
| 2389 | 2389 |
| 2390 } } // namespace v8::internal | 2390 } } // namespace v8::internal |
| OLD | NEW |