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

Side by Side Diff: src/d8.cc

Issue 133523003: Revert "Temporarily disable performance.now() in the d8 shell." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
162 Persistent<Context> Shell::utility_context_; 163 Persistent<Context> Shell::utility_context_;
163 #endif // V8_SHARED 164 #endif // V8_SHARED
164 165
165 Persistent<Context> Shell::evaluation_context_; 166 Persistent<Context> Shell::evaluation_context_;
166 ShellOptions Shell::options; 167 ShellOptions Shell::options;
167 const char* Shell::kPrompt = "d8> "; 168 const char* Shell::kPrompt = "d8> ";
168 169
169 170
170 #ifndef V8_SHARED 171 #ifndef V8_SHARED
171 const int MB = 1024 * 1024; 172 const int MB = 1024 * 1024;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 281
281 282
282 int PerIsolateData::RealmFind(Handle<Context> context) { 283 int PerIsolateData::RealmFind(Handle<Context> context) {
283 for (int i = 0; i < realm_count_; ++i) { 284 for (int i = 0; i < realm_count_; ++i) {
284 if (realms_[i] == context) return i; 285 if (realms_[i] == context) return i;
285 } 286 }
286 return -1; 287 return -1;
287 } 288 }
288 289
289 290
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
290 // Realm.current() returns the index of the currently active realm. 300 // Realm.current() returns the index of the currently active realm.
291 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { 301 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) {
292 Isolate* isolate = args.GetIsolate(); 302 Isolate* isolate = args.GetIsolate();
293 PerIsolateData* data = PerIsolateData::Get(isolate); 303 PerIsolateData* data = PerIsolateData::Get(isolate);
294 int index = data->RealmFind(isolate->GetEnteredContext()); 304 int index = data->RealmFind(isolate->GetEnteredContext());
295 if (index == -1) return; 305 if (index == -1) return;
296 args.GetReturnValue().Set(index); 306 args.GetReturnValue().Set(index);
297 } 307 }
298 308
299 309
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 realm_template->Set(String::NewFromUtf8(isolate, "dispose"), 889 realm_template->Set(String::NewFromUtf8(isolate, "dispose"),
880 FunctionTemplate::New(isolate, RealmDispose)); 890 FunctionTemplate::New(isolate, RealmDispose));
881 realm_template->Set(String::NewFromUtf8(isolate, "switch"), 891 realm_template->Set(String::NewFromUtf8(isolate, "switch"),
882 FunctionTemplate::New(isolate, RealmSwitch)); 892 FunctionTemplate::New(isolate, RealmSwitch));
883 realm_template->Set(String::NewFromUtf8(isolate, "eval"), 893 realm_template->Set(String::NewFromUtf8(isolate, "eval"),
884 FunctionTemplate::New(isolate, RealmEval)); 894 FunctionTemplate::New(isolate, RealmEval));
885 realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"), 895 realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"),
886 RealmSharedGet, RealmSharedSet); 896 RealmSharedGet, RealmSharedSet);
887 global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template); 897 global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template);
888 898
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
889 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) 907 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
890 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); 908 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
891 AddOSMethods(isolate, os_templ); 909 AddOSMethods(isolate, os_templ);
892 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); 910 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ);
893 #endif // V8_SHARED 911 #endif // V8_SHARED
894 912
895 return global_template; 913 return global_template;
896 } 914 }
897 915
898 916
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 } 1763 }
1746 1764
1747 } // namespace v8 1765 } // namespace v8
1748 1766
1749 1767
1750 #ifndef GOOGLE3 1768 #ifndef GOOGLE3
1751 int main(int argc, char* argv[]) { 1769 int main(int argc, char* argv[]) {
1752 return v8::Shell::Main(argc, argv); 1770 return v8::Shell::Main(argc, argv);
1753 } 1771 }
1754 #endif 1772 #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