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

Side by Side Diff: src/d8.h

Issue 7318002: ported --isolate option to d8 and refactored to group together option parsing (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« 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 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
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 {
Yang 2011/07/07 16:04:49 class necessary for the --isolate option
116 public:
117 SourceGroup() :
118 #if !(defined(USING_V8_SHARED) || defined(V8_SHARED))
119 next_semaphore_(v8::internal::OS::CreateSemaphore(0)),
120 done_semaphore_(v8::internal::OS::CreateSemaphore(0)),
121 thread_(NULL),
122 #endif // USING_V8_SHARED
123 argv_(NULL),
124 begin_offset_(0),
125 end_offset_(0) { }
126
127 void Begin(char** argv, int offset) {
128 argv_ = const_cast<const char**>(argv);
129 begin_offset_ = offset;
130 }
131
132 void End(int offset) { end_offset_ = offset; }
133
134 void Execute();
135
136 #if !(defined(USING_V8_SHARED) || defined(V8_SHARED))
137 void StartExecuteInThread();
138 void WaitForThread();
139 #endif // USING_V8_SHARED
140
141 private:
142 #if !(defined(USING_V8_SHARED) || defined(V8_SHARED))
143 class IsolateThread : public i::Thread {
144 public:
145 explicit IsolateThread(SourceGroup* group)
146 : i::Thread(GetThreadOptions()), group_(group) {}
147
148 virtual void Run() {
149 group_->ExecuteInThread();
150 }
151
152 private:
153 SourceGroup* group_;
154 };
155
156 static i::Thread::Options GetThreadOptions();
157
158 void ExecuteInThread();
159 void ExitShell(int exit_code);
160 Handle<String> ReadFile(const char* name);
161
162 i::Semaphore* next_semaphore_;
163 i::Semaphore* done_semaphore_;
164 i::Thread* thread_;
165 #endif // USING_V8_SHARED
166
167 const char** argv_;
168 int begin_offset_;
169 int end_offset_;
170 };
171
172
173 class ShellOptions {
Yang 2011/07/07 16:04:49 grouped all the options for the shell in here.
174 public:
175 ShellOptions() :
176 script_executed(false),
177 last_run(true),
178 FLAG_stress_opt(false),
179 FLAG_stress_deopt(false),
180 FLAG_interactive_shell(false),
181 FLAG_test_shell(false),
182 FLAG_preemption(true),
183 preemption_interval(10),
184 num_isolates(1),
185 isolate_sources(NULL),
186 parallel_files(NULL) { }
187
188 bool script_executed;
189 bool last_run;
190 bool FLAG_stress_opt;
191 bool FLAG_stress_deopt;
192 bool FLAG_interactive_shell;
193 bool FLAG_test_shell;
194 bool FLAG_preemption;
195 int preemption_interval;
196 int num_isolates;
197 SourceGroup* isolate_sources;
198 i::List< i::Vector<const char> >* parallel_files;
199 };
200
201
115 class Shell: public i::AllStatic { 202 class Shell: public i::AllStatic {
116 public: 203 public:
117 static bool ExecuteString(Handle<String> source, 204 static bool ExecuteString(Handle<String> source,
118 Handle<Value> name, 205 Handle<Value> name,
119 bool print_result, 206 bool print_result,
120 bool report_exceptions); 207 bool report_exceptions);
121 static const char* ToCString(const v8::String::Utf8Value& value); 208 static const char* ToCString(const v8::String::Utf8Value& value);
122 static void ReportException(TryCatch* try_catch); 209 static void ReportException(TryCatch* try_catch);
123 static void OnExit(); 210 static void OnExit();
124 static int* LookupCounter(const char* name); 211 static int* LookupCounter(const char* name);
125 static void* CreateHistogram(const char* name, 212 static void* CreateHistogram(const char* name,
126 int min, 213 int min,
127 int max, 214 int max,
128 size_t buckets); 215 size_t buckets);
129 static void AddHistogramSample(void* histogram, int sample); 216 static void AddHistogramSample(void* histogram, int sample);
130 static void MapCounters(const char* name); 217 static void MapCounters(const char* name);
131 static Handle<String> ReadFile(const char* name); 218 static Handle<String> ReadFile(const char* name);
132 static void Initialize(bool test_shell); 219 static void Initialize();
133 static void RenewEvaluationContext(); 220 static Persistent<Context> CreateEvaluationContext();
134 static void InstallUtilityScript(); 221 static void InstallUtilityScript();
135 static void RunShell(); 222 static void RunShell();
223 static bool SetOptions(int argc, char* argv[]);
136 static int RunScript(char* filename); 224 static int RunScript(char* filename);
137 static int RunMain(int argc, char* argv[], bool* executed); 225 static int RunMain(int argc, char* argv[]);
138 static int Main(int argc, char* argv[]); 226 static int Main(int argc, char* argv[]);
139 static Handle<ObjectTemplate> CreateGlobalTemplate(); 227 static Handle<ObjectTemplate> CreateGlobalTemplate();
140 static Handle<Array> GetCompletions(Handle<String> text, 228 static Handle<Array> GetCompletions(Handle<String> text,
141 Handle<String> full); 229 Handle<String> full);
142 #ifdef ENABLE_DEBUGGER_SUPPORT 230 #ifdef ENABLE_DEBUGGER_SUPPORT
143 static Handle<Object> DebugMessageDetails(Handle<String> message); 231 static Handle<Object> DebugMessageDetails(Handle<String> message);
144 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); 232 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command);
145 #endif 233 #endif
146 234
147 #ifdef WIN32 235 #ifdef WIN32
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 static Handle<Value> UnsetEnvironment(const Arguments& args); 286 static Handle<Value> UnsetEnvironment(const Arguments& args);
199 static Handle<Value> SetUMask(const Arguments& args); 287 static Handle<Value> SetUMask(const Arguments& args);
200 static Handle<Value> MakeDirectory(const Arguments& args); 288 static Handle<Value> MakeDirectory(const Arguments& args);
201 static Handle<Value> RemoveDirectory(const Arguments& args); 289 static Handle<Value> RemoveDirectory(const Arguments& args);
202 290
203 static void AddOSMethods(Handle<ObjectTemplate> os_template); 291 static void AddOSMethods(Handle<ObjectTemplate> os_template);
204 292
205 static const char* kHistoryFileName; 293 static const char* kHistoryFileName;
206 static const char* kPrompt; 294 static const char* kPrompt;
207 295
296 static ShellOptions options;
297
208 private: 298 private:
209 static Persistent<Context> utility_context_; 299 static Persistent<Context> utility_context_;
210 static Persistent<Context> evaluation_context_; 300 static Persistent<Context> evaluation_context_;
211 static CounterMap* counter_map_; 301 static CounterMap* counter_map_;
212 // We statically allocate a set of local counters to be used if we 302 // 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 303 // don't want to store the stats in a memory-mapped file
214 static CounterCollection local_counters_; 304 static CounterCollection local_counters_;
215 static CounterCollection* counters_; 305 static CounterCollection* counters_;
216 static i::OS::MemoryMappedFile* counters_file_; 306 static i::OS::MemoryMappedFile* counters_file_;
307 static i::Mutex* context_mutex_;
217 static Counter* GetCounter(const char* name, bool is_histogram); 308 static Counter* GetCounter(const char* name, bool is_histogram);
218 static Handle<Value> CreateExternalArray(const Arguments& args, 309 static Handle<Value> CreateExternalArray(const Arguments& args,
219 ExternalArrayType type, 310 ExternalArrayType type,
220 size_t element_size); 311 size_t element_size);
221 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); 312 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data);
222 }; 313 };
223 314
224 315
225 class LineEditor { 316 class LineEditor {
226 public: 317 public:
(...skipping 13 matching lines...) Expand all
240 const char* name_; 331 const char* name_;
241 LineEditor* next_; 332 LineEditor* next_;
242 static LineEditor* first_; 333 static LineEditor* first_;
243 }; 334 };
244 335
245 336
246 } // namespace v8 337 } // namespace v8
247 338
248 339
249 #endif // V8_D8_H_ 340 #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