OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 for (int i = 0; i < cursor; i++) { | 620 for (int i = 0; i < cursor; i++) { |
621 new_elements->set(i, elements->get(i)); | 621 new_elements->set(i, elements->get(i)); |
622 } | 622 } |
623 elements = new_elements; | 623 elements = new_elements; |
624 } | 624 } |
625 ASSERT(cursor + 4 <= elements->length()); | 625 ASSERT(cursor + 4 <= elements->length()); |
626 | 626 |
627 Handle<Object> recv = frames[i].receiver(); | 627 Handle<Object> recv = frames[i].receiver(); |
628 Handle<JSFunction> fun = frames[i].function(); | 628 Handle<JSFunction> fun = frames[i].function(); |
629 Handle<Code> code = frames[i].code(); | 629 Handle<Code> code = frames[i].code(); |
630 Handle<Smi> offset(Smi::FromInt(frames[i].offset())); | 630 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); |
631 elements->set(cursor++, *recv); | 631 elements->set(cursor++, *recv); |
632 elements->set(cursor++, *fun); | 632 elements->set(cursor++, *fun); |
633 elements->set(cursor++, *code); | 633 elements->set(cursor++, *code); |
634 elements->set(cursor++, *offset); | 634 elements->set(cursor++, *offset); |
635 } | 635 } |
636 } | 636 } |
637 } | 637 } |
638 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); | 638 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); |
639 result->set_length(Smi::FromInt(cursor)); | 639 result->set_length(Smi::FromInt(cursor)); |
640 return result; | 640 return result; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 int column_offset = position - start; | 703 int column_offset = position - start; |
704 if (relative_line_number == 0) { | 704 if (relative_line_number == 0) { |
705 // For the case where the code is on the same line as the script | 705 // For the case where the code is on the same line as the script |
706 // tag. | 706 // tag. |
707 column_offset += script->column_offset()->value(); | 707 column_offset += script->column_offset()->value(); |
708 } | 708 } |
709 CHECK_NOT_EMPTY_HANDLE( | 709 CHECK_NOT_EMPTY_HANDLE( |
710 this, | 710 this, |
711 JSObject::SetLocalPropertyIgnoreAttributes( | 711 JSObject::SetLocalPropertyIgnoreAttributes( |
712 stack_frame, column_key, | 712 stack_frame, column_key, |
713 Handle<Smi>(Smi::FromInt(column_offset + 1)), NONE)); | 713 Handle<Smi>(Smi::FromInt(column_offset + 1), this), NONE)); |
714 } | 714 } |
715 CHECK_NOT_EMPTY_HANDLE( | 715 CHECK_NOT_EMPTY_HANDLE( |
716 this, | 716 this, |
717 JSObject::SetLocalPropertyIgnoreAttributes( | 717 JSObject::SetLocalPropertyIgnoreAttributes( |
718 stack_frame, line_key, | 718 stack_frame, line_key, |
719 Handle<Smi>(Smi::FromInt(line_number + 1)), NONE)); | 719 Handle<Smi>(Smi::FromInt(line_number + 1), this), NONE)); |
720 } | 720 } |
721 | 721 |
722 if (options & StackTrace::kScriptName) { | 722 if (options & StackTrace::kScriptName) { |
723 Handle<Object> script_name(script->name(), this); | 723 Handle<Object> script_name(script->name(), this); |
724 CHECK_NOT_EMPTY_HANDLE(this, | 724 CHECK_NOT_EMPTY_HANDLE(this, |
725 JSObject::SetLocalPropertyIgnoreAttributes( | 725 JSObject::SetLocalPropertyIgnoreAttributes( |
726 stack_frame, script_key, script_name, NONE)); | 726 stack_frame, script_key, script_name, NONE)); |
727 } | 727 } |
728 | 728 |
729 if (options & StackTrace::kScriptNameOrSourceURL) { | 729 if (options & StackTrace::kScriptNameOrSourceURL) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 | 860 |
861 // Get the data object from access check info. | 861 // Get the data object from access check info. |
862 JSFunction* constructor = JSFunction::cast(receiver->map()->constructor()); | 862 JSFunction* constructor = JSFunction::cast(receiver->map()->constructor()); |
863 if (!constructor->shared()->IsApiFunction()) return; | 863 if (!constructor->shared()->IsApiFunction()) return; |
864 Object* data_obj = | 864 Object* data_obj = |
865 constructor->shared()->get_api_func_data()->access_check_info(); | 865 constructor->shared()->get_api_func_data()->access_check_info(); |
866 if (data_obj == heap_.undefined_value()) return; | 866 if (data_obj == heap_.undefined_value()) return; |
867 | 867 |
868 HandleScope scope(this); | 868 HandleScope scope(this); |
869 Handle<JSObject> receiver_handle(receiver); | 869 Handle<JSObject> receiver_handle(receiver); |
870 Handle<Object> data(AccessCheckInfo::cast(data_obj)->data()); | 870 Handle<Object> data(AccessCheckInfo::cast(data_obj)->data(), this); |
871 { VMState state(this, EXTERNAL); | 871 { VMState state(this, EXTERNAL); |
872 thread_local_top()->failed_access_check_callback_( | 872 thread_local_top()->failed_access_check_callback_( |
873 v8::Utils::ToLocal(receiver_handle), | 873 v8::Utils::ToLocal(receiver_handle), |
874 type, | 874 type, |
875 v8::Utils::ToLocal(data)); | 875 v8::Utils::ToLocal(data)); |
876 } | 876 } |
877 } | 877 } |
878 | 878 |
879 | 879 |
880 enum MayAccessDecision { | 880 enum MayAccessDecision { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 "Uncaught RangeError: Maximum call stack size exceeded"; | 1007 "Uncaught RangeError: Maximum call stack size exceeded"; |
1008 | 1008 |
1009 | 1009 |
1010 Failure* Isolate::StackOverflow() { | 1010 Failure* Isolate::StackOverflow() { |
1011 HandleScope scope(this); | 1011 HandleScope scope(this); |
1012 // At this point we cannot create an Error object using its javascript | 1012 // At this point we cannot create an Error object using its javascript |
1013 // constructor. Instead, we copy the pre-constructed boilerplate and | 1013 // constructor. Instead, we copy the pre-constructed boilerplate and |
1014 // attach the stack trace as a hidden property. | 1014 // attach the stack trace as a hidden property. |
1015 Handle<String> key = factory()->stack_overflow_symbol(); | 1015 Handle<String> key = factory()->stack_overflow_symbol(); |
1016 Handle<JSObject> boilerplate = | 1016 Handle<JSObject> boilerplate = |
1017 Handle<JSObject>::cast(GetProperty(js_builtins_object(), key)); | 1017 Handle<JSObject>::cast(GetProperty(this, js_builtins_object(), key)); |
1018 Handle<JSObject> exception = Copy(boilerplate); | 1018 Handle<JSObject> exception = Copy(boilerplate); |
1019 DoThrow(*exception, NULL); | 1019 DoThrow(*exception, NULL); |
1020 | 1020 |
1021 // Get stack trace limit. | 1021 // Get stack trace limit. |
1022 Handle<Object> error = GetProperty(js_builtins_object(), "$Error"); | 1022 Handle<Object> error = GetProperty(js_builtins_object(), "$Error"); |
1023 if (!error->IsJSObject()) return Failure::Exception(); | 1023 if (!error->IsJSObject()) return Failure::Exception(); |
1024 Handle<Object> stack_trace_limit = | 1024 Handle<Object> stack_trace_limit = |
1025 GetProperty(Handle<JSObject>::cast(error), "stackTraceLimit"); | 1025 GetProperty(Handle<JSObject>::cast(error), "stackTraceLimit"); |
1026 if (!stack_trace_limit->IsNumber()) return Failure::Exception(); | 1026 if (!stack_trace_limit->IsNumber()) return Failure::Exception(); |
1027 int limit = static_cast<int>(stack_trace_limit->Number()); | 1027 int limit = static_cast<int>(stack_trace_limit->Number()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 } | 1088 } |
1089 | 1089 |
1090 | 1090 |
1091 void Isolate::PrintCurrentStackTrace(FILE* out) { | 1091 void Isolate::PrintCurrentStackTrace(FILE* out) { |
1092 StackTraceFrameIterator it(this); | 1092 StackTraceFrameIterator it(this); |
1093 while (!it.done()) { | 1093 while (!it.done()) { |
1094 HandleScope scope(this); | 1094 HandleScope scope(this); |
1095 // Find code position if recorded in relocation info. | 1095 // Find code position if recorded in relocation info. |
1096 JavaScriptFrame* frame = it.frame(); | 1096 JavaScriptFrame* frame = it.frame(); |
1097 int pos = frame->LookupCode()->SourcePosition(frame->pc()); | 1097 int pos = frame->LookupCode()->SourcePosition(frame->pc()); |
1098 Handle<Object> pos_obj(Smi::FromInt(pos)); | 1098 Handle<Object> pos_obj(Smi::FromInt(pos), this); |
1099 // Fetch function and receiver. | 1099 // Fetch function and receiver. |
1100 Handle<JSFunction> fun(JSFunction::cast(frame->function())); | 1100 Handle<JSFunction> fun(JSFunction::cast(frame->function())); |
1101 Handle<Object> recv(frame->receiver()); | 1101 Handle<Object> recv(frame->receiver(), this); |
1102 // Advance to the next JavaScript frame and determine if the | 1102 // Advance to the next JavaScript frame and determine if the |
1103 // current frame is the top-level frame. | 1103 // current frame is the top-level frame. |
1104 it.Advance(); | 1104 it.Advance(); |
1105 Handle<Object> is_top_level = it.done() | 1105 Handle<Object> is_top_level = it.done() |
1106 ? factory()->true_value() | 1106 ? factory()->true_value() |
1107 : factory()->false_value(); | 1107 : factory()->false_value(); |
1108 // Generate and print stack trace line. | 1108 // Generate and print stack trace line. |
1109 Handle<String> line = | 1109 Handle<String> line = |
1110 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 1110 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
1111 if (line->length() > 0) { | 1111 if (line->length() > 0) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 } | 1181 } |
1182 } | 1182 } |
1183 return false; | 1183 return false; |
1184 } | 1184 } |
1185 | 1185 |
1186 | 1186 |
1187 void Isolate::DoThrow(Object* exception, MessageLocation* location) { | 1187 void Isolate::DoThrow(Object* exception, MessageLocation* location) { |
1188 ASSERT(!has_pending_exception()); | 1188 ASSERT(!has_pending_exception()); |
1189 | 1189 |
1190 HandleScope scope(this); | 1190 HandleScope scope(this); |
1191 Handle<Object> exception_handle(exception); | 1191 Handle<Object> exception_handle(exception, this); |
1192 | 1192 |
1193 // Determine reporting and whether the exception is caught externally. | 1193 // Determine reporting and whether the exception is caught externally. |
1194 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 1194 bool catchable_by_javascript = is_catchable_by_javascript(exception); |
1195 bool can_be_caught_externally = false; | 1195 bool can_be_caught_externally = false; |
1196 bool should_report_exception = | 1196 bool should_report_exception = |
1197 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); | 1197 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); |
1198 bool report_exception = catchable_by_javascript && should_report_exception; | 1198 bool report_exception = catchable_by_javascript && should_report_exception; |
1199 bool try_catch_needs_message = | 1199 bool try_catch_needs_message = |
1200 can_be_caught_externally && try_catch_handler()->capture_message_; | 1200 can_be_caught_externally && try_catch_handler()->capture_message_; |
1201 bool bootstrapping = bootstrapper()->IsActive(); | 1201 bool bootstrapping = bootstrapper()->IsActive(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 context()->mark_out_of_memory(); | 1356 context()->mark_out_of_memory(); |
1357 } else if (thread_local_top_.pending_exception_ == | 1357 } else if (thread_local_top_.pending_exception_ == |
1358 heap()->termination_exception()) { | 1358 heap()->termination_exception()) { |
1359 // Do nothing: if needed, the exception has been already propagated to | 1359 // Do nothing: if needed, the exception has been already propagated to |
1360 // v8::TryCatch. | 1360 // v8::TryCatch. |
1361 } else { | 1361 } else { |
1362 if (thread_local_top_.has_pending_message_) { | 1362 if (thread_local_top_.has_pending_message_) { |
1363 thread_local_top_.has_pending_message_ = false; | 1363 thread_local_top_.has_pending_message_ = false; |
1364 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { | 1364 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { |
1365 HandleScope scope(this); | 1365 HandleScope scope(this); |
1366 Handle<Object> message_obj(thread_local_top_.pending_message_obj_); | 1366 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, |
| 1367 this); |
1367 if (thread_local_top_.pending_message_script_ != NULL) { | 1368 if (thread_local_top_.pending_message_script_ != NULL) { |
1368 Handle<Script> script(thread_local_top_.pending_message_script_); | 1369 Handle<Script> script(thread_local_top_.pending_message_script_); |
1369 int start_pos = thread_local_top_.pending_message_start_pos_; | 1370 int start_pos = thread_local_top_.pending_message_start_pos_; |
1370 int end_pos = thread_local_top_.pending_message_end_pos_; | 1371 int end_pos = thread_local_top_.pending_message_end_pos_; |
1371 MessageLocation location(script, start_pos, end_pos); | 1372 MessageLocation location(script, start_pos, end_pos); |
1372 MessageHandler::ReportMessage(this, &location, message_obj); | 1373 MessageHandler::ReportMessage(this, &location, message_obj); |
1373 } else { | 1374 } else { |
1374 MessageHandler::ReportMessage(this, NULL, message_obj); | 1375 MessageHandler::ReportMessage(this, NULL, message_obj); |
1375 } | 1376 } |
1376 } | 1377 } |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 | 2280 |
2280 #ifdef DEBUG | 2281 #ifdef DEBUG |
2281 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2282 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2282 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2283 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2283 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2284 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2284 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2285 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2285 #undef ISOLATE_FIELD_OFFSET | 2286 #undef ISOLATE_FIELD_OFFSET |
2286 #endif | 2287 #endif |
2287 | 2288 |
2288 } } // namespace v8::internal | 2289 } } // namespace v8::internal |
OLD | NEW |