Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index 5f870c8208f7c2add547a7d5ab378e11498958e8..713227de9c904998bf3d158246dda37ba7bb7ba5 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -26,7 +26,6 @@ |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| // This file relies on the fact that the following declarations have been made |
| -// |
| // in runtime.js: |
| // var $Object = global.Object; |
| // var $Boolean = global.Boolean; |
| @@ -43,7 +42,6 @@ var $isFinite = GlobalIsFinite; |
| // ---------------------------------------------------------------------------- |
| - |
| // Helper function used to install functions on objects. |
| function InstallFunctions(object, attributes, functions) { |
| if (functions.length >= 8) { |
| @@ -198,6 +196,7 @@ function GlobalEval(x) { |
| // Set up global object. |
| function SetUpGlobal() { |
| %CheckIsBootstrapping(); |
| + |
| // ECMA 262 - 15.1.1.1. |
| %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| @@ -220,27 +219,22 @@ function SetUpGlobal() { |
| SetUpGlobal(); |
| + |
| // ---------------------------------------------------------------------------- |
| // Boolean (first part of definition) |
| - |
| -%SetCode($Boolean, function(x) { |
| +function BooleanConstructor(x) { |
|
rossberg
2013/04/11 12:00:18
Move this to the rest of the Boolean stuff.
Michael Starzinger
2013/04/11 12:08:44
Done.
|
| if (%_IsConstructCall()) { |
| %_SetValueOf(this, ToBoolean(x)); |
| } else { |
| return ToBoolean(x); |
| } |
| -}); |
| - |
| -%FunctionSetPrototype($Boolean, new $Boolean(false)); |
| +} |
| -%SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); |
| // ---------------------------------------------------------------------------- |
| // Object |
| -$Object.prototype.constructor = $Object; |
| - |
| // ECMA-262 - 15.2.4.2 |
| function ObjectToString() { |
| if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; |
| @@ -1357,7 +1351,7 @@ function ObjectPoisonProto(obj) { |
| } |
| -%SetCode($Object, function(x) { |
| +function ObjectConstructor(x) { |
| if (%_IsConstructCall()) { |
| if (x == null) return this; |
| return ToObject(x); |
| @@ -1365,7 +1359,7 @@ function ObjectPoisonProto(obj) { |
| if (x == null) return { }; |
| return ToObject(x); |
| } |
| -}); |
| +} |
| // ---------------------------------------------------------------------------- |
| @@ -1374,6 +1368,8 @@ function ObjectPoisonProto(obj) { |
| function SetUpObject() { |
| %CheckIsBootstrapping(); |
| + $Object.prototype.constructor = $Object; |
| + %SetCode($Object, ObjectConstructor); |
| %FunctionSetName(ObjectPoisonProto, "__proto__"); |
| %FunctionRemovePrototype(ObjectPoisonProto); |
| %SetExpectedNumberOfProperties($Object, 4); |
| @@ -1415,6 +1411,7 @@ function SetUpObject() { |
| SetUpObject(); |
| + |
| // ---------------------------------------------------------------------------- |
| // Boolean |
| @@ -1444,9 +1441,13 @@ function BooleanValueOf() { |
| // ---------------------------------------------------------------------------- |
| - |
| function SetUpBoolean () { |
| %CheckIsBootstrapping(); |
| + |
| + %SetCode($Boolean, BooleanConstructor); |
| + %FunctionSetPrototype($Boolean, new $Boolean(false)); |
| + %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); |
| + |
| InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( |
| "toString", BooleanToString, |
| "valueOf", BooleanValueOf |
| @@ -1459,17 +1460,15 @@ SetUpBoolean(); |
| // ---------------------------------------------------------------------------- |
| // Number |
| -// Set the Number function and constructor. |
| -%SetCode($Number, function(x) { |
| +function NumberConstructor(x) { |
| var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); |
| if (%_IsConstructCall()) { |
| %_SetValueOf(this, value); |
| } else { |
| return value; |
| } |
| -}); |
| +} |
| -%FunctionSetPrototype($Number, new $Number(0)); |
| // ECMA-262 section 15.7.4.2. |
| function NumberToString(radix) { |
| @@ -1607,6 +1606,11 @@ function NumberIsNaN(number) { |
| function SetUpNumber() { |
| %CheckIsBootstrapping(); |
| + |
| + // Set the Number function and constructor. |
|
rossberg
2013/04/11 12:00:18
Nit: remove this comment
Michael Starzinger
2013/04/11 12:08:44
Done.
|
| + %SetCode($Number, NumberConstructor); |
| + %FunctionSetPrototype($Number, new $Number(0)); |
| + |
| %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); |
| // Set up the constructor property on the Number prototype object. |
| %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); |
| @@ -1659,8 +1663,6 @@ SetUpNumber(); |
| // ---------------------------------------------------------------------------- |
| // Function |
| -$Function.prototype.constructor = $Function; |
| - |
| function FunctionSourceString(func) { |
| while (%IsJSFunctionProxy(func)) { |
| func = %GetCallTrap(func); |
| @@ -1784,12 +1786,15 @@ function NewFunction(arg1) { // length == 1 |
| return %SetNewFunctionAttributes(f); |
| } |
| -%SetCode($Function, NewFunction); |
| // ---------------------------------------------------------------------------- |
| function SetUpFunction() { |
| %CheckIsBootstrapping(); |
| + |
| + $Function.prototype.constructor = $Function; |
| + %SetCode($Function, NewFunction); |
| + |
| InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| "bind", FunctionBind, |
| "toString", FunctionToString |