diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-09-15 09:41:08 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-09-15 09:42:06 -0700 |
commit | 1b15af9dd2bf4adb7a2e73ae17a12e2e98a88f72 (patch) | |
tree | feede6d06b8c99b92e29a9fdcf0e9ade05b981d0 /deps/v8/src/v8natives.js | |
parent | f8b90946aec53b453d82dd66a4d812ec86487629 (diff) | |
download | node-1b15af9dd2bf4adb7a2e73ae17a12e2e98a88f72.tar.gz |
Upgrade V8 to 3.6.4
Diffstat (limited to 'deps/v8/src/v8natives.js')
-rw-r--r-- | deps/v8/src/v8natives.js | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/deps/v8/src/v8natives.js b/deps/v8/src/v8natives.js index 1616ac366..588bdb21b 100644 --- a/deps/v8/src/v8natives.js +++ b/deps/v8/src/v8natives.js @@ -298,7 +298,7 @@ function ObjectDefineGetter(name, fun) { if (receiver == null && !IS_UNDETECTABLE(receiver)) { receiver = %GlobalReceiver(global); } - if (!IS_FUNCTION(fun)) { + if (!IS_SPEC_FUNCTION(fun)) { throw new $TypeError('Object.prototype.__defineGetter__: Expecting function'); } var desc = new PropertyDescriptor(); @@ -323,7 +323,7 @@ function ObjectDefineSetter(name, fun) { if (receiver == null && !IS_UNDETECTABLE(receiver)) { receiver = %GlobalReceiver(global); } - if (!IS_FUNCTION(fun)) { + if (!IS_SPEC_FUNCTION(fun)) { throw new $TypeError( 'Object.prototype.__defineSetter__: Expecting function'); } @@ -453,7 +453,7 @@ function ToPropertyDescriptor(obj) { if ("get" in obj) { var get = obj.get; - if (!IS_UNDEFINED(get) && !IS_FUNCTION(get)) { + if (!IS_UNDEFINED(get) && !IS_SPEC_FUNCTION(get)) { throw MakeTypeError("getter_must_be_callable", [get]); } desc.setGet(get); @@ -461,7 +461,7 @@ function ToPropertyDescriptor(obj) { if ("set" in obj) { var set = obj.set; - if (!IS_UNDEFINED(set) && !IS_FUNCTION(set)) { + if (!IS_UNDEFINED(set) && !IS_SPEC_FUNCTION(set)) { throw MakeTypeError("setter_must_be_callable", [set]); } desc.setSet(set); @@ -623,7 +623,7 @@ function GetTrap(handler, name, defaultTrap) { throw MakeTypeError("handler_trap_missing", [handler, name]); } trap = defaultTrap; - } else if (!IS_FUNCTION(trap)) { + } else if (!IS_SPEC_FUNCTION(trap)) { throw MakeTypeError("handler_trap_must_be_callable", [handler, name]); } return trap; @@ -977,7 +977,7 @@ function ObjectDefineProperty(obj, p, attributes) { // Clone the attributes object for protection. // TODO(rossberg): not spec'ed yet, so not sure if this should involve // non-own properties as it does (or non-enumerable ones, as it doesn't?). - var attributesClone = {} + var attributesClone = {}; for (var a in attributes) { attributesClone[a] = attributes[a]; } @@ -1041,7 +1041,16 @@ function ProxyFix(obj) { if (IS_UNDEFINED(props)) { throw MakeTypeError("handler_returned_undefined", [handler, "fix"]); } - %Fix(obj); + + if (IS_SPEC_FUNCTION(obj)) { + var callTrap = %GetCallTrap(obj); + var constructTrap = %GetConstructTrap(obj); + var code = DelegateCallAndConstruct(callTrap, constructTrap); + %Fix(obj); // becomes a regular function + %SetCode(obj, code); + } else { + %Fix(obj); + } ObjectDefineProperties(obj, props); } @@ -1412,6 +1421,10 @@ SetUpNumber(); $Function.prototype.constructor = $Function; function FunctionSourceString(func) { + while (%IsJSFunctionProxy(func)) { + func = %GetCallTrap(func); + } + if (!IS_FUNCTION(func)) { throw new $TypeError('Function.prototype.toString is not generic'); } @@ -1441,12 +1454,13 @@ function FunctionToString() { // ES5 15.3.4.5 function FunctionBind(this_arg) { // Length is 1. - if (!IS_FUNCTION(this)) { + if (!IS_SPEC_FUNCTION(this)) { throw new $TypeError('Bind must be called on a function'); } // this_arg is not an argument that should be bound. var argc_bound = (%_ArgumentsLength() || 1) - 1; var fn = this; + if (argc_bound == 0) { var result = function() { if (%_IsConstructCall()) { @@ -1455,8 +1469,7 @@ function FunctionBind(this_arg) { // Length is 1. // materializing it and guarantee that this function will be optimized. return %NewObjectFromBound(fn, null); } - - return fn.apply(this_arg, arguments); + return %Apply(fn, this_arg, arguments, 0, %_ArgumentsLength()); }; } else { var bound_args = new InternalArray(argc_bound); @@ -1486,7 +1499,7 @@ function FunctionBind(this_arg) { // Length is 1. for (var i = 0; i < argc; i++) { args[argc_bound + i] = %_Arguments(i); } - return fn.apply(this_arg, args); + return %Apply(fn, this_arg, args, 0, argc + argc_bound); }; } @@ -1497,11 +1510,16 @@ function FunctionBind(this_arg) { // Length is 1. // is called and make them non-enumerable and non-configurable. // To be consistent with our normal functions we leave this as it is. - // Set the correct length. - var length = (this.length - argc_bound) > 0 ? this.length - argc_bound : 0; %FunctionRemovePrototype(result); %FunctionSetBound(result); - %BoundFunctionSetLength(result, length); + // Set the correct length. If this is a function proxy, this.length might + // throw, or return a bogus result. Leave length alone in that case. + // TODO(rossberg): This is underspecified in the current proxy proposal. + try { + var old_length = ToInteger(this.length); + var length = (old_length - argc_bound) > 0 ? old_length - argc_bound : 0; + %BoundFunctionSetLength(result, length); + } catch(x) {} return result; } |