OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 i::HashMap::Entry* entry_; | 105 i::HashMap::Entry* entry_; |
106 }; | 106 }; |
107 | 107 |
108 private: | 108 private: |
109 static int Hash(const char* name); | 109 static int Hash(const char* name); |
110 static bool Match(void* key1, void* key2); | 110 static bool Match(void* key1, void* key2); |
111 i::HashMap hash_map_; | 111 i::HashMap hash_map_; |
112 }; | 112 }; |
113 | 113 |
114 | 114 |
| 115 class SourceGroup { |
| 116 public: |
| 117 SourceGroup() |
| 118 : next_semaphore_(v8::internal::OS::CreateSemaphore(0)), |
| 119 done_semaphore_(v8::internal::OS::CreateSemaphore(0)), |
| 120 thread_(NULL), |
| 121 argv_(NULL), |
| 122 begin_offset_(0), |
| 123 end_offset_(0) { } |
| 124 |
| 125 void Begin(char** argv, int offset) { |
| 126 argv_ = const_cast<const char**>(argv); |
| 127 begin_offset_ = offset; |
| 128 } |
| 129 |
| 130 void End(int offset) { end_offset_ = offset; } |
| 131 |
| 132 void Execute(); |
| 133 |
| 134 void StartExecuteInThread(); |
| 135 void WaitForThread(); |
| 136 |
| 137 private: |
| 138 class IsolateThread : public i::Thread { |
| 139 public: |
| 140 explicit IsolateThread(SourceGroup* group) |
| 141 : i::Thread(GetThreadOptions()), group_(group) {} |
| 142 |
| 143 virtual void Run() { |
| 144 group_->ExecuteInThread(); |
| 145 } |
| 146 |
| 147 private: |
| 148 SourceGroup* group_; |
| 149 }; |
| 150 |
| 151 static i::Thread::Options GetThreadOptions(); |
| 152 void ExecuteInThread(); |
| 153 |
| 154 i::Semaphore* next_semaphore_; |
| 155 i::Semaphore* done_semaphore_; |
| 156 i::Thread* thread_; |
| 157 |
| 158 void ExitShell(int exit_code); |
| 159 Handle<String> ReadFile(const char* name); |
| 160 |
| 161 const char** argv_; |
| 162 int begin_offset_; |
| 163 int end_offset_; |
| 164 }; |
| 165 |
| 166 |
| 167 class ShellOptions { |
| 168 public: |
| 169 ShellOptions() |
| 170 : script_executed(false), |
| 171 last_run(true), |
| 172 stress_opt(false), |
| 173 stress_deopt(false), |
| 174 interactive_shell(false), |
| 175 test_shell(false), |
| 176 use_preemption(true), |
| 177 preemption_interval(10), |
| 178 num_isolates(1), |
| 179 isolate_sources(NULL), |
| 180 parallel_files(NULL) { } |
| 181 |
| 182 bool script_executed; |
| 183 bool last_run; |
| 184 bool stress_opt; |
| 185 bool stress_deopt; |
| 186 bool interactive_shell; |
| 187 bool test_shell; |
| 188 bool use_preemption; |
| 189 int preemption_interval; |
| 190 int num_isolates; |
| 191 SourceGroup* isolate_sources; |
| 192 i::List< i::Vector<const char> >* parallel_files; |
| 193 }; |
| 194 |
| 195 |
115 class Shell: public i::AllStatic { | 196 class Shell: public i::AllStatic { |
116 public: | 197 public: |
117 static bool ExecuteString(Handle<String> source, | 198 static bool ExecuteString(Handle<String> source, |
118 Handle<Value> name, | 199 Handle<Value> name, |
119 bool print_result, | 200 bool print_result, |
120 bool report_exceptions); | 201 bool report_exceptions); |
121 static const char* ToCString(const v8::String::Utf8Value& value); | 202 static const char* ToCString(const v8::String::Utf8Value& value); |
122 static void ReportException(TryCatch* try_catch); | 203 static void ReportException(TryCatch* try_catch); |
123 static void OnExit(); | 204 static void OnExit(); |
124 static int* LookupCounter(const char* name); | 205 static int* LookupCounter(const char* name); |
125 static void* CreateHistogram(const char* name, | 206 static void* CreateHistogram(const char* name, |
126 int min, | 207 int min, |
127 int max, | 208 int max, |
128 size_t buckets); | 209 size_t buckets); |
129 static void AddHistogramSample(void* histogram, int sample); | 210 static void AddHistogramSample(void* histogram, int sample); |
130 static void MapCounters(const char* name); | 211 static void MapCounters(const char* name); |
131 static Handle<String> ReadFile(const char* name); | 212 static Handle<String> ReadFile(const char* name); |
132 static void Initialize(bool test_shell); | 213 static void Initialize(); |
133 static void RenewEvaluationContext(); | 214 static Persistent<Context> CreateEvaluationContext(); |
134 static void InstallUtilityScript(); | 215 static void InstallUtilityScript(); |
135 static void RunShell(); | 216 static void RunShell(); |
| 217 static bool SetOptions(int argc, char* argv[]); |
136 static int RunScript(char* filename); | 218 static int RunScript(char* filename); |
137 static int RunMain(int argc, char* argv[], bool* executed); | 219 static int RunMain(int argc, char* argv[]); |
138 static int Main(int argc, char* argv[]); | 220 static int Main(int argc, char* argv[]); |
139 static Handle<ObjectTemplate> CreateGlobalTemplate(); | 221 static Handle<ObjectTemplate> CreateGlobalTemplate(); |
140 static Handle<Array> GetCompletions(Handle<String> text, | 222 static Handle<Array> GetCompletions(Handle<String> text, |
141 Handle<String> full); | 223 Handle<String> full); |
142 #ifdef ENABLE_DEBUGGER_SUPPORT | 224 #ifdef ENABLE_DEBUGGER_SUPPORT |
143 static Handle<Object> DebugMessageDetails(Handle<String> message); | 225 static Handle<Object> DebugMessageDetails(Handle<String> message); |
144 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); | 226 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); |
145 #endif | 227 #endif |
146 | 228 |
147 #ifdef WIN32 | 229 #ifdef WIN32 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 static Handle<Value> UnsetEnvironment(const Arguments& args); | 280 static Handle<Value> UnsetEnvironment(const Arguments& args); |
199 static Handle<Value> SetUMask(const Arguments& args); | 281 static Handle<Value> SetUMask(const Arguments& args); |
200 static Handle<Value> MakeDirectory(const Arguments& args); | 282 static Handle<Value> MakeDirectory(const Arguments& args); |
201 static Handle<Value> RemoveDirectory(const Arguments& args); | 283 static Handle<Value> RemoveDirectory(const Arguments& args); |
202 | 284 |
203 static void AddOSMethods(Handle<ObjectTemplate> os_template); | 285 static void AddOSMethods(Handle<ObjectTemplate> os_template); |
204 | 286 |
205 static const char* kHistoryFileName; | 287 static const char* kHistoryFileName; |
206 static const char* kPrompt; | 288 static const char* kPrompt; |
207 | 289 |
| 290 static ShellOptions options; |
| 291 |
208 private: | 292 private: |
209 static Persistent<Context> utility_context_; | 293 static Persistent<Context> utility_context_; |
210 static Persistent<Context> evaluation_context_; | 294 static Persistent<Context> evaluation_context_; |
211 static CounterMap* counter_map_; | 295 static CounterMap* counter_map_; |
212 // We statically allocate a set of local counters to be used if we | 296 // We statically allocate a set of local counters to be used if we |
213 // don't want to store the stats in a memory-mapped file | 297 // don't want to store the stats in a memory-mapped file |
214 static CounterCollection local_counters_; | 298 static CounterCollection local_counters_; |
215 static CounterCollection* counters_; | 299 static CounterCollection* counters_; |
216 static i::OS::MemoryMappedFile* counters_file_; | 300 static i::OS::MemoryMappedFile* counters_file_; |
| 301 static i::Mutex* context_mutex_; |
217 static Counter* GetCounter(const char* name, bool is_histogram); | 302 static Counter* GetCounter(const char* name, bool is_histogram); |
218 static Handle<Value> CreateExternalArray(const Arguments& args, | 303 static Handle<Value> CreateExternalArray(const Arguments& args, |
219 ExternalArrayType type, | 304 ExternalArrayType type, |
220 size_t element_size); | 305 size_t element_size); |
221 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); | 306 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); |
222 }; | 307 }; |
223 | 308 |
224 | 309 |
225 class LineEditor { | 310 class LineEditor { |
226 public: | 311 public: |
(...skipping 13 matching lines...) Expand all Loading... |
240 const char* name_; | 325 const char* name_; |
241 LineEditor* next_; | 326 LineEditor* next_; |
242 static LineEditor* first_; | 327 static LineEditor* first_; |
243 }; | 328 }; |
244 | 329 |
245 | 330 |
246 } // namespace v8 | 331 } // namespace v8 |
247 | 332 |
248 | 333 |
249 #endif // V8_D8_H_ | 334 #endif // V8_D8_H_ |
OLD | NEW |