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

Side by Side Diff: src/d8.h

Issue 1240993003: Revert of Make d8 stop using to-be-deprecated APIs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | 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 #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
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 Local<String> Prompt(const char* prompt) = 0; 102 virtual Handle<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
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 Local<String> ReadFile(Isolate* isolate, const char* name); 166 Handle<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
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 MaybeLocal<Script> CompileString( 352 static Local<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, Local<String> source, 356 static bool ExecuteString(Isolate* isolate, Handle<String> source,
357 Local<Value> name, bool print_result, 357 Handle<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 Local<String> ReadFile(Isolate* isolate, const char* name); 362 static Handle<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<Local<Object>> ObjectList; 374 typedef i::List<Handle<Object>> ObjectList;
375 static bool SerializeValue(Isolate* isolate, Local<Value> value, 375 static bool SerializeValue(Isolate* isolate, Handle<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 Local<Array> GetCompletions(Isolate* isolate, Local<String> text, 383 static Handle<Array> GetCompletions(Isolate* isolate,
384 Local<String> full); 384 Handle<String> text,
385 Handle<String> full);
385 static int* LookupCounter(const char* name); 386 static int* LookupCounter(const char* name);
386 static void* CreateHistogram(const char* name, 387 static void* CreateHistogram(const char* name,
387 int min, 388 int min,
388 int max, 389 int max,
389 size_t buckets); 390 size_t buckets);
390 static void AddHistogramSample(void* histogram, int sample); 391 static void AddHistogramSample(void* histogram, int sample);
391 static void MapCounters(v8::Isolate* isolate, const char* name); 392 static void MapCounters(v8::Isolate* isolate, const char* name);
392 393
393 static Local<Object> DebugMessageDetails(Isolate* isolate, 394 static Local<Object> DebugMessageDetails(Isolate* isolate,
394 Local<String> message); 395 Handle<String> message);
395 static Local<Value> DebugCommandToJSONRequest(Isolate* isolate, 396 static Local<Value> DebugCommandToJSONRequest(Isolate* isolate,
396 Local<String> command); 397 Handle<String> command);
397 398
398 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); 399 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args);
399 #endif // !V8_SHARED 400 #endif // !V8_SHARED
400 401
401 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); 402 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args);
402 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); 403 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args);
403 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); 404 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args);
404 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); 405 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args);
405 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); 406 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args);
406 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); 407 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args);
407 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); 408 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args);
408 static void RealmSharedGet(Local<String> property, 409 static void RealmSharedGet(Local<String> property,
409 const PropertyCallbackInfo<Value>& info); 410 const PropertyCallbackInfo<Value>& info);
410 static void RealmSharedSet(Local<String> property, 411 static void RealmSharedSet(Local<String> property,
411 Local<Value> value, 412 Local<Value> value,
412 const PropertyCallbackInfo<void>& info); 413 const PropertyCallbackInfo<void>& info);
413 414
414 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args); 415 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
415 static void Write(const v8::FunctionCallbackInfo<v8::Value>& args); 416 static void Write(const v8::FunctionCallbackInfo<v8::Value>& args);
416 static void QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args); 417 static void QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args);
417 static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args); 418 static void Quit(const v8::FunctionCallbackInfo<v8::Value>& args);
418 static void Version(const v8::FunctionCallbackInfo<v8::Value>& args); 419 static void Version(const v8::FunctionCallbackInfo<v8::Value>& args);
419 static void Read(const v8::FunctionCallbackInfo<v8::Value>& args); 420 static void Read(const v8::FunctionCallbackInfo<v8::Value>& args);
420 static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args); 421 static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args);
421 static Local<String> ReadFromStdin(Isolate* isolate); 422 static Handle<String> ReadFromStdin(Isolate* isolate);
422 static void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) { 423 static void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
423 args.GetReturnValue().Set(ReadFromStdin(args.GetIsolate())); 424 args.GetReturnValue().Set(ReadFromStdin(args.GetIsolate()));
424 } 425 }
425 static void Load(const v8::FunctionCallbackInfo<v8::Value>& args); 426 static void Load(const v8::FunctionCallbackInfo<v8::Value>& args);
426 static void WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args); 427 static void WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args);
427 static void WorkerPostMessage( 428 static void WorkerPostMessage(
428 const v8::FunctionCallbackInfo<v8::Value>& args); 429 const v8::FunctionCallbackInfo<v8::Value>& args);
429 static void WorkerGetMessage(const v8::FunctionCallbackInfo<v8::Value>& args); 430 static void WorkerGetMessage(const v8::FunctionCallbackInfo<v8::Value>& args);
430 static void WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args); 431 static void WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args);
431 // The OS object on the global object contains methods for performing 432 // The OS object on the global object contains methods for performing
(...skipping 24 matching lines...) Expand all
456 // the "mkdir -p" command. 457 // the "mkdir -p" command.
457 static void System(const v8::FunctionCallbackInfo<v8::Value>& args); 458 static void System(const v8::FunctionCallbackInfo<v8::Value>& args);
458 static void ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); 459 static void ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
459 static void SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args); 460 static void SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args);
460 static void UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args); 461 static void UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args);
461 static void SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args); 462 static void SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args);
462 static void MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); 463 static void MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
463 static void RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); 464 static void RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
464 465
465 static void AddOSMethods(v8::Isolate* isolate, 466 static void AddOSMethods(v8::Isolate* isolate,
466 Local<ObjectTemplate> os_template); 467 Handle<ObjectTemplate> os_template);
467 468
468 static const char* kPrompt; 469 static const char* kPrompt;
469 static ShellOptions options; 470 static ShellOptions options;
470 static ArrayBuffer::Allocator* array_buffer_allocator; 471 static ArrayBuffer::Allocator* array_buffer_allocator;
471 472
472 private: 473 private:
473 static Global<Context> evaluation_context_; 474 static Persistent<Context> evaluation_context_;
474 static base::OnceType quit_once_; 475 static base::OnceType quit_once_;
475 #ifndef V8_SHARED 476 #ifndef V8_SHARED
476 static Global<Context> utility_context_; 477 static Persistent<Context> utility_context_;
477 static CounterMap* counter_map_; 478 static CounterMap* counter_map_;
478 // We statically allocate a set of local counters to be used if we 479 // We statically allocate a set of local counters to be used if we
479 // don't want to store the stats in a memory-mapped file 480 // don't want to store the stats in a memory-mapped file
480 static CounterCollection local_counters_; 481 static CounterCollection local_counters_;
481 static CounterCollection* counters_; 482 static CounterCollection* counters_;
482 static base::OS::MemoryMappedFile* counters_file_; 483 static base::OS::MemoryMappedFile* counters_file_;
483 static base::LazyMutex context_mutex_; 484 static base::LazyMutex context_mutex_;
484 static const base::TimeTicks kInitialTicks; 485 static const base::TimeTicks kInitialTicks;
485 486
486 static base::LazyMutex workers_mutex_; 487 static base::LazyMutex workers_mutex_;
487 static bool allow_new_workers_; 488 static bool allow_new_workers_;
488 static i::List<Worker*> workers_; 489 static i::List<Worker*> workers_;
489 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_; 490 static i::List<SharedArrayBuffer::Contents> externalized_shared_contents_;
490 491
491 static Counter* GetCounter(const char* name, bool is_histogram); 492 static Counter* GetCounter(const char* name, bool is_histogram);
492 static void InstallUtilityScript(Isolate* isolate); 493 static void InstallUtilityScript(Isolate* isolate);
493 #endif // !V8_SHARED 494 #endif // !V8_SHARED
494 static void Initialize(Isolate* isolate); 495 static void Initialize(Isolate* isolate);
495 static void InitializeDebugger(Isolate* isolate); 496 static void InitializeDebugger(Isolate* isolate);
496 static void RunShell(Isolate* isolate); 497 static void RunShell(Isolate* isolate);
497 static bool SetOptions(int argc, char* argv[]); 498 static bool SetOptions(int argc, char* argv[]);
498 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); 499 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate);
499 }; 500 };
500 501
501 502
502 } // namespace v8 503 } // namespace v8
503 504
504 505
505 #endif // V8_D8_H_ 506 #endif // V8_D8_H_
OLDNEW
« no previous file with comments | « no previous file | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698