| 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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 // If the abort-on-uncaught-exception flag is specified, abort on any | 1192 // If the abort-on-uncaught-exception flag is specified, abort on any |
| 1193 // exception not caught by JavaScript, even when an external handler is | 1193 // exception not caught by JavaScript, even when an external handler is |
| 1194 // present. This flag is intended for use by JavaScript developers, so | 1194 // present. This flag is intended for use by JavaScript developers, so |
| 1195 // print a user-friendly stack trace (not an internal one). | 1195 // print a user-friendly stack trace (not an internal one). |
| 1196 if (fatal_exception_depth == 0 && | 1196 if (fatal_exception_depth == 0 && |
| 1197 FLAG_abort_on_uncaught_exception && | 1197 FLAG_abort_on_uncaught_exception && |
| 1198 (report_exception || can_be_caught_externally)) { | 1198 (report_exception || can_be_caught_externally)) { |
| 1199 fatal_exception_depth++; | 1199 fatal_exception_depth++; |
| 1200 PrintF(stderr, | 1200 PrintF(stderr, |
| 1201 "%s\n\nFROM\n", | 1201 "%s\n\nFROM\n", |
| 1202 *MessageHandler::GetLocalizedMessage(this, message_obj)); | 1202 MessageHandler::GetLocalizedMessage(this, message_obj).get()); |
| 1203 PrintCurrentStackTrace(stderr); | 1203 PrintCurrentStackTrace(stderr); |
| 1204 OS::Abort(); | 1204 OS::Abort(); |
| 1205 } | 1205 } |
| 1206 } else if (location != NULL && !location->script().is_null()) { | 1206 } else if (location != NULL && !location->script().is_null()) { |
| 1207 // We are bootstrapping and caught an error where the location is set | 1207 // We are bootstrapping and caught an error where the location is set |
| 1208 // and we have a script for the location. | 1208 // and we have a script for the location. |
| 1209 // In this case we could have an extension (or an internal error | 1209 // In this case we could have an extension (or an internal error |
| 1210 // somewhere) and we print out the line number at which the error occured | 1210 // somewhere) and we print out the line number at which the error occured |
| 1211 // to the console for easier debugging. | 1211 // to the console for easier debugging. |
| 1212 int line_number = GetScriptLineNumberSafe(location->script(), | 1212 int line_number = GetScriptLineNumberSafe(location->script(), |
| 1213 location->start_pos()); | 1213 location->start_pos()); |
| 1214 if (exception->IsString() && location->script()->name()->IsString()) { | 1214 if (exception->IsString() && location->script()->name()->IsString()) { |
| 1215 OS::PrintError( | 1215 OS::PrintError( |
| 1216 "Extension or internal compilation error: %s in %s at line %d.\n", | 1216 "Extension or internal compilation error: %s in %s at line %d.\n", |
| 1217 *String::cast(exception)->ToCString(), | 1217 String::cast(exception)->ToCString().get(), |
| 1218 *String::cast(location->script()->name())->ToCString(), | 1218 String::cast(location->script()->name())->ToCString().get(), |
| 1219 line_number + 1); | 1219 line_number + 1); |
| 1220 } else if (location->script()->name()->IsString()) { | 1220 } else if (location->script()->name()->IsString()) { |
| 1221 OS::PrintError( | 1221 OS::PrintError( |
| 1222 "Extension or internal compilation error in %s at line %d.\n", | 1222 "Extension or internal compilation error in %s at line %d.\n", |
| 1223 *String::cast(location->script()->name())->ToCString(), | 1223 String::cast(location->script()->name())->ToCString().get(), |
| 1224 line_number + 1); | 1224 line_number + 1); |
| 1225 } else { | 1225 } else { |
| 1226 OS::PrintError("Extension or internal compilation error.\n"); | 1226 OS::PrintError("Extension or internal compilation error.\n"); |
| 1227 } | 1227 } |
| 1228 } | 1228 } |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 // Save the message for reporting if the the exception remains uncaught. | 1231 // Save the message for reporting if the the exception remains uncaught. |
| 1232 thread_local_top()->has_pending_message_ = report_exception; | 1232 thread_local_top()->has_pending_message_ = report_exception; |
| 1233 | 1233 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 Script::cast(thread_local_top_.pending_message_script_)); | 1333 Script::cast(thread_local_top_.pending_message_script_)); |
| 1334 int start_pos = thread_local_top_.pending_message_start_pos_; | 1334 int start_pos = thread_local_top_.pending_message_start_pos_; |
| 1335 int end_pos = thread_local_top_.pending_message_end_pos_; | 1335 int end_pos = thread_local_top_.pending_message_end_pos_; |
| 1336 return MessageLocation(script, start_pos, end_pos); | 1336 return MessageLocation(script, start_pos, end_pos); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 return MessageLocation(); | 1339 return MessageLocation(); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 | 1342 |
| 1343 void Isolate::TraceException(bool flag) { | |
| 1344 FLAG_trace_exception = flag; // TODO(isolates): This is an unfortunate use. | |
| 1345 } | |
| 1346 | |
| 1347 | |
| 1348 bool Isolate::OptionalRescheduleException(bool is_bottom_call) { | 1343 bool Isolate::OptionalRescheduleException(bool is_bottom_call) { |
| 1349 ASSERT(has_pending_exception()); | 1344 ASSERT(has_pending_exception()); |
| 1350 PropagatePendingExceptionToExternalTryCatch(); | 1345 PropagatePendingExceptionToExternalTryCatch(); |
| 1351 | 1346 |
| 1352 // Always reschedule out of memory exceptions. | 1347 // Always reschedule out of memory exceptions. |
| 1353 if (!is_out_of_memory()) { | 1348 if (!is_out_of_memory()) { |
| 1354 bool is_termination_exception = | 1349 bool is_termination_exception = |
| 1355 pending_exception() == heap_.termination_exception(); | 1350 pending_exception() == heap_.termination_exception(); |
| 1356 | 1351 |
| 1357 // Do not reschedule the exception if this is the bottom call. | 1352 // Do not reschedule the exception if this is the bottom call. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 // We must stop the logger before we tear down other components. | 1698 // We must stop the logger before we tear down other components. |
| 1704 Sampler* sampler = logger_->sampler(); | 1699 Sampler* sampler = logger_->sampler(); |
| 1705 if (sampler && sampler->IsActive()) sampler->Stop(); | 1700 if (sampler && sampler->IsActive()) sampler->Stop(); |
| 1706 | 1701 |
| 1707 delete deoptimizer_data_; | 1702 delete deoptimizer_data_; |
| 1708 deoptimizer_data_ = NULL; | 1703 deoptimizer_data_ = NULL; |
| 1709 builtins_.TearDown(); | 1704 builtins_.TearDown(); |
| 1710 bootstrapper_->TearDown(); | 1705 bootstrapper_->TearDown(); |
| 1711 | 1706 |
| 1712 if (runtime_profiler_ != NULL) { | 1707 if (runtime_profiler_ != NULL) { |
| 1713 runtime_profiler_->TearDown(); | |
| 1714 delete runtime_profiler_; | 1708 delete runtime_profiler_; |
| 1715 runtime_profiler_ = NULL; | 1709 runtime_profiler_ = NULL; |
| 1716 } | 1710 } |
| 1717 heap_.TearDown(); | 1711 heap_.TearDown(); |
| 1718 logger_->TearDown(); | 1712 logger_->TearDown(); |
| 1719 | 1713 |
| 1720 delete heap_profiler_; | 1714 delete heap_profiler_; |
| 1721 heap_profiler_ = NULL; | 1715 heap_profiler_ = NULL; |
| 1722 delete cpu_profiler_; | 1716 delete cpu_profiler_; |
| 1723 cpu_profiler_ = NULL; | 1717 cpu_profiler_ = NULL; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 clear_scheduled_exception(); | 2058 clear_scheduled_exception(); |
| 2065 | 2059 |
| 2066 // Deserializing may put strange things in the root array's copy of the | 2060 // Deserializing may put strange things in the root array's copy of the |
| 2067 // stack guard. | 2061 // stack guard. |
| 2068 heap_.SetStackLimits(); | 2062 heap_.SetStackLimits(); |
| 2069 | 2063 |
| 2070 // Quiet the heap NaN if needed on target platform. | 2064 // Quiet the heap NaN if needed on target platform. |
| 2071 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); | 2065 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); |
| 2072 | 2066 |
| 2073 runtime_profiler_ = new RuntimeProfiler(this); | 2067 runtime_profiler_ = new RuntimeProfiler(this); |
| 2074 runtime_profiler_->SetUp(); | |
| 2075 | 2068 |
| 2076 // If we are deserializing, log non-function code objects and compiled | 2069 // If we are deserializing, log non-function code objects and compiled |
| 2077 // functions found in the snapshot. | 2070 // functions found in the snapshot. |
| 2078 if (!create_heap_objects && | 2071 if (!create_heap_objects && |
| 2079 (FLAG_log_code || FLAG_ll_prof || logger_->is_logging_code_events())) { | 2072 (FLAG_log_code || |
| 2073 FLAG_ll_prof || |
| 2074 FLAG_perf_jit_prof || |
| 2075 FLAG_perf_basic_prof || |
| 2076 logger_->is_logging_code_events())) { |
| 2080 HandleScope scope(this); | 2077 HandleScope scope(this); |
| 2081 LOG(this, LogCodeObjects()); | 2078 LOG(this, LogCodeObjects()); |
| 2082 LOG(this, LogCompiledFunctions()); | 2079 LOG(this, LogCompiledFunctions()); |
| 2083 } | 2080 } |
| 2084 | 2081 |
| 2082 // If we are profiling with the Linux perf tool, we need to disable |
| 2083 // code relocation. |
| 2084 if (FLAG_perf_jit_prof || FLAG_perf_basic_prof) { |
| 2085 FLAG_compact_code_space = false; |
| 2086 } |
| 2087 |
| 2085 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), | 2088 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), |
| 2086 Internals::kIsolateEmbedderDataOffset); | 2089 Internals::kIsolateEmbedderDataOffset); |
| 2087 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), | 2090 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), |
| 2088 Internals::kIsolateRootsOffset); | 2091 Internals::kIsolateRootsOffset); |
| 2089 | 2092 |
| 2090 state_ = INITIALIZED; | 2093 state_ = INITIALIZED; |
| 2091 time_millis_at_init_ = OS::TimeCurrentMillis(); | 2094 time_millis_at_init_ = OS::TimeCurrentMillis(); |
| 2092 | 2095 |
| 2093 if (!create_heap_objects) { | 2096 if (!create_heap_objects) { |
| 2094 // Now that the heap is consistent, it's OK to generate the code for the | 2097 // Now that the heap is consistent, it's OK to generate the code for the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2109 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(this); | 2112 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(this); |
| 2110 StubFailureTrampolineStub::GenerateAheadOfTime(this); | 2113 StubFailureTrampolineStub::GenerateAheadOfTime(this); |
| 2111 StubFailureTailCallTrampolineStub::GenerateAheadOfTime(this); | 2114 StubFailureTailCallTrampolineStub::GenerateAheadOfTime(this); |
| 2112 // TODO(mstarzinger): The following is an ugly hack to make sure the | 2115 // TODO(mstarzinger): The following is an ugly hack to make sure the |
| 2113 // interface descriptor is initialized even when stubs have been | 2116 // interface descriptor is initialized even when stubs have been |
| 2114 // deserialized out of the snapshot without the graph builder. | 2117 // deserialized out of the snapshot without the graph builder. |
| 2115 FastCloneShallowArrayStub stub(FastCloneShallowArrayStub::CLONE_ELEMENTS, | 2118 FastCloneShallowArrayStub stub(FastCloneShallowArrayStub::CLONE_ELEMENTS, |
| 2116 DONT_TRACK_ALLOCATION_SITE, 0); | 2119 DONT_TRACK_ALLOCATION_SITE, 0); |
| 2117 stub.InitializeInterfaceDescriptor( | 2120 stub.InitializeInterfaceDescriptor( |
| 2118 this, code_stub_interface_descriptor(CodeStub::FastCloneShallowArray)); | 2121 this, code_stub_interface_descriptor(CodeStub::FastCloneShallowArray)); |
| 2119 BinaryOpStub::InitializeForIsolate(this); | 2122 BinaryOpICStub::InstallDescriptors(this); |
| 2120 CompareNilICStub::InitializeForIsolate(this); | 2123 CompareNilICStub::InitializeForIsolate(this); |
| 2121 ToBooleanStub::InitializeForIsolate(this); | 2124 ToBooleanStub::InitializeForIsolate(this); |
| 2122 ArrayConstructorStubBase::InstallDescriptors(this); | 2125 ArrayConstructorStubBase::InstallDescriptors(this); |
| 2123 InternalArrayConstructorStubBase::InstallDescriptors(this); | 2126 InternalArrayConstructorStubBase::InstallDescriptors(this); |
| 2124 FastNewClosureStub::InstallDescriptors(this); | 2127 FastNewClosureStub::InstallDescriptors(this); |
| 2125 NumberToStringStub::InstallDescriptors(this); | 2128 NumberToStringStub::InstallDescriptors(this); |
| 2126 NewStringAddStub::InstallDescriptors(this); | 2129 NewStringAddStub::InstallDescriptors(this); |
| 2127 } | 2130 } |
| 2128 | 2131 |
| 2129 initialized_from_snapshot_ = (des != NULL); | 2132 initialized_from_snapshot_ = (des != NULL); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 | 2330 |
| 2328 #ifdef DEBUG | 2331 #ifdef DEBUG |
| 2329 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2332 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2330 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2333 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2331 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2334 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2332 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2335 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2333 #undef ISOLATE_FIELD_OFFSET | 2336 #undef ISOLATE_FIELD_OFFSET |
| 2334 #endif | 2337 #endif |
| 2335 | 2338 |
| 2336 } } // namespace v8::internal | 2339 } } // namespace v8::internal |
| OLD | NEW |