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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return Shell::ReadFromStdin(isolate_); | 153 return Shell::ReadFromStdin(isolate_); |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 #ifndef V8_SHARED | 157 #ifndef V8_SHARED |
158 CounterMap* Shell::counter_map_; | 158 CounterMap* Shell::counter_map_; |
159 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; | 159 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; |
160 CounterCollection Shell::local_counters_; | 160 CounterCollection Shell::local_counters_; |
161 CounterCollection* Shell::counters_ = &local_counters_; | 161 CounterCollection* Shell::counters_ = &local_counters_; |
162 i::Mutex Shell::context_mutex_; | 162 i::Mutex Shell::context_mutex_; |
| 163 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); |
163 Persistent<Context> Shell::utility_context_; | 164 Persistent<Context> Shell::utility_context_; |
164 #endif // V8_SHARED | 165 #endif // V8_SHARED |
165 | 166 |
166 Persistent<Context> Shell::evaluation_context_; | 167 Persistent<Context> Shell::evaluation_context_; |
167 ShellOptions Shell::options; | 168 ShellOptions Shell::options; |
168 const char* Shell::kPrompt = "d8> "; | 169 const char* Shell::kPrompt = "d8> "; |
169 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); | |
170 | 170 |
171 | 171 |
172 const int MB = 1024 * 1024; | 172 const int MB = 1024 * 1024; |
173 | 173 |
174 | 174 |
175 #ifndef V8_SHARED | 175 #ifndef V8_SHARED |
176 bool CounterMap::Match(void* key1, void* key2) { | 176 bool CounterMap::Match(void* key1, void* key2) { |
177 const char* name1 = reinterpret_cast<const char*>(key1); | 177 const char* name1 = reinterpret_cast<const char*>(key1); |
178 const char* name2 = reinterpret_cast<const char*>(key2); | 178 const char* name2 = reinterpret_cast<const char*>(key2); |
179 return strcmp(name1, name2) == 0; | 179 return strcmp(name1, name2) == 0; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 | 284 |
285 int PerIsolateData::RealmFind(Handle<Context> context) { | 285 int PerIsolateData::RealmFind(Handle<Context> context) { |
286 for (int i = 0; i < realm_count_; ++i) { | 286 for (int i = 0; i < realm_count_; ++i) { |
287 if (realms_[i] == context) return i; | 287 if (realms_[i] == context) return i; |
288 } | 288 } |
289 return -1; | 289 return -1; |
290 } | 290 } |
291 | 291 |
292 | 292 |
| 293 #ifndef V8_SHARED |
293 // performance.now() returns a time stamp as double, measured in milliseconds. | 294 // performance.now() returns a time stamp as double, measured in milliseconds. |
294 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { | 295 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { |
295 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks; | 296 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks; |
296 args.GetReturnValue().Set(delta.InMillisecondsF()); | 297 args.GetReturnValue().Set(delta.InMillisecondsF()); |
297 } | 298 } |
| 299 #endif // V8_SHARED |
298 | 300 |
299 | 301 |
300 // Realm.current() returns the index of the currently active realm. | 302 // Realm.current() returns the index of the currently active realm. |
301 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { | 303 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { |
302 Isolate* isolate = args.GetIsolate(); | 304 Isolate* isolate = args.GetIsolate(); |
303 PerIsolateData* data = PerIsolateData::Get(isolate); | 305 PerIsolateData* data = PerIsolateData::Get(isolate); |
304 int index = data->RealmFind(isolate->GetEnteredContext()); | 306 int index = data->RealmFind(isolate->GetEnteredContext()); |
305 if (index == -1) return; | 307 if (index == -1) return; |
306 args.GetReturnValue().Set(index); | 308 args.GetReturnValue().Set(index); |
307 } | 309 } |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 realm_template->Set(String::New("dispose"), | 875 realm_template->Set(String::New("dispose"), |
874 FunctionTemplate::New(RealmDispose)); | 876 FunctionTemplate::New(RealmDispose)); |
875 realm_template->Set(String::New("switch"), | 877 realm_template->Set(String::New("switch"), |
876 FunctionTemplate::New(RealmSwitch)); | 878 FunctionTemplate::New(RealmSwitch)); |
877 realm_template->Set(String::New("eval"), | 879 realm_template->Set(String::New("eval"), |
878 FunctionTemplate::New(RealmEval)); | 880 FunctionTemplate::New(RealmEval)); |
879 realm_template->SetAccessor(String::New("shared"), | 881 realm_template->SetAccessor(String::New("shared"), |
880 RealmSharedGet, RealmSharedSet); | 882 RealmSharedGet, RealmSharedSet); |
881 global_template->Set(String::New("Realm"), realm_template); | 883 global_template->Set(String::New("Realm"), realm_template); |
882 | 884 |
| 885 #ifndef V8_SHARED |
883 Handle<ObjectTemplate> performance_template = ObjectTemplate::New(); | 886 Handle<ObjectTemplate> performance_template = ObjectTemplate::New(); |
884 performance_template->Set(String::New("now"), | 887 performance_template->Set(String::New("now"), |
885 FunctionTemplate::New(PerformanceNow)); | 888 FunctionTemplate::New(PerformanceNow)); |
886 global_template->Set(String::New("performance"), performance_template); | 889 global_template->Set(String::New("performance"), performance_template); |
| 890 #endif // V8_SHARED |
887 | 891 |
888 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) | 892 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) |
889 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); | 893 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); |
890 AddOSMethods(os_templ); | 894 AddOSMethods(os_templ); |
891 global_template->Set(String::New("os"), os_templ); | 895 global_template->Set(String::New("os"), os_templ); |
892 #endif // V8_SHARED | 896 #endif // V8_SHARED |
893 | 897 |
894 return global_template; | 898 return global_template; |
895 } | 899 } |
896 | 900 |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 } | 1755 } |
1752 | 1756 |
1753 } // namespace v8 | 1757 } // namespace v8 |
1754 | 1758 |
1755 | 1759 |
1756 #ifndef GOOGLE3 | 1760 #ifndef GOOGLE3 |
1757 int main(int argc, char* argv[]) { | 1761 int main(int argc, char* argv[]) { |
1758 return v8::Shell::Main(argc, argv); | 1762 return v8::Shell::Main(argc, argv); |
1759 } | 1763 } |
1760 #endif | 1764 #endif |
OLD | NEW |