| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 #ifdef ENABLE_VMSTATE_TRACKING | 260 #ifdef ENABLE_VMSTATE_TRACKING |
| 261 StateTag current_vm_state_; | 261 StateTag current_vm_state_; |
| 262 #endif | 262 #endif |
| 263 | 263 |
| 264 // Generated code scratch locations. | 264 // Generated code scratch locations. |
| 265 int32_t formal_count_; | 265 int32_t formal_count_; |
| 266 | 266 |
| 267 // Call back function to report unsafe JS accesses. | 267 // Call back function to report unsafe JS accesses. |
| 268 v8::FailedAccessCheckCallback failed_access_check_callback_; | 268 v8::FailedAccessCheckCallback failed_access_check_callback_; |
| 269 | 269 |
| 270 // Whether out of memory exceptions should be ignored. |
| 271 bool ignore_out_of_memory_; |
| 272 |
| 270 private: | 273 private: |
| 271 void InitializeInternal(); | 274 void InitializeInternal(); |
| 272 | 275 |
| 273 Address try_catch_handler_address_; | 276 Address try_catch_handler_address_; |
| 274 }; | 277 }; |
| 275 | 278 |
| 276 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) | 279 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) |
| 277 | 280 |
| 278 #define ISOLATE_PLATFORM_INIT_LIST(V) \ | 281 #define ISOLATE_PLATFORM_INIT_LIST(V) \ |
| 279 /* VirtualFrame::SpilledScope state */ \ | 282 /* VirtualFrame::SpilledScope state */ \ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 Isolate* isolate = reinterpret_cast<Isolate*>( | 462 Isolate* isolate = reinterpret_cast<Isolate*>( |
| 460 Thread::GetExistingThreadLocal(isolate_key_)); | 463 Thread::GetExistingThreadLocal(isolate_key_)); |
| 461 ASSERT(isolate != NULL); | 464 ASSERT(isolate != NULL); |
| 462 return isolate; | 465 return isolate; |
| 463 } | 466 } |
| 464 | 467 |
| 465 INLINE(static Isolate* UncheckedCurrent()) { | 468 INLINE(static Isolate* UncheckedCurrent()) { |
| 466 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_)); | 469 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_)); |
| 467 } | 470 } |
| 468 | 471 |
| 472 // Usually called by Init(), but can be called early e.g. to allow |
| 473 // testing components that require logging but not the whole |
| 474 // isolate. |
| 475 // |
| 476 // Safe to call more than once. |
| 477 void InitializeLoggingAndCounters(); |
| 478 |
| 469 bool Init(Deserializer* des); | 479 bool Init(Deserializer* des); |
| 470 | 480 |
| 471 bool IsInitialized() { return state_ == INITIALIZED; } | 481 bool IsInitialized() { return state_ == INITIALIZED; } |
| 472 | 482 |
| 473 // True if at least one thread Enter'ed this isolate. | 483 // True if at least one thread Enter'ed this isolate. |
| 474 bool IsInUse() { return entry_stack_ != NULL; } | 484 bool IsInUse() { return entry_stack_ != NULL; } |
| 475 | 485 |
| 476 // Destroys the non-default isolates. | 486 // Destroys the non-default isolates. |
| 477 // Sets default isolate into "has_been_disposed" state rather then destroying, | 487 // Sets default isolate into "has_been_disposed" state rather then destroying, |
| 478 // for legacy API reasons. | 488 // for legacy API reasons. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 505 static Thread::LocalStorageKey thread_id_key() { | 515 static Thread::LocalStorageKey thread_id_key() { |
| 506 return thread_id_key_; | 516 return thread_id_key_; |
| 507 } | 517 } |
| 508 | 518 |
| 509 // If a client attempts to create a Locker without specifying an isolate, | 519 // If a client attempts to create a Locker without specifying an isolate, |
| 510 // we assume that the client is using legacy behavior. Set up the current | 520 // we assume that the client is using legacy behavior. Set up the current |
| 511 // thread to be inside the implicit isolate (or fail a check if we have | 521 // thread to be inside the implicit isolate (or fail a check if we have |
| 512 // switched to non-legacy behavior). | 522 // switched to non-legacy behavior). |
| 513 static void EnterDefaultIsolate(); | 523 static void EnterDefaultIsolate(); |
| 514 | 524 |
| 515 // Debug. | |
| 516 // Mutex for serializing access to break control structures. | 525 // Mutex for serializing access to break control structures. |
| 517 Mutex* break_access() { return break_access_; } | 526 Mutex* break_access() { return break_access_; } |
| 518 | 527 |
| 528 // Mutex for serializing access to debugger. |
| 529 Mutex* debugger_access() { return debugger_access_; } |
| 530 |
| 519 Address get_address_from_id(AddressId id); | 531 Address get_address_from_id(AddressId id); |
| 520 | 532 |
| 521 // Access to top context (where the current function object was created). | 533 // Access to top context (where the current function object was created). |
| 522 Context* context() { return thread_local_top_.context_; } | 534 Context* context() { return thread_local_top_.context_; } |
| 523 void set_context(Context* context) { | 535 void set_context(Context* context) { |
| 524 thread_local_top_.context_ = context; | 536 thread_local_top_.context_ = context; |
| 525 } | 537 } |
| 526 Context** context_address() { return &thread_local_top_.context_; } | 538 Context** context_address() { return &thread_local_top_.context_; } |
| 527 | 539 |
| 528 SaveContext* save_context() {return thread_local_top_.save_context_; } | 540 SaveContext* save_context() {return thread_local_top_.save_context_; } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 }; | 681 }; |
| 670 | 682 |
| 671 void SetCaptureStackTraceForUncaughtExceptions( | 683 void SetCaptureStackTraceForUncaughtExceptions( |
| 672 bool capture, | 684 bool capture, |
| 673 int frame_limit, | 685 int frame_limit, |
| 674 StackTrace::StackTraceOptions options); | 686 StackTrace::StackTraceOptions options); |
| 675 | 687 |
| 676 // Tells whether the current context has experienced an out of memory | 688 // Tells whether the current context has experienced an out of memory |
| 677 // exception. | 689 // exception. |
| 678 bool is_out_of_memory(); | 690 bool is_out_of_memory(); |
| 691 bool ignore_out_of_memory() { |
| 692 return thread_local_top_.ignore_out_of_memory_; |
| 693 } |
| 694 void set_ignore_out_of_memory(bool value) { |
| 695 thread_local_top_.ignore_out_of_memory_ = value; |
| 696 } |
| 679 | 697 |
| 680 void PrintCurrentStackTrace(FILE* out); | 698 void PrintCurrentStackTrace(FILE* out); |
| 681 void PrintStackTrace(FILE* out, char* thread_data); | 699 void PrintStackTrace(FILE* out, char* thread_data); |
| 682 void PrintStack(StringStream* accumulator); | 700 void PrintStack(StringStream* accumulator); |
| 683 void PrintStack(); | 701 void PrintStack(); |
| 684 Handle<String> StackTraceString(); | 702 Handle<String> StackTraceString(); |
| 685 Handle<JSArray> CaptureCurrentStackTrace( | 703 Handle<JSArray> CaptureCurrentStackTrace( |
| 686 int frame_limit, | 704 int frame_limit, |
| 687 StackTrace::StackTraceOptions options); | 705 StackTrace::StackTraceOptions options); |
| 688 | 706 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 #undef GLOBAL_ARRAY_ACCESSOR | 795 #undef GLOBAL_ARRAY_ACCESSOR |
| 778 | 796 |
| 779 #define GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \ | 797 #define GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \ |
| 780 Handle<type> name() { \ | 798 Handle<type> name() { \ |
| 781 return Handle<type>(context()->global_context()->name()); \ | 799 return Handle<type>(context()->global_context()->name()); \ |
| 782 } | 800 } |
| 783 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSOR) | 801 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSOR) |
| 784 #undef GLOBAL_CONTEXT_FIELD_ACCESSOR | 802 #undef GLOBAL_CONTEXT_FIELD_ACCESSOR |
| 785 | 803 |
| 786 Bootstrapper* bootstrapper() { return bootstrapper_; } | 804 Bootstrapper* bootstrapper() { return bootstrapper_; } |
| 787 Counters* counters() { return counters_; } | 805 Counters* counters() { |
| 806 // Call InitializeLoggingAndCounters() if logging is needed before |
| 807 // the isolate is fully initialized. |
| 808 ASSERT(counters_ != NULL); |
| 809 return counters_; |
| 810 } |
| 788 CodeRange* code_range() { return code_range_; } | 811 CodeRange* code_range() { return code_range_; } |
| 789 RuntimeProfiler* runtime_profiler() { return runtime_profiler_; } | 812 RuntimeProfiler* runtime_profiler() { return runtime_profiler_; } |
| 790 CompilationCache* compilation_cache() { return compilation_cache_; } | 813 CompilationCache* compilation_cache() { return compilation_cache_; } |
| 791 Logger* logger() { return logger_; } | 814 Logger* logger() { |
| 815 // Call InitializeLoggingAndCounters() if logging is needed before |
| 816 // the isolate is fully initialized. |
| 817 ASSERT(logger_ != NULL); |
| 818 return logger_; |
| 819 } |
| 792 StackGuard* stack_guard() { return &stack_guard_; } | 820 StackGuard* stack_guard() { return &stack_guard_; } |
| 793 Heap* heap() { return &heap_; } | 821 Heap* heap() { return &heap_; } |
| 794 StatsTable* stats_table() { return stats_table_; } | 822 StatsTable* stats_table(); |
| 795 StubCache* stub_cache() { return stub_cache_; } | 823 StubCache* stub_cache() { return stub_cache_; } |
| 796 DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; } | 824 DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; } |
| 797 ThreadLocalTop* thread_local_top() { return &thread_local_top_; } | 825 ThreadLocalTop* thread_local_top() { return &thread_local_top_; } |
| 798 | 826 |
| 799 TranscendentalCache* transcendental_cache() const { | 827 TranscendentalCache* transcendental_cache() const { |
| 800 return transcendental_cache_; | 828 return transcendental_cache_; |
| 801 } | 829 } |
| 802 | 830 |
| 803 MemoryAllocator* memory_allocator() { | 831 MemoryAllocator* memory_allocator() { |
| 804 return memory_allocator_; | 832 return memory_allocator_; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 | 929 |
| 902 ZoneObjectList* result_constant_list() { | 930 ZoneObjectList* result_constant_list() { |
| 903 return &result_constant_list_; | 931 return &result_constant_list_; |
| 904 } | 932 } |
| 905 | 933 |
| 906 void* PreallocatedStorageNew(size_t size); | 934 void* PreallocatedStorageNew(size_t size); |
| 907 void PreallocatedStorageDelete(void* p); | 935 void PreallocatedStorageDelete(void* p); |
| 908 void PreallocatedStorageInit(size_t size); | 936 void PreallocatedStorageInit(size_t size); |
| 909 | 937 |
| 910 #ifdef ENABLE_DEBUGGER_SUPPORT | 938 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 911 Debugger* debugger() { return debugger_; } | 939 Debugger* debugger() { |
| 912 Debug* debug() { return debug_; } | 940 if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger(); |
| 941 return debugger_; |
| 942 } |
| 943 Debug* debug() { |
| 944 if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger(); |
| 945 return debug_; |
| 946 } |
| 913 #endif | 947 #endif |
| 914 | 948 |
| 915 #ifdef ENABLE_LOGGING_AND_PROFILING | 949 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 916 ProducerHeapProfile* producer_heap_profile() { | 950 ProducerHeapProfile* producer_heap_profile() { |
| 917 return producer_heap_profile_; | 951 return producer_heap_profile_; |
| 918 } | 952 } |
| 919 #endif | 953 #endif |
| 920 | 954 |
| 921 #ifdef DEBUG | 955 #ifdef DEBUG |
| 922 HistogramInfo* heap_histograms() { return heap_histograms_; } | 956 HistogramInfo* heap_histograms() { return heap_histograms_; } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 // This mutex protects highest_thread_id_, thread_data_table_ and | 1072 // This mutex protects highest_thread_id_, thread_data_table_ and |
| 1039 // default_isolate_. | 1073 // default_isolate_. |
| 1040 static Mutex* process_wide_mutex_; | 1074 static Mutex* process_wide_mutex_; |
| 1041 | 1075 |
| 1042 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1076 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
| 1043 static Thread::LocalStorageKey isolate_key_; | 1077 static Thread::LocalStorageKey isolate_key_; |
| 1044 static Thread::LocalStorageKey thread_id_key_; | 1078 static Thread::LocalStorageKey thread_id_key_; |
| 1045 static Isolate* default_isolate_; | 1079 static Isolate* default_isolate_; |
| 1046 static ThreadDataTable* thread_data_table_; | 1080 static ThreadDataTable* thread_data_table_; |
| 1047 | 1081 |
| 1048 bool PreInit(); | |
| 1049 | |
| 1050 void Deinit(); | 1082 void Deinit(); |
| 1051 | 1083 |
| 1052 static void SetIsolateThreadLocals(Isolate* isolate, | 1084 static void SetIsolateThreadLocals(Isolate* isolate, |
| 1053 PerIsolateThreadData* data); | 1085 PerIsolateThreadData* data); |
| 1054 | 1086 |
| 1055 enum State { | 1087 enum State { |
| 1056 UNINITIALIZED, // Some components may not have been allocated. | 1088 UNINITIALIZED, // Some components may not have been allocated. |
| 1057 PREINITIALIZED, // Components have been allocated but not initialized. | |
| 1058 INITIALIZED // All components are fully initialized. | 1089 INITIALIZED // All components are fully initialized. |
| 1059 }; | 1090 }; |
| 1060 | 1091 |
| 1061 State state_; | 1092 State state_; |
| 1062 EntryStackItem* entry_stack_; | 1093 EntryStackItem* entry_stack_; |
| 1063 | 1094 |
| 1064 // Allocate and insert PerIsolateThreadData into the ThreadDataTable | 1095 // Allocate and insert PerIsolateThreadData into the ThreadDataTable |
| 1065 // (regardless of whether such data already exists). | 1096 // (regardless of whether such data already exists). |
| 1066 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); | 1097 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); |
| 1067 | 1098 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1091 void PrintStackTrace(FILE* out, ThreadLocalTop* thread); | 1122 void PrintStackTrace(FILE* out, ThreadLocalTop* thread); |
| 1092 void MarkCompactPrologue(bool is_compacting, | 1123 void MarkCompactPrologue(bool is_compacting, |
| 1093 ThreadLocalTop* archived_thread_data); | 1124 ThreadLocalTop* archived_thread_data); |
| 1094 void MarkCompactEpilogue(bool is_compacting, | 1125 void MarkCompactEpilogue(bool is_compacting, |
| 1095 ThreadLocalTop* archived_thread_data); | 1126 ThreadLocalTop* archived_thread_data); |
| 1096 | 1127 |
| 1097 void FillCache(); | 1128 void FillCache(); |
| 1098 | 1129 |
| 1099 void PropagatePendingExceptionToExternalTryCatch(); | 1130 void PropagatePendingExceptionToExternalTryCatch(); |
| 1100 | 1131 |
| 1132 void InitializeDebugger(); |
| 1133 |
| 1101 int stack_trace_nesting_level_; | 1134 int stack_trace_nesting_level_; |
| 1102 StringStream* incomplete_message_; | 1135 StringStream* incomplete_message_; |
| 1103 // The preallocated memory thread singleton. | 1136 // The preallocated memory thread singleton. |
| 1104 PreallocatedMemoryThread* preallocated_memory_thread_; | 1137 PreallocatedMemoryThread* preallocated_memory_thread_; |
| 1105 Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT | 1138 Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT |
| 1106 NoAllocationStringAllocator* preallocated_message_space_; | 1139 NoAllocationStringAllocator* preallocated_message_space_; |
| 1107 | 1140 |
| 1108 Bootstrapper* bootstrapper_; | 1141 Bootstrapper* bootstrapper_; |
| 1109 RuntimeProfiler* runtime_profiler_; | 1142 RuntimeProfiler* runtime_profiler_; |
| 1110 CompilationCache* compilation_cache_; | 1143 CompilationCache* compilation_cache_; |
| 1111 Counters* counters_; | 1144 Counters* counters_; |
| 1112 CodeRange* code_range_; | 1145 CodeRange* code_range_; |
| 1113 Mutex* break_access_; | 1146 Mutex* break_access_; |
| 1147 Atomic32 debugger_initialized_; |
| 1148 Mutex* debugger_access_; |
| 1114 Heap heap_; | 1149 Heap heap_; |
| 1115 Logger* logger_; | 1150 Logger* logger_; |
| 1116 StackGuard stack_guard_; | 1151 StackGuard stack_guard_; |
| 1117 StatsTable* stats_table_; | 1152 StatsTable* stats_table_; |
| 1118 StubCache* stub_cache_; | 1153 StubCache* stub_cache_; |
| 1119 DeoptimizerData* deoptimizer_data_; | 1154 DeoptimizerData* deoptimizer_data_; |
| 1120 ThreadLocalTop thread_local_top_; | 1155 ThreadLocalTop thread_local_top_; |
| 1121 bool capture_stack_trace_for_uncaught_exceptions_; | 1156 bool capture_stack_trace_for_uncaught_exceptions_; |
| 1122 int stack_trace_for_uncaught_exceptions_frame_limit_; | 1157 int stack_trace_for_uncaught_exceptions_frame_limit_; |
| 1123 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_; | 1158 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 1232 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 1198 static const intptr_t name##_debug_offset_; | 1233 static const intptr_t name##_debug_offset_; |
| 1199 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 1234 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 1200 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 1235 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 1201 #undef ISOLATE_FIELD_OFFSET | 1236 #undef ISOLATE_FIELD_OFFSET |
| 1202 #endif | 1237 #endif |
| 1203 | 1238 |
| 1204 friend class ExecutionAccess; | 1239 friend class ExecutionAccess; |
| 1205 friend class IsolateInitializer; | 1240 friend class IsolateInitializer; |
| 1206 friend class ThreadId; | 1241 friend class ThreadId; |
| 1242 friend class TestMemoryAllocatorScope; |
| 1207 friend class v8::Isolate; | 1243 friend class v8::Isolate; |
| 1208 friend class v8::Locker; | 1244 friend class v8::Locker; |
| 1209 | 1245 |
| 1210 DISALLOW_COPY_AND_ASSIGN(Isolate); | 1246 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| 1211 }; | 1247 }; |
| 1212 | 1248 |
| 1213 | 1249 |
| 1214 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the | 1250 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
| 1215 // class as a work around for a bug in the generated code found with these | 1251 // class as a work around for a bug in the generated code found with these |
| 1216 // versions of GCC. See V8 issue 122 for details. | 1252 // versions of GCC. See V8 issue 122 for details. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 | 1415 |
| 1380 } } // namespace v8::internal | 1416 } } // namespace v8::internal |
| 1381 | 1417 |
| 1382 // TODO(isolates): Get rid of these -inl.h includes and place them only where | 1418 // TODO(isolates): Get rid of these -inl.h includes and place them only where |
| 1383 // they're needed. | 1419 // they're needed. |
| 1384 #include "allocation-inl.h" | 1420 #include "allocation-inl.h" |
| 1385 #include "zone-inl.h" | 1421 #include "zone-inl.h" |
| 1386 #include "frames-inl.h" | 1422 #include "frames-inl.h" |
| 1387 | 1423 |
| 1388 #endif // V8_ISOLATE_H_ | 1424 #endif // V8_ISOLATE_H_ |
| OLD | NEW |