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

Side by Side Diff: Source/bindings/core/v8/ScriptProfiler.cpp

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011, Google Inc. All rights reserved. 2 * Copyright (c) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 #if ENABLE(ASSERT) 298 #if ENABLE(ASSERT)
299 v8::Isolate* m_isolate; 299 v8::Isolate* m_isolate;
300 #endif 300 #endif
301 } wrapperVisitor(visitor, isolate); 301 } wrapperVisitor(visitor, isolate);
302 302
303 v8::V8::VisitHandlesWithClassIds(isolate, &wrapperVisitor); 303 v8::V8::VisitHandlesWithClassIds(isolate, &wrapperVisitor);
304 } 304 }
305 305
306 ProfileNameIdleTimeMap* ScriptProfiler::currentProfileNameIdleTimeMap() 306 ProfileNameIdleTimeMap* ScriptProfiler::currentProfileNameIdleTimeMap()
307 { 307 {
308 AtomicallyInitializedStatic(WTF::ThreadSpecific<ProfileNameIdleTimeMap>*, ma p = new WTF::ThreadSpecific<ProfileNameIdleTimeMap>); 308 AtomicallyInitializedStaticReference(WTF::ThreadSpecific<ProfileNameIdleTime Map>, map, new WTF::ThreadSpecific<ProfileNameIdleTimeMap>);
309 return *map; 309 return map;
310 } 310 }
311 311
312 void ScriptProfiler::setIdle(bool isIdle) 312 void ScriptProfiler::setIdle(bool isIdle)
313 { 313 {
314 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 314 v8::Isolate* isolate = v8::Isolate::GetCurrent();
315 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) 315 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler())
316 profiler->SetIdle(isIdle); 316 profiler->SetIdle(isIdle);
317 } 317 }
318 318
319 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698