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

Side by Side Diff: src/promise.js

Issue 250883002: Fix |RunMicrotasks()| leaking reference to the last context being run on. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: remove external_ Created 6 years, 7 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
« no previous file with comments | « src/object-observe.js ('k') | src/v8natives.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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 break; 166 break;
167 } 167 }
168 return deferred.promise; 168 return deferred.promise;
169 } 169 }
170 170
171 function PromiseCatch(onReject) { 171 function PromiseCatch(onReject) {
172 return this.then(UNDEFINED, onReject); 172 return this.then(UNDEFINED, onReject);
173 } 173 }
174 174
175 function PromiseEnqueue(value, tasks) { 175 function PromiseEnqueue(value, tasks) {
176 GetMicrotaskQueue().push(function() { 176 EnqueueMicrotask(function() {
177 for (var i = 0; i < tasks.length; i += 2) { 177 for (var i = 0; i < tasks.length; i += 2) {
178 PromiseHandle(value, tasks[i], tasks[i + 1]) 178 PromiseHandle(value, tasks[i], tasks[i + 1])
179 } 179 }
180 }); 180 });
181
182 %SetMicrotaskPending(true);
183 } 181 }
184 182
185 function PromiseHandle(value, handler, deferred) { 183 function PromiseHandle(value, handler, deferred) {
186 try { 184 try {
187 var result = handler(value); 185 var result = handler(value);
188 if (result === deferred.promise) 186 if (result === deferred.promise)
189 throw MakeTypeError('promise_cyclic', [result]); 187 throw MakeTypeError('promise_cyclic', [result]);
190 else if (IsPromise(result)) 188 else if (IsPromise(result))
191 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain); 189 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain);
192 else 190 else
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 "resolve", PromiseCast 316 "resolve", PromiseCast
319 ]); 317 ]);
320 InstallFunctions($Promise.prototype, DONT_ENUM, [ 318 InstallFunctions($Promise.prototype, DONT_ENUM, [
321 "chain", PromiseChain, 319 "chain", PromiseChain,
322 "then", PromiseThen, 320 "then", PromiseThen,
323 "catch", PromiseCatch 321 "catch", PromiseCatch
324 ]); 322 ]);
325 } 323 }
326 324
327 SetUpPromise(); 325 SetUpPromise();
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698