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

Side by Side Diff: src/d8.cc

Issue 38753006: Revert "Add window.performance.now() to the d8 shell." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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/d8.h ('k') | test/mjsunit/d8-performance-now.js » ('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 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Persistent<Context> Shell::utility_context_; 163 Persistent<Context> Shell::utility_context_;
164 #endif // V8_SHARED 164 #endif // V8_SHARED
165 165
166 Persistent<Context> Shell::evaluation_context_; 166 Persistent<Context> Shell::evaluation_context_;
167 ShellOptions Shell::options; 167 ShellOptions Shell::options;
168 const char* Shell::kPrompt = "d8> "; 168 const char* Shell::kPrompt = "d8> ";
169 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow();
170 169
171 170
172 const int MB = 1024 * 1024; 171 const int MB = 1024 * 1024;
173 172
174 173
175 #ifndef V8_SHARED 174 #ifndef V8_SHARED
176 bool CounterMap::Match(void* key1, void* key2) { 175 bool CounterMap::Match(void* key1, void* key2) {
177 const char* name1 = reinterpret_cast<const char*>(key1); 176 const char* name1 = reinterpret_cast<const char*>(key1);
178 const char* name2 = reinterpret_cast<const char*>(key2); 177 const char* name2 = reinterpret_cast<const char*>(key2);
179 return strcmp(name1, name2) == 0; 178 return strcmp(name1, name2) == 0;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // window.performance.now() returns a time stamp as double, measured in
294 // milliseconds.
295 void Shell::WindowPerformanceNow(
296 const v8::FunctionCallbackInfo<v8::Value>& args) {
297 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks;
298 args.GetReturnValue().Set(delta.InMillisecondsF());
299 }
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
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 Handle<ObjectTemplate> window_template = ObjectTemplate::New();
886 Handle<ObjectTemplate> performance_template = ObjectTemplate::New();
887 performance_template->Set(String::New("now"),
888 FunctionTemplate::New(WindowPerformanceNow));
889 window_template->Set(String::New("performance"), performance_template);
890 global_template->Set(String::New("window"), window_template);
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
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
OLDNEW
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/d8-performance-now.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698