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/d8.h

Issue 2356703003: Revert of [d8] Fix the shared-library build (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 SourceType source_type); 339 SourceType source_type);
322 static bool ExecuteString(Isolate* isolate, Local<String> source, 340 static bool ExecuteString(Isolate* isolate, Local<String> source,
323 Local<Value> name, bool print_result, 341 Local<Value> name, bool print_result,
324 bool report_exceptions, 342 bool report_exceptions,
325 SourceType source_type = SCRIPT); 343 SourceType source_type = SCRIPT);
326 static const char* ToCString(const v8::String::Utf8Value& value); 344 static const char* ToCString(const v8::String::Utf8Value& value);
327 static void ReportException(Isolate* isolate, TryCatch* try_catch); 345 static void ReportException(Isolate* isolate, TryCatch* try_catch);
328 static Local<String> ReadFile(Isolate* isolate, const char* name); 346 static Local<String> ReadFile(Isolate* isolate, const char* name);
329 static Local<Context> CreateEvaluationContext(Isolate* isolate); 347 static Local<Context> CreateEvaluationContext(Isolate* isolate);
330 static int RunMain(Isolate* isolate, int argc, char* argv[], bool last_run); 348 static int RunMain(Isolate* isolate, int argc, char* argv[], bool last_run);
331 static int Main(int argc, char* argv[]); 349 static int Main(int argc, char* argv[]);
332 static void Exit(int exit_code); 350 static void Exit(int exit_code);
333 static void OnExit(Isolate* isolate); 351 static void OnExit(Isolate* isolate);
334 static void CollectGarbage(Isolate* isolate); 352 static void CollectGarbage(Isolate* isolate);
335 static void EmptyMessageQueues(Isolate* isolate); 353 static void EmptyMessageQueues(Isolate* isolate);
336 354
355 #ifndef V8_SHARED
337 // TODO(binji): stupid implementation for now. Is there an easy way to hash an 356 // TODO(binji): stupid implementation for now. Is there an easy way to hash an
338 // object for use in base::HashMap? By pointer? 357 // object for use in base::HashMap? By pointer?
339 typedef i::List<Local<Object>> ObjectList; 358 typedef i::List<Local<Object>> ObjectList;
340 static bool SerializeValue(Isolate* isolate, Local<Value> value, 359 static bool SerializeValue(Isolate* isolate, Local<Value> value,
341 const ObjectList& to_transfer, 360 const ObjectList& to_transfer,
342 ObjectList* seen_objects, 361 ObjectList* seen_objects,
343 SerializationData* out_data); 362 SerializationData* out_data);
344 static MaybeLocal<Value> DeserializeValue(Isolate* isolate, 363 static MaybeLocal<Value> DeserializeValue(Isolate* isolate,
345 const SerializationData& data, 364 const SerializationData& data,
346 int* offset); 365 int* offset);
347 static void CleanupWorkers(); 366 static void CleanupWorkers();
348 static int* LookupCounter(const char* name); 367 static int* LookupCounter(const char* name);
349 static void* CreateHistogram(const char* name, 368 static void* CreateHistogram(const char* name,
350 int min, 369 int min,
351 int max, 370 int max,
352 size_t buckets); 371 size_t buckets);
353 static void AddHistogramSample(void* histogram, int sample); 372 static void AddHistogramSample(void* histogram, int sample);
354 static void MapCounters(v8::Isolate* isolate, const char* name); 373 static void MapCounters(v8::Isolate* isolate, const char* name);
355 374
356 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); 375 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args);
376 #endif // !V8_SHARED
357 377
358 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); 378 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args);
359 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); 379 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args);
360 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); 380 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args);
361 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); 381 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args);
362 static void RealmCreateAllowCrossRealmAccess( 382 static void RealmCreateAllowCrossRealmAccess(
363 const v8::FunctionCallbackInfo<v8::Value>& args); 383 const v8::FunctionCallbackInfo<v8::Value>& args);
364 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); 384 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args);
365 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); 385 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args);
366 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); 386 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 static void AddOSMethods(v8::Isolate* isolate, 444 static void AddOSMethods(v8::Isolate* isolate,
425 Local<ObjectTemplate> os_template); 445 Local<ObjectTemplate> os_template);
426 446
427 static const char* kPrompt; 447 static const char* kPrompt;
428 static ShellOptions options; 448 static ShellOptions options;
429 static ArrayBuffer::Allocator* array_buffer_allocator; 449 static ArrayBuffer::Allocator* array_buffer_allocator;
430 450
431 private: 451 private:
432 static Global<Context> evaluation_context_; 452 static Global<Context> evaluation_context_;
433 static base::OnceType quit_once_; 453 static base::OnceType quit_once_;
454 #ifndef V8_SHARED
434 static Global<Function> stringify_function_; 455 static Global<Function> stringify_function_;
435 static CounterMap* counter_map_; 456 static CounterMap* counter_map_;
436 // We statically allocate a set of local counters to be used if we 457 // We statically allocate a set of local counters to be used if we
437 // don't want to store the stats in a memory-mapped file 458 // don't want to store the stats in a memory-mapped file
438 static CounterCollection local_counters_; 459 static CounterCollection local_counters_;
439 static CounterCollection* counters_; 460 static CounterCollection* counters_;
440 static base::OS::MemoryMappedFile* counters_file_; 461 static base::OS::MemoryMappedFile* counters_file_;
441 static base::LazyMutex context_mutex_; 462 static base::LazyMutex context_mutex_;
442 static const base::TimeTicks kInitialTicks; 463 static const base::TimeTicks kInitialTicks;
443 464
444 static base::LazyMutex workers_mutex_; 465 static base::LazyMutex workers_mutex_;
445 static bool allow_new_workers_; 466 static bool allow_new_workers_;
446 static i::List<Worker*> workers_; 467 static i::List<Worker*> workers_;
447 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_; 468 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_;
448 469
449 static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate); 470 static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate);
450 static Counter* GetCounter(const char* name, bool is_histogram); 471 static Counter* GetCounter(const char* name, bool is_histogram);
451 static Local<String> Stringify(Isolate* isolate, Local<Value> value); 472 static Local<String> Stringify(Isolate* isolate, Local<Value> value);
473 #endif // !V8_SHARED
452 static void Initialize(Isolate* isolate); 474 static void Initialize(Isolate* isolate);
453 static void RunShell(Isolate* isolate); 475 static void RunShell(Isolate* isolate);
454 static bool SetOptions(int argc, char* argv[]); 476 static bool SetOptions(int argc, char* argv[]);
455 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); 477 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate);
456 static MaybeLocal<Context> CreateRealm( 478 static MaybeLocal<Context> CreateRealm(
457 const v8::FunctionCallbackInfo<v8::Value>& args); 479 const v8::FunctionCallbackInfo<v8::Value>& args);
458 }; 480 };
459 481
460 482
461 } // namespace v8 483 } // namespace v8
462 484
463 485
464 #endif // V8_D8_H_ 486 #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