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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/d8-performance-now.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 25771eed9ba5c28d88d07acace71c1481aa33e9f..1560b09a2b5b77cda7b6592b07be6aa865503f46 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -159,6 +159,7 @@ i::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
CounterCollection Shell::local_counters_;
CounterCollection* Shell::counters_ = &local_counters_;
i::Mutex Shell::context_mutex_;
+const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow();
Persistent<Context> Shell::utility_context_;
#endif // V8_SHARED
@@ -287,6 +288,15 @@ int PerIsolateData::RealmFind(Handle<Context> context) {
}
+#ifndef V8_SHARED
+// performance.now() returns a time stamp as double, measured in milliseconds.
+void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks;
+ args.GetReturnValue().Set(delta.InMillisecondsF());
+}
+#endif // V8_SHARED
+
+
// Realm.current() returns the index of the currently active realm.
void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
@@ -886,6 +896,14 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
RealmSharedGet, RealmSharedSet);
global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template);
+#ifndef V8_SHARED
+ Handle<ObjectTemplate> performance_template = ObjectTemplate::New(isolate);
+ performance_template->Set(String::NewFromUtf8(isolate, "now"),
+ FunctionTemplate::New(isolate, PerformanceNow));
+ global_template->Set(String::NewFromUtf8(isolate, "performance"),
+ performance_template);
+#endif // V8_SHARED
+
#if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
AddOSMethods(isolate, os_templ);
« 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