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

Side by Side Diff: Source/bindings/core/v8/V8Initializer.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 WTF::ArrayBufferContents::freeMemory(data, size); 235 WTF::ArrayBufferContents::freeMemory(data, size);
236 } 236 }
237 }; 237 };
238 238
239 } // namespace 239 } // namespace
240 240
241 typedef Deque<PromiseRejectMessage> PromiseRejectMessageQueue; 241 typedef Deque<PromiseRejectMessage> PromiseRejectMessageQueue;
242 242
243 static PromiseRejectMessageQueue& promiseRejectMessageQueue() 243 static PromiseRejectMessageQueue& promiseRejectMessageQueue()
244 { 244 {
245 AtomicallyInitializedStatic(ThreadSpecific<PromiseRejectMessageQueue>*, queu e = new ThreadSpecific<PromiseRejectMessageQueue>); 245 AtomicallyInitializedStaticReference(ThreadSpecific<PromiseRejectMessageQueu e>, queue, new ThreadSpecific<PromiseRejectMessageQueue>);
246 return **queue; 246 return *queue;
247 } 247 }
248 248
249 void V8Initializer::reportRejectedPromises() 249 void V8Initializer::reportRejectedPromises()
250 { 250 {
251 PromiseRejectMessageQueue& queue = promiseRejectMessageQueue(); 251 PromiseRejectMessageQueue& queue = promiseRejectMessageQueue();
252 while (!queue.isEmpty()) { 252 while (!queue.isEmpty()) {
253 PromiseRejectMessage message = queue.takeFirst(); 253 PromiseRejectMessage message = queue.takeFirst();
254 ScriptState* scriptState = message.m_promise.scriptState(); 254 ScriptState* scriptState = message.m_promise.scriptState();
255 if (!scriptState->contextIsValid()) 255 if (!scriptState->contextIsValid())
256 continue; 256 continue;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 536
537 v8::V8::AddMessageListener(messageHandlerInWorker); 537 v8::V8::AddMessageListener(messageHandlerInWorker);
538 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); 538 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
539 539
540 uint32_t here; 540 uint32_t here;
541 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 541 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
542 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 542 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
543 } 543 }
544 544
545 } // namespace blink 545 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698