| OLD | NEW |
| 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 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 // Harmony egal. | 1377 // Harmony egal. |
| 1378 function ObjectIs(obj1, obj2) { | 1378 function ObjectIs(obj1, obj2) { |
| 1379 if (obj1 === obj2) { | 1379 if (obj1 === obj2) { |
| 1380 return (obj1 !== 0) || (1 / obj1 === 1 / obj2); | 1380 return (obj1 !== 0) || (1 / obj1 === 1 / obj2); |
| 1381 } else { | 1381 } else { |
| 1382 return (obj1 !== obj1) && (obj2 !== obj2); | 1382 return (obj1 !== obj1) && (obj2 !== obj2); |
| 1383 } | 1383 } |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 | 1386 |
| 1387 // ECMA-262, Edition 6, section B.2.2.1.1 | 1387 // Harmony __proto__ getter. |
| 1388 function ObjectGetProto() { | 1388 function ObjectGetProto() { |
| 1389 return %GetPrototype(ToObject(this)); | 1389 return %GetPrototype(this); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 | 1392 |
| 1393 // ECMA-262, Edition 6, section B.2.2.1.2 | 1393 // Harmony __proto__ setter. |
| 1394 function ObjectSetProto(proto) { | 1394 function ObjectSetProto(obj) { |
| 1395 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); | 1395 return %SetPrototype(this, obj); |
| 1396 | |
| 1397 if (IS_SPEC_OBJECT(proto) || IS_NULL(proto) && IS_SPEC_OBJECT(this)) { | |
| 1398 %SetPrototype(this, proto); | |
| 1399 } | |
| 1400 } | 1396 } |
| 1401 | 1397 |
| 1402 | 1398 |
| 1403 function ObjectConstructor(x) { | 1399 function ObjectConstructor(x) { |
| 1404 if (%_IsConstructCall()) { | 1400 if (%_IsConstructCall()) { |
| 1405 if (x == null) return this; | 1401 if (x == null) return this; |
| 1406 return ToObject(x); | 1402 return ToObject(x); |
| 1407 } else { | 1403 } else { |
| 1408 if (x == null) return { }; | 1404 if (x == null) return { }; |
| 1409 return ToObject(x); | 1405 return ToObject(x); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 | 1882 |
| 1887 SetUpFunction(); | 1883 SetUpFunction(); |
| 1888 | 1884 |
| 1889 | 1885 |
| 1890 //---------------------------------------------------------------------------- | 1886 //---------------------------------------------------------------------------- |
| 1891 | 1887 |
| 1892 // TODO(rossberg): very simple abstraction for generic microtask queue. | 1888 // TODO(rossberg): very simple abstraction for generic microtask queue. |
| 1893 // Eventually, we should move to a real event queue that allows to maintain | 1889 // Eventually, we should move to a real event queue that allows to maintain |
| 1894 // relative ordering of different kinds of tasks. | 1890 // relative ordering of different kinds of tasks. |
| 1895 | 1891 |
| 1896 function GetMicrotaskQueue() { | 1892 RunMicrotasks.runners = new InternalArray; |
| 1897 var microtaskState = %GetMicrotaskState(); | |
| 1898 if (IS_UNDEFINED(microtaskState.queue)) { | |
| 1899 microtaskState.queue = new InternalArray; | |
| 1900 } | |
| 1901 return microtaskState.queue; | |
| 1902 } | |
| 1903 | 1893 |
| 1904 function RunMicrotasks() { | 1894 function RunMicrotasks() { |
| 1905 while (%SetMicrotaskPending(false)) { | 1895 while (%SetMicrotaskPending(false)) { |
| 1906 var microtaskState = %GetMicrotaskState(); | 1896 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i](); |
| 1907 if (IS_UNDEFINED(microtaskState.queue)) | |
| 1908 return; | |
| 1909 | |
| 1910 var microtasks = microtaskState.queue; | |
| 1911 microtaskState.queue = new InternalArray; | |
| 1912 | |
| 1913 for (var i = 0; i < microtasks.length; i++) { | |
| 1914 microtasks[i](); | |
| 1915 } | |
| 1916 } | 1897 } |
| 1917 } | 1898 } |
| 1918 | |
| 1919 function EnqueueExternalMicrotask(fn) { | |
| 1920 GetMicrotaskQueue().push(fn); | |
| 1921 %SetMicrotaskPending(true); | |
| 1922 } | |
| OLD | NEW |