ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 1 | // Copyright 2009 the V8 project authors. All rights reserved. |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 27 | |
| 28 | #ifndef V8_D8_H_ |
| 29 | #define V8_D8_H_ |
| 30 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 31 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 32 | #ifndef V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 33 | #include "v8.h" |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 34 | #include "allocation.h" |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 35 | #include "hashmap.h" |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 36 | #else |
| 37 | #include "../include/v8.h" |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 38 | #endif // V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 39 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 40 | namespace v8 { |
| 41 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 42 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 43 | #ifndef V8_SHARED |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 44 | // A single counter in a counter collection. |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 45 | class Counter { |
| 46 | public: |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 47 | static const int kMaxNameSize = 64; |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 48 | int32_t* Bind(const char* name, bool histogram); |
| 49 | int32_t* ptr() { return &count_; } |
| 50 | int32_t count() { return count_; } |
| 51 | int32_t sample_total() { return sample_total_; } |
| 52 | bool is_histogram() { return is_histogram_; } |
| 53 | void AddSample(int32_t sample); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 54 | private: |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 55 | int32_t count_; |
| 56 | int32_t sample_total_; |
| 57 | bool is_histogram_; |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 58 | uint8_t name_[kMaxNameSize]; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | // A set of counters and associated information. An instance of this |
| 63 | // class is stored directly in the memory-mapped counters file if |
| 64 | // the --map-counters options is used |
| 65 | class CounterCollection { |
| 66 | public: |
| 67 | CounterCollection(); |
| 68 | Counter* GetNextCounter(); |
| 69 | private: |
| 70 | static const unsigned kMaxCounters = 256; |
| 71 | uint32_t magic_number_; |
| 72 | uint32_t max_counters_; |
| 73 | uint32_t max_name_size_; |
| 74 | uint32_t counters_in_use_; |
| 75 | Counter counters_[kMaxCounters]; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 79 | class CounterMap { |
| 80 | public: |
| 81 | CounterMap(): hash_map_(Match) { } |
| 82 | Counter* Lookup(const char* name) { |
| 83 | i::HashMap::Entry* answer = hash_map_.Lookup( |
| 84 | const_cast<char*>(name), |
| 85 | Hash(name), |
| 86 | false); |
| 87 | if (!answer) return NULL; |
| 88 | return reinterpret_cast<Counter*>(answer->value); |
| 89 | } |
| 90 | void Set(const char* name, Counter* value) { |
| 91 | i::HashMap::Entry* answer = hash_map_.Lookup( |
| 92 | const_cast<char*>(name), |
| 93 | Hash(name), |
| 94 | true); |
| 95 | ASSERT(answer != NULL); |
| 96 | answer->value = value; |
| 97 | } |
| 98 | class Iterator { |
| 99 | public: |
| 100 | explicit Iterator(CounterMap* map) |
| 101 | : map_(&map->hash_map_), entry_(map_->Start()) { } |
| 102 | void Next() { entry_ = map_->Next(entry_); } |
| 103 | bool More() { return entry_ != NULL; } |
| 104 | const char* CurrentKey() { return static_cast<const char*>(entry_->key); } |
| 105 | Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); } |
| 106 | private: |
| 107 | i::HashMap* map_; |
| 108 | i::HashMap::Entry* entry_; |
| 109 | }; |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 110 | |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 111 | private: |
| 112 | static int Hash(const char* name); |
| 113 | static bool Match(void* key1, void* key2); |
| 114 | i::HashMap hash_map_; |
| 115 | }; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 116 | #endif // V8_SHARED |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 117 | |
| 118 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 119 | class SourceGroup { |
| 120 | public: |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 121 | SourceGroup() : |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 122 | #ifndef V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 123 | next_semaphore_(v8::internal::OS::CreateSemaphore(0)), |
| 124 | done_semaphore_(v8::internal::OS::CreateSemaphore(0)), |
| 125 | thread_(NULL), |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 126 | #endif // V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 127 | argv_(NULL), |
| 128 | begin_offset_(0), |
| 129 | end_offset_(0) { } |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 130 | |
| 131 | void Begin(char** argv, int offset) { |
| 132 | argv_ = const_cast<const char**>(argv); |
| 133 | begin_offset_ = offset; |
| 134 | } |
| 135 | |
| 136 | void End(int offset) { end_offset_ = offset; } |
| 137 | |
| 138 | void Execute(); |
| 139 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 140 | #ifndef V8_SHARED |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 141 | void StartExecuteInThread(); |
| 142 | void WaitForThread(); |
| 143 | |
| 144 | private: |
| 145 | class IsolateThread : public i::Thread { |
| 146 | public: |
| 147 | explicit IsolateThread(SourceGroup* group) |
| 148 | : i::Thread(GetThreadOptions()), group_(group) {} |
| 149 | |
| 150 | virtual void Run() { |
| 151 | group_->ExecuteInThread(); |
| 152 | } |
| 153 | |
| 154 | private: |
| 155 | SourceGroup* group_; |
| 156 | }; |
| 157 | |
| 158 | static i::Thread::Options GetThreadOptions(); |
| 159 | void ExecuteInThread(); |
| 160 | |
| 161 | i::Semaphore* next_semaphore_; |
| 162 | i::Semaphore* done_semaphore_; |
| 163 | i::Thread* thread_; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 164 | #endif // V8_SHARED |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 165 | |
| 166 | void ExitShell(int exit_code); |
| 167 | Handle<String> ReadFile(const char* name); |
| 168 | |
| 169 | const char** argv_; |
| 170 | int begin_offset_; |
| 171 | int end_offset_; |
| 172 | }; |
| 173 | |
| 174 | |
| 175 | class ShellOptions { |
| 176 | public: |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 177 | ShellOptions() : |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 178 | #ifndef V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 179 | use_preemption(true), |
| 180 | preemption_interval(10), |
| 181 | parallel_files(NULL), |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 182 | #endif // V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 183 | script_executed(false), |
| 184 | last_run(true), |
| 185 | stress_opt(false), |
| 186 | stress_deopt(false), |
| 187 | interactive_shell(false), |
| 188 | test_shell(false), |
| 189 | num_isolates(1), |
| 190 | isolate_sources(NULL) { } |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 191 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 192 | #ifndef V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 193 | bool use_preemption; |
| 194 | int preemption_interval; |
| 195 | i::List< i::Vector<const char> >* parallel_files; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 196 | #endif // V8_SHARED |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 197 | bool script_executed; |
| 198 | bool last_run; |
| 199 | bool stress_opt; |
| 200 | bool stress_deopt; |
| 201 | bool interactive_shell; |
| 202 | bool test_shell; |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 203 | int num_isolates; |
| 204 | SourceGroup* isolate_sources; |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 205 | }; |
| 206 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 207 | #ifdef V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 208 | class Shell { |
| 209 | #else |
| 210 | class Shell : public i::AllStatic { |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 211 | #endif // V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 212 | public: |
| 213 | static bool ExecuteString(Handle<String> source, |
| 214 | Handle<Value> name, |
| 215 | bool print_result, |
| 216 | bool report_exceptions); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 217 | static const char* ToCString(const v8::String::Utf8Value& value); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 218 | static void ReportException(TryCatch* try_catch); |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 219 | static Handle<String> ReadFile(const char* name); |
| 220 | static Persistent<Context> CreateEvaluationContext(); |
| 221 | static int RunMain(int argc, char* argv[]); |
| 222 | static int Main(int argc, char* argv[]); |
| 223 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 224 | #ifndef V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 225 | static Handle<Array> GetCompletions(Handle<String> text, |
| 226 | Handle<String> full); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 227 | static void OnExit(); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 228 | static int* LookupCounter(const char* name); |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 229 | static void* CreateHistogram(const char* name, |
| 230 | int min, |
| 231 | int max, |
| 232 | size_t buckets); |
| 233 | static void AddHistogramSample(void* histogram, int sample); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 234 | static void MapCounters(const char* name); |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 235 | #endif // V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 236 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 237 | #ifdef ENABLE_DEBUGGER_SUPPORT |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 238 | static Handle<Object> DebugMessageDetails(Handle<String> message); |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 239 | static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 240 | #endif |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 241 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 242 | #ifdef WIN32 |
| 243 | #undef Yield |
| 244 | #endif |
| 245 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 246 | static Handle<Value> Print(const Arguments& args); |
christian.plesner.hansen@gmail.com | 5a6af92 | 2009-08-12 14:20:51 +0000 | [diff] [blame] | 247 | static Handle<Value> Write(const Arguments& args); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 248 | static Handle<Value> Yield(const Arguments& args); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 249 | static Handle<Value> Quit(const Arguments& args); |
| 250 | static Handle<Value> Version(const Arguments& args); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 251 | static Handle<Value> Read(const Arguments& args); |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 252 | static Handle<Value> ReadLine(const Arguments& args); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 253 | static Handle<Value> Load(const Arguments& args); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 254 | static Handle<Value> Int8Array(const Arguments& args); |
| 255 | static Handle<Value> Uint8Array(const Arguments& args); |
| 256 | static Handle<Value> Int16Array(const Arguments& args); |
| 257 | static Handle<Value> Uint16Array(const Arguments& args); |
| 258 | static Handle<Value> Int32Array(const Arguments& args); |
| 259 | static Handle<Value> Uint32Array(const Arguments& args); |
| 260 | static Handle<Value> Float32Array(const Arguments& args); |
| 261 | static Handle<Value> Float64Array(const Arguments& args); |
| 262 | static Handle<Value> PixelArray(const Arguments& args); |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 263 | // The OS object on the global object contains methods for performing |
| 264 | // operating system calls: |
| 265 | // |
| 266 | // os.system("program_name", ["arg1", "arg2", ...], timeout1, timeout2) will |
| 267 | // run the command, passing the arguments to the program. The standard output |
| 268 | // of the program will be picked up and returned as a multiline string. If |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 269 | // timeout1 is present then it should be a number. -1 indicates no timeout |
| 270 | // and a positive number is used as a timeout in milliseconds that limits the |
| 271 | // time spent waiting between receiving output characters from the program. |
| 272 | // timeout2, if present, should be a number indicating the limit in |
| 273 | // milliseconds on the total running time of the program. Exceptions are |
| 274 | // thrown on timeouts or other errors or if the exit status of the program |
| 275 | // indicates an error. |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 276 | // |
| 277 | // os.chdir(dir) changes directory to the given directory. Throws an |
| 278 | // exception/ on error. |
| 279 | // |
| 280 | // os.setenv(variable, value) sets an environment variable. Repeated calls to |
| 281 | // this method leak memory due to the API of setenv in the standard C library. |
| 282 | // |
| 283 | // os.umask(alue) calls the umask system call and returns the old umask. |
| 284 | // |
| 285 | // os.mkdirp(name, mask) creates a directory. The mask (if present) is anded |
| 286 | // with the current umask. Intermediate directories are created if necessary. |
| 287 | // An exception is not thrown if the directory already exists. Analogous to |
| 288 | // the "mkdir -p" command. |
| 289 | static Handle<Value> OSObject(const Arguments& args); |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 290 | static Handle<Value> System(const Arguments& args); |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 291 | static Handle<Value> ChangeDirectory(const Arguments& args); |
| 292 | static Handle<Value> SetEnvironment(const Arguments& args); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 293 | static Handle<Value> UnsetEnvironment(const Arguments& args); |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 294 | static Handle<Value> SetUMask(const Arguments& args); |
| 295 | static Handle<Value> MakeDirectory(const Arguments& args); |
| 296 | static Handle<Value> RemoveDirectory(const Arguments& args); |
| 297 | |
| 298 | static void AddOSMethods(Handle<ObjectTemplate> os_template); |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 299 | #ifndef V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 300 | static const char* kHistoryFileName; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 301 | #endif // V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 302 | static const char* kPrompt; |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 303 | static ShellOptions options; |
| 304 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 305 | private: |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 306 | static Persistent<Context> evaluation_context_; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 307 | #ifndef V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 308 | static Persistent<Context> utility_context_; |
kasperl@chromium.org | f5aa837 | 2009-03-24 14:47:14 +0000 | [diff] [blame] | 309 | static CounterMap* counter_map_; |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 310 | // We statically allocate a set of local counters to be used if we |
| 311 | // don't want to store the stats in a memory-mapped file |
| 312 | static CounterCollection local_counters_; |
| 313 | static CounterCollection* counters_; |
| 314 | static i::OS::MemoryMappedFile* counters_file_; |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 315 | static i::Mutex* context_mutex_; |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 316 | |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 317 | static Counter* GetCounter(const char* name, bool is_histogram); |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 318 | static void InstallUtilityScript(); |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 319 | #endif // V8_SHARED |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 320 | static void Initialize(); |
| 321 | static void RunShell(); |
| 322 | static bool SetOptions(int argc, char* argv[]); |
| 323 | static Handle<ObjectTemplate> CreateGlobalTemplate(); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 324 | static Handle<Value> CreateExternalArray(const Arguments& args, |
| 325 | ExternalArrayType type, |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 326 | size_t element_size); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 327 | static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 328 | }; |
| 329 | |
| 330 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 331 | #ifndef V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 332 | class LineEditor { |
| 333 | public: |
| 334 | enum Type { DUMB = 0, READLINE = 1 }; |
| 335 | LineEditor(Type type, const char* name); |
| 336 | virtual ~LineEditor() { } |
| 337 | |
| 338 | virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; |
| 339 | virtual bool Open() { return true; } |
| 340 | virtual bool Close() { return true; } |
| 341 | virtual void AddHistory(const char* str) { } |
| 342 | |
| 343 | const char* name() { return name_; } |
| 344 | static LineEditor* Get(); |
| 345 | private: |
| 346 | Type type_; |
| 347 | const char* name_; |
| 348 | LineEditor* next_; |
| 349 | static LineEditor* first_; |
| 350 | }; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 351 | #endif // V8_SHARED |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 352 | |
| 353 | |
| 354 | } // namespace v8 |
| 355 | |
| 356 | |
| 357 | #endif // V8_D8_H_ |