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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 ~SourceGroup(); | 152 ~SourceGroup(); |
153 | 153 |
154 void Begin(char** argv, int offset) { | 154 void Begin(char** argv, int offset) { |
155 argv_ = const_cast<const char**>(argv); | 155 argv_ = const_cast<const char**>(argv); |
156 begin_offset_ = offset; | 156 begin_offset_ = offset; |
157 } | 157 } |
158 | 158 |
159 void End(int offset) { end_offset_ = offset; } | 159 void End(int offset) { end_offset_ = offset; } |
160 | 160 |
161 void Execute(); | 161 void Execute(Isolate* isolate); |
162 | 162 |
163 #ifndef V8_SHARED | 163 #ifndef V8_SHARED |
164 void StartExecuteInThread(); | 164 void StartExecuteInThread(); |
165 void WaitForThread(); | 165 void WaitForThread(); |
166 | 166 |
167 private: | 167 private: |
168 class IsolateThread : public i::Thread { | 168 class IsolateThread : public i::Thread { |
169 public: | 169 public: |
170 explicit IsolateThread(SourceGroup* group) | 170 explicit IsolateThread(SourceGroup* group) |
171 : i::Thread(GetThreadOptions()), group_(group) {} | 171 : i::Thread(GetThreadOptions()), group_(group) {} |
172 | 172 |
173 virtual void Run() { | 173 virtual void Run() { |
174 group_->ExecuteInThread(); | 174 group_->ExecuteInThread(); |
175 } | 175 } |
176 | 176 |
177 private: | 177 private: |
178 SourceGroup* group_; | 178 SourceGroup* group_; |
179 }; | 179 }; |
180 | 180 |
181 static i::Thread::Options GetThreadOptions(); | 181 static i::Thread::Options GetThreadOptions(); |
182 void ExecuteInThread(); | 182 void ExecuteInThread(); |
183 | 183 |
184 i::Semaphore* next_semaphore_; | 184 i::Semaphore* next_semaphore_; |
185 i::Semaphore* done_semaphore_; | 185 i::Semaphore* done_semaphore_; |
186 i::Thread* thread_; | 186 i::Thread* thread_; |
187 #endif // V8_SHARED | 187 #endif // V8_SHARED |
188 | 188 |
189 void ExitShell(int exit_code); | 189 void ExitShell(int exit_code); |
190 Handle<String> ReadFile(const char* name); | 190 Handle<String> ReadFile(Isolate* isolate, const char* name); |
191 | 191 |
192 const char** argv_; | 192 const char** argv_; |
193 int begin_offset_; | 193 int begin_offset_; |
194 int end_offset_; | 194 int end_offset_; |
195 }; | 195 }; |
196 | 196 |
197 | 197 |
198 class BinaryResource : public v8::String::ExternalAsciiStringResource { | 198 class BinaryResource : public v8::String::ExternalAsciiStringResource { |
199 public: | 199 public: |
200 BinaryResource(const char* string, int length) | 200 BinaryResource(const char* string, int length) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 class Shell : public i::AllStatic { | 265 class Shell : public i::AllStatic { |
266 #endif // V8_SHARED | 266 #endif // V8_SHARED |
267 | 267 |
268 public: | 268 public: |
269 static bool ExecuteString(Handle<String> source, | 269 static bool ExecuteString(Handle<String> source, |
270 Handle<Value> name, | 270 Handle<Value> name, |
271 bool print_result, | 271 bool print_result, |
272 bool report_exceptions); | 272 bool report_exceptions); |
273 static const char* ToCString(const v8::String::Utf8Value& value); | 273 static const char* ToCString(const v8::String::Utf8Value& value); |
274 static void ReportException(TryCatch* try_catch); | 274 static void ReportException(TryCatch* try_catch); |
275 static Handle<String> ReadFile(const char* name); | 275 static Handle<String> ReadFile(Isolate* isolate, const char* name); |
276 static Persistent<Context> CreateEvaluationContext(); | 276 static Persistent<Context> CreateEvaluationContext(Isolate* isolate); |
277 static int RunMain(int argc, char* argv[]); | 277 static int RunMain(Isolate* isolate, int argc, char* argv[]); |
278 static int Main(int argc, char* argv[]); | 278 static int Main(int argc, char* argv[]); |
279 static void Exit(int exit_code); | 279 static void Exit(int exit_code); |
280 | 280 |
281 #ifndef V8_SHARED | 281 #ifndef V8_SHARED |
282 static Handle<Array> GetCompletions(Handle<String> text, | 282 static Handle<Array> GetCompletions(Handle<String> text, |
283 Handle<String> full); | 283 Handle<String> full); |
284 static void OnExit(); | 284 static void OnExit(); |
285 static int* LookupCounter(const char* name); | 285 static int* LookupCounter(const char* name); |
286 static void* CreateHistogram(const char* name, | 286 static void* CreateHistogram(const char* name, |
287 int min, | 287 int min, |
(...skipping 15 matching lines...) Expand all Loading... |
303 | 303 |
304 static Handle<Value> Print(const Arguments& args); | 304 static Handle<Value> Print(const Arguments& args); |
305 static Handle<Value> Write(const Arguments& args); | 305 static Handle<Value> Write(const Arguments& args); |
306 static Handle<Value> Yield(const Arguments& args); | 306 static Handle<Value> Yield(const Arguments& args); |
307 static Handle<Value> Quit(const Arguments& args); | 307 static Handle<Value> Quit(const Arguments& args); |
308 static Handle<Value> Version(const Arguments& args); | 308 static Handle<Value> Version(const Arguments& args); |
309 static Handle<Value> EnableProfiler(const Arguments& args); | 309 static Handle<Value> EnableProfiler(const Arguments& args); |
310 static Handle<Value> DisableProfiler(const Arguments& args); | 310 static Handle<Value> DisableProfiler(const Arguments& args); |
311 static Handle<Value> Read(const Arguments& args); | 311 static Handle<Value> Read(const Arguments& args); |
312 static Handle<Value> ReadBuffer(const Arguments& args); | 312 static Handle<Value> ReadBuffer(const Arguments& args); |
313 static Handle<String> ReadFromStdin(); | 313 static Handle<String> ReadFromStdin(Isolate* isolate); |
314 static Handle<Value> ReadLine(const Arguments& args) { | 314 static Handle<Value> ReadLine(const Arguments& args) { |
315 return ReadFromStdin(); | 315 return ReadFromStdin(args.GetIsolate()); |
316 } | 316 } |
317 static Handle<Value> Load(const Arguments& args); | 317 static Handle<Value> Load(const Arguments& args); |
318 static Handle<Value> ArrayBuffer(const Arguments& args); | 318 static Handle<Value> ArrayBuffer(const Arguments& args); |
319 static Handle<Value> Int8Array(const Arguments& args); | 319 static Handle<Value> Int8Array(const Arguments& args); |
320 static Handle<Value> Uint8Array(const Arguments& args); | 320 static Handle<Value> Uint8Array(const Arguments& args); |
321 static Handle<Value> Int16Array(const Arguments& args); | 321 static Handle<Value> Int16Array(const Arguments& args); |
322 static Handle<Value> Uint16Array(const Arguments& args); | 322 static Handle<Value> Uint16Array(const Arguments& args); |
323 static Handle<Value> Int32Array(const Arguments& args); | 323 static Handle<Value> Int32Array(const Arguments& args); |
324 static Handle<Value> Uint32Array(const Arguments& args); | 324 static Handle<Value> Uint32Array(const Arguments& args); |
325 static Handle<Value> Float32Array(const Arguments& args); | 325 static Handle<Value> Float32Array(const Arguments& args); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 static Handle<Value> System(const Arguments& args); | 358 static Handle<Value> System(const Arguments& args); |
359 static Handle<Value> ChangeDirectory(const Arguments& args); | 359 static Handle<Value> ChangeDirectory(const Arguments& args); |
360 static Handle<Value> SetEnvironment(const Arguments& args); | 360 static Handle<Value> SetEnvironment(const Arguments& args); |
361 static Handle<Value> UnsetEnvironment(const Arguments& args); | 361 static Handle<Value> UnsetEnvironment(const Arguments& args); |
362 static Handle<Value> SetUMask(const Arguments& args); | 362 static Handle<Value> SetUMask(const Arguments& args); |
363 static Handle<Value> MakeDirectory(const Arguments& args); | 363 static Handle<Value> MakeDirectory(const Arguments& args); |
364 static Handle<Value> RemoveDirectory(const Arguments& args); | 364 static Handle<Value> RemoveDirectory(const Arguments& args); |
365 | 365 |
366 static void AddOSMethods(Handle<ObjectTemplate> os_template); | 366 static void AddOSMethods(Handle<ObjectTemplate> os_template); |
367 | 367 |
368 static LineEditor* console; | |
369 static const char* kPrompt; | 368 static const char* kPrompt; |
370 static ShellOptions options; | 369 static ShellOptions options; |
371 | 370 |
372 private: | 371 private: |
373 static Persistent<Context> evaluation_context_; | 372 static Persistent<Context> evaluation_context_; |
374 #ifndef V8_SHARED | 373 #ifndef V8_SHARED |
375 static Persistent<Context> utility_context_; | 374 static Persistent<Context> utility_context_; |
376 static CounterMap* counter_map_; | 375 static CounterMap* counter_map_; |
377 // We statically allocate a set of local counters to be used if we | 376 // We statically allocate a set of local counters to be used if we |
378 // don't want to store the stats in a memory-mapped file | 377 // don't want to store the stats in a memory-mapped file |
379 static CounterCollection local_counters_; | 378 static CounterCollection local_counters_; |
380 static CounterCollection* counters_; | 379 static CounterCollection* counters_; |
381 static i::OS::MemoryMappedFile* counters_file_; | 380 static i::OS::MemoryMappedFile* counters_file_; |
382 static i::Mutex* context_mutex_; | 381 static i::Mutex* context_mutex_; |
383 | 382 |
384 static Counter* GetCounter(const char* name, bool is_histogram); | 383 static Counter* GetCounter(const char* name, bool is_histogram); |
385 static void InstallUtilityScript(); | 384 static void InstallUtilityScript(); |
386 #endif // V8_SHARED | 385 #endif // V8_SHARED |
387 static void Initialize(); | 386 static void Initialize(Isolate* isolate); |
388 static void RunShell(); | 387 static void RunShell(Isolate* isolate); |
389 static bool SetOptions(int argc, char* argv[]); | 388 static bool SetOptions(int argc, char* argv[]); |
390 static Handle<ObjectTemplate> CreateGlobalTemplate(); | 389 static Handle<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); |
391 static Handle<FunctionTemplate> CreateArrayBufferTemplate(InvocationCallback); | 390 static Handle<FunctionTemplate> CreateArrayBufferTemplate(InvocationCallback); |
392 static Handle<FunctionTemplate> CreateArrayTemplate(InvocationCallback); | 391 static Handle<FunctionTemplate> CreateArrayTemplate(InvocationCallback); |
393 static Handle<Value> CreateExternalArrayBuffer(Handle<Object> buffer, | 392 static Handle<Value> CreateExternalArrayBuffer(Isolate* isolate, |
| 393 Handle<Object> buffer, |
394 int32_t size); | 394 int32_t size); |
395 static Handle<Object> CreateExternalArray(Handle<Object> array, | 395 static Handle<Object> CreateExternalArray(Isolate* isolate, |
| 396 Handle<Object> array, |
396 Handle<Object> buffer, | 397 Handle<Object> buffer, |
397 ExternalArrayType type, | 398 ExternalArrayType type, |
398 int32_t length, | 399 int32_t length, |
399 int32_t byteLength, | 400 int32_t byteLength, |
400 int32_t byteOffset, | 401 int32_t byteOffset, |
401 int32_t element_size); | 402 int32_t element_size); |
402 static Handle<Value> CreateExternalArray(const Arguments& args, | 403 static Handle<Value> CreateExternalArray(const Arguments& args, |
403 ExternalArrayType type, | 404 ExternalArrayType type, |
404 int32_t element_size); | 405 int32_t element_size); |
405 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); | 406 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); |
406 }; | 407 }; |
407 | 408 |
408 | 409 |
409 } // namespace v8 | 410 } // namespace v8 |
410 | 411 |
411 | 412 |
412 #endif // V8_D8_H_ | 413 #endif // V8_D8_H_ |
OLD | NEW |