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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return Shell::ReadFromStdin(isolate_); | 152 return Shell::ReadFromStdin(isolate_); |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 #ifndef V8_SHARED | 156 #ifndef V8_SHARED |
157 CounterMap* Shell::counter_map_; | 157 CounterMap* Shell::counter_map_; |
158 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; | 158 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; |
159 CounterCollection Shell::local_counters_; | 159 CounterCollection Shell::local_counters_; |
160 CounterCollection* Shell::counters_ = &local_counters_; | 160 CounterCollection* Shell::counters_ = &local_counters_; |
161 i::Mutex Shell::context_mutex_; | 161 i::Mutex Shell::context_mutex_; |
162 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); | |
163 Persistent<Context> Shell::utility_context_; | 162 Persistent<Context> Shell::utility_context_; |
164 #endif // V8_SHARED | 163 #endif // V8_SHARED |
165 | 164 |
166 Persistent<Context> Shell::evaluation_context_; | 165 Persistent<Context> Shell::evaluation_context_; |
167 ShellOptions Shell::options; | 166 ShellOptions Shell::options; |
168 const char* Shell::kPrompt = "d8> "; | 167 const char* Shell::kPrompt = "d8> "; |
169 | 168 |
170 | 169 |
171 #ifndef V8_SHARED | 170 #ifndef V8_SHARED |
172 const int MB = 1024 * 1024; | 171 const int MB = 1024 * 1024; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 280 |
282 | 281 |
283 int PerIsolateData::RealmFind(Handle<Context> context) { | 282 int PerIsolateData::RealmFind(Handle<Context> context) { |
284 for (int i = 0; i < realm_count_; ++i) { | 283 for (int i = 0; i < realm_count_; ++i) { |
285 if (realms_[i] == context) return i; | 284 if (realms_[i] == context) return i; |
286 } | 285 } |
287 return -1; | 286 return -1; |
288 } | 287 } |
289 | 288 |
290 | 289 |
291 #ifndef V8_SHARED | |
292 // performance.now() returns a time stamp as double, measured in milliseconds. | |
293 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
294 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks; | |
295 args.GetReturnValue().Set(delta.InMillisecondsF()); | |
296 } | |
297 #endif // V8_SHARED | |
298 | |
299 | |
300 // Realm.current() returns the index of the currently active realm. | 290 // Realm.current() returns the index of the currently active realm. |
301 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { | 291 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { |
302 Isolate* isolate = args.GetIsolate(); | 292 Isolate* isolate = args.GetIsolate(); |
303 PerIsolateData* data = PerIsolateData::Get(isolate); | 293 PerIsolateData* data = PerIsolateData::Get(isolate); |
304 int index = data->RealmFind(isolate->GetEnteredContext()); | 294 int index = data->RealmFind(isolate->GetEnteredContext()); |
305 if (index == -1) return; | 295 if (index == -1) return; |
306 args.GetReturnValue().Set(index); | 296 args.GetReturnValue().Set(index); |
307 } | 297 } |
308 | 298 |
309 | 299 |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 realm_template->Set(String::NewFromUtf8(isolate, "dispose"), | 879 realm_template->Set(String::NewFromUtf8(isolate, "dispose"), |
890 FunctionTemplate::New(isolate, RealmDispose)); | 880 FunctionTemplate::New(isolate, RealmDispose)); |
891 realm_template->Set(String::NewFromUtf8(isolate, "switch"), | 881 realm_template->Set(String::NewFromUtf8(isolate, "switch"), |
892 FunctionTemplate::New(isolate, RealmSwitch)); | 882 FunctionTemplate::New(isolate, RealmSwitch)); |
893 realm_template->Set(String::NewFromUtf8(isolate, "eval"), | 883 realm_template->Set(String::NewFromUtf8(isolate, "eval"), |
894 FunctionTemplate::New(isolate, RealmEval)); | 884 FunctionTemplate::New(isolate, RealmEval)); |
895 realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"), | 885 realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"), |
896 RealmSharedGet, RealmSharedSet); | 886 RealmSharedGet, RealmSharedSet); |
897 global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template); | 887 global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template); |
898 | 888 |
899 #ifndef V8_SHARED | |
900 Handle<ObjectTemplate> performance_template = ObjectTemplate::New(isolate); | |
901 performance_template->Set(String::NewFromUtf8(isolate, "now"), | |
902 FunctionTemplate::New(isolate, PerformanceNow)); | |
903 global_template->Set(String::NewFromUtf8(isolate, "performance"), | |
904 performance_template); | |
905 #endif // V8_SHARED | |
906 | |
907 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) | 889 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) |
908 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); | 890 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); |
909 AddOSMethods(isolate, os_templ); | 891 AddOSMethods(isolate, os_templ); |
910 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); | 892 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); |
911 #endif // V8_SHARED | 893 #endif // V8_SHARED |
912 | 894 |
913 return global_template; | 895 return global_template; |
914 } | 896 } |
915 | 897 |
916 | 898 |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 } | 1745 } |
1764 | 1746 |
1765 } // namespace v8 | 1747 } // namespace v8 |
1766 | 1748 |
1767 | 1749 |
1768 #ifndef GOOGLE3 | 1750 #ifndef GOOGLE3 |
1769 int main(int argc, char* argv[]) { | 1751 int main(int argc, char* argv[]) { |
1770 return v8::Shell::Main(argc, argv); | 1752 return v8::Shell::Main(argc, argv); |
1771 } | 1753 } |
1772 #endif | 1754 #endif |
OLD | NEW |