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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 friend class ThreadDataTable; | 415 friend class ThreadDataTable; |
416 friend class EntryStackItem; | 416 friend class EntryStackItem; |
417 | 417 |
418 DISALLOW_COPY_AND_ASSIGN(PerIsolateThreadData); | 418 DISALLOW_COPY_AND_ASSIGN(PerIsolateThreadData); |
419 }; | 419 }; |
420 | 420 |
421 | 421 |
422 enum AddressId { | 422 enum AddressId { |
423 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address, | 423 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address, |
424 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM) | 424 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM) |
425 #undef C | 425 #undef DECLARE_ENUM |
426 kIsolateAddressCount | 426 kIsolateAddressCount |
427 }; | 427 }; |
428 | 428 |
429 // Returns the PerIsolateThreadData for the current thread (or NULL if one is | 429 // Returns the PerIsolateThreadData for the current thread (or NULL if one is |
430 // not currently set). | 430 // not currently set). |
431 static PerIsolateThreadData* CurrentPerIsolateThreadData() { | 431 static PerIsolateThreadData* CurrentPerIsolateThreadData() { |
432 return reinterpret_cast<PerIsolateThreadData*>( | 432 return reinterpret_cast<PerIsolateThreadData*>( |
433 Thread::GetThreadLocal(per_isolate_thread_data_key_)); | 433 Thread::GetThreadLocal(per_isolate_thread_data_key_)); |
434 } | 434 } |
435 | 435 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1031 } |
1032 date_cache_ = date_cache; | 1032 date_cache_ = date_cache; |
1033 } | 1033 } |
1034 | 1034 |
1035 private: | 1035 private: |
1036 Isolate(); | 1036 Isolate(); |
1037 | 1037 |
1038 friend struct GlobalState; | 1038 friend struct GlobalState; |
1039 friend struct InitializeGlobalState; | 1039 friend struct InitializeGlobalState; |
1040 | 1040 |
| 1041 enum State { |
| 1042 UNINITIALIZED, // Some components may not have been allocated. |
| 1043 INITIALIZED // All components are fully initialized. |
| 1044 }; |
| 1045 |
| 1046 // These fields are accessed through the API, offsets must be kept in sync |
| 1047 // with v8::internal::Internals (in include/v8.h) constants. This is also |
| 1048 // verified in Isolate::Init() using runtime checks. |
| 1049 State state_; // Will be padded to kApiPointerSize. |
| 1050 void* embedder_data_; |
| 1051 Heap heap_; |
| 1052 |
1041 // The per-process lock should be acquired before the ThreadDataTable is | 1053 // The per-process lock should be acquired before the ThreadDataTable is |
1042 // modified. | 1054 // modified. |
1043 class ThreadDataTable { | 1055 class ThreadDataTable { |
1044 public: | 1056 public: |
1045 ThreadDataTable(); | 1057 ThreadDataTable(); |
1046 ~ThreadDataTable(); | 1058 ~ThreadDataTable(); |
1047 | 1059 |
1048 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); | 1060 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); |
1049 void Insert(PerIsolateThreadData* data); | 1061 void Insert(PerIsolateThreadData* data); |
1050 void Remove(Isolate* isolate, ThreadId thread_id); | 1062 void Remove(Isolate* isolate, ThreadId thread_id); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 static Thread::LocalStorageKey isolate_key_; | 1100 static Thread::LocalStorageKey isolate_key_; |
1089 static Thread::LocalStorageKey thread_id_key_; | 1101 static Thread::LocalStorageKey thread_id_key_; |
1090 static Isolate* default_isolate_; | 1102 static Isolate* default_isolate_; |
1091 static ThreadDataTable* thread_data_table_; | 1103 static ThreadDataTable* thread_data_table_; |
1092 | 1104 |
1093 void Deinit(); | 1105 void Deinit(); |
1094 | 1106 |
1095 static void SetIsolateThreadLocals(Isolate* isolate, | 1107 static void SetIsolateThreadLocals(Isolate* isolate, |
1096 PerIsolateThreadData* data); | 1108 PerIsolateThreadData* data); |
1097 | 1109 |
1098 enum State { | |
1099 UNINITIALIZED, // Some components may not have been allocated. | |
1100 INITIALIZED // All components are fully initialized. | |
1101 }; | |
1102 | |
1103 State state_; | |
1104 EntryStackItem* entry_stack_; | |
1105 | |
1106 // Allocate and insert PerIsolateThreadData into the ThreadDataTable | 1110 // Allocate and insert PerIsolateThreadData into the ThreadDataTable |
1107 // (regardless of whether such data already exists). | 1111 // (regardless of whether such data already exists). |
1108 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); | 1112 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); |
1109 | 1113 |
1110 // Find the PerThread for this particular (isolate, thread) combination. | 1114 // Find the PerThread for this particular (isolate, thread) combination. |
1111 // If one does not yet exist, allocate a new one. | 1115 // If one does not yet exist, allocate a new one. |
1112 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1116 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
1113 | 1117 |
1114 // PreInits and returns a default isolate. Needed when a new thread tries | 1118 // PreInits and returns a default isolate. Needed when a new thread tries |
1115 // to create a Locker for the first time (the lock itself is in the isolate). | 1119 // to create a Locker for the first time (the lock itself is in the isolate). |
(...skipping 23 matching lines...) Expand all Loading... |
1139 void FillCache(); | 1143 void FillCache(); |
1140 | 1144 |
1141 void PropagatePendingExceptionToExternalTryCatch(); | 1145 void PropagatePendingExceptionToExternalTryCatch(); |
1142 | 1146 |
1143 void InitializeDebugger(); | 1147 void InitializeDebugger(); |
1144 | 1148 |
1145 // Traverse prototype chain to find out whether the object is derived from | 1149 // Traverse prototype chain to find out whether the object is derived from |
1146 // the Error object. | 1150 // the Error object. |
1147 bool IsErrorObject(Handle<Object> obj); | 1151 bool IsErrorObject(Handle<Object> obj); |
1148 | 1152 |
| 1153 EntryStackItem* entry_stack_; |
1149 int stack_trace_nesting_level_; | 1154 int stack_trace_nesting_level_; |
1150 StringStream* incomplete_message_; | 1155 StringStream* incomplete_message_; |
1151 // The preallocated memory thread singleton. | 1156 // The preallocated memory thread singleton. |
1152 PreallocatedMemoryThread* preallocated_memory_thread_; | 1157 PreallocatedMemoryThread* preallocated_memory_thread_; |
1153 Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT | 1158 Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT |
1154 NoAllocationStringAllocator* preallocated_message_space_; | 1159 NoAllocationStringAllocator* preallocated_message_space_; |
1155 | |
1156 Bootstrapper* bootstrapper_; | 1160 Bootstrapper* bootstrapper_; |
1157 RuntimeProfiler* runtime_profiler_; | 1161 RuntimeProfiler* runtime_profiler_; |
1158 CompilationCache* compilation_cache_; | 1162 CompilationCache* compilation_cache_; |
1159 Counters* counters_; | 1163 Counters* counters_; |
1160 CodeRange* code_range_; | 1164 CodeRange* code_range_; |
1161 Mutex* break_access_; | 1165 Mutex* break_access_; |
1162 Atomic32 debugger_initialized_; | 1166 Atomic32 debugger_initialized_; |
1163 Mutex* debugger_access_; | 1167 Mutex* debugger_access_; |
1164 Heap heap_; | |
1165 Logger* logger_; | 1168 Logger* logger_; |
1166 StackGuard stack_guard_; | 1169 StackGuard stack_guard_; |
1167 StatsTable* stats_table_; | 1170 StatsTable* stats_table_; |
1168 StubCache* stub_cache_; | 1171 StubCache* stub_cache_; |
1169 DeoptimizerData* deoptimizer_data_; | 1172 DeoptimizerData* deoptimizer_data_; |
1170 ThreadLocalTop thread_local_top_; | 1173 ThreadLocalTop thread_local_top_; |
1171 bool capture_stack_trace_for_uncaught_exceptions_; | 1174 bool capture_stack_trace_for_uncaught_exceptions_; |
1172 int stack_trace_for_uncaught_exceptions_frame_limit_; | 1175 int stack_trace_for_uncaught_exceptions_frame_limit_; |
1173 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_; | 1176 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_; |
1174 TranscendentalCache* transcendental_cache_; | 1177 TranscendentalCache* transcendental_cache_; |
(...skipping 20 matching lines...) Expand all Loading... |
1195 bool has_installed_extensions_; | 1198 bool has_installed_extensions_; |
1196 StringTracker* string_tracker_; | 1199 StringTracker* string_tracker_; |
1197 unibrow::Mapping<unibrow::Ecma262UnCanonicalize> jsregexp_uncanonicalize_; | 1200 unibrow::Mapping<unibrow::Ecma262UnCanonicalize> jsregexp_uncanonicalize_; |
1198 unibrow::Mapping<unibrow::CanonicalizationRange> jsregexp_canonrange_; | 1201 unibrow::Mapping<unibrow::CanonicalizationRange> jsregexp_canonrange_; |
1199 StringInputBuffer objects_string_compare_buffer_a_; | 1202 StringInputBuffer objects_string_compare_buffer_a_; |
1200 StringInputBuffer objects_string_compare_buffer_b_; | 1203 StringInputBuffer objects_string_compare_buffer_b_; |
1201 StaticResource<StringInputBuffer> objects_string_input_buffer_; | 1204 StaticResource<StringInputBuffer> objects_string_input_buffer_; |
1202 unibrow::Mapping<unibrow::Ecma262Canonicalize> | 1205 unibrow::Mapping<unibrow::Ecma262Canonicalize> |
1203 regexp_macro_assembler_canonicalize_; | 1206 regexp_macro_assembler_canonicalize_; |
1204 RegExpStack* regexp_stack_; | 1207 RegExpStack* regexp_stack_; |
1205 | |
1206 DateCache* date_cache_; | 1208 DateCache* date_cache_; |
1207 | |
1208 unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; | 1209 unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; |
1209 void* embedder_data_; | |
1210 | 1210 |
1211 // The garbage collector should be a little more aggressive when it knows | 1211 // The garbage collector should be a little more aggressive when it knows |
1212 // that a context was recently exited. | 1212 // that a context was recently exited. |
1213 bool context_exit_happened_; | 1213 bool context_exit_happened_; |
1214 | 1214 |
1215 // Time stamp at initialization. | 1215 // Time stamp at initialization. |
1216 double time_millis_at_init_; | 1216 double time_millis_at_init_; |
1217 | 1217 |
1218 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \ | 1218 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \ |
1219 defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__) | 1219 defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 | 1406 |
1407 // Mark the global context with out of memory. | 1407 // Mark the global context with out of memory. |
1408 inline void Context::mark_out_of_memory() { | 1408 inline void Context::mark_out_of_memory() { |
1409 global_context()->set_out_of_memory(HEAP->true_value()); | 1409 global_context()->set_out_of_memory(HEAP->true_value()); |
1410 } | 1410 } |
1411 | 1411 |
1412 | 1412 |
1413 } } // namespace v8::internal | 1413 } } // namespace v8::internal |
1414 | 1414 |
1415 #endif // V8_ISOLATE_H_ | 1415 #endif // V8_ISOLATE_H_ |
OLD | NEW |