Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/isolate.h

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_ISOLATE_H_ 5 #ifndef V8_ISOLATE_H_
6 #define V8_ISOLATE_H_ 6 #define V8_ISOLATE_H_
7 7
8 #include "include/v8-debug.h" 8 #include "include/v8-debug.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
11 #include "src/base/atomicops.h" 11 #include "src/base/atomicops.h"
12 #include "src/builtins.h" 12 #include "src/builtins.h"
13 #include "src/contexts.h" 13 #include "src/contexts.h"
14 #include "src/date.h" 14 #include "src/date.h"
15 #include "src/execution.h" 15 #include "src/execution.h"
16 #include "src/frames.h" 16 #include "src/frames.h"
17 #include "src/global-handles.h" 17 #include "src/global-handles.h"
18 #include "src/handles.h" 18 #include "src/handles.h"
19 #include "src/hashmap.h" 19 #include "src/hashmap.h"
20 #include "src/heap.h" 20 #include "src/heap.h"
21 #include "src/optimizing-compiler-thread.h" 21 #include "src/optimizing-compiler-thread.h"
22 #include "src/regexp-stack.h" 22 #include "src/regexp-stack.h"
23 #include "src/runtime.h" 23 #include "src/runtime.h"
24 #include "src/runtime-profiler.h" 24 #include "src/runtime-profiler.h"
25 #include "src/zone.h" 25 #include "src/zone.h"
26 26
27 namespace v8 { 27 namespace v8 {
28
29 namespace base {
30 class RandomNumberGenerator;
31 }
32
28 namespace internal { 33 namespace internal {
29 34
30 class Bootstrapper; 35 class Bootstrapper;
31 class CallInterfaceDescriptor; 36 class CallInterfaceDescriptor;
32 class CodeGenerator; 37 class CodeGenerator;
33 class CodeRange; 38 class CodeRange;
34 class CodeStubInterfaceDescriptor; 39 class CodeStubInterfaceDescriptor;
35 class CodeTracer; 40 class CodeTracer;
36 class CompilationCache; 41 class CompilationCache;
37 class ConsStringIteratorOp; 42 class ConsStringIteratorOp;
(...skipping 10 matching lines...) Expand all
48 class FunctionInfoListener; 53 class FunctionInfoListener;
49 class HandleScopeImplementer; 54 class HandleScopeImplementer;
50 class HeapProfiler; 55 class HeapProfiler;
51 class HStatistics; 56 class HStatistics;
52 class HTracer; 57 class HTracer;
53 class InlineRuntimeFunctionsTable; 58 class InlineRuntimeFunctionsTable;
54 class InnerPointerToCodeCache; 59 class InnerPointerToCodeCache;
55 class MaterializedObjectStore; 60 class MaterializedObjectStore;
56 class NoAllocationStringAllocator; 61 class NoAllocationStringAllocator;
57 class CodeAgingHelper; 62 class CodeAgingHelper;
58 class RandomNumberGenerator;
59 class RegExpStack; 63 class RegExpStack;
60 class SaveContext; 64 class SaveContext;
61 class StringTracker; 65 class StringTracker;
62 class StubCache; 66 class StubCache;
63 class SweeperThread; 67 class SweeperThread;
64 class ThreadManager; 68 class ThreadManager;
65 class ThreadState; 69 class ThreadState;
66 class ThreadVisitor; // Defined in v8threads.h 70 class ThreadVisitor; // Defined in v8threads.h
67 class UnicodeCache; 71 class UnicodeCache;
68 template <StateTag Tag> class VMState; 72 template <StateTag Tag> class VMState;
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address, 442 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address,
439 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM) 443 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM)
440 #undef DECLARE_ENUM 444 #undef DECLARE_ENUM
441 kIsolateAddressCount 445 kIsolateAddressCount
442 }; 446 };
443 447
444 // Returns the PerIsolateThreadData for the current thread (or NULL if one is 448 // Returns the PerIsolateThreadData for the current thread (or NULL if one is
445 // not currently set). 449 // not currently set).
446 static PerIsolateThreadData* CurrentPerIsolateThreadData() { 450 static PerIsolateThreadData* CurrentPerIsolateThreadData() {
447 return reinterpret_cast<PerIsolateThreadData*>( 451 return reinterpret_cast<PerIsolateThreadData*>(
448 Thread::GetThreadLocal(per_isolate_thread_data_key_)); 452 base::Thread::GetThreadLocal(per_isolate_thread_data_key_));
449 } 453 }
450 454
451 // Returns the isolate inside which the current thread is running. 455 // Returns the isolate inside which the current thread is running.
452 INLINE(static Isolate* Current()) { 456 INLINE(static Isolate* Current()) {
453 Isolate* isolate = reinterpret_cast<Isolate*>( 457 Isolate* isolate = reinterpret_cast<Isolate*>(
454 Thread::GetExistingThreadLocal(isolate_key_)); 458 base::Thread::GetExistingThreadLocal(isolate_key_));
455 ASSERT(isolate != NULL); 459 ASSERT(isolate != NULL);
456 return isolate; 460 return isolate;
457 } 461 }
458 462
459 INLINE(static Isolate* UncheckedCurrent()) { 463 INLINE(static Isolate* UncheckedCurrent()) {
460 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_)); 464 return reinterpret_cast<Isolate*>(
465 base::Thread::GetThreadLocal(isolate_key_));
461 } 466 }
462 467
463 // Usually called by Init(), but can be called early e.g. to allow 468 // Usually called by Init(), but can be called early e.g. to allow
464 // testing components that require logging but not the whole 469 // testing components that require logging but not the whole
465 // isolate. 470 // isolate.
466 // 471 //
467 // Safe to call more than once. 472 // Safe to call more than once.
468 void InitializeLoggingAndCounters(); 473 void InitializeLoggingAndCounters();
469 474
470 bool Init(Deserializer* des); 475 bool Init(Deserializer* des);
(...skipping 21 matching lines...) Expand all
492 // If one does not yet exist, return null. 497 // If one does not yet exist, return null.
493 PerIsolateThreadData* FindPerThreadDataForThisThread(); 498 PerIsolateThreadData* FindPerThreadDataForThisThread();
494 499
495 // Find the PerThread for given (isolate, thread) combination 500 // Find the PerThread for given (isolate, thread) combination
496 // If one does not yet exist, return null. 501 // If one does not yet exist, return null.
497 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); 502 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id);
498 503
499 // Returns the key used to store the pointer to the current isolate. 504 // Returns the key used to store the pointer to the current isolate.
500 // Used internally for V8 threads that do not execute JavaScript but still 505 // Used internally for V8 threads that do not execute JavaScript but still
501 // are part of the domain of an isolate (like the context switcher). 506 // are part of the domain of an isolate (like the context switcher).
502 static Thread::LocalStorageKey isolate_key() { 507 static base::Thread::LocalStorageKey isolate_key() {
503 return isolate_key_; 508 return isolate_key_;
504 } 509 }
505 510
506 // Returns the key used to store process-wide thread IDs. 511 // Returns the key used to store process-wide thread IDs.
507 static Thread::LocalStorageKey thread_id_key() { 512 static base::Thread::LocalStorageKey thread_id_key() {
508 return thread_id_key_; 513 return thread_id_key_;
509 } 514 }
510 515
511 static Thread::LocalStorageKey per_isolate_thread_data_key(); 516 static base::Thread::LocalStorageKey per_isolate_thread_data_key();
512 517
513 // Mutex for serializing access to break control structures. 518 // Mutex for serializing access to break control structures.
514 RecursiveMutex* break_access() { return &break_access_; } 519 base::RecursiveMutex* break_access() { return &break_access_; }
515 520
516 Address get_address_from_id(AddressId id); 521 Address get_address_from_id(AddressId id);
517 522
518 // Access to top context (where the current function object was created). 523 // Access to top context (where the current function object was created).
519 Context* context() { return thread_local_top_.context_; } 524 Context* context() { return thread_local_top_.context_; }
520 void set_context(Context* context) { 525 void set_context(Context* context) {
521 ASSERT(context == NULL || context->IsContext()); 526 ASSERT(context == NULL || context->IsContext());
522 thread_local_top_.context_ = context; 527 thread_local_top_.context_ = context;
523 } 528 }
524 Context** context_address() { return &thread_local_top_.context_; } 529 Context** context_address() { return &thread_local_top_.context_; }
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 bool serializer_enabled() const { return serializer_enabled_; } 977 bool serializer_enabled() const { return serializer_enabled_; }
973 978
974 bool IsDead() { return has_fatal_error_; } 979 bool IsDead() { return has_fatal_error_; }
975 void SignalFatalError() { has_fatal_error_ = true; } 980 void SignalFatalError() { has_fatal_error_ = true; }
976 981
977 bool use_crankshaft() const; 982 bool use_crankshaft() const;
978 983
979 bool initialized_from_snapshot() { return initialized_from_snapshot_; } 984 bool initialized_from_snapshot() { return initialized_from_snapshot_; }
980 985
981 double time_millis_since_init() { 986 double time_millis_since_init() {
982 return OS::TimeCurrentMillis() - time_millis_at_init_; 987 return base::OS::TimeCurrentMillis() - time_millis_at_init_;
983 } 988 }
984 989
985 DateCache* date_cache() { 990 DateCache* date_cache() {
986 return date_cache_; 991 return date_cache_;
987 } 992 }
988 993
989 void set_date_cache(DateCache* date_cache) { 994 void set_date_cache(DateCache* date_cache) {
990 if (date_cache != date_cache_) { 995 if (date_cache != date_cache_) {
991 delete date_cache_; 996 delete date_cache_;
992 } 997 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 HTracer* GetHTracer(); 1056 HTracer* GetHTracer();
1052 CodeTracer* GetCodeTracer(); 1057 CodeTracer* GetCodeTracer();
1053 1058
1054 FunctionEntryHook function_entry_hook() { return function_entry_hook_; } 1059 FunctionEntryHook function_entry_hook() { return function_entry_hook_; }
1055 void set_function_entry_hook(FunctionEntryHook function_entry_hook) { 1060 void set_function_entry_hook(FunctionEntryHook function_entry_hook) {
1056 function_entry_hook_ = function_entry_hook; 1061 function_entry_hook_ = function_entry_hook;
1057 } 1062 }
1058 1063
1059 void* stress_deopt_count_address() { return &stress_deopt_count_; } 1064 void* stress_deopt_count_address() { return &stress_deopt_count_; }
1060 1065
1061 inline RandomNumberGenerator* random_number_generator(); 1066 inline base::RandomNumberGenerator* random_number_generator();
1062 1067
1063 // Given an address occupied by a live code object, return that object. 1068 // Given an address occupied by a live code object, return that object.
1064 Object* FindCodeObject(Address a); 1069 Object* FindCodeObject(Address a);
1065 1070
1066 int NextOptimizationId() { 1071 int NextOptimizationId() {
1067 int id = next_optimization_id_++; 1072 int id = next_optimization_id_++;
1068 if (!Smi::IsValid(next_optimization_id_)) { 1073 if (!Smi::IsValid(next_optimization_id_)) {
1069 next_optimization_id_ = 0; 1074 next_optimization_id_ = 0;
1070 } 1075 }
1071 return id; 1076 return id;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 int entry_count; 1142 int entry_count;
1138 PerIsolateThreadData* previous_thread_data; 1143 PerIsolateThreadData* previous_thread_data;
1139 Isolate* previous_isolate; 1144 Isolate* previous_isolate;
1140 EntryStackItem* previous_item; 1145 EntryStackItem* previous_item;
1141 1146
1142 private: 1147 private:
1143 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); 1148 DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
1144 }; 1149 };
1145 1150
1146 // This mutex protects highest_thread_id_ and thread_data_table_. 1151 // This mutex protects highest_thread_id_ and thread_data_table_.
1147 static Mutex process_wide_mutex_; 1152 static base::Mutex process_wide_mutex_;
1148 1153
1149 static Thread::LocalStorageKey per_isolate_thread_data_key_; 1154 static base::Thread::LocalStorageKey per_isolate_thread_data_key_;
1150 static Thread::LocalStorageKey isolate_key_; 1155 static base::Thread::LocalStorageKey isolate_key_;
1151 static Thread::LocalStorageKey thread_id_key_; 1156 static base::Thread::LocalStorageKey thread_id_key_;
1152 static ThreadDataTable* thread_data_table_; 1157 static ThreadDataTable* thread_data_table_;
1153 1158
1154 // A global counter for all generated Isolates, might overflow. 1159 // A global counter for all generated Isolates, might overflow.
1155 static base::Atomic32 isolate_counter_; 1160 static base::Atomic32 isolate_counter_;
1156 1161
1157 void Deinit(); 1162 void Deinit();
1158 1163
1159 static void SetIsolateThreadLocals(Isolate* isolate, 1164 static void SetIsolateThreadLocals(Isolate* isolate,
1160 PerIsolateThreadData* data); 1165 PerIsolateThreadData* data);
1161 1166
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 base::Atomic32 id_; 1200 base::Atomic32 id_;
1196 EntryStackItem* entry_stack_; 1201 EntryStackItem* entry_stack_;
1197 int stack_trace_nesting_level_; 1202 int stack_trace_nesting_level_;
1198 StringStream* incomplete_message_; 1203 StringStream* incomplete_message_;
1199 Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT 1204 Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT
1200 Bootstrapper* bootstrapper_; 1205 Bootstrapper* bootstrapper_;
1201 RuntimeProfiler* runtime_profiler_; 1206 RuntimeProfiler* runtime_profiler_;
1202 CompilationCache* compilation_cache_; 1207 CompilationCache* compilation_cache_;
1203 Counters* counters_; 1208 Counters* counters_;
1204 CodeRange* code_range_; 1209 CodeRange* code_range_;
1205 RecursiveMutex break_access_; 1210 base::RecursiveMutex break_access_;
1206 base::Atomic32 debugger_initialized_; 1211 base::Atomic32 debugger_initialized_;
1207 Logger* logger_; 1212 Logger* logger_;
1208 StackGuard stack_guard_; 1213 StackGuard stack_guard_;
1209 StatsTable* stats_table_; 1214 StatsTable* stats_table_;
1210 StubCache* stub_cache_; 1215 StubCache* stub_cache_;
1211 CodeAgingHelper* code_aging_helper_; 1216 CodeAgingHelper* code_aging_helper_;
1212 DeoptimizerData* deoptimizer_data_; 1217 DeoptimizerData* deoptimizer_data_;
1213 MaterializedObjectStore* materialized_object_store_; 1218 MaterializedObjectStore* materialized_object_store_;
1214 ThreadLocalTop thread_local_top_; 1219 ThreadLocalTop thread_local_top_;
1215 bool capture_stack_trace_for_uncaught_exceptions_; 1220 bool capture_stack_trace_for_uncaught_exceptions_;
(...skipping 21 matching lines...) Expand all
1237 ConsStringIteratorOp objects_string_compare_iterator_a_; 1242 ConsStringIteratorOp objects_string_compare_iterator_a_;
1238 ConsStringIteratorOp objects_string_compare_iterator_b_; 1243 ConsStringIteratorOp objects_string_compare_iterator_b_;
1239 StaticResource<ConsStringIteratorOp> objects_string_iterator_; 1244 StaticResource<ConsStringIteratorOp> objects_string_iterator_;
1240 unibrow::Mapping<unibrow::Ecma262Canonicalize> 1245 unibrow::Mapping<unibrow::Ecma262Canonicalize>
1241 regexp_macro_assembler_canonicalize_; 1246 regexp_macro_assembler_canonicalize_;
1242 RegExpStack* regexp_stack_; 1247 RegExpStack* regexp_stack_;
1243 DateCache* date_cache_; 1248 DateCache* date_cache_;
1244 unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; 1249 unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
1245 CodeStubInterfaceDescriptor* code_stub_interface_descriptors_; 1250 CodeStubInterfaceDescriptor* code_stub_interface_descriptors_;
1246 CallInterfaceDescriptor* call_descriptors_; 1251 CallInterfaceDescriptor* call_descriptors_;
1247 RandomNumberGenerator* random_number_generator_; 1252 base::RandomNumberGenerator* random_number_generator_;
1248 1253
1249 // Whether the isolate has been created for snapshotting. 1254 // Whether the isolate has been created for snapshotting.
1250 bool serializer_enabled_; 1255 bool serializer_enabled_;
1251 1256
1252 // True if fatal error has been signaled for this isolate. 1257 // True if fatal error has been signaled for this isolate.
1253 bool has_fatal_error_; 1258 bool has_fatal_error_;
1254 1259
1255 // True if this isolate was initialized from a snapshot. 1260 // True if this isolate was initialized from a snapshot.
1256 bool initialized_from_snapshot_; 1261 bool initialized_from_snapshot_;
1257 1262
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 : file_(NULL), 1450 : file_(NULL),
1446 scope_depth_(0) { 1451 scope_depth_(0) {
1447 if (!ShouldRedirect()) { 1452 if (!ShouldRedirect()) {
1448 file_ = stdout; 1453 file_ = stdout;
1449 return; 1454 return;
1450 } 1455 }
1451 1456
1452 if (FLAG_redirect_code_traces_to == NULL) { 1457 if (FLAG_redirect_code_traces_to == NULL) {
1453 SNPrintF(filename_, 1458 SNPrintF(filename_,
1454 "code-%d-%d.asm", 1459 "code-%d-%d.asm",
1455 OS::GetCurrentProcessId(), 1460 base::OS::GetCurrentProcessId(),
1456 isolate_id); 1461 isolate_id);
1457 } else { 1462 } else {
1458 StrNCpy(filename_, FLAG_redirect_code_traces_to, filename_.length()); 1463 StrNCpy(filename_, FLAG_redirect_code_traces_to, filename_.length());
1459 } 1464 }
1460 1465
1461 WriteChars(filename_.start(), "", 0, false); 1466 WriteChars(filename_.start(), "", 0, false);
1462 } 1467 }
1463 1468
1464 class Scope { 1469 class Scope {
1465 public: 1470 public:
1466 explicit Scope(CodeTracer* tracer) : tracer_(tracer) { tracer->OpenFile(); } 1471 explicit Scope(CodeTracer* tracer) : tracer_(tracer) { tracer->OpenFile(); }
1467 ~Scope() { tracer_->CloseFile(); } 1472 ~Scope() { tracer_->CloseFile(); }
1468 1473
1469 FILE* file() const { return tracer_->file(); } 1474 FILE* file() const { return tracer_->file(); }
1470 1475
1471 private: 1476 private:
1472 CodeTracer* tracer_; 1477 CodeTracer* tracer_;
1473 }; 1478 };
1474 1479
1475 void OpenFile() { 1480 void OpenFile() {
1476 if (!ShouldRedirect()) { 1481 if (!ShouldRedirect()) {
1477 return; 1482 return;
1478 } 1483 }
1479 1484
1480 if (file_ == NULL) { 1485 if (file_ == NULL) {
1481 file_ = OS::FOpen(filename_.start(), "a"); 1486 file_ = base::OS::FOpen(filename_.start(), "a");
1482 } 1487 }
1483 1488
1484 scope_depth_++; 1489 scope_depth_++;
1485 } 1490 }
1486 1491
1487 void CloseFile() { 1492 void CloseFile() {
1488 if (!ShouldRedirect()) { 1493 if (!ShouldRedirect()) {
1489 return; 1494 return;
1490 } 1495 }
1491 1496
(...skipping 11 matching lines...) Expand all
1503 } 1508 }
1504 1509
1505 EmbeddedVector<char, 128> filename_; 1510 EmbeddedVector<char, 128> filename_;
1506 FILE* file_; 1511 FILE* file_;
1507 int scope_depth_; 1512 int scope_depth_;
1508 }; 1513 };
1509 1514
1510 } } // namespace v8::internal 1515 } } // namespace v8::internal
1511 1516
1512 #endif // V8_ISOLATE_H_ 1517 #endif // V8_ISOLATE_H_
OLDNEW
« src/base/macros.h ('K') | « src/incremental-marking.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698