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

Side by Side Diff: src/d8.h

Issue 7586001: Fixed a known issue in D8 (read file), enabled D8 shared library build on Windows. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed the mess where d8 was getting the BUILDING_V8_SHARED compile flag. Created 9 years, 4 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 | « src/SConscript ('k') | 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_D8_H_ 28 #ifndef V8_D8_H_
29 #define V8_D8_H_ 29 #define V8_D8_H_
30 30
31 31
32 #ifndef USING_V8_SHARED 32 #ifndef V8_SHARED
33 #include "v8.h" 33 #include "v8.h"
34 #include "allocation.h" 34 #include "allocation.h"
35 #include "hashmap.h" 35 #include "hashmap.h"
36 #else 36 #else
37 #include "../include/v8.h" 37 #include "../include/v8.h"
38 #endif // USING_V8_SHARED 38 #endif // V8_SHARED
39 39
40 namespace v8 { 40 namespace v8 {
41 41
42 #ifndef USING_V8_SHARED 42 #ifndef V8_SHARED
43 namespace i = v8::internal; 43 namespace i = v8::internal;
44 #endif // USING_V8_SHARED 44 #endif // V8_SHARED
45 45
46 46
47 #ifndef USING_V8_SHARED 47 #ifndef V8_SHARED
48 // A single counter in a counter collection. 48 // A single counter in a counter collection.
49 class Counter { 49 class Counter {
50 public: 50 public:
51 static const int kMaxNameSize = 64; 51 static const int kMaxNameSize = 64;
52 int32_t* Bind(const char* name, bool histogram); 52 int32_t* Bind(const char* name, bool histogram);
53 int32_t* ptr() { return &count_; } 53 int32_t* ptr() { return &count_; }
54 int32_t count() { return count_; } 54 int32_t count() { return count_; }
55 int32_t sample_total() { return sample_total_; } 55 int32_t sample_total() { return sample_total_; }
56 bool is_histogram() { return is_histogram_; } 56 bool is_histogram() { return is_histogram_; }
57 void AddSample(int32_t sample); 57 void AddSample(int32_t sample);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 private: 110 private:
111 i::HashMap* map_; 111 i::HashMap* map_;
112 i::HashMap::Entry* entry_; 112 i::HashMap::Entry* entry_;
113 }; 113 };
114 114
115 private: 115 private:
116 static int Hash(const char* name); 116 static int Hash(const char* name);
117 static bool Match(void* key1, void* key2); 117 static bool Match(void* key1, void* key2);
118 i::HashMap hash_map_; 118 i::HashMap hash_map_;
119 }; 119 };
120 #endif // USING_V8_SHARED 120 #endif // V8_SHARED
121 121
122 122
123 class SourceGroup { 123 class SourceGroup {
124 public: 124 public:
125 SourceGroup() : 125 SourceGroup() :
126 #ifndef USING_V8_SHARED 126 #ifndef V8_SHARED
127 next_semaphore_(v8::internal::OS::CreateSemaphore(0)), 127 next_semaphore_(v8::internal::OS::CreateSemaphore(0)),
128 done_semaphore_(v8::internal::OS::CreateSemaphore(0)), 128 done_semaphore_(v8::internal::OS::CreateSemaphore(0)),
129 thread_(NULL), 129 thread_(NULL),
130 #endif // USING_V8_SHARED 130 #endif // V8_SHARED
131 argv_(NULL), 131 argv_(NULL),
132 begin_offset_(0), 132 begin_offset_(0),
133 end_offset_(0) { } 133 end_offset_(0) { }
134 134
135 void Begin(char** argv, int offset) { 135 void Begin(char** argv, int offset) {
136 argv_ = const_cast<const char**>(argv); 136 argv_ = const_cast<const char**>(argv);
137 begin_offset_ = offset; 137 begin_offset_ = offset;
138 } 138 }
139 139
140 void End(int offset) { end_offset_ = offset; } 140 void End(int offset) { end_offset_ = offset; }
141 141
142 void Execute(); 142 void Execute();
143 143
144 #ifndef USING_V8_SHARED 144 #ifndef V8_SHARED
145 void StartExecuteInThread(); 145 void StartExecuteInThread();
146 void WaitForThread(); 146 void WaitForThread();
147 147
148 private: 148 private:
149 class IsolateThread : public i::Thread { 149 class IsolateThread : public i::Thread {
150 public: 150 public:
151 explicit IsolateThread(SourceGroup* group) 151 explicit IsolateThread(SourceGroup* group)
152 : i::Thread(GetThreadOptions()), group_(group) {} 152 : i::Thread(GetThreadOptions()), group_(group) {}
153 153
154 virtual void Run() { 154 virtual void Run() {
155 group_->ExecuteInThread(); 155 group_->ExecuteInThread();
156 } 156 }
157 157
158 private: 158 private:
159 SourceGroup* group_; 159 SourceGroup* group_;
160 }; 160 };
161 161
162 static i::Thread::Options GetThreadOptions(); 162 static i::Thread::Options GetThreadOptions();
163 void ExecuteInThread(); 163 void ExecuteInThread();
164 164
165 i::Semaphore* next_semaphore_; 165 i::Semaphore* next_semaphore_;
166 i::Semaphore* done_semaphore_; 166 i::Semaphore* done_semaphore_;
167 i::Thread* thread_; 167 i::Thread* thread_;
168 #endif // USING_V8_SHARED 168 #endif // V8_SHARED
169 169
170 void ExitShell(int exit_code); 170 void ExitShell(int exit_code);
171 Handle<String> ReadFile(const char* name); 171 Handle<String> ReadFile(const char* name);
172 172
173 const char** argv_; 173 const char** argv_;
174 int begin_offset_; 174 int begin_offset_;
175 int end_offset_; 175 int end_offset_;
176 }; 176 };
177 177
178 178
179 class ShellOptions { 179 class ShellOptions {
180 public: 180 public:
181 ShellOptions() : 181 ShellOptions() :
182 #ifndef USING_V8_SHARED 182 #ifndef V8_SHARED
183 use_preemption(true), 183 use_preemption(true),
184 preemption_interval(10), 184 preemption_interval(10),
185 parallel_files(NULL), 185 parallel_files(NULL),
186 #endif // USING_V8_SHARED 186 #endif // V8_SHARED
187 script_executed(false), 187 script_executed(false),
188 last_run(true), 188 last_run(true),
189 stress_opt(false), 189 stress_opt(false),
190 stress_deopt(false), 190 stress_deopt(false),
191 interactive_shell(false), 191 interactive_shell(false),
192 test_shell(false), 192 test_shell(false),
193 num_isolates(1), 193 num_isolates(1),
194 isolate_sources(NULL) { } 194 isolate_sources(NULL) { }
195 195
196 #ifndef USING_V8_SHARED 196 #ifndef V8_SHARED
197 bool use_preemption; 197 bool use_preemption;
198 int preemption_interval; 198 int preemption_interval;
199 i::List< i::Vector<const char> >* parallel_files; 199 i::List< i::Vector<const char> >* parallel_files;
200 #endif // USING_V8_SHARED 200 #endif // V8_SHARED
201 bool script_executed; 201 bool script_executed;
202 bool last_run; 202 bool last_run;
203 bool stress_opt; 203 bool stress_opt;
204 bool stress_deopt; 204 bool stress_deopt;
205 bool interactive_shell; 205 bool interactive_shell;
206 bool test_shell; 206 bool test_shell;
207 int num_isolates; 207 int num_isolates;
208 SourceGroup* isolate_sources; 208 SourceGroup* isolate_sources;
209 }; 209 };
210 210
211 #ifdef USING_V8_SHARED 211 #ifdef V8_SHARED
212 class Shell { 212 class Shell {
213 #else 213 #else
214 class Shell : public i::AllStatic { 214 class Shell : public i::AllStatic {
215 #endif // USING_V8_SHARED 215 #endif // V8_SHARED
216 public: 216 public:
217 static bool ExecuteString(Handle<String> source, 217 static bool ExecuteString(Handle<String> source,
218 Handle<Value> name, 218 Handle<Value> name,
219 bool print_result, 219 bool print_result,
220 bool report_exceptions); 220 bool report_exceptions);
221 static const char* ToCString(const v8::String::Utf8Value& value); 221 static const char* ToCString(const v8::String::Utf8Value& value);
222 static void ReportException(TryCatch* try_catch); 222 static void ReportException(TryCatch* try_catch);
223 static Handle<String> ReadFile(const char* name); 223 static Handle<String> ReadFile(const char* name);
224 static Persistent<Context> CreateEvaluationContext(); 224 static Persistent<Context> CreateEvaluationContext();
225 static int RunMain(int argc, char* argv[]); 225 static int RunMain(int argc, char* argv[]);
226 static int Main(int argc, char* argv[]); 226 static int Main(int argc, char* argv[]);
227 227
228 #ifndef USING_V8_SHARED 228 #ifndef V8_SHARED
229 static Handle<Array> GetCompletions(Handle<String> text, 229 static Handle<Array> GetCompletions(Handle<String> text,
230 Handle<String> full); 230 Handle<String> full);
231 static void OnExit(); 231 static void OnExit();
232 static int* LookupCounter(const char* name); 232 static int* LookupCounter(const char* name);
233 static void* CreateHistogram(const char* name, 233 static void* CreateHistogram(const char* name,
234 int min, 234 int min,
235 int max, 235 int max,
236 size_t buckets); 236 size_t buckets);
237 static void AddHistogramSample(void* histogram, int sample); 237 static void AddHistogramSample(void* histogram, int sample);
238 static void MapCounters(const char* name); 238 static void MapCounters(const char* name);
239 #endif // USING_V8_SHARED 239 #endif // V8_SHARED
240 240
241 #ifdef ENABLE_DEBUGGER_SUPPORT 241 #ifdef ENABLE_DEBUGGER_SUPPORT
242 static Handle<Object> DebugMessageDetails(Handle<String> message); 242 static Handle<Object> DebugMessageDetails(Handle<String> message);
243 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); 243 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command);
244 #endif 244 #endif
245 245
246 #ifdef WIN32 246 #ifdef WIN32
247 #undef Yield 247 #undef Yield
248 #endif 248 #endif
249 249
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 static Handle<Value> OSObject(const Arguments& args); 293 static Handle<Value> OSObject(const Arguments& args);
294 static Handle<Value> System(const Arguments& args); 294 static Handle<Value> System(const Arguments& args);
295 static Handle<Value> ChangeDirectory(const Arguments& args); 295 static Handle<Value> ChangeDirectory(const Arguments& args);
296 static Handle<Value> SetEnvironment(const Arguments& args); 296 static Handle<Value> SetEnvironment(const Arguments& args);
297 static Handle<Value> UnsetEnvironment(const Arguments& args); 297 static Handle<Value> UnsetEnvironment(const Arguments& args);
298 static Handle<Value> SetUMask(const Arguments& args); 298 static Handle<Value> SetUMask(const Arguments& args);
299 static Handle<Value> MakeDirectory(const Arguments& args); 299 static Handle<Value> MakeDirectory(const Arguments& args);
300 static Handle<Value> RemoveDirectory(const Arguments& args); 300 static Handle<Value> RemoveDirectory(const Arguments& args);
301 301
302 static void AddOSMethods(Handle<ObjectTemplate> os_template); 302 static void AddOSMethods(Handle<ObjectTemplate> os_template);
303 #ifndef USING_V8_SHARED 303 #ifndef V8_SHARED
304 static const char* kHistoryFileName; 304 static const char* kHistoryFileName;
305 #endif // USING_V8_SHARED 305 #endif // V8_SHARED
306 static const char* kPrompt; 306 static const char* kPrompt;
307 static ShellOptions options; 307 static ShellOptions options;
308 308
309 private: 309 private:
310 static Persistent<Context> evaluation_context_; 310 static Persistent<Context> evaluation_context_;
311 #ifndef USING_V8_SHARED 311 #ifndef V8_SHARED
312 static Persistent<Context> utility_context_; 312 static Persistent<Context> utility_context_;
313 static CounterMap* counter_map_; 313 static CounterMap* counter_map_;
314 // We statically allocate a set of local counters to be used if we 314 // We statically allocate a set of local counters to be used if we
315 // don't want to store the stats in a memory-mapped file 315 // don't want to store the stats in a memory-mapped file
316 static CounterCollection local_counters_; 316 static CounterCollection local_counters_;
317 static CounterCollection* counters_; 317 static CounterCollection* counters_;
318 static i::OS::MemoryMappedFile* counters_file_; 318 static i::OS::MemoryMappedFile* counters_file_;
319 static i::Mutex* context_mutex_; 319 static i::Mutex* context_mutex_;
320 320
321 static Counter* GetCounter(const char* name, bool is_histogram); 321 static Counter* GetCounter(const char* name, bool is_histogram);
322 static void InstallUtilityScript(); 322 static void InstallUtilityScript();
323 #endif // USING_V8_SHARED 323 #endif // V8_SHARED
324 static void Initialize(); 324 static void Initialize();
325 static void RunShell(); 325 static void RunShell();
326 static bool SetOptions(int argc, char* argv[]); 326 static bool SetOptions(int argc, char* argv[]);
327 static Handle<ObjectTemplate> CreateGlobalTemplate(); 327 static Handle<ObjectTemplate> CreateGlobalTemplate();
328 static Handle<Value> CreateExternalArray(const Arguments& args, 328 static Handle<Value> CreateExternalArray(const Arguments& args,
329 ExternalArrayType type, 329 ExternalArrayType type,
330 size_t element_size); 330 size_t element_size);
331 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); 331 static void ExternalArrayWeakCallback(Persistent<Value> object, void* data);
332 }; 332 };
333 333
334 334
335 #ifndef USING_V8_SHARED 335 #ifndef V8_SHARED
336 class LineEditor { 336 class LineEditor {
337 public: 337 public:
338 enum Type { DUMB = 0, READLINE = 1 }; 338 enum Type { DUMB = 0, READLINE = 1 };
339 LineEditor(Type type, const char* name); 339 LineEditor(Type type, const char* name);
340 virtual ~LineEditor() { } 340 virtual ~LineEditor() { }
341 341
342 virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; 342 virtual i::SmartPointer<char> Prompt(const char* prompt) = 0;
343 virtual bool Open() { return true; } 343 virtual bool Open() { return true; }
344 virtual bool Close() { return true; } 344 virtual bool Close() { return true; }
345 virtual void AddHistory(const char* str) { } 345 virtual void AddHistory(const char* str) { }
346 346
347 const char* name() { return name_; } 347 const char* name() { return name_; }
348 static LineEditor* Get(); 348 static LineEditor* Get();
349 private: 349 private:
350 Type type_; 350 Type type_;
351 const char* name_; 351 const char* name_;
352 LineEditor* next_; 352 LineEditor* next_;
353 static LineEditor* first_; 353 static LineEditor* first_;
354 }; 354 };
355 #endif // USING_V8_SHARED 355 #endif // V8_SHARED
356 356
357 357
358 } // namespace v8 358 } // namespace v8
359 359
360 360
361 #endif // V8_D8_H_ 361 #endif // V8_D8_H_
OLDNEW
« no previous file with comments | « src/SConscript ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698