| 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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 void SetData(void* data) { embedder_data_ = data; } | 1057 void SetData(void* data) { embedder_data_ = data; } |
| 1058 void* GetData() { return embedder_data_; } | 1058 void* GetData() { return embedder_data_; } |
| 1059 | 1059 |
| 1060 LookupResult* top_lookup_result() { | 1060 LookupResult* top_lookup_result() { |
| 1061 return thread_local_top_.top_lookup_result_; | 1061 return thread_local_top_.top_lookup_result_; |
| 1062 } | 1062 } |
| 1063 void SetTopLookupResult(LookupResult* top) { | 1063 void SetTopLookupResult(LookupResult* top) { |
| 1064 thread_local_top_.top_lookup_result_ = top; | 1064 thread_local_top_.top_lookup_result_ = top; |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 bool IsDead() { return has_fatal_error_; } |
| 1068 void SignalFatalError() { has_fatal_error_ = true; } |
| 1069 |
| 1070 bool use_crankshaft() const { return use_crankshaft_; } |
| 1071 |
| 1067 bool initialized_from_snapshot() { return initialized_from_snapshot_; } | 1072 bool initialized_from_snapshot() { return initialized_from_snapshot_; } |
| 1068 | 1073 |
| 1069 double time_millis_since_init() { | 1074 double time_millis_since_init() { |
| 1070 return OS::TimeCurrentMillis() - time_millis_at_init_; | 1075 return OS::TimeCurrentMillis() - time_millis_at_init_; |
| 1071 } | 1076 } |
| 1072 | 1077 |
| 1073 DateCache* date_cache() { | 1078 DateCache* date_cache() { |
| 1074 return date_cache_; | 1079 return date_cache_; |
| 1075 } | 1080 } |
| 1076 | 1081 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1153 |
| 1149 // The per-process lock should be acquired before the ThreadDataTable is | 1154 // The per-process lock should be acquired before the ThreadDataTable is |
| 1150 // modified. | 1155 // modified. |
| 1151 class ThreadDataTable { | 1156 class ThreadDataTable { |
| 1152 public: | 1157 public: |
| 1153 ThreadDataTable(); | 1158 ThreadDataTable(); |
| 1154 ~ThreadDataTable(); | 1159 ~ThreadDataTable(); |
| 1155 | 1160 |
| 1156 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); | 1161 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); |
| 1157 void Insert(PerIsolateThreadData* data); | 1162 void Insert(PerIsolateThreadData* data); |
| 1158 void Remove(Isolate* isolate, ThreadId thread_id); | |
| 1159 void Remove(PerIsolateThreadData* data); | 1163 void Remove(PerIsolateThreadData* data); |
| 1160 void RemoveAllThreads(Isolate* isolate); | 1164 void RemoveAllThreads(Isolate* isolate); |
| 1161 | 1165 |
| 1162 private: | 1166 private: |
| 1163 PerIsolateThreadData* list_; | 1167 PerIsolateThreadData* list_; |
| 1164 }; | 1168 }; |
| 1165 | 1169 |
| 1166 // These items form a stack synchronously with threads Enter'ing and Exit'ing | 1170 // These items form a stack synchronously with threads Enter'ing and Exit'ing |
| 1167 // the Isolate. The top of the stack points to a thread which is currently | 1171 // the Isolate. The top of the stack points to a thread which is currently |
| 1168 // running the Isolate. When the stack is empty, the Isolate is considered | 1172 // running the Isolate. When the stack is empty, the Isolate is considered |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1183 PerIsolateThreadData* previous_thread_data; | 1187 PerIsolateThreadData* previous_thread_data; |
| 1184 Isolate* previous_isolate; | 1188 Isolate* previous_isolate; |
| 1185 EntryStackItem* previous_item; | 1189 EntryStackItem* previous_item; |
| 1186 | 1190 |
| 1187 private: | 1191 private: |
| 1188 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); | 1192 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); |
| 1189 }; | 1193 }; |
| 1190 | 1194 |
| 1191 // This mutex protects highest_thread_id_, thread_data_table_ and | 1195 // This mutex protects highest_thread_id_, thread_data_table_ and |
| 1192 // default_isolate_. | 1196 // default_isolate_. |
| 1193 static RecursiveMutex process_wide_mutex_; | 1197 static Mutex process_wide_mutex_; |
| 1194 | 1198 |
| 1195 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1199 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
| 1196 static Thread::LocalStorageKey isolate_key_; | 1200 static Thread::LocalStorageKey isolate_key_; |
| 1197 static Thread::LocalStorageKey thread_id_key_; | 1201 static Thread::LocalStorageKey thread_id_key_; |
| 1198 static Isolate* default_isolate_; | 1202 static Isolate* default_isolate_; |
| 1199 static ThreadDataTable* thread_data_table_; | 1203 static ThreadDataTable* thread_data_table_; |
| 1200 | 1204 |
| 1201 // A global counter for all generated Isolates, might overflow. | 1205 // A global counter for all generated Isolates, might overflow. |
| 1202 static Atomic32 isolate_counter_; | 1206 static Atomic32 isolate_counter_; |
| 1203 | 1207 |
| 1204 void Deinit(); | 1208 void Deinit(); |
| 1205 | 1209 |
| 1206 static void SetIsolateThreadLocals(Isolate* isolate, | 1210 static void SetIsolateThreadLocals(Isolate* isolate, |
| 1207 PerIsolateThreadData* data); | 1211 PerIsolateThreadData* data); |
| 1208 | 1212 |
| 1209 // Allocate and insert PerIsolateThreadData into the ThreadDataTable | |
| 1210 // (regardless of whether such data already exists). | |
| 1211 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); | |
| 1212 | |
| 1213 // Find the PerThread for this particular (isolate, thread) combination. | 1213 // Find the PerThread for this particular (isolate, thread) combination. |
| 1214 // If one does not yet exist, allocate a new one. | 1214 // If one does not yet exist, allocate a new one. |
| 1215 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1215 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
| 1216 | 1216 |
| 1217 // Initializes the current thread to run this Isolate. | 1217 // Initializes the current thread to run this Isolate. |
| 1218 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate | 1218 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate |
| 1219 // at the same time, this should be prevented using external locking. | 1219 // at the same time, this should be prevented using external locking. |
| 1220 void Enter(); | 1220 void Enter(); |
| 1221 | 1221 |
| 1222 // Exits the current thread. The previosuly entered Isolate is restored | 1222 // Exits the current thread. The previosuly entered Isolate is restored |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 ConsStringIteratorOp objects_string_compare_iterator_a_; | 1298 ConsStringIteratorOp objects_string_compare_iterator_a_; |
| 1299 ConsStringIteratorOp objects_string_compare_iterator_b_; | 1299 ConsStringIteratorOp objects_string_compare_iterator_b_; |
| 1300 StaticResource<ConsStringIteratorOp> objects_string_iterator_; | 1300 StaticResource<ConsStringIteratorOp> objects_string_iterator_; |
| 1301 unibrow::Mapping<unibrow::Ecma262Canonicalize> | 1301 unibrow::Mapping<unibrow::Ecma262Canonicalize> |
| 1302 regexp_macro_assembler_canonicalize_; | 1302 regexp_macro_assembler_canonicalize_; |
| 1303 RegExpStack* regexp_stack_; | 1303 RegExpStack* regexp_stack_; |
| 1304 DateCache* date_cache_; | 1304 DateCache* date_cache_; |
| 1305 unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; | 1305 unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; |
| 1306 CodeStubInterfaceDescriptor* code_stub_interface_descriptors_; | 1306 CodeStubInterfaceDescriptor* code_stub_interface_descriptors_; |
| 1307 | 1307 |
| 1308 // True if fatal error has been signaled for this isolate. |
| 1309 bool has_fatal_error_; |
| 1310 |
| 1311 // True if we are using the Crankshaft optimizing compiler. |
| 1312 bool use_crankshaft_; |
| 1313 |
| 1308 // True if this isolate was initialized from a snapshot. | 1314 // True if this isolate was initialized from a snapshot. |
| 1309 bool initialized_from_snapshot_; | 1315 bool initialized_from_snapshot_; |
| 1310 | 1316 |
| 1311 // Time stamp at initialization. | 1317 // Time stamp at initialization. |
| 1312 double time_millis_at_init_; | 1318 double time_millis_at_init_; |
| 1313 | 1319 |
| 1314 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \ | 1320 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \ |
| 1315 V8_TARGET_ARCH_A64 && !defined(__aarch64__) || \ | 1321 V8_TARGET_ARCH_A64 && !defined(__aarch64__) || \ |
| 1316 V8_TARGET_ARCH_MIPS && !defined(__mips__) | 1322 V8_TARGET_ARCH_MIPS && !defined(__mips__) |
| 1317 bool simulator_initialized_; | 1323 bool simulator_initialized_; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1390 |
| 1385 | 1391 |
| 1386 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the | 1392 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
| 1387 // class as a work around for a bug in the generated code found with these | 1393 // class as a work around for a bug in the generated code found with these |
| 1388 // versions of GCC. See V8 issue 122 for details. | 1394 // versions of GCC. See V8 issue 122 for details. |
| 1389 class SaveContext BASE_EMBEDDED { | 1395 class SaveContext BASE_EMBEDDED { |
| 1390 public: | 1396 public: |
| 1391 inline explicit SaveContext(Isolate* isolate); | 1397 inline explicit SaveContext(Isolate* isolate); |
| 1392 | 1398 |
| 1393 ~SaveContext() { | 1399 ~SaveContext() { |
| 1394 if (context_.is_null()) { | 1400 isolate_->set_context(context_.is_null() ? NULL : *context_); |
| 1395 Isolate* isolate = Isolate::Current(); | 1401 isolate_->set_save_context(prev_); |
| 1396 isolate->set_context(NULL); | |
| 1397 isolate->set_save_context(prev_); | |
| 1398 } else { | |
| 1399 Isolate* isolate = context_->GetIsolate(); | |
| 1400 isolate->set_context(*context_); | |
| 1401 isolate->set_save_context(prev_); | |
| 1402 } | |
| 1403 } | 1402 } |
| 1404 | 1403 |
| 1405 Handle<Context> context() { return context_; } | 1404 Handle<Context> context() { return context_; } |
| 1406 SaveContext* prev() { return prev_; } | 1405 SaveContext* prev() { return prev_; } |
| 1407 | 1406 |
| 1408 // Returns true if this save context is below a given JavaScript frame. | 1407 // Returns true if this save context is below a given JavaScript frame. |
| 1409 bool IsBelowFrame(JavaScriptFrame* frame) { | 1408 bool IsBelowFrame(JavaScriptFrame* frame) { |
| 1410 return (c_entry_fp_ == 0) || (c_entry_fp_ > frame->sp()); | 1409 return (c_entry_fp_ == 0) || (c_entry_fp_ > frame->sp()); |
| 1411 } | 1410 } |
| 1412 | 1411 |
| 1413 private: | 1412 private: |
| 1413 Isolate* isolate_; |
| 1414 Handle<Context> context_; | 1414 Handle<Context> context_; |
| 1415 SaveContext* prev_; | 1415 SaveContext* prev_; |
| 1416 Address c_entry_fp_; | 1416 Address c_entry_fp_; |
| 1417 }; | 1417 }; |
| 1418 | 1418 |
| 1419 | 1419 |
| 1420 class AssertNoContextChange BASE_EMBEDDED { | 1420 class AssertNoContextChange BASE_EMBEDDED { |
| 1421 #ifdef DEBUG | 1421 #ifdef DEBUG |
| 1422 public: | 1422 public: |
| 1423 AssertNoContextChange() : context_(Isolate::Current()->context()) { } | 1423 AssertNoContextChange() : context_(Isolate::Current()->context()) { } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 | 1526 |
| 1527 // Mark the native context with out of memory. | 1527 // Mark the native context with out of memory. |
| 1528 inline void Context::mark_out_of_memory() { | 1528 inline void Context::mark_out_of_memory() { |
| 1529 native_context()->set_out_of_memory(HEAP->true_value()); | 1529 native_context()->set_out_of_memory(HEAP->true_value()); |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 | 1532 |
| 1533 } } // namespace v8::internal | 1533 } } // namespace v8::internal |
| 1534 | 1534 |
| 1535 #endif // V8_ISOLATE_H_ | 1535 #endif // V8_ISOLATE_H_ |
| OLD | NEW |