[runtime] Simplify CHECK_OBJECT_COERCIBLE.
authorbmeurer <bmeurer@chromium.org>
Wed, 12 Aug 2015 11:11:32 +0000 (04:11 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 12 Aug 2015 11:11:38 +0000 (11:11 +0000)
Don't use IS_NULL_OR_UNDEFINED() for CHECK_OBJECT_COERCIBLE() because it
will also return true for undetectable objects, but use IS_NULL() and
IS_UNDEFINED() directly, which will only return true for null or
undefined (which matches the semantics of the abstract operation
CheckObjectCoercible).

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1287033002

Cr-Commit-Position: refs/heads/master@{#30129}

src/macros.py

index 124b1e7..ee0770b 100644 (file)
@@ -136,7 +136,7 @@ macro IS_SPEC_FUNCTION(arg) = (%_ClassOf(arg) === 'Function');
 
 # Macro for ES6 CheckObjectCoercible
 # Will throw a TypeError of the form "[functionName] called on null or undefined".
-macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL_OR_UNDEFINED(arg) && !IS_UNDETECTABLE(arg)) throw MakeTypeError(kCalledOnNullOrUndefined, functionName);
+macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL(%IS_VAR(arg)) || IS_UNDEFINED(arg)) throw MakeTypeError(kCalledOnNullOrUndefined, functionName);
 
 # Indices in bound function info retrieved by %BoundFunctionGetBindings(...).
 define kBoundFunctionIndex = 0;