| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 Address js_entry_sp_; // the stack pointer of the bottom js entry frame | 249 Address js_entry_sp_; // the stack pointer of the bottom js entry frame |
| 250 Address external_callback_; // the external callback we're currently in | 250 Address external_callback_; // the external callback we're currently in |
| 251 StateTag current_vm_state_; | 251 StateTag current_vm_state_; |
| 252 | 252 |
| 253 // Generated code scratch locations. | 253 // Generated code scratch locations. |
| 254 int32_t formal_count_; | 254 int32_t formal_count_; |
| 255 | 255 |
| 256 // Call back function to report unsafe JS accesses. | 256 // Call back function to report unsafe JS accesses. |
| 257 v8::FailedAccessCheckCallback failed_access_check_callback_; | 257 v8::FailedAccessCheckCallback failed_access_check_callback_; |
| 258 | 258 |
| 259 // Whether out of memory exceptions should be ignored. |
| 260 bool ignore_out_of_memory_; |
| 261 |
| 259 private: | 262 private: |
| 260 void InitializeInternal(); | 263 void InitializeInternal(); |
| 261 | 264 |
| 262 Address try_catch_handler_address_; | 265 Address try_catch_handler_address_; |
| 263 }; | 266 }; |
| 264 | 267 |
| 265 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) | 268 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) |
| 266 | 269 |
| 267 #define ISOLATE_PLATFORM_INIT_LIST(V) \ | 270 #define ISOLATE_PLATFORM_INIT_LIST(V) \ |
| 268 /* VirtualFrame::SpilledScope state */ \ | 271 /* VirtualFrame::SpilledScope state */ \ |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 Isolate* isolate = reinterpret_cast<Isolate*>( | 442 Isolate* isolate = reinterpret_cast<Isolate*>( |
| 440 Thread::GetExistingThreadLocal(isolate_key_)); | 443 Thread::GetExistingThreadLocal(isolate_key_)); |
| 441 ASSERT(isolate != NULL); | 444 ASSERT(isolate != NULL); |
| 442 return isolate; | 445 return isolate; |
| 443 } | 446 } |
| 444 | 447 |
| 445 INLINE(static Isolate* UncheckedCurrent()) { | 448 INLINE(static Isolate* UncheckedCurrent()) { |
| 446 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_)); | 449 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_)); |
| 447 } | 450 } |
| 448 | 451 |
| 452 // Usually called by Init(), but can be called early e.g. to allow |
| 453 // testing components that require logging but not the whole |
| 454 // isolate. |
| 455 // |
| 456 // Safe to call more than once. |
| 457 void InitializeLoggingAndCounters(); |
| 458 |
| 449 bool Init(Deserializer* des); | 459 bool Init(Deserializer* des); |
| 450 | 460 |
| 451 bool IsInitialized() { return state_ == INITIALIZED; } | 461 bool IsInitialized() { return state_ == INITIALIZED; } |
| 452 | 462 |
| 453 // True if at least one thread Enter'ed this isolate. | 463 // True if at least one thread Enter'ed this isolate. |
| 454 bool IsInUse() { return entry_stack_ != NULL; } | 464 bool IsInUse() { return entry_stack_ != NULL; } |
| 455 | 465 |
| 456 // Destroys the non-default isolates. | 466 // Destroys the non-default isolates. |
| 457 // Sets default isolate into "has_been_disposed" state rather then destroying, | 467 // Sets default isolate into "has_been_disposed" state rather then destroying, |
| 458 // for legacy API reasons. | 468 // for legacy API reasons. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 static Thread::LocalStorageKey thread_id_key() { | 501 static Thread::LocalStorageKey thread_id_key() { |
| 492 return thread_id_key_; | 502 return thread_id_key_; |
| 493 } | 503 } |
| 494 | 504 |
| 495 // If a client attempts to create a Locker without specifying an isolate, | 505 // If a client attempts to create a Locker without specifying an isolate, |
| 496 // we assume that the client is using legacy behavior. Set up the current | 506 // we assume that the client is using legacy behavior. Set up the current |
| 497 // thread to be inside the implicit isolate (or fail a check if we have | 507 // thread to be inside the implicit isolate (or fail a check if we have |
| 498 // switched to non-legacy behavior). | 508 // switched to non-legacy behavior). |
| 499 static void EnterDefaultIsolate(); | 509 static void EnterDefaultIsolate(); |
| 500 | 510 |
| 501 // Debug. | |
| 502 // Mutex for serializing access to break control structures. | 511 // Mutex for serializing access to break control structures. |
| 503 Mutex* break_access() { return break_access_; } | 512 Mutex* break_access() { return break_access_; } |
| 504 | 513 |
| 514 // Mutex for serializing access to debugger. |
| 515 Mutex* debugger_access() { return debugger_access_; } |
| 516 |
| 505 Address get_address_from_id(AddressId id); | 517 Address get_address_from_id(AddressId id); |
| 506 | 518 |
| 507 // Access to top context (where the current function object was created). | 519 // Access to top context (where the current function object was created). |
| 508 Context* context() { return thread_local_top_.context_; } | 520 Context* context() { return thread_local_top_.context_; } |
| 509 void set_context(Context* context) { | 521 void set_context(Context* context) { |
| 510 ASSERT(context == NULL || context->IsContext()); | 522 ASSERT(context == NULL || context->IsContext()); |
| 511 thread_local_top_.context_ = context; | 523 thread_local_top_.context_ = context; |
| 512 } | 524 } |
| 513 Context** context_address() { return &thread_local_top_.context_; } | 525 Context** context_address() { return &thread_local_top_.context_; } |
| 514 | 526 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 }; | 666 }; |
| 655 | 667 |
| 656 void SetCaptureStackTraceForUncaughtExceptions( | 668 void SetCaptureStackTraceForUncaughtExceptions( |
| 657 bool capture, | 669 bool capture, |
| 658 int frame_limit, | 670 int frame_limit, |
| 659 StackTrace::StackTraceOptions options); | 671 StackTrace::StackTraceOptions options); |
| 660 | 672 |
| 661 // Tells whether the current context has experienced an out of memory | 673 // Tells whether the current context has experienced an out of memory |
| 662 // exception. | 674 // exception. |
| 663 bool is_out_of_memory(); | 675 bool is_out_of_memory(); |
| 676 bool ignore_out_of_memory() { |
| 677 return thread_local_top_.ignore_out_of_memory_; |
| 678 } |
| 679 void set_ignore_out_of_memory(bool value) { |
| 680 thread_local_top_.ignore_out_of_memory_ = value; |
| 681 } |
| 664 | 682 |
| 665 void PrintCurrentStackTrace(FILE* out); | 683 void PrintCurrentStackTrace(FILE* out); |
| 666 void PrintStackTrace(FILE* out, char* thread_data); | 684 void PrintStackTrace(FILE* out, char* thread_data); |
| 667 void PrintStack(StringStream* accumulator); | 685 void PrintStack(StringStream* accumulator); |
| 668 void PrintStack(); | 686 void PrintStack(); |
| 669 Handle<String> StackTraceString(); | 687 Handle<String> StackTraceString(); |
| 670 Handle<JSArray> CaptureCurrentStackTrace( | 688 Handle<JSArray> CaptureCurrentStackTrace( |
| 671 int frame_limit, | 689 int frame_limit, |
| 672 StackTrace::StackTraceOptions options); | 690 StackTrace::StackTraceOptions options); |
| 673 | 691 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 #undef GLOBAL_ARRAY_ACCESSOR | 780 #undef GLOBAL_ARRAY_ACCESSOR |
| 763 | 781 |
| 764 #define GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \ | 782 #define GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \ |
| 765 Handle<type> name() { \ | 783 Handle<type> name() { \ |
| 766 return Handle<type>(context()->global_context()->name()); \ | 784 return Handle<type>(context()->global_context()->name()); \ |
| 767 } | 785 } |
| 768 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSOR) | 786 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSOR) |
| 769 #undef GLOBAL_CONTEXT_FIELD_ACCESSOR | 787 #undef GLOBAL_CONTEXT_FIELD_ACCESSOR |
| 770 | 788 |
| 771 Bootstrapper* bootstrapper() { return bootstrapper_; } | 789 Bootstrapper* bootstrapper() { return bootstrapper_; } |
| 772 Counters* counters() { return counters_; } | 790 Counters* counters() { |
| 791 // Call InitializeLoggingAndCounters() if logging is needed before |
| 792 // the isolate is fully initialized. |
| 793 ASSERT(counters_ != NULL); |
| 794 return counters_; |
| 795 } |
| 773 CodeRange* code_range() { return code_range_; } | 796 CodeRange* code_range() { return code_range_; } |
| 774 RuntimeProfiler* runtime_profiler() { return runtime_profiler_; } | 797 RuntimeProfiler* runtime_profiler() { return runtime_profiler_; } |
| 775 CompilationCache* compilation_cache() { return compilation_cache_; } | 798 CompilationCache* compilation_cache() { return compilation_cache_; } |
| 776 Logger* logger() { return logger_; } | 799 Logger* logger() { |
| 800 // Call InitializeLoggingAndCounters() if logging is needed before |
| 801 // the isolate is fully initialized. |
| 802 ASSERT(logger_ != NULL); |
| 803 return logger_; |
| 804 } |
| 777 StackGuard* stack_guard() { return &stack_guard_; } | 805 StackGuard* stack_guard() { return &stack_guard_; } |
| 778 Heap* heap() { return &heap_; } | 806 Heap* heap() { return &heap_; } |
| 779 StatsTable* stats_table() { return stats_table_; } | 807 StatsTable* stats_table(); |
| 780 StubCache* stub_cache() { return stub_cache_; } | 808 StubCache* stub_cache() { return stub_cache_; } |
| 781 DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; } | 809 DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; } |
| 782 ThreadLocalTop* thread_local_top() { return &thread_local_top_; } | 810 ThreadLocalTop* thread_local_top() { return &thread_local_top_; } |
| 783 | 811 |
| 784 TranscendentalCache* transcendental_cache() const { | 812 TranscendentalCache* transcendental_cache() const { |
| 785 return transcendental_cache_; | 813 return transcendental_cache_; |
| 786 } | 814 } |
| 787 | 815 |
| 788 MemoryAllocator* memory_allocator() { | 816 MemoryAllocator* memory_allocator() { |
| 789 return memory_allocator_; | 817 return memory_allocator_; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 unibrow::Mapping<unibrow::Ecma262Canonicalize>* | 898 unibrow::Mapping<unibrow::Ecma262Canonicalize>* |
| 871 interp_canonicalize_mapping() { | 899 interp_canonicalize_mapping() { |
| 872 return &interp_canonicalize_mapping_; | 900 return &interp_canonicalize_mapping_; |
| 873 } | 901 } |
| 874 | 902 |
| 875 void* PreallocatedStorageNew(size_t size); | 903 void* PreallocatedStorageNew(size_t size); |
| 876 void PreallocatedStorageDelete(void* p); | 904 void PreallocatedStorageDelete(void* p); |
| 877 void PreallocatedStorageInit(size_t size); | 905 void PreallocatedStorageInit(size_t size); |
| 878 | 906 |
| 879 #ifdef ENABLE_DEBUGGER_SUPPORT | 907 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 880 Debugger* debugger() { return debugger_; } | 908 Debugger* debugger() { |
| 881 Debug* debug() { return debug_; } | 909 if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger(); |
| 910 return debugger_; |
| 911 } |
| 912 Debug* debug() { |
| 913 if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger(); |
| 914 return debug_; |
| 915 } |
| 882 #endif | 916 #endif |
| 883 | 917 |
| 884 inline bool DebuggerHasBreakPoints(); | 918 inline bool DebuggerHasBreakPoints(); |
| 885 | 919 |
| 886 #ifdef DEBUG | 920 #ifdef DEBUG |
| 887 HistogramInfo* heap_histograms() { return heap_histograms_; } | 921 HistogramInfo* heap_histograms() { return heap_histograms_; } |
| 888 | 922 |
| 889 JSObject::SpillInformation* js_spill_information() { | 923 JSObject::SpillInformation* js_spill_information() { |
| 890 return &js_spill_information_; | 924 return &js_spill_information_; |
| 891 } | 925 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 // This mutex protects highest_thread_id_, thread_data_table_ and | 1037 // This mutex protects highest_thread_id_, thread_data_table_ and |
| 1004 // default_isolate_. | 1038 // default_isolate_. |
| 1005 static Mutex* process_wide_mutex_; | 1039 static Mutex* process_wide_mutex_; |
| 1006 | 1040 |
| 1007 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1041 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
| 1008 static Thread::LocalStorageKey isolate_key_; | 1042 static Thread::LocalStorageKey isolate_key_; |
| 1009 static Thread::LocalStorageKey thread_id_key_; | 1043 static Thread::LocalStorageKey thread_id_key_; |
| 1010 static Isolate* default_isolate_; | 1044 static Isolate* default_isolate_; |
| 1011 static ThreadDataTable* thread_data_table_; | 1045 static ThreadDataTable* thread_data_table_; |
| 1012 | 1046 |
| 1013 bool PreInit(); | |
| 1014 | |
| 1015 void Deinit(); | 1047 void Deinit(); |
| 1016 | 1048 |
| 1017 static void SetIsolateThreadLocals(Isolate* isolate, | 1049 static void SetIsolateThreadLocals(Isolate* isolate, |
| 1018 PerIsolateThreadData* data); | 1050 PerIsolateThreadData* data); |
| 1019 | 1051 |
| 1020 enum State { | 1052 enum State { |
| 1021 UNINITIALIZED, // Some components may not have been allocated. | 1053 UNINITIALIZED, // Some components may not have been allocated. |
| 1022 PREINITIALIZED, // Components have been allocated but not initialized. | |
| 1023 INITIALIZED // All components are fully initialized. | 1054 INITIALIZED // All components are fully initialized. |
| 1024 }; | 1055 }; |
| 1025 | 1056 |
| 1026 State state_; | 1057 State state_; |
| 1027 EntryStackItem* entry_stack_; | 1058 EntryStackItem* entry_stack_; |
| 1028 | 1059 |
| 1029 // Allocate and insert PerIsolateThreadData into the ThreadDataTable | 1060 // Allocate and insert PerIsolateThreadData into the ThreadDataTable |
| 1030 // (regardless of whether such data already exists). | 1061 // (regardless of whether such data already exists). |
| 1031 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); | 1062 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); |
| 1032 | 1063 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1056 void PrintStackTrace(FILE* out, ThreadLocalTop* thread); | 1087 void PrintStackTrace(FILE* out, ThreadLocalTop* thread); |
| 1057 void MarkCompactPrologue(bool is_compacting, | 1088 void MarkCompactPrologue(bool is_compacting, |
| 1058 ThreadLocalTop* archived_thread_data); | 1089 ThreadLocalTop* archived_thread_data); |
| 1059 void MarkCompactEpilogue(bool is_compacting, | 1090 void MarkCompactEpilogue(bool is_compacting, |
| 1060 ThreadLocalTop* archived_thread_data); | 1091 ThreadLocalTop* archived_thread_data); |
| 1061 | 1092 |
| 1062 void FillCache(); | 1093 void FillCache(); |
| 1063 | 1094 |
| 1064 void PropagatePendingExceptionToExternalTryCatch(); | 1095 void PropagatePendingExceptionToExternalTryCatch(); |
| 1065 | 1096 |
| 1097 void InitializeDebugger(); |
| 1098 |
| 1066 int stack_trace_nesting_level_; | 1099 int stack_trace_nesting_level_; |
| 1067 StringStream* incomplete_message_; | 1100 StringStream* incomplete_message_; |
| 1068 // The preallocated memory thread singleton. | 1101 // The preallocated memory thread singleton. |
| 1069 PreallocatedMemoryThread* preallocated_memory_thread_; | 1102 PreallocatedMemoryThread* preallocated_memory_thread_; |
| 1070 Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT | 1103 Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT |
| 1071 NoAllocationStringAllocator* preallocated_message_space_; | 1104 NoAllocationStringAllocator* preallocated_message_space_; |
| 1072 | 1105 |
| 1073 Bootstrapper* bootstrapper_; | 1106 Bootstrapper* bootstrapper_; |
| 1074 RuntimeProfiler* runtime_profiler_; | 1107 RuntimeProfiler* runtime_profiler_; |
| 1075 CompilationCache* compilation_cache_; | 1108 CompilationCache* compilation_cache_; |
| 1076 Counters* counters_; | 1109 Counters* counters_; |
| 1077 CodeRange* code_range_; | 1110 CodeRange* code_range_; |
| 1078 Mutex* break_access_; | 1111 Mutex* break_access_; |
| 1112 Atomic32 debugger_initialized_; |
| 1113 Mutex* debugger_access_; |
| 1079 Heap heap_; | 1114 Heap heap_; |
| 1080 Logger* logger_; | 1115 Logger* logger_; |
| 1081 StackGuard stack_guard_; | 1116 StackGuard stack_guard_; |
| 1082 StatsTable* stats_table_; | 1117 StatsTable* stats_table_; |
| 1083 StubCache* stub_cache_; | 1118 StubCache* stub_cache_; |
| 1084 DeoptimizerData* deoptimizer_data_; | 1119 DeoptimizerData* deoptimizer_data_; |
| 1085 ThreadLocalTop thread_local_top_; | 1120 ThreadLocalTop thread_local_top_; |
| 1086 bool capture_stack_trace_for_uncaught_exceptions_; | 1121 bool capture_stack_trace_for_uncaught_exceptions_; |
| 1087 int stack_trace_for_uncaught_exceptions_frame_limit_; | 1122 int stack_trace_for_uncaught_exceptions_frame_limit_; |
| 1088 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_; | 1123 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 1193 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 1159 #undef ISOLATE_FIELD_OFFSET | 1194 #undef ISOLATE_FIELD_OFFSET |
| 1160 #endif | 1195 #endif |
| 1161 | 1196 |
| 1162 friend class ExecutionAccess; | 1197 friend class ExecutionAccess; |
| 1163 friend class IsolateInitializer; | 1198 friend class IsolateInitializer; |
| 1164 friend class ThreadManager; | 1199 friend class ThreadManager; |
| 1165 friend class Simulator; | 1200 friend class Simulator; |
| 1166 friend class StackGuard; | 1201 friend class StackGuard; |
| 1167 friend class ThreadId; | 1202 friend class ThreadId; |
| 1203 friend class TestMemoryAllocatorScope; |
| 1168 friend class v8::Isolate; | 1204 friend class v8::Isolate; |
| 1169 friend class v8::Locker; | 1205 friend class v8::Locker; |
| 1170 friend class v8::Unlocker; | 1206 friend class v8::Unlocker; |
| 1171 | 1207 |
| 1172 DISALLOW_COPY_AND_ASSIGN(Isolate); | 1208 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| 1173 }; | 1209 }; |
| 1174 | 1210 |
| 1175 | 1211 |
| 1176 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the | 1212 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
| 1177 // class as a work around for a bug in the generated code found with these | 1213 // class as a work around for a bug in the generated code found with these |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 | 1357 |
| 1322 // Mark the global context with out of memory. | 1358 // Mark the global context with out of memory. |
| 1323 inline void Context::mark_out_of_memory() { | 1359 inline void Context::mark_out_of_memory() { |
| 1324 global_context()->set_out_of_memory(HEAP->true_value()); | 1360 global_context()->set_out_of_memory(HEAP->true_value()); |
| 1325 } | 1361 } |
| 1326 | 1362 |
| 1327 | 1363 |
| 1328 } } // namespace v8::internal | 1364 } } // namespace v8::internal |
| 1329 | 1365 |
| 1330 #endif // V8_ISOLATE_H_ | 1366 #endif // V8_ISOLATE_H_ |
| OLD | NEW |