OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 17 matching lines...) Expand all Loading... |
28 #ifndef V8_D8_H_ | 28 #ifndef V8_D8_H_ |
29 #define V8_D8_H_ | 29 #define V8_D8_H_ |
30 | 30 |
31 #ifndef V8_SHARED | 31 #ifndef V8_SHARED |
32 #include "allocation.h" | 32 #include "allocation.h" |
33 #include "hashmap.h" | 33 #include "hashmap.h" |
34 #include "smart-pointers.h" | 34 #include "smart-pointers.h" |
35 #include "v8.h" | 35 #include "v8.h" |
36 #else | 36 #else |
37 #include "../include/v8.h" | 37 #include "../include/v8.h" |
38 #endif // V8_SHARED | 38 #endif // !V8_SHARED |
39 | 39 |
40 namespace v8 { | 40 namespace v8 { |
41 | 41 |
42 | 42 |
43 #ifndef V8_SHARED | 43 #ifndef V8_SHARED |
44 // A single counter in a counter collection. | 44 // A single counter in a counter collection. |
45 class Counter { | 45 class Counter { |
46 public: | 46 public: |
47 static const int kMaxNameSize = 64; | 47 static const int kMaxNameSize = 64; |
48 int32_t* Bind(const char* name, bool histogram); | 48 int32_t* Bind(const char* name, bool histogram); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 private: | 106 private: |
107 i::HashMap* map_; | 107 i::HashMap* map_; |
108 i::HashMap::Entry* entry_; | 108 i::HashMap::Entry* entry_; |
109 }; | 109 }; |
110 | 110 |
111 private: | 111 private: |
112 static int Hash(const char* name); | 112 static int Hash(const char* name); |
113 static bool Match(void* key1, void* key2); | 113 static bool Match(void* key1, void* key2); |
114 i::HashMap hash_map_; | 114 i::HashMap hash_map_; |
115 }; | 115 }; |
116 #endif // V8_SHARED | 116 #endif // !V8_SHARED |
117 | 117 |
118 | 118 |
119 class LineEditor { | 119 class LineEditor { |
120 public: | 120 public: |
121 enum Type { DUMB = 0, READLINE = 1 }; | 121 enum Type { DUMB = 0, READLINE = 1 }; |
122 LineEditor(Type type, const char* name); | 122 LineEditor(Type type, const char* name); |
123 virtual ~LineEditor() { } | 123 virtual ~LineEditor() { } |
124 | 124 |
125 virtual Handle<String> Prompt(const char* prompt) = 0; | 125 virtual Handle<String> Prompt(const char* prompt) = 0; |
126 virtual bool Open(Isolate* isolate) { return true; } | 126 virtual bool Open(Isolate* isolate) { return true; } |
127 virtual bool Close() { return true; } | 127 virtual bool Close() { return true; } |
128 virtual void AddHistory(const char* str) { } | 128 virtual void AddHistory(const char* str) { } |
129 | 129 |
130 const char* name() { return name_; } | 130 const char* name() { return name_; } |
131 static LineEditor* Get() { return current_; } | 131 static LineEditor* Get() { return current_; } |
132 private: | 132 private: |
133 Type type_; | 133 Type type_; |
134 const char* name_; | 134 const char* name_; |
135 static LineEditor* current_; | 135 static LineEditor* current_; |
136 }; | 136 }; |
137 | 137 |
138 | 138 |
139 class SourceGroup { | 139 class SourceGroup { |
140 public: | 140 public: |
141 SourceGroup() : | 141 SourceGroup() : |
142 #ifndef V8_SHARED | 142 #ifndef V8_SHARED |
143 next_semaphore_(0), | 143 next_semaphore_(0), |
144 done_semaphore_(0), | 144 done_semaphore_(0), |
145 thread_(NULL), | 145 thread_(NULL), |
146 #endif // V8_SHARED | 146 #endif // !V8_SHARED |
147 argv_(NULL), | 147 argv_(NULL), |
148 begin_offset_(0), | 148 begin_offset_(0), |
149 end_offset_(0) {} | 149 end_offset_(0) {} |
150 | 150 |
151 ~SourceGroup(); | 151 ~SourceGroup(); |
152 | 152 |
153 void Begin(char** argv, int offset) { | 153 void Begin(char** argv, int offset) { |
154 argv_ = const_cast<const char**>(argv); | 154 argv_ = const_cast<const char**>(argv); |
155 begin_offset_ = offset; | 155 begin_offset_ = offset; |
156 } | 156 } |
(...skipping 19 matching lines...) Expand all Loading... |
176 private: | 176 private: |
177 SourceGroup* group_; | 177 SourceGroup* group_; |
178 }; | 178 }; |
179 | 179 |
180 static i::Thread::Options GetThreadOptions(); | 180 static i::Thread::Options GetThreadOptions(); |
181 void ExecuteInThread(); | 181 void ExecuteInThread(); |
182 | 182 |
183 i::Semaphore next_semaphore_; | 183 i::Semaphore next_semaphore_; |
184 i::Semaphore done_semaphore_; | 184 i::Semaphore done_semaphore_; |
185 i::Thread* thread_; | 185 i::Thread* thread_; |
186 #endif // V8_SHARED | 186 #endif // !V8_SHARED |
187 | 187 |
188 void ExitShell(int exit_code); | 188 void ExitShell(int exit_code); |
189 Handle<String> ReadFile(Isolate* isolate, const char* name); | 189 Handle<String> ReadFile(Isolate* isolate, const char* name); |
190 | 190 |
191 const char** argv_; | 191 const char** argv_; |
192 int begin_offset_; | 192 int begin_offset_; |
193 int end_offset_; | 193 int end_offset_; |
194 }; | 194 }; |
195 | 195 |
196 | 196 |
(...skipping 17 matching lines...) Expand all Loading... |
214 size_t length_; | 214 size_t length_; |
215 }; | 215 }; |
216 | 216 |
217 | 217 |
218 class ShellOptions { | 218 class ShellOptions { |
219 public: | 219 public: |
220 ShellOptions() : | 220 ShellOptions() : |
221 #ifndef V8_SHARED | 221 #ifndef V8_SHARED |
222 num_parallel_files(0), | 222 num_parallel_files(0), |
223 parallel_files(NULL), | 223 parallel_files(NULL), |
224 #endif // V8_SHARED | 224 #endif // !V8_SHARED |
225 script_executed(false), | 225 script_executed(false), |
226 last_run(true), | 226 last_run(true), |
227 send_idle_notification(false), | 227 send_idle_notification(false), |
228 stress_opt(false), | 228 stress_opt(false), |
229 stress_deopt(false), | 229 stress_deopt(false), |
230 interactive_shell(false), | 230 interactive_shell(false), |
231 test_shell(false), | 231 test_shell(false), |
232 dump_heap_constants(false), | 232 dump_heap_constants(false), |
233 expected_to_throw(false), | 233 expected_to_throw(false), |
234 mock_arraybuffer_allocator(false), | 234 mock_arraybuffer_allocator(false), |
235 num_isolates(1), | 235 num_isolates(1), |
236 isolate_sources(NULL), | 236 isolate_sources(NULL), |
237 icu_data_file(NULL) { } | 237 icu_data_file(NULL) { } |
238 | 238 |
239 ~ShellOptions() { | 239 ~ShellOptions() { |
240 #ifndef V8_SHARED | 240 #ifndef V8_SHARED |
241 delete[] parallel_files; | 241 delete[] parallel_files; |
242 #endif // V8_SHARED | 242 #endif // !V8_SHARED |
243 delete[] isolate_sources; | 243 delete[] isolate_sources; |
244 } | 244 } |
245 | 245 |
246 #ifndef V8_SHARED | 246 #ifndef V8_SHARED |
247 int num_parallel_files; | 247 int num_parallel_files; |
248 char** parallel_files; | 248 char** parallel_files; |
249 #endif // V8_SHARED | 249 #endif // !V8_SHARED |
250 bool script_executed; | 250 bool script_executed; |
251 bool last_run; | 251 bool last_run; |
252 bool send_idle_notification; | 252 bool send_idle_notification; |
253 bool stress_opt; | 253 bool stress_opt; |
254 bool stress_deopt; | 254 bool stress_deopt; |
255 bool interactive_shell; | 255 bool interactive_shell; |
256 bool test_shell; | 256 bool test_shell; |
257 bool dump_heap_constants; | 257 bool dump_heap_constants; |
258 bool expected_to_throw; | 258 bool expected_to_throw; |
259 bool mock_arraybuffer_allocator; | 259 bool mock_arraybuffer_allocator; |
(...skipping 28 matching lines...) Expand all Loading... |
288 Handle<String> text, | 288 Handle<String> text, |
289 Handle<String> full); | 289 Handle<String> full); |
290 static int* LookupCounter(const char* name); | 290 static int* LookupCounter(const char* name); |
291 static void* CreateHistogram(const char* name, | 291 static void* CreateHistogram(const char* name, |
292 int min, | 292 int min, |
293 int max, | 293 int max, |
294 size_t buckets); | 294 size_t buckets); |
295 static void AddHistogramSample(void* histogram, int sample); | 295 static void AddHistogramSample(void* histogram, int sample); |
296 static void MapCounters(const char* name); | 296 static void MapCounters(const char* name); |
297 | 297 |
298 #ifdef ENABLE_DEBUGGER_SUPPORT | |
299 static Local<Object> DebugMessageDetails(Isolate* isolate, | 298 static Local<Object> DebugMessageDetails(Isolate* isolate, |
300 Handle<String> message); | 299 Handle<String> message); |
301 static Local<Value> DebugCommandToJSONRequest(Isolate* isolate, | 300 static Local<Value> DebugCommandToJSONRequest(Isolate* isolate, |
302 Handle<String> command); | 301 Handle<String> command); |
303 static void DispatchDebugMessages(); | 302 static void DispatchDebugMessages(); |
304 #endif // ENABLE_DEBUGGER_SUPPORT | |
305 | 303 |
306 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); | 304 static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); |
307 #endif // V8_SHARED | 305 #endif // !V8_SHARED |
308 | 306 |
309 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); | 307 static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); |
310 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); | 308 static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); |
311 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); | 309 static void RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); |
312 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); | 310 static void RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args); |
313 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); | 311 static void RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args); |
314 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); | 312 static void RealmSwitch(const v8::FunctionCallbackInfo<v8::Value>& args); |
315 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); | 313 static void RealmEval(const v8::FunctionCallbackInfo<v8::Value>& args); |
316 static void RealmSharedGet(Local<String> property, | 314 static void RealmSharedGet(Local<String> property, |
317 const PropertyCallbackInfo<Value>& info); | 315 const PropertyCallbackInfo<Value>& info); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // We statically allocate a set of local counters to be used if we | 391 // We statically allocate a set of local counters to be used if we |
394 // don't want to store the stats in a memory-mapped file | 392 // don't want to store the stats in a memory-mapped file |
395 static CounterCollection local_counters_; | 393 static CounterCollection local_counters_; |
396 static CounterCollection* counters_; | 394 static CounterCollection* counters_; |
397 static i::OS::MemoryMappedFile* counters_file_; | 395 static i::OS::MemoryMappedFile* counters_file_; |
398 static i::Mutex context_mutex_; | 396 static i::Mutex context_mutex_; |
399 static const i::TimeTicks kInitialTicks; | 397 static const i::TimeTicks kInitialTicks; |
400 | 398 |
401 static Counter* GetCounter(const char* name, bool is_histogram); | 399 static Counter* GetCounter(const char* name, bool is_histogram); |
402 static void InstallUtilityScript(Isolate* isolate); | 400 static void InstallUtilityScript(Isolate* isolate); |
403 #endif // V8_SHARED | 401 #endif // !V8_SHARED |
404 static void Initialize(Isolate* isolate); | 402 static void Initialize(Isolate* isolate); |
405 static void InitializeDebugger(Isolate* isolate); | 403 static void InitializeDebugger(Isolate* isolate); |
406 static void RunShell(Isolate* isolate); | 404 static void RunShell(Isolate* isolate); |
407 static bool SetOptions(int argc, char* argv[]); | 405 static bool SetOptions(int argc, char* argv[]); |
408 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); | 406 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); |
409 static Handle<FunctionTemplate> CreateArrayBufferTemplate(FunctionCallback); | 407 static Handle<FunctionTemplate> CreateArrayBufferTemplate(FunctionCallback); |
410 static Handle<FunctionTemplate> CreateArrayTemplate(FunctionCallback); | 408 static Handle<FunctionTemplate> CreateArrayTemplate(FunctionCallback); |
411 static Handle<Value> CreateExternalArrayBuffer(Isolate* isolate, | 409 static Handle<Value> CreateExternalArrayBuffer(Isolate* isolate, |
412 Handle<Object> buffer, | 410 Handle<Object> buffer, |
413 int32_t size); | 411 int32_t size); |
(...skipping 12 matching lines...) Expand all Loading... |
426 static void ExternalArrayWeakCallback(Isolate* isolate, | 424 static void ExternalArrayWeakCallback(Isolate* isolate, |
427 Persistent<Object>* object, | 425 Persistent<Object>* object, |
428 uint8_t* data); | 426 uint8_t* data); |
429 }; | 427 }; |
430 | 428 |
431 | 429 |
432 } // namespace v8 | 430 } // namespace v8 |
433 | 431 |
434 | 432 |
435 #endif // V8_D8_H_ | 433 #endif // V8_D8_H_ |
OLD | NEW |