OLD | NEW |
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 #ifndef V8_SHARED |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 }; | 92 }; |
93 #endif // !V8_SHARED | 93 #endif // !V8_SHARED |
94 | 94 |
95 | 95 |
96 class LineEditor { | 96 class LineEditor { |
97 public: | 97 public: |
98 enum Type { DUMB = 0, READLINE = 1 }; | 98 enum Type { DUMB = 0, READLINE = 1 }; |
99 LineEditor(Type type, const char* name); | 99 LineEditor(Type type, const char* name); |
100 virtual ~LineEditor() { } | 100 virtual ~LineEditor() { } |
101 | 101 |
102 virtual Handle<String> Prompt(const char* prompt) = 0; | 102 virtual Local<String> Prompt(const char* prompt) = 0; |
103 virtual bool Open(Isolate* isolate) { return true; } | 103 virtual bool Open(Isolate* isolate) { return true; } |
104 virtual bool Close() { return true; } | 104 virtual bool Close() { return true; } |
105 virtual void AddHistory(const char* str) { } | 105 virtual void AddHistory(const char* str) { } |
106 | 106 |
107 const char* name() { return name_; } | 107 const char* name() { return name_; } |
108 static LineEditor* Get() { return current_; } | 108 static LineEditor* Get() { return current_; } |
109 private: | 109 private: |
110 Type type_; | 110 Type type_; |
111 const char* name_; | 111 const char* name_; |
112 static LineEditor* current_; | 112 static LineEditor* current_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 static base::Thread::Options GetThreadOptions(); | 157 static base::Thread::Options GetThreadOptions(); |
158 void ExecuteInThread(); | 158 void ExecuteInThread(); |
159 | 159 |
160 base::Semaphore next_semaphore_; | 160 base::Semaphore next_semaphore_; |
161 base::Semaphore done_semaphore_; | 161 base::Semaphore done_semaphore_; |
162 base::Thread* thread_; | 162 base::Thread* thread_; |
163 #endif // !V8_SHARED | 163 #endif // !V8_SHARED |
164 | 164 |
165 void ExitShell(int exit_code); | 165 void ExitShell(int exit_code); |
166 Handle<String> ReadFile(Isolate* isolate, const char* name); | 166 Local<String> ReadFile(Isolate* isolate, const char* name); |
167 | 167 |
168 const char** argv_; | 168 const char** argv_; |
169 int begin_offset_; | 169 int begin_offset_; |
170 int end_offset_; | 170 int end_offset_; |
171 }; | 171 }; |
172 | 172 |
173 #ifndef V8_SHARED | 173 #ifndef V8_SHARED |
174 enum SerializationTag { | 174 enum SerializationTag { |
175 kSerializationTagUndefined, | 175 kSerializationTagUndefined, |
176 kSerializationTagNull, | 176 kSerializationTagNull, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 #ifdef V8_SHARED | 343 #ifdef V8_SHARED |
344 class Shell { | 344 class Shell { |
345 #else | 345 #else |
346 class Shell : public i::AllStatic { | 346 class Shell : public i::AllStatic { |
347 #endif // V8_SHARED | 347 #endif // V8_SHARED |
348 | 348 |
349 public: | 349 public: |
350 enum SourceType { SCRIPT, MODULE }; | 350 enum SourceType { SCRIPT, MODULE }; |
351 | 351 |
352 static Local<Script> CompileString( | 352 static MaybeLocal<Script> CompileString( |
353 Isolate* isolate, Local<String> source, Local<Value> name, | 353 Isolate* isolate, Local<String> source, Local<Value> name, |
354 v8::ScriptCompiler::CompileOptions compile_options, | 354 v8::ScriptCompiler::CompileOptions compile_options, |
355 SourceType source_type); | 355 SourceType source_type); |
356 static bool ExecuteString(Isolate* isolate, Handle<String> source, | 356 static bool ExecuteString(Isolate* isolate, Local<String> source, |
357 Handle<Value> name, bool print_result, | 357 Local<Value> name, bool print_result, |
358 bool report_exceptions, | 358 bool report_exceptions, |
359 SourceType source_type = SCRIPT); | 359 SourceType source_type = SCRIPT); |
360 static const char* ToCString(const v8::String::Utf8Value& value); | 360 static const char* ToCString(const v8::String::Utf8Value& value); |
361 static void ReportException(Isolate* isolate, TryCatch* try_catch); | 361 static void ReportException(Isolate* isolate, TryCatch* try_catch); |
362 static Handle<String> ReadFile(Isolate* isolate, const char* name); | 362 static Local<String> ReadFile(Isolate* isolate, const char* name); |
363 static Local<Context> CreateEvaluationContext(Isolate* isolate); | 363 static Local<Context> CreateEvaluationContext(Isolate* isolate); |
364 static int RunMain(Isolate* isolate, int argc, char* argv[]); | 364 static int RunMain(Isolate* isolate, int argc, char* argv[]); |
365 static int Main(int argc, char* argv[]); | 365 static int Main(int argc, char* argv[]); |
366 static void Exit(int exit_code); | 366 static void Exit(int exit_code); |
367 static void OnExit(Isolate* isolate); | 367 static void OnExit(Isolate* isolate); |
368 static void CollectGarbage(Isolate* isolate); | 368 static void CollectGarbage(Isolate* isolate); |
369 static void EmptyMessageQueues(Isolate* isolate); | 369 static void EmptyMessageQueues(Isolate* isolate); |
370 | 370 |
371 #ifndef V8_SHARED | 371 #ifndef V8_SHARED |
372 // TODO(binji): stupid implementation for now. Is there an easy way to hash an | 372 // TODO(binji): stupid implementation for now. Is there an easy way to hash an |
373 // object for use in i::HashMap? By pointer? | 373 // object for use in i::HashMap? By pointer? |
374 typedef i::List<Handle<Object>> ObjectList; | 374 typedef i::List<Local<Object>> ObjectList; |
375 static bool SerializeValue(Isolate* isolate, Handle<Value> value, | 375 static bool SerializeValue(Isolate* isolate, Local<Value> value, |
376 const ObjectList& to_transfer, | 376 const ObjectList& to_transfer, |
377 ObjectList* seen_objects, | 377 ObjectList* seen_objects, |
378 SerializationData* out_data); | 378 SerializationData* out_data); |
379 static MaybeLocal<Value> DeserializeValue(Isolate* isolate, | 379 static MaybeLocal<Value> DeserializeValue(Isolate* isolate, |
380 const SerializationData& data, | 380 const SerializationData& data, |
381 int* offset); | 381 int* offset); |
382 static void CleanupWorkers(); | 382 static void CleanupWorkers(); |
383 static Handle<Array> GetCompletions(Isolate* isolate, | 383 static Local<Array> GetCompletions(Isolate* isolate, Local<String> text, |
384 Handle<String> text, | 384 Local<String> full); |
385 Handle<String> full); | |
386 static int* LookupCounter(const char* name); | 385 static int* LookupCounter(const char* name); |
387 static void* CreateHistogram(const char* name, | 386 static void* CreateHistogram(const char* name, |
388 int min, | 387 int min, |
389 int max, | 388 int max, |
390 size_t buckets); | 389 size_t buckets); |
391 static void AddHistogramSample(void* histogram, int sample); | 390 static void AddHistogramSample(void* histogram, int sample); |
392 static void MapCounters(v8::Isolate* isolate, const char* name); | 391 static void MapCounters(v8::Isolate* isolate, const char* name); |
393 | 392 |
394 static Local<Object> DebugMessageDetails(Isolate* isolate, | 393 static Local<Object> DebugMessageDetails(Isolate* isolate, |
395 Handle<String> message); | 394 Local<String> message); |
396 static Local<Value> DebugCommandToJSONRequest(Isolate* isolate, | 395 static Local<Value> DebugCommandToJSONRequest(Isolate* isolate, |
397 Handle<String> command); | 396 Local<String> command); |
398 | 397 |
399 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); | 398 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); |
400 #endif // !V8_SHARED | 399 #endif // !V8_SHARED |
401 | 400 |
402 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); | 401 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); |
403 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); | 402 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); |
404 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); | 403 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); |
405 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); | 404 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); |
406 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); | 405 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); |
407 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); | 406 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); |
408 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); | 407 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); |
409 static void RealmSharedGet(Local<String> property, | 408 static void RealmSharedGet(Local<String> property, |
410 const PropertyCallbackInfo<Value>& info); | 409 const PropertyCallbackInfo<Value>& info); |
411 static void RealmSharedSet(Local<String> property, | 410 static void RealmSharedSet(Local<String> property, |
412 Local<Value> value, | 411 Local<Value> value, |
413 const PropertyCallbackInfo<void>& info); | 412 const PropertyCallbackInfo<void>& info); |
414 | 413 |
415 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args); | 414 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args); |
416 static void Write(const v8::FunctionCallbackInfo<v8::Value>& args); | 415 static void Write(const v8::FunctionCallbackInfo<v8::Value>& args); |
417 static void QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args); | 416 static void QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args); |
418 static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args); | 417 static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args); |
419 static void Version(const v8::FunctionCallbackInfo<v8::Value>& args); | 418 static void Version(const v8::FunctionCallbackInfo<v8::Value>& args); |
420 static void Read(const v8::FunctionCallbackInfo<v8::Value>& args); | 419 static void Read(const v8::FunctionCallbackInfo<v8::Value>& args); |
421 static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args); | 420 static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args); |
422 static Handle<String> ReadFromStdin(Isolate* isolate); | 421 static Local<String> ReadFromStdin(Isolate* isolate); |
423 static void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) { | 422 static void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) { |
424 args.GetReturnValue().Set(ReadFromStdin(args.GetIsolate())); | 423 args.GetReturnValue().Set(ReadFromStdin(args.GetIsolate())); |
425 } | 424 } |
426 static void Load(const v8::FunctionCallbackInfo<v8::Value>& args); | 425 static void Load(const v8::FunctionCallbackInfo<v8::Value>& args); |
427 static void WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args); | 426 static void WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args); |
428 static void WorkerPostMessage( | 427 static void WorkerPostMessage( |
429 const v8::FunctionCallbackInfo<v8::Value>& args); | 428 const v8::FunctionCallbackInfo<v8::Value>& args); |
430 static void WorkerGetMessage(const v8::FunctionCallbackInfo<v8::Value>& args); | 429 static void WorkerGetMessage(const v8::FunctionCallbackInfo<v8::Value>& args); |
431 static void WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args); | 430 static void WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args); |
432 // The OS object on the global object contains methods for performing | 431 // The OS object on the global object contains methods for performing |
(...skipping 24 matching lines...) Expand all Loading... |
457 // the "mkdir -p" command. | 456 // the "mkdir -p" command. |
458 static void System(const v8::FunctionCallbackInfo<v8::Value>& args); | 457 static void System(const v8::FunctionCallbackInfo<v8::Value>& args); |
459 static void ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); | 458 static void ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); |
460 static void SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args); | 459 static void SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args); |
461 static void UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args); | 460 static void UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args); |
462 static void SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args); | 461 static void SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args); |
463 static void MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); | 462 static void MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); |
464 static void RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); | 463 static void RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); |
465 | 464 |
466 static void AddOSMethods(v8::Isolate* isolate, | 465 static void AddOSMethods(v8::Isolate* isolate, |
467 Handle<ObjectTemplate> os_template); | 466 Local<ObjectTemplate> os_template); |
468 | 467 |
469 static const char* kPrompt; | 468 static const char* kPrompt; |
470 static ShellOptions options; | 469 static ShellOptions options; |
471 static ArrayBuffer::Allocator* array_buffer_allocator; | 470 static ArrayBuffer::Allocator* array_buffer_allocator; |
472 | 471 |
473 private: | 472 private: |
474 static Persistent<Context> evaluation_context_; | 473 static Global<Context> evaluation_context_; |
475 static base::OnceType quit_once_; | 474 static base::OnceType quit_once_; |
476 #ifndef V8_SHARED | 475 #ifndef V8_SHARED |
477 static Persistent<Context> utility_context_; | 476 static Global<Context> utility_context_; |
478 static CounterMap* counter_map_; | 477 static CounterMap* counter_map_; |
479 // We statically allocate a set of local counters to be used if we | 478 // We statically allocate a set of local counters to be used if we |
480 // don't want to store the stats in a memory-mapped file | 479 // don't want to store the stats in a memory-mapped file |
481 static CounterCollection local_counters_; | 480 static CounterCollection local_counters_; |
482 static CounterCollection* counters_; | 481 static CounterCollection* counters_; |
483 static base::OS::MemoryMappedFile* counters_file_; | 482 static base::OS::MemoryMappedFile* counters_file_; |
484 static base::LazyMutex context_mutex_; | 483 static base::LazyMutex context_mutex_; |
485 static const base::TimeTicks kInitialTicks; | 484 static const base::TimeTicks kInitialTicks; |
486 | 485 |
487 static base::LazyMutex workers_mutex_; | 486 static base::LazyMutex workers_mutex_; |
488 static bool allow_new_workers_; | 487 static bool allow_new_workers_; |
489 static i::List<Worker*> workers_; | 488 static i::List<Worker*> workers_; |
490 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_; | 489 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_; |
491 | 490 |
492 static Counter* GetCounter(const char* name, bool is_histogram); | 491 static Counter* GetCounter(const char* name, bool is_histogram); |
493 static void InstallUtilityScript(Isolate* isolate); | 492 static void InstallUtilityScript(Isolate* isolate); |
494 #endif // !V8_SHARED | 493 #endif // !V8_SHARED |
495 static void Initialize(Isolate* isolate); | 494 static void Initialize(Isolate* isolate); |
496 static void InitializeDebugger(Isolate* isolate); | 495 static void InitializeDebugger(Isolate* isolate); |
497 static void RunShell(Isolate* isolate); | 496 static void RunShell(Isolate* isolate); |
498 static bool SetOptions(int argc, char* argv[]); | 497 static bool SetOptions(int argc, char* argv[]); |
499 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); | 498 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); |
500 }; | 499 }; |
501 | 500 |
502 | 501 |
503 } // namespace v8 | 502 } // namespace v8 |
504 | 503 |
505 | 504 |
506 #endif // V8_D8_H_ | 505 #endif // V8_D8_H_ |
OLD | NEW |