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

Side by Side Diff: src/d8.h

Issue 2356713002: Version 5.5.228.1 (cherry-pick) (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « src/basic-block-profiler.h ('k') | src/d8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_D8_H_ 5 #ifndef V8_D8_H_
6 #define V8_D8_H_ 6 #define V8_D8_H_
7 7
8 #ifndef V8_SHARED
8 #include "src/allocation.h" 9 #include "src/allocation.h"
9 #include "src/base/hashmap.h" 10 #include "src/base/hashmap.h"
10 #include "src/base/platform/time.h" 11 #include "src/base/platform/time.h"
11 #include "src/list.h" 12 #include "src/list.h"
13 #else
14 #include "include/v8.h"
15 #include "src/base/compiler-specific.h"
16 #endif // !V8_SHARED
12 17
13 #include "src/base/once.h" 18 #include "src/base/once.h"
14 19
15 20
16 namespace v8 { 21 namespace v8 {
17 22
18 23
24 #ifndef V8_SHARED
19 // A single counter in a counter collection. 25 // A single counter in a counter collection.
20 class Counter { 26 class Counter {
21 public: 27 public:
22 static const int kMaxNameSize = 64; 28 static const int kMaxNameSize = 64;
23 int32_t* Bind(const char* name, bool histogram); 29 int32_t* Bind(const char* name, bool histogram);
24 int32_t* ptr() { return &count_; } 30 int32_t* ptr() { return &count_; }
25 int32_t count() { return count_; } 31 int32_t count() { return count_; }
26 int32_t sample_total() { return sample_total_; } 32 int32_t sample_total() { return sample_total_; }
27 bool is_histogram() { return is_histogram_; } 33 bool is_histogram() { return is_histogram_; }
28 void AddSample(int32_t sample); 34 void AddSample(int32_t sample);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 private: 83 private:
78 base::HashMap* map_; 84 base::HashMap* map_;
79 base::HashMap::Entry* entry_; 85 base::HashMap::Entry* entry_;
80 }; 86 };
81 87
82 private: 88 private:
83 static int Hash(const char* name); 89 static int Hash(const char* name);
84 static bool Match(void* key1, void* key2); 90 static bool Match(void* key1, void* key2);
85 base::HashMap hash_map_; 91 base::HashMap hash_map_;
86 }; 92 };
93 #endif // !V8_SHARED
87 94
88 95
89 class SourceGroup { 96 class SourceGroup {
90 public: 97 public:
91 SourceGroup() : 98 SourceGroup() :
99 #ifndef V8_SHARED
92 next_semaphore_(0), 100 next_semaphore_(0),
93 done_semaphore_(0), 101 done_semaphore_(0),
94 thread_(NULL), 102 thread_(NULL),
103 #endif // !V8_SHARED
95 argv_(NULL), 104 argv_(NULL),
96 begin_offset_(0), 105 begin_offset_(0),
97 end_offset_(0) {} 106 end_offset_(0) {}
98 107
99 ~SourceGroup(); 108 ~SourceGroup();
100 109
101 void Begin(char** argv, int offset) { 110 void Begin(char** argv, int offset) {
102 argv_ = const_cast<const char**>(argv); 111 argv_ = const_cast<const char**>(argv);
103 begin_offset_ = offset; 112 begin_offset_ = offset;
104 } 113 }
105 114
106 void End(int offset) { end_offset_ = offset; } 115 void End(int offset) { end_offset_ = offset; }
107 116
108 void Execute(Isolate* isolate); 117 void Execute(Isolate* isolate);
109 118
119 #ifndef V8_SHARED
110 void StartExecuteInThread(); 120 void StartExecuteInThread();
111 void WaitForThread(); 121 void WaitForThread();
112 void JoinThread(); 122 void JoinThread();
113 123
114 private: 124 private:
115 class IsolateThread : public base::Thread { 125 class IsolateThread : public base::Thread {
116 public: 126 public:
117 explicit IsolateThread(SourceGroup* group) 127 explicit IsolateThread(SourceGroup* group)
118 : base::Thread(GetThreadOptions()), group_(group) {} 128 : base::Thread(GetThreadOptions()), group_(group) {}
119 129
120 virtual void Run() { 130 virtual void Run() {
121 group_->ExecuteInThread(); 131 group_->ExecuteInThread();
122 } 132 }
123 133
124 private: 134 private:
125 SourceGroup* group_; 135 SourceGroup* group_;
126 }; 136 };
127 137
128 static base::Thread::Options GetThreadOptions(); 138 static base::Thread::Options GetThreadOptions();
129 void ExecuteInThread(); 139 void ExecuteInThread();
130 140
131 base::Semaphore next_semaphore_; 141 base::Semaphore next_semaphore_;
132 base::Semaphore done_semaphore_; 142 base::Semaphore done_semaphore_;
133 base::Thread* thread_; 143 base::Thread* thread_;
144 #endif // !V8_SHARED
134 145
135 void ExitShell(int exit_code); 146 void ExitShell(int exit_code);
136 Local<String> ReadFile(Isolate* isolate, const char* name); 147 Local<String> ReadFile(Isolate* isolate, const char* name);
137 148
138 const char** argv_; 149 const char** argv_;
139 int begin_offset_; 150 int begin_offset_;
140 int end_offset_; 151 int end_offset_;
141 }; 152 };
142 153
154 #ifndef V8_SHARED
143 enum SerializationTag { 155 enum SerializationTag {
144 kSerializationTagUndefined, 156 kSerializationTagUndefined,
145 kSerializationTagNull, 157 kSerializationTagNull,
146 kSerializationTagTrue, 158 kSerializationTagTrue,
147 kSerializationTagFalse, 159 kSerializationTagFalse,
148 kSerializationTagNumber, 160 kSerializationTagNumber,
149 kSerializationTagString, 161 kSerializationTagString,
150 kSerializationTagArray, 162 kSerializationTagArray,
151 kSerializationTagObject, 163 kSerializationTagObject,
152 kSerializationTagArrayBuffer, 164 kSerializationTagArrayBuffer,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 static void PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args); 260 static void PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args);
249 261
250 base::Semaphore in_semaphore_; 262 base::Semaphore in_semaphore_;
251 base::Semaphore out_semaphore_; 263 base::Semaphore out_semaphore_;
252 SerializationDataQueue in_queue_; 264 SerializationDataQueue in_queue_;
253 SerializationDataQueue out_queue_; 265 SerializationDataQueue out_queue_;
254 base::Thread* thread_; 266 base::Thread* thread_;
255 char* script_; 267 char* script_;
256 base::Atomic32 running_; 268 base::Atomic32 running_;
257 }; 269 };
270 #endif // !V8_SHARED
258 271
259 272
260 class ShellOptions { 273 class ShellOptions {
261 public: 274 public:
262 ShellOptions() 275 ShellOptions()
263 : script_executed(false), 276 : script_executed(false),
264 send_idle_notification(false), 277 send_idle_notification(false),
265 invoke_weak_callbacks(false), 278 invoke_weak_callbacks(false),
266 omit_quit(false), 279 omit_quit(false),
267 stress_opt(false), 280 stress_opt(false),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 int num_isolates; 317 int num_isolates;
305 v8::ScriptCompiler::CompileOptions compile_options; 318 v8::ScriptCompiler::CompileOptions compile_options;
306 SourceGroup* isolate_sources; 319 SourceGroup* isolate_sources;
307 const char* icu_data_file; 320 const char* icu_data_file;
308 const char* natives_blob; 321 const char* natives_blob;
309 const char* snapshot_blob; 322 const char* snapshot_blob;
310 bool trace_enabled; 323 bool trace_enabled;
311 const char* trace_config; 324 const char* trace_config;
312 }; 325 };
313 326
327 #ifdef V8_SHARED
328 class Shell {
329 #else
314 class Shell : public i::AllStatic { 330 class Shell : public i::AllStatic {
331 #endif // V8_SHARED
332
315 public: 333 public:
316 enum SourceType { SCRIPT, MODULE }; 334 enum SourceType { SCRIPT, MODULE };
317 335
318 static MaybeLocal<Script> CompileString( 336 static MaybeLocal<Script> CompileString(
319 Isolate* isolate, Local<String> source, Local<Value> name, 337 Isolate* isolate, Local<String> source, Local<Value> name,
320 v8::ScriptCompiler::CompileOptions compile_options); 338 v8::ScriptCompiler::CompileOptions compile_options);
321 static bool ExecuteString(Isolate* isolate, Local<String> source, 339 static bool ExecuteString(Isolate* isolate, Local<String> source,
322 Local<Value> name, bool print_result, 340 Local<Value> name, bool print_result,
323 bool report_exceptions, 341 bool report_exceptions,
324 SourceType source_type = SCRIPT); 342 SourceType source_type = SCRIPT);
325 static const char* ToCString(const v8::String::Utf8Value& value); 343 static const char* ToCString(const v8::String::Utf8Value& value);
326 static void ReportException(Isolate* isolate, TryCatch* try_catch); 344 static void ReportException(Isolate* isolate, TryCatch* try_catch);
327 static Local<String> ReadFile(Isolate* isolate, const char* name); 345 static Local<String> ReadFile(Isolate* isolate, const char* name);
328 static Local<Context> CreateEvaluationContext(Isolate* isolate); 346 static Local<Context> CreateEvaluationContext(Isolate* isolate);
329 static int RunMain(Isolate* isolate, int argc, char* argv[], bool last_run); 347 static int RunMain(Isolate* isolate, int argc, char* argv[], bool last_run);
330 static int Main(int argc, char* argv[]); 348 static int Main(int argc, char* argv[]);
331 static void Exit(int exit_code); 349 static void Exit(int exit_code);
332 static void OnExit(Isolate* isolate); 350 static void OnExit(Isolate* isolate);
333 static void CollectGarbage(Isolate* isolate); 351 static void CollectGarbage(Isolate* isolate);
334 static void EmptyMessageQueues(Isolate* isolate); 352 static void EmptyMessageQueues(Isolate* isolate);
335 353
354 #ifndef V8_SHARED
336 // TODO(binji): stupid implementation for now. Is there an easy way to hash an 355 // TODO(binji): stupid implementation for now. Is there an easy way to hash an
337 // object for use in base::HashMap? By pointer? 356 // object for use in base::HashMap? By pointer?
338 typedef i::List<Local<Object>> ObjectList; 357 typedef i::List<Local<Object>> ObjectList;
339 static bool SerializeValue(Isolate* isolate, Local<Value> value, 358 static bool SerializeValue(Isolate* isolate, Local<Value> value,
340 const ObjectList& to_transfer, 359 const ObjectList& to_transfer,
341 ObjectList* seen_objects, 360 ObjectList* seen_objects,
342 SerializationData* out_data); 361 SerializationData* out_data);
343 static MaybeLocal<Value> DeserializeValue(Isolate* isolate, 362 static MaybeLocal<Value> DeserializeValue(Isolate* isolate,
344 const SerializationData& data, 363 const SerializationData& data,
345 int* offset); 364 int* offset);
346 static void CleanupWorkers(); 365 static void CleanupWorkers();
347 static int* LookupCounter(const char* name); 366 static int* LookupCounter(const char* name);
348 static void* CreateHistogram(const char* name, 367 static void* CreateHistogram(const char* name,
349 int min, 368 int min,
350 int max, 369 int max,
351 size_t buckets); 370 size_t buckets);
352 static void AddHistogramSample(void* histogram, int sample); 371 static void AddHistogramSample(void* histogram, int sample);
353 static void MapCounters(v8::Isolate* isolate, const char* name); 372 static void MapCounters(v8::Isolate* isolate, const char* name);
354 373
355 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); 374 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args);
375 #endif // !V8_SHARED
356 376
357 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); 377 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args);
358 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); 378 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args);
359 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); 379 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args);
360 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); 380 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args);
361 static void RealmCreateAllowCrossRealmAccess( 381 static void RealmCreateAllowCrossRealmAccess(
362 const v8::FunctionCallbackInfo<v8::Value>& args); 382 const v8::FunctionCallbackInfo<v8::Value>& args);
363 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); 383 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args);
364 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); 384 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args);
365 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); 385 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 static void AddOSMethods(v8::Isolate* isolate, 443 static void AddOSMethods(v8::Isolate* isolate,
424 Local<ObjectTemplate> os_template); 444 Local<ObjectTemplate> os_template);
425 445
426 static const char* kPrompt; 446 static const char* kPrompt;
427 static ShellOptions options; 447 static ShellOptions options;
428 static ArrayBuffer::Allocator* array_buffer_allocator; 448 static ArrayBuffer::Allocator* array_buffer_allocator;
429 449
430 private: 450 private:
431 static Global<Context> evaluation_context_; 451 static Global<Context> evaluation_context_;
432 static base::OnceType quit_once_; 452 static base::OnceType quit_once_;
453 #ifndef V8_SHARED
433 static Global<Function> stringify_function_; 454 static Global<Function> stringify_function_;
434 static CounterMap* counter_map_; 455 static CounterMap* counter_map_;
435 // We statically allocate a set of local counters to be used if we 456 // We statically allocate a set of local counters to be used if we
436 // don't want to store the stats in a memory-mapped file 457 // don't want to store the stats in a memory-mapped file
437 static CounterCollection local_counters_; 458 static CounterCollection local_counters_;
438 static CounterCollection* counters_; 459 static CounterCollection* counters_;
439 static base::OS::MemoryMappedFile* counters_file_; 460 static base::OS::MemoryMappedFile* counters_file_;
440 static base::LazyMutex context_mutex_; 461 static base::LazyMutex context_mutex_;
441 static const base::TimeTicks kInitialTicks; 462 static const base::TimeTicks kInitialTicks;
442 463
443 static base::LazyMutex workers_mutex_; 464 static base::LazyMutex workers_mutex_;
444 static bool allow_new_workers_; 465 static bool allow_new_workers_;
445 static i::List<Worker*> workers_; 466 static i::List<Worker*> workers_;
446 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_; 467 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_;
447 468
448 static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate); 469 static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate);
449 static Counter* GetCounter(const char* name, bool is_histogram); 470 static Counter* GetCounter(const char* name, bool is_histogram);
450 static Local<String> Stringify(Isolate* isolate, Local<Value> value); 471 static Local<String> Stringify(Isolate* isolate, Local<Value> value);
472 #endif // !V8_SHARED
451 static void Initialize(Isolate* isolate); 473 static void Initialize(Isolate* isolate);
452 static void RunShell(Isolate* isolate); 474 static void RunShell(Isolate* isolate);
453 static bool SetOptions(int argc, char* argv[]); 475 static bool SetOptions(int argc, char* argv[]);
454 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); 476 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate);
455 static MaybeLocal<Context> CreateRealm( 477 static MaybeLocal<Context> CreateRealm(
456 const v8::FunctionCallbackInfo<v8::Value>& args); 478 const v8::FunctionCallbackInfo<v8::Value>& args);
457 }; 479 };
458 480
459 481
460 } // namespace v8 482 } // namespace v8
461 483
462 484
463 #endif // V8_D8_H_ 485 #endif // V8_D8_H_
OLDNEW
« no previous file with comments | « src/basic-block-profiler.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698