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(); | |
164 Persistent<Context> Shell::utility_context_; | 163 Persistent<Context> Shell::utility_context_; |
165 #endif // V8_SHARED | 164 #endif // V8_SHARED |
166 | 165 |
167 Persistent<Context> Shell::evaluation_context_; | 166 Persistent<Context> Shell::evaluation_context_; |
168 ShellOptions Shell::options; | 167 ShellOptions Shell::options; |
169 const char* Shell::kPrompt = "d8> "; | 168 const char* Shell::kPrompt = "d8> "; |
170 | 169 |
171 | 170 |
172 const int MB = 1024 * 1024; | 171 const int MB = 1024 * 1024; |
173 | 172 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 282 |
284 | 283 |
285 int PerIsolateData::RealmFind(Handle<Context> context) { | 284 int PerIsolateData::RealmFind(Handle<Context> context) { |
286 for (int i = 0; i < realm_count_; ++i) { | 285 for (int i = 0; i < realm_count_; ++i) { |
287 if (realms_[i] == context) return i; | 286 if (realms_[i] == context) return i; |
288 } | 287 } |
289 return -1; | 288 return -1; |
290 } | 289 } |
291 | 290 |
292 | 291 |
293 #ifndef V8_SHARED | |
294 // performance.now() returns a time stamp as double, measured in milliseconds. | |
295 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
296 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks; | |
297 args.GetReturnValue().Set(delta.InMillisecondsF()); | |
298 } | |
299 #endif // V8_SHARED | |
300 | |
301 | |
302 // Realm.current() returns the index of the currently active realm. | 292 // Realm.current() returns the index of the currently active realm. |
303 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { | 293 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { |
304 Isolate* isolate = args.GetIsolate(); | 294 Isolate* isolate = args.GetIsolate(); |
305 PerIsolateData* data = PerIsolateData::Get(isolate); | 295 PerIsolateData* data = PerIsolateData::Get(isolate); |
306 int index = data->RealmFind(isolate->GetEnteredContext()); | 296 int index = data->RealmFind(isolate->GetEnteredContext()); |
307 if (index == -1) return; | 297 if (index == -1) return; |
308 args.GetReturnValue().Set(index); | 298 args.GetReturnValue().Set(index); |
309 } | 299 } |
310 | 300 |
311 | 301 |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 realm_template->Set(String::New("dispose"), | 865 realm_template->Set(String::New("dispose"), |
876 FunctionTemplate::New(RealmDispose)); | 866 FunctionTemplate::New(RealmDispose)); |
877 realm_template->Set(String::New("switch"), | 867 realm_template->Set(String::New("switch"), |
878 FunctionTemplate::New(RealmSwitch)); | 868 FunctionTemplate::New(RealmSwitch)); |
879 realm_template->Set(String::New("eval"), | 869 realm_template->Set(String::New("eval"), |
880 FunctionTemplate::New(RealmEval)); | 870 FunctionTemplate::New(RealmEval)); |
881 realm_template->SetAccessor(String::New("shared"), | 871 realm_template->SetAccessor(String::New("shared"), |
882 RealmSharedGet, RealmSharedSet); | 872 RealmSharedGet, RealmSharedSet); |
883 global_template->Set(String::New("Realm"), realm_template); | 873 global_template->Set(String::New("Realm"), realm_template); |
884 | 874 |
885 #ifndef V8_SHARED | |
886 Handle<ObjectTemplate> performance_template = ObjectTemplate::New(); | |
887 performance_template->Set(String::New("now"), | |
888 FunctionTemplate::New(PerformanceNow)); | |
889 global_template->Set(String::New("performance"), performance_template); | |
890 #endif // V8_SHARED | |
891 | |
892 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) | 875 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) |
893 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); | 876 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); |
894 AddOSMethods(os_templ); | 877 AddOSMethods(os_templ); |
895 global_template->Set(String::New("os"), os_templ); | 878 global_template->Set(String::New("os"), os_templ); |
896 #endif // V8_SHARED | 879 #endif // V8_SHARED |
897 | 880 |
898 return global_template; | 881 return global_template; |
899 } | 882 } |
900 | 883 |
901 | 884 |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 } | 1738 } |
1756 | 1739 |
1757 } // namespace v8 | 1740 } // namespace v8 |
1758 | 1741 |
1759 | 1742 |
1760 #ifndef GOOGLE3 | 1743 #ifndef GOOGLE3 |
1761 int main(int argc, char* argv[]) { | 1744 int main(int argc, char* argv[]) { |
1762 return v8::Shell::Main(argc, argv); | 1745 return v8::Shell::Main(argc, argv); |
1763 } | 1746 } |
1764 #endif | 1747 #endif |
OLD | NEW |