| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 28 matching lines...) Expand all Loading... |
| 39 // const $floor = MathFloor | 39 // const $floor = MathFloor |
| 40 | 40 |
| 41 const $isNaN = GlobalIsNaN; | 41 const $isNaN = GlobalIsNaN; |
| 42 const $isFinite = GlobalIsFinite; | 42 const $isFinite = GlobalIsFinite; |
| 43 | 43 |
| 44 // ---------------------------------------------------------------------------- | 44 // ---------------------------------------------------------------------------- |
| 45 | 45 |
| 46 | 46 |
| 47 // Helper function used to install functions on objects. | 47 // Helper function used to install functions on objects. |
| 48 function InstallFunctions(object, attributes, functions) { | 48 function InstallFunctions(object, attributes, functions) { |
| 49 if (functions.length >= 8) { |
| 50 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); |
| 51 } |
| 49 for (var i = 0; i < functions.length; i += 2) { | 52 for (var i = 0; i < functions.length; i += 2) { |
| 50 var key = functions[i]; | 53 var key = functions[i]; |
| 51 var f = functions[i + 1]; | 54 var f = functions[i + 1]; |
| 52 %FunctionSetName(f, key); | 55 %FunctionSetName(f, key); |
| 53 %SetProperty(object, key, f, attributes); | 56 %SetProperty(object, key, f, attributes); |
| 54 } | 57 } |
| 58 %TransformToFastProperties(object); |
| 55 } | 59 } |
| 56 | 60 |
| 57 // Emulates JSC by installing functions on a hidden prototype that | 61 // Emulates JSC by installing functions on a hidden prototype that |
| 58 // lies above the current object/prototype. This lets you override | 62 // lies above the current object/prototype. This lets you override |
| 59 // functions on String.prototype etc. and then restore the old function | 63 // functions on String.prototype etc. and then restore the old function |
| 60 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 | 64 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 |
| 61 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { | 65 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { |
| 62 var hidden_prototype = new $Object(); | 66 var hidden_prototype = new $Object(); |
| 63 %SetHiddenPrototype(object, hidden_prototype); | 67 %SetHiddenPrototype(object, hidden_prototype); |
| 64 InstallFunctions(hidden_prototype, attributes, functions); | 68 InstallFunctions(hidden_prototype, attributes, functions); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 451 |
| 448 function NumberToJSON(key) { | 452 function NumberToJSON(key) { |
| 449 return CheckJSONPrimitive(this.valueOf()); | 453 return CheckJSONPrimitive(this.valueOf()); |
| 450 } | 454 } |
| 451 | 455 |
| 452 | 456 |
| 453 // ---------------------------------------------------------------------------- | 457 // ---------------------------------------------------------------------------- |
| 454 | 458 |
| 455 function SetupNumber() { | 459 function SetupNumber() { |
| 456 // Setup the constructor property on the Number prototype object. | 460 // Setup the constructor property on the Number prototype object. |
| 461 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); |
| 457 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); | 462 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); |
| 458 | 463 |
| 464 %OptimizeObjectForAddingMultipleProperties($Number, 5); |
| 459 // ECMA-262 section 15.7.3.1. | 465 // ECMA-262 section 15.7.3.1. |
| 460 %SetProperty($Number, | 466 %SetProperty($Number, |
| 461 "MAX_VALUE", | 467 "MAX_VALUE", |
| 462 1.7976931348623157e+308, | 468 1.7976931348623157e+308, |
| 463 DONT_ENUM | DONT_DELETE | READ_ONLY); | 469 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 464 | 470 |
| 465 // ECMA-262 section 15.7.3.2. | 471 // ECMA-262 section 15.7.3.2. |
| 466 %SetProperty($Number, "MIN_VALUE", 5e-324, DONT_ENUM | DONT_DELETE | READ_ONLY
); | 472 %SetProperty($Number, "MIN_VALUE", 5e-324, DONT_ENUM | DONT_DELETE | READ_ONLY
); |
| 467 | 473 |
| 468 // ECMA-262 section 15.7.3.3. | 474 // ECMA-262 section 15.7.3.3. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 568 |
| 563 // ---------------------------------------------------------------------------- | 569 // ---------------------------------------------------------------------------- |
| 564 | 570 |
| 565 function SetupFunction() { | 571 function SetupFunction() { |
| 566 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 572 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 567 "toString", FunctionToString | 573 "toString", FunctionToString |
| 568 )); | 574 )); |
| 569 } | 575 } |
| 570 | 576 |
| 571 SetupFunction(); | 577 SetupFunction(); |
| OLD | NEW |