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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "v8.h" | 30 #include "v8.h" |
31 | 31 |
| 32 #include "allocation-inl.h" |
32 #include "ast.h" | 33 #include "ast.h" |
33 #include "bootstrapper.h" | 34 #include "bootstrapper.h" |
34 #include "codegen.h" | 35 #include "codegen.h" |
35 #include "compilation-cache.h" | 36 #include "compilation-cache.h" |
| 37 #include "cpu-profiler.h" |
36 #include "debug.h" | 38 #include "debug.h" |
37 #include "deoptimizer.h" | 39 #include "deoptimizer.h" |
38 #include "heap-profiler.h" | 40 #include "heap-profiler.h" |
39 #include "hydrogen.h" | 41 #include "hydrogen.h" |
40 #include "isolate.h" | 42 #include "isolate.h" |
41 #include "lithium-allocator.h" | 43 #include "lithium-allocator.h" |
42 #include "log.h" | 44 #include "log.h" |
43 #include "marking-thread.h" | 45 #include "marking-thread.h" |
44 #include "messages.h" | 46 #include "messages.h" |
45 #include "platform.h" | 47 #include "platform.h" |
46 #include "regexp-stack.h" | 48 #include "regexp-stack.h" |
47 #include "runtime-profiler.h" | 49 #include "runtime-profiler.h" |
| 50 #include "sampler.h" |
48 #include "scopeinfo.h" | 51 #include "scopeinfo.h" |
49 #include "serialize.h" | 52 #include "serialize.h" |
50 #include "simulator.h" | 53 #include "simulator.h" |
51 #include "spaces.h" | 54 #include "spaces.h" |
52 #include "stub-cache.h" | 55 #include "stub-cache.h" |
53 #include "sweeper-thread.h" | 56 #include "sweeper-thread.h" |
54 #include "version.h" | 57 #include "version.h" |
55 #include "vm-state-inl.h" | 58 #include "vm-state-inl.h" |
56 | 59 |
57 | 60 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 external_caught_exception_ = false; | 103 external_caught_exception_ = false; |
101 failed_access_check_callback_ = NULL; | 104 failed_access_check_callback_ = NULL; |
102 save_context_ = NULL; | 105 save_context_ = NULL; |
103 catcher_ = NULL; | 106 catcher_ = NULL; |
104 top_lookup_result_ = NULL; | 107 top_lookup_result_ = NULL; |
105 | 108 |
106 // These members are re-initialized later after deserialization | 109 // These members are re-initialized later after deserialization |
107 // is complete. | 110 // is complete. |
108 pending_exception_ = NULL; | 111 pending_exception_ = NULL; |
109 has_pending_message_ = false; | 112 has_pending_message_ = false; |
| 113 rethrowing_message_ = false; |
110 pending_message_obj_ = NULL; | 114 pending_message_obj_ = NULL; |
111 pending_message_script_ = NULL; | 115 pending_message_script_ = NULL; |
112 scheduled_exception_ = NULL; | 116 scheduled_exception_ = NULL; |
113 } | 117 } |
114 | 118 |
115 | 119 |
116 void ThreadLocalTop::Initialize() { | 120 void ThreadLocalTop::Initialize() { |
117 InitializeInternal(); | 121 InitializeInternal(); |
118 #ifdef USE_SIMULATOR | 122 #ifdef USE_SIMULATOR |
119 #ifdef V8_TARGET_ARCH_A64 | 123 #if V8_TARGET_ARCH_A64 |
120 simulator_ = Simulator::current(isolate_); | 124 simulator_ = Simulator::current(isolate_); |
121 #elif V8_TARGET_ARCH_ARM | 125 #elif V8_TARGET_ARCH_ARM |
122 simulator_ = Simulator::current(isolate_); | 126 simulator_ = Simulator::current(isolate_); |
123 #elif V8_TARGET_ARCH_MIPS | 127 #elif V8_TARGET_ARCH_MIPS |
124 simulator_ = Simulator::current(isolate_); | 128 simulator_ = Simulator::current(isolate_); |
125 #endif | 129 #endif |
126 #endif | 130 #endif |
127 thread_id_ = ThreadId::Current(); | 131 thread_id_ = ThreadId::Current(); |
128 } | 132 } |
129 | 133 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 Object* scheduled; | 485 Object* scheduled; |
482 if (thread->scheduled_exception_->ToObject(&scheduled)) { | 486 if (thread->scheduled_exception_->ToObject(&scheduled)) { |
483 v->VisitPointer(&scheduled); | 487 v->VisitPointer(&scheduled); |
484 thread->scheduled_exception_ = scheduled; | 488 thread->scheduled_exception_ = scheduled; |
485 } | 489 } |
486 | 490 |
487 for (v8::TryCatch* block = thread->TryCatchHandler(); | 491 for (v8::TryCatch* block = thread->TryCatchHandler(); |
488 block != NULL; | 492 block != NULL; |
489 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { | 493 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { |
490 v->VisitPointer(BitCast<Object**>(&(block->exception_))); | 494 v->VisitPointer(BitCast<Object**>(&(block->exception_))); |
491 v->VisitPointer(BitCast<Object**>(&(block->message_))); | 495 v->VisitPointer(BitCast<Object**>(&(block->message_obj_))); |
| 496 v->VisitPointer(BitCast<Object**>(&(block->message_script_))); |
492 } | 497 } |
493 | 498 |
494 // Iterate over pointers on native execution stack. | 499 // Iterate over pointers on native execution stack. |
495 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { | 500 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { |
496 it.frame()->Iterate(v); | 501 it.frame()->Iterate(v); |
497 } | 502 } |
498 | 503 |
499 // Iterate pointers in live lookup results. | 504 // Iterate pointers in live lookup results. |
500 thread->top_lookup_result_->Iterate(v); | 505 thread->top_lookup_result_->Iterate(v); |
501 } | 506 } |
502 | 507 |
503 | 508 |
504 void Isolate::Iterate(ObjectVisitor* v) { | 509 void Isolate::Iterate(ObjectVisitor* v) { |
505 ThreadLocalTop* current_t = thread_local_top(); | 510 ThreadLocalTop* current_t = thread_local_top(); |
506 Iterate(v, current_t); | 511 Iterate(v, current_t); |
507 } | 512 } |
508 | 513 |
| 514 |
509 void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) { | 515 void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) { |
510 for (DeferredHandles* deferred = deferred_handles_head_; | 516 for (DeferredHandles* deferred = deferred_handles_head_; |
511 deferred != NULL; | 517 deferred != NULL; |
512 deferred = deferred->next_) { | 518 deferred = deferred->next_) { |
513 deferred->Iterate(visitor); | 519 deferred->Iterate(visitor); |
514 } | 520 } |
515 } | 521 } |
516 | 522 |
517 | 523 |
518 #ifdef DEBUG | 524 #ifdef DEBUG |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 Throw(exception); | 1163 Throw(exception); |
1158 PropagatePendingExceptionToExternalTryCatch(); | 1164 PropagatePendingExceptionToExternalTryCatch(); |
1159 if (has_pending_exception()) { | 1165 if (has_pending_exception()) { |
1160 thread_local_top()->scheduled_exception_ = pending_exception(); | 1166 thread_local_top()->scheduled_exception_ = pending_exception(); |
1161 thread_local_top()->external_caught_exception_ = false; | 1167 thread_local_top()->external_caught_exception_ = false; |
1162 clear_pending_exception(); | 1168 clear_pending_exception(); |
1163 } | 1169 } |
1164 } | 1170 } |
1165 | 1171 |
1166 | 1172 |
| 1173 void Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) { |
| 1174 ASSERT(handler == try_catch_handler()); |
| 1175 ASSERT(handler->HasCaught()); |
| 1176 ASSERT(handler->rethrow_); |
| 1177 ASSERT(handler->capture_message_); |
| 1178 Object* message = reinterpret_cast<Object*>(handler->message_obj_); |
| 1179 Object* script = reinterpret_cast<Object*>(handler->message_script_); |
| 1180 ASSERT(message->IsJSMessageObject() || message->IsTheHole()); |
| 1181 ASSERT(script->IsScript() || script->IsTheHole()); |
| 1182 thread_local_top()->pending_message_obj_ = message; |
| 1183 thread_local_top()->pending_message_script_ = script; |
| 1184 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_; |
| 1185 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_; |
| 1186 } |
| 1187 |
| 1188 |
1167 Failure* Isolate::PromoteScheduledException() { | 1189 Failure* Isolate::PromoteScheduledException() { |
1168 MaybeObject* thrown = scheduled_exception(); | 1190 MaybeObject* thrown = scheduled_exception(); |
1169 clear_scheduled_exception(); | 1191 clear_scheduled_exception(); |
1170 // Re-throw the exception to avoid getting repeated error reporting. | 1192 // Re-throw the exception to avoid getting repeated error reporting. |
1171 return ReThrow(thrown); | 1193 return ReThrow(thrown); |
1172 } | 1194 } |
1173 | 1195 |
1174 | 1196 |
1175 void Isolate::PrintCurrentStackTrace(FILE* out) { | 1197 void Isolate::PrintCurrentStackTrace(FILE* out) { |
1176 StackTraceFrameIterator it(this); | 1198 StackTraceFrameIterator it(this); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 HandleScope scope(this); | 1297 HandleScope scope(this); |
1276 Handle<Object> exception_handle(exception, this); | 1298 Handle<Object> exception_handle(exception, this); |
1277 | 1299 |
1278 // Determine reporting and whether the exception is caught externally. | 1300 // Determine reporting and whether the exception is caught externally. |
1279 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 1301 bool catchable_by_javascript = is_catchable_by_javascript(exception); |
1280 bool can_be_caught_externally = false; | 1302 bool can_be_caught_externally = false; |
1281 bool should_report_exception = | 1303 bool should_report_exception = |
1282 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); | 1304 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); |
1283 bool report_exception = catchable_by_javascript && should_report_exception; | 1305 bool report_exception = catchable_by_javascript && should_report_exception; |
1284 bool try_catch_needs_message = | 1306 bool try_catch_needs_message = |
1285 can_be_caught_externally && try_catch_handler()->capture_message_; | 1307 can_be_caught_externally && try_catch_handler()->capture_message_ && |
| 1308 !thread_local_top()->rethrowing_message_; |
1286 bool bootstrapping = bootstrapper()->IsActive(); | 1309 bool bootstrapping = bootstrapper()->IsActive(); |
1287 | 1310 |
| 1311 thread_local_top()->rethrowing_message_ = false; |
| 1312 |
1288 #ifdef ENABLE_DEBUGGER_SUPPORT | 1313 #ifdef ENABLE_DEBUGGER_SUPPORT |
1289 // Notify debugger of exception. | 1314 // Notify debugger of exception. |
1290 if (catchable_by_javascript) { | 1315 if (catchable_by_javascript) { |
1291 debugger_->OnException(exception_handle, report_exception); | 1316 debugger_->OnException(exception_handle, report_exception); |
1292 } | 1317 } |
1293 #endif | 1318 #endif |
1294 | 1319 |
1295 // Generate the message if required. | 1320 // Generate the message if required. |
1296 if (report_exception || try_catch_needs_message) { | 1321 if (report_exception || try_catch_needs_message) { |
1297 MessageLocation potential_computed_location; | 1322 MessageLocation potential_computed_location; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 heap()->termination_exception()) { | 1484 heap()->termination_exception()) { |
1460 // Do nothing: if needed, the exception has been already propagated to | 1485 // Do nothing: if needed, the exception has been already propagated to |
1461 // v8::TryCatch. | 1486 // v8::TryCatch. |
1462 } else { | 1487 } else { |
1463 if (thread_local_top_.has_pending_message_) { | 1488 if (thread_local_top_.has_pending_message_) { |
1464 thread_local_top_.has_pending_message_ = false; | 1489 thread_local_top_.has_pending_message_ = false; |
1465 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { | 1490 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { |
1466 HandleScope scope(this); | 1491 HandleScope scope(this); |
1467 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, | 1492 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, |
1468 this); | 1493 this); |
1469 if (thread_local_top_.pending_message_script_ != NULL) { | 1494 if (!thread_local_top_.pending_message_script_->IsTheHole()) { |
1470 Handle<Script> script(thread_local_top_.pending_message_script_); | 1495 Handle<Script> script( |
| 1496 Script::cast(thread_local_top_.pending_message_script_)); |
1471 int start_pos = thread_local_top_.pending_message_start_pos_; | 1497 int start_pos = thread_local_top_.pending_message_start_pos_; |
1472 int end_pos = thread_local_top_.pending_message_end_pos_; | 1498 int end_pos = thread_local_top_.pending_message_end_pos_; |
1473 MessageLocation location(script, start_pos, end_pos); | 1499 MessageLocation location(script, start_pos, end_pos); |
1474 MessageHandler::ReportMessage(this, &location, message_obj); | 1500 MessageHandler::ReportMessage(this, &location, message_obj); |
1475 } else { | 1501 } else { |
1476 MessageHandler::ReportMessage(this, NULL, message_obj); | 1502 MessageHandler::ReportMessage(this, NULL, message_obj); |
1477 } | 1503 } |
1478 } | 1504 } |
1479 } | 1505 } |
1480 } | 1506 } |
1481 clear_pending_message(); | 1507 clear_pending_message(); |
1482 } | 1508 } |
1483 | 1509 |
1484 | 1510 |
1485 MessageLocation Isolate::GetMessageLocation() { | 1511 MessageLocation Isolate::GetMessageLocation() { |
1486 ASSERT(has_pending_exception()); | 1512 ASSERT(has_pending_exception()); |
1487 | 1513 |
1488 if (!thread_local_top_.pending_exception_->IsOutOfMemory() && | 1514 if (!thread_local_top_.pending_exception_->IsOutOfMemory() && |
1489 thread_local_top_.pending_exception_ != heap()->termination_exception() && | 1515 thread_local_top_.pending_exception_ != heap()->termination_exception() && |
1490 thread_local_top_.has_pending_message_ && | 1516 thread_local_top_.has_pending_message_ && |
1491 !thread_local_top_.pending_message_obj_->IsTheHole() && | 1517 !thread_local_top_.pending_message_obj_->IsTheHole() && |
1492 thread_local_top_.pending_message_script_ != NULL) { | 1518 !thread_local_top_.pending_message_obj_->IsTheHole()) { |
1493 Handle<Script> script(thread_local_top_.pending_message_script_); | 1519 Handle<Script> script( |
| 1520 Script::cast(thread_local_top_.pending_message_script_)); |
1494 int start_pos = thread_local_top_.pending_message_start_pos_; | 1521 int start_pos = thread_local_top_.pending_message_start_pos_; |
1495 int end_pos = thread_local_top_.pending_message_end_pos_; | 1522 int end_pos = thread_local_top_.pending_message_end_pos_; |
1496 return MessageLocation(script, start_pos, end_pos); | 1523 return MessageLocation(script, start_pos, end_pos); |
1497 } | 1524 } |
1498 | 1525 |
1499 return MessageLocation(); | 1526 return MessageLocation(); |
1500 } | 1527 } |
1501 | 1528 |
1502 | 1529 |
1503 void Isolate::TraceException(bool flag) { | 1530 void Isolate::TraceException(bool flag) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 return to + sizeof(ThreadLocalTop); | 1647 return to + sizeof(ThreadLocalTop); |
1621 } | 1648 } |
1622 | 1649 |
1623 | 1650 |
1624 char* Isolate::RestoreThread(char* from) { | 1651 char* Isolate::RestoreThread(char* from) { |
1625 OS::MemCopy(reinterpret_cast<char*>(thread_local_top()), from, | 1652 OS::MemCopy(reinterpret_cast<char*>(thread_local_top()), from, |
1626 sizeof(ThreadLocalTop)); | 1653 sizeof(ThreadLocalTop)); |
1627 // This might be just paranoia, but it seems to be needed in case a | 1654 // This might be just paranoia, but it seems to be needed in case a |
1628 // thread_local_top_ is restored on a separate OS thread. | 1655 // thread_local_top_ is restored on a separate OS thread. |
1629 #ifdef USE_SIMULATOR | 1656 #ifdef USE_SIMULATOR |
1630 #ifdef V8_TARGET_ARCH_A64 | 1657 #if V8_TARGET_ARCH_A64 |
1631 thread_local_top()->simulator_ = Simulator::current(this); | 1658 thread_local_top()->simulator_ = Simulator::current(this); |
1632 #elif V8_TARGET_ARCH_ARM | 1659 #elif V8_TARGET_ARCH_ARM |
1633 thread_local_top()->simulator_ = Simulator::current(this); | 1660 thread_local_top()->simulator_ = Simulator::current(this); |
1634 #elif V8_TARGET_ARCH_MIPS | 1661 #elif V8_TARGET_ARCH_MIPS |
1635 thread_local_top()->simulator_ = Simulator::current(this); | 1662 thread_local_top()->simulator_ = Simulator::current(this); |
1636 #endif | 1663 #endif |
1637 #endif | 1664 #endif |
1638 ASSERT(context() == NULL || context()->IsContext()); | 1665 ASSERT(context() == NULL || context()->IsContext()); |
1639 return from + sizeof(ThreadLocalTop); | 1666 return from + sizeof(ThreadLocalTop); |
1640 } | 1667 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 capture_stack_trace_for_uncaught_exceptions_(false), | 1762 capture_stack_trace_for_uncaught_exceptions_(false), |
1736 stack_trace_for_uncaught_exceptions_frame_limit_(0), | 1763 stack_trace_for_uncaught_exceptions_frame_limit_(0), |
1737 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), | 1764 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), |
1738 transcendental_cache_(NULL), | 1765 transcendental_cache_(NULL), |
1739 memory_allocator_(NULL), | 1766 memory_allocator_(NULL), |
1740 keyed_lookup_cache_(NULL), | 1767 keyed_lookup_cache_(NULL), |
1741 context_slot_cache_(NULL), | 1768 context_slot_cache_(NULL), |
1742 descriptor_lookup_cache_(NULL), | 1769 descriptor_lookup_cache_(NULL), |
1743 handle_scope_implementer_(NULL), | 1770 handle_scope_implementer_(NULL), |
1744 unicode_cache_(NULL), | 1771 unicode_cache_(NULL), |
| 1772 runtime_zone_(this), |
1745 in_use_list_(0), | 1773 in_use_list_(0), |
1746 free_list_(0), | 1774 free_list_(0), |
1747 preallocated_storage_preallocated_(false), | 1775 preallocated_storage_preallocated_(false), |
1748 inner_pointer_to_code_cache_(NULL), | 1776 inner_pointer_to_code_cache_(NULL), |
1749 write_iterator_(NULL), | 1777 write_iterator_(NULL), |
1750 global_handles_(NULL), | 1778 global_handles_(NULL), |
1751 context_switcher_(NULL), | 1779 context_switcher_(NULL), |
1752 thread_manager_(NULL), | 1780 thread_manager_(NULL), |
1753 fp_stubs_generated_(false), | 1781 fp_stubs_generated_(false), |
1754 has_installed_extensions_(false), | 1782 has_installed_extensions_(false), |
1755 string_tracker_(NULL), | 1783 string_tracker_(NULL), |
1756 regexp_stack_(NULL), | 1784 regexp_stack_(NULL), |
1757 date_cache_(NULL), | 1785 date_cache_(NULL), |
1758 code_stub_interface_descriptors_(NULL), | 1786 code_stub_interface_descriptors_(NULL), |
1759 context_exit_happened_(false), | 1787 context_exit_happened_(false), |
| 1788 initialized_from_snapshot_(false), |
1760 cpu_profiler_(NULL), | 1789 cpu_profiler_(NULL), |
1761 heap_profiler_(NULL), | 1790 heap_profiler_(NULL), |
| 1791 function_entry_hook_(NULL), |
1762 deferred_handles_head_(NULL), | 1792 deferred_handles_head_(NULL), |
1763 optimizing_compiler_thread_(this), | 1793 optimizing_compiler_thread_(this), |
1764 marking_thread_(NULL), | 1794 marking_thread_(NULL), |
1765 sweeper_thread_(NULL), | 1795 sweeper_thread_(NULL), |
1766 callback_table_(NULL) { | 1796 callback_table_(NULL) { |
1767 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 1797 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
1768 TRACE_ISOLATE(constructor); | 1798 TRACE_ISOLATE(constructor); |
1769 | 1799 |
1770 memset(isolate_addresses_, 0, | 1800 memset(isolate_addresses_, 0, |
1771 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 1801 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
1772 | 1802 |
1773 heap_.isolate_ = this; | 1803 heap_.isolate_ = this; |
1774 stack_guard_.isolate_ = this; | 1804 stack_guard_.isolate_ = this; |
1775 | 1805 |
1776 // ThreadManager is initialized early to support locking an isolate | 1806 // ThreadManager is initialized early to support locking an isolate |
1777 // before it is entered. | 1807 // before it is entered. |
1778 thread_manager_ = new ThreadManager(); | 1808 thread_manager_ = new ThreadManager(); |
1779 thread_manager_->isolate_ = this; | 1809 thread_manager_->isolate_ = this; |
1780 | 1810 |
1781 #if defined(V8_TARGET_ARCH_A64) && !defined(__arm__) || \ | 1811 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \ |
1782 defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \ | 1812 V8_TARGET_ARCH_A64 && !defined(__arm__) || \ |
1783 defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__) | 1813 V8_TARGET_ARCH_MIPS && !defined(__mips__) |
1784 simulator_initialized_ = false; | 1814 simulator_initialized_ = false; |
1785 simulator_i_cache_ = NULL; | 1815 simulator_i_cache_ = NULL; |
1786 simulator_redirection_ = NULL; | 1816 simulator_redirection_ = NULL; |
1787 #endif | 1817 #endif |
1788 | 1818 |
1789 #ifdef DEBUG | 1819 #ifdef DEBUG |
1790 // heap_histograms_ initializes itself. | 1820 // heap_histograms_ initializes itself. |
1791 memset(&js_spill_information_, 0, sizeof(js_spill_information_)); | 1821 memset(&js_spill_information_, 0, sizeof(js_spill_information_)); |
1792 memset(code_kind_statistics_, 0, | 1822 memset(code_kind_statistics_, 0, |
1793 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS); | 1823 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 | 1875 |
1846 void Isolate::GlobalTearDown() { | 1876 void Isolate::GlobalTearDown() { |
1847 delete thread_data_table_; | 1877 delete thread_data_table_; |
1848 } | 1878 } |
1849 | 1879 |
1850 | 1880 |
1851 void Isolate::Deinit() { | 1881 void Isolate::Deinit() { |
1852 if (state_ == INITIALIZED) { | 1882 if (state_ == INITIALIZED) { |
1853 TRACE_ISOLATE(deinit); | 1883 TRACE_ISOLATE(deinit); |
1854 | 1884 |
| 1885 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1886 debugger()->UnloadDebugger(); |
| 1887 #endif |
| 1888 |
1855 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Stop(); | 1889 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Stop(); |
1856 | 1890 |
1857 if (FLAG_sweeper_threads > 0) { | 1891 if (FLAG_sweeper_threads > 0) { |
1858 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 1892 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
1859 sweeper_thread_[i]->Stop(); | 1893 sweeper_thread_[i]->Stop(); |
1860 delete sweeper_thread_[i]; | 1894 delete sweeper_thread_[i]; |
1861 } | 1895 } |
1862 delete[] sweeper_thread_; | 1896 delete[] sweeper_thread_; |
1863 } | 1897 } |
1864 | 1898 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 void Isolate::SetIsolateThreadLocals(Isolate* isolate, | 1966 void Isolate::SetIsolateThreadLocals(Isolate* isolate, |
1933 PerIsolateThreadData* data) { | 1967 PerIsolateThreadData* data) { |
1934 Thread::SetThreadLocal(isolate_key_, isolate); | 1968 Thread::SetThreadLocal(isolate_key_, isolate); |
1935 Thread::SetThreadLocal(per_isolate_thread_data_key_, data); | 1969 Thread::SetThreadLocal(per_isolate_thread_data_key_, data); |
1936 } | 1970 } |
1937 | 1971 |
1938 | 1972 |
1939 Isolate::~Isolate() { | 1973 Isolate::~Isolate() { |
1940 TRACE_ISOLATE(destructor); | 1974 TRACE_ISOLATE(destructor); |
1941 | 1975 |
| 1976 // Has to be called while counters_ are still alive |
| 1977 runtime_zone_.DeleteKeptSegment(); |
| 1978 |
| 1979 // The entry stack must be empty when we get here, |
| 1980 // except for the default isolate, where it can |
| 1981 // still contain up to one entry stack item |
| 1982 ASSERT(entry_stack_ == NULL || this == default_isolate_); |
| 1983 ASSERT(entry_stack_ == NULL || entry_stack_->previous_item == NULL); |
| 1984 |
| 1985 delete entry_stack_; |
| 1986 entry_stack_ = NULL; |
| 1987 |
1942 delete[] assembler_spare_buffer_; | 1988 delete[] assembler_spare_buffer_; |
1943 assembler_spare_buffer_ = NULL; | 1989 assembler_spare_buffer_ = NULL; |
1944 | 1990 |
1945 delete unicode_cache_; | 1991 delete unicode_cache_; |
1946 unicode_cache_ = NULL; | 1992 unicode_cache_ = NULL; |
1947 | 1993 |
1948 delete date_cache_; | 1994 delete date_cache_; |
1949 date_cache_ = NULL; | 1995 date_cache_ = NULL; |
1950 | 1996 |
1951 delete[] code_stub_interface_descriptors_; | 1997 delete[] code_stub_interface_descriptors_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 delete string_tracker_; | 2044 delete string_tracker_; |
1999 string_tracker_ = NULL; | 2045 string_tracker_ = NULL; |
2000 | 2046 |
2001 delete memory_allocator_; | 2047 delete memory_allocator_; |
2002 memory_allocator_ = NULL; | 2048 memory_allocator_ = NULL; |
2003 delete code_range_; | 2049 delete code_range_; |
2004 code_range_ = NULL; | 2050 code_range_ = NULL; |
2005 delete global_handles_; | 2051 delete global_handles_; |
2006 global_handles_ = NULL; | 2052 global_handles_ = NULL; |
2007 | 2053 |
| 2054 delete string_stream_debug_object_cache_; |
| 2055 string_stream_debug_object_cache_ = NULL; |
| 2056 |
2008 delete external_reference_table_; | 2057 delete external_reference_table_; |
2009 external_reference_table_ = NULL; | 2058 external_reference_table_ = NULL; |
2010 | 2059 |
2011 delete callback_table_; | 2060 delete callback_table_; |
2012 callback_table_ = NULL; | 2061 callback_table_ = NULL; |
2013 | 2062 |
2014 #ifdef ENABLE_DEBUGGER_SUPPORT | 2063 #ifdef ENABLE_DEBUGGER_SUPPORT |
2015 delete debugger_; | 2064 delete debugger_; |
2016 debugger_ = NULL; | 2065 debugger_ = NULL; |
2017 delete debug_; | 2066 delete debug_; |
(...skipping 17 matching lines...) Expand all Loading... |
2035 if (!external_caught) return; | 2084 if (!external_caught) return; |
2036 | 2085 |
2037 if (thread_local_top_.pending_exception_->IsOutOfMemory()) { | 2086 if (thread_local_top_.pending_exception_->IsOutOfMemory()) { |
2038 // Do not propagate OOM exception: we should kill VM asap. | 2087 // Do not propagate OOM exception: we should kill VM asap. |
2039 } else if (thread_local_top_.pending_exception_ == | 2088 } else if (thread_local_top_.pending_exception_ == |
2040 heap()->termination_exception()) { | 2089 heap()->termination_exception()) { |
2041 try_catch_handler()->can_continue_ = false; | 2090 try_catch_handler()->can_continue_ = false; |
2042 try_catch_handler()->has_terminated_ = true; | 2091 try_catch_handler()->has_terminated_ = true; |
2043 try_catch_handler()->exception_ = heap()->null_value(); | 2092 try_catch_handler()->exception_ = heap()->null_value(); |
2044 } else { | 2093 } else { |
| 2094 v8::TryCatch* handler = try_catch_handler(); |
2045 // At this point all non-object (failure) exceptions have | 2095 // At this point all non-object (failure) exceptions have |
2046 // been dealt with so this shouldn't fail. | 2096 // been dealt with so this shouldn't fail. |
2047 ASSERT(!pending_exception()->IsFailure()); | 2097 ASSERT(!pending_exception()->IsFailure()); |
2048 try_catch_handler()->can_continue_ = true; | 2098 ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() || |
2049 try_catch_handler()->has_terminated_ = false; | 2099 thread_local_top_.pending_message_obj_->IsTheHole()); |
2050 try_catch_handler()->exception_ = pending_exception(); | 2100 ASSERT(thread_local_top_.pending_message_script_->IsScript() || |
2051 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { | 2101 thread_local_top_.pending_message_script_->IsTheHole()); |
2052 try_catch_handler()->message_ = thread_local_top_.pending_message_obj_; | 2102 handler->can_continue_ = true; |
2053 } | 2103 handler->has_terminated_ = false; |
| 2104 handler->exception_ = pending_exception(); |
| 2105 // Propagate to the external try-catch only if we got an actual message. |
| 2106 if (thread_local_top_.pending_message_obj_->IsTheHole()) return; |
| 2107 |
| 2108 handler->message_obj_ = thread_local_top_.pending_message_obj_; |
| 2109 handler->message_script_ = thread_local_top_.pending_message_script_; |
| 2110 handler->message_start_pos_ = thread_local_top_.pending_message_start_pos_; |
| 2111 handler->message_end_pos_ = thread_local_top_.pending_message_end_pos_; |
2054 } | 2112 } |
2055 } | 2113 } |
2056 | 2114 |
2057 | 2115 |
2058 void Isolate::InitializeLoggingAndCounters() { | 2116 void Isolate::InitializeLoggingAndCounters() { |
2059 if (logger_ == NULL) { | 2117 if (logger_ == NULL) { |
2060 logger_ = new Logger(this); | 2118 logger_ = new Logger(this); |
2061 } | 2119 } |
2062 if (counters_ == NULL) { | 2120 if (counters_ == NULL) { |
2063 counters_ = new Counters(this); | 2121 counters_ = new Counters(this); |
(...skipping 11 matching lines...) Expand all Loading... |
2075 Release_Store(&debugger_initialized_, true); | 2133 Release_Store(&debugger_initialized_, true); |
2076 #endif | 2134 #endif |
2077 } | 2135 } |
2078 | 2136 |
2079 | 2137 |
2080 bool Isolate::Init(Deserializer* des) { | 2138 bool Isolate::Init(Deserializer* des) { |
2081 ASSERT(state_ != INITIALIZED); | 2139 ASSERT(state_ != INITIALIZED); |
2082 ASSERT(Isolate::Current() == this); | 2140 ASSERT(Isolate::Current() == this); |
2083 TRACE_ISOLATE(init); | 2141 TRACE_ISOLATE(init); |
2084 | 2142 |
| 2143 if (function_entry_hook() != NULL) { |
| 2144 // When function entry hooking is in effect, we have to create the code |
| 2145 // stubs from scratch to get entry hooks, rather than loading the previously |
| 2146 // generated stubs from disk. |
| 2147 // If this assert fires, the initialization path has regressed. |
| 2148 ASSERT(des == NULL); |
| 2149 } |
| 2150 |
2085 // The initialization process does not handle memory exhaustion. | 2151 // The initialization process does not handle memory exhaustion. |
2086 DisallowAllocationFailure disallow_allocation_failure; | 2152 DisallowAllocationFailure disallow_allocation_failure; |
2087 | 2153 |
2088 InitializeLoggingAndCounters(); | 2154 InitializeLoggingAndCounters(); |
2089 | 2155 |
2090 InitializeDebugger(); | 2156 InitializeDebugger(); |
2091 | 2157 |
2092 memory_allocator_ = new MemoryAllocator(this); | 2158 memory_allocator_ = new MemoryAllocator(this); |
2093 code_range_ = new CodeRange(this); | 2159 code_range_ = new CodeRange(this); |
2094 | 2160 |
(...skipping 27 matching lines...) Expand all Loading... |
2122 code_stub_interface_descriptors_ = | 2188 code_stub_interface_descriptors_ = |
2123 new CodeStubInterfaceDescriptor[CodeStub::NUMBER_OF_IDS]; | 2189 new CodeStubInterfaceDescriptor[CodeStub::NUMBER_OF_IDS]; |
2124 cpu_profiler_ = new CpuProfiler(this); | 2190 cpu_profiler_ = new CpuProfiler(this); |
2125 heap_profiler_ = new HeapProfiler(heap()); | 2191 heap_profiler_ = new HeapProfiler(heap()); |
2126 | 2192 |
2127 // Enable logging before setting up the heap | 2193 // Enable logging before setting up the heap |
2128 logger_->SetUp(this); | 2194 logger_->SetUp(this); |
2129 | 2195 |
2130 // Initialize other runtime facilities | 2196 // Initialize other runtime facilities |
2131 #if defined(USE_SIMULATOR) | 2197 #if defined(USE_SIMULATOR) |
2132 #if defined(V8_TARGET_ARCH_A64) || defined(V8_TARGET_ARCH_ARM) || \ | 2198 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_A64 || V8_TARGET_ARCH_MIPS |
2133 defined(V8_TARGET_ARCH_MIPS) | |
2134 Simulator::Initialize(this); | 2199 Simulator::Initialize(this); |
2135 #endif | 2200 #endif |
2136 #endif | 2201 #endif |
2137 | 2202 |
2138 { // NOLINT | 2203 { // NOLINT |
2139 // Ensure that the thread has a valid stack guard. The v8::Locker object | 2204 // Ensure that the thread has a valid stack guard. The v8::Locker object |
2140 // will ensure this too, but we don't have to use lockers if we are only | 2205 // will ensure this too, but we don't have to use lockers if we are only |
2141 // using one thread. | 2206 // using one thread. |
2142 ExecutionAccess lock(this); | 2207 ExecutionAccess lock(this); |
2143 stack_guard_.InitThread(lock); | 2208 stack_guard_.InitThread(lock); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 } | 2332 } |
2268 } | 2333 } |
2269 | 2334 |
2270 if (FLAG_sweeper_threads > 0) { | 2335 if (FLAG_sweeper_threads > 0) { |
2271 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads]; | 2336 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads]; |
2272 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 2337 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
2273 sweeper_thread_[i] = new SweeperThread(this); | 2338 sweeper_thread_[i] = new SweeperThread(this); |
2274 sweeper_thread_[i]->Start(); | 2339 sweeper_thread_[i]->Start(); |
2275 } | 2340 } |
2276 } | 2341 } |
| 2342 |
| 2343 initialized_from_snapshot_ = (des != NULL); |
| 2344 |
2277 return true; | 2345 return true; |
2278 } | 2346 } |
2279 | 2347 |
2280 | 2348 |
2281 // Initialized lazily to allow early | 2349 // Initialized lazily to allow early |
2282 // v8::V8::SetAddHistogramSampleFunction calls. | 2350 // v8::V8::SetAddHistogramSampleFunction calls. |
2283 StatsTable* Isolate::stats_table() { | 2351 StatsTable* Isolate::stats_table() { |
2284 if (stats_table_ == NULL) { | 2352 if (stats_table_ == NULL) { |
2285 stats_table_ = new StatsTable; | 2353 stats_table_ = new StatsTable; |
2286 } | 2354 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 | 2513 |
2446 #ifdef DEBUG | 2514 #ifdef DEBUG |
2447 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2515 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2448 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2516 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2449 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2517 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2450 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2518 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2451 #undef ISOLATE_FIELD_OFFSET | 2519 #undef ISOLATE_FIELD_OFFSET |
2452 #endif | 2520 #endif |
2453 | 2521 |
2454 } } // namespace v8::internal | 2522 } } // namespace v8::internal |
OLD | NEW |