Commit 5b5391b8 authored by jgruber's avatar jgruber Committed by Commit Bot

[builtins] Clean out macros.py

Remove unused macros, and move macro definitions used only in a single
file into the file itself.

Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: If62107816ad1e6addf58705a075d3eba4f23bf08
Reviewed-on: https://chromium-review.googlesource.com/721381Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48625}
parent 6148cbfa
...@@ -45,6 +45,45 @@ var SetValues = global.Set.prototype.values; ...@@ -45,6 +45,45 @@ var SetValues = global.Set.prototype.values;
// - ScriptMirror // - ScriptMirror
// - ScopeMirror // - ScopeMirror
macro IS_BOOLEAN(arg)
(typeof(arg) === 'boolean')
endmacro
macro IS_DATE(arg)
(%IsDate(arg))
endmacro
macro IS_ERROR(arg)
(%_ClassOf(arg) === 'Error')
endmacro
macro IS_GENERATOR(arg)
(%_ClassOf(arg) === 'Generator')
endmacro
macro IS_MAP(arg)
(%_IsJSMap(arg))
endmacro
macro IS_MAP_ITERATOR(arg)
(%_ClassOf(arg) === 'Map Iterator')
endmacro
macro IS_SCRIPT(arg)
(%_ClassOf(arg) === 'Script')
endmacro
macro IS_SET(arg)
(%_IsJSSet(arg))
endmacro
macro IS_SET_ITERATOR(arg)
(%_ClassOf(arg) === 'Set Iterator')
endmacro
// Must match PropertyFilter in property-details.h
define PROPERTY_FILTER_NONE = 0;
// Type names of the different mirrors. // Type names of the different mirrors.
var MirrorType = { var MirrorType = {
UNDEFINED_TYPE : 'undefined', UNDEFINED_TYPE : 'undefined',
......
...@@ -29,6 +29,13 @@ utils.Import(function(from) { ...@@ -29,6 +29,13 @@ utils.Import(function(from) {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
macro IS_PROXY(arg)
(%_IsJSProxy(arg))
endmacro
macro INVERT_NEG_ZERO(arg)
((arg) + 0)
endmacro
function ArraySpeciesCreate(array, length) { function ArraySpeciesCreate(array, length) {
length = INVERT_NEG_ZERO(length); length = INVERT_NEG_ZERO(length);
......
...@@ -46,6 +46,24 @@ utils.Import(function(from) { ...@@ -46,6 +46,24 @@ utils.Import(function(from) {
// Utilities for definitions // Utilities for definitions
macro IS_OBJECT(arg)
(typeof(arg) === 'object')
endmacro
macro NUMBER_IS_NAN(arg)
(%IS_VAR(arg) !== arg)
endmacro
macro NUMBER_IS_FINITE(arg)
(%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0)))
endmacro
// To avoid ES2015 Function name inference.
macro ANONYMOUS_FUNCTION(fn)
(0, (fn))
endmacro
/** /**
* Adds bound method to the prototype of the given object. * Adds bound method to the prototype of the given object.
*/ */
......
...@@ -45,26 +45,12 @@ define kMaxUint32 = 4294967295; ...@@ -45,26 +45,12 @@ define kMaxUint32 = 4294967295;
# It will *not* generate a runtime typeof call for the most important # It will *not* generate a runtime typeof call for the most important
# values of 'bar'. # values of 'bar'.
macro IS_ARRAY(arg) = (%_IsArray(arg)); macro IS_ARRAY(arg) = (%_IsArray(arg));
macro IS_ARRAYBUFFER(arg) = (%_ClassOf(arg) === 'ArrayBuffer');
macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean');
macro IS_DATE(arg) = (%IsDate(arg));
macro IS_ERROR(arg) = (%_ClassOf(arg) === 'Error');
macro IS_FUNCTION(arg) = (%IsFunction(arg)); macro IS_FUNCTION(arg) = (%IsFunction(arg));
macro IS_GENERATOR(arg) = (%_ClassOf(arg) === 'Generator');
macro IS_MAP(arg) = (%_IsJSMap(arg));
macro IS_MAP_ITERATOR(arg) = (%_ClassOf(arg) === 'Map Iterator');
macro IS_NULL(arg) = (arg === null); macro IS_NULL(arg) = (arg === null);
macro IS_NULL_OR_UNDEFINED(arg) = (arg == null); macro IS_NULL_OR_UNDEFINED(arg) = (arg == null);
macro IS_NUMBER(arg) = (typeof(arg) === 'number'); macro IS_NUMBER(arg) = (typeof(arg) === 'number');
macro IS_OBJECT(arg) = (typeof(arg) === 'object');
macro IS_PROXY(arg) = (%_IsJSProxy(arg));
macro IS_SCRIPT(arg) = (%_ClassOf(arg) === 'Script');
macro IS_SET(arg) = (%_IsJSSet(arg));
macro IS_SET_ITERATOR(arg) = (%_ClassOf(arg) === 'Set Iterator');
macro IS_SHAREDARRAYBUFFER(arg) = (%_ClassOf(arg) === 'SharedArrayBuffer');
macro IS_STRING(arg) = (typeof(arg) === 'string'); macro IS_STRING(arg) = (typeof(arg) === 'string');
macro IS_SYMBOL(arg) = (typeof(arg) === 'symbol'); macro IS_SYMBOL(arg) = (typeof(arg) === 'symbol');
macro IS_TYPEDARRAY(arg) = (%_IsTypedArray(arg));
macro IS_UNDEFINED(arg) = (arg === (void 0)); macro IS_UNDEFINED(arg) = (arg === (void 0));
macro IS_WEAKMAP(arg) = (%_IsJSWeakMap(arg)); macro IS_WEAKMAP(arg) = (%_IsJSWeakMap(arg));
macro IS_WEAKSET(arg) = (%_IsJSWeakSet(arg)); macro IS_WEAKSET(arg) = (%_IsJSWeakSet(arg));
...@@ -80,24 +66,14 @@ macro IS_CALLABLE(arg) = (typeof(arg) === 'function'); ...@@ -80,24 +66,14 @@ macro IS_CALLABLE(arg) = (typeof(arg) === 'function');
macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL(%IS_VAR(arg)) || IS_UNDEFINED(arg)) throw %make_type_error(kCalledOnNullOrUndefined, functionName); macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL(%IS_VAR(arg)) || IS_UNDEFINED(arg)) throw %make_type_error(kCalledOnNullOrUndefined, functionName);
# Inline macros. Use %IS_VAR to make sure arg is evaluated only once. # Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
macro NUMBER_IS_NAN(arg) = (%IS_VAR(arg) !== arg);
macro NUMBER_IS_FINITE(arg) = (%_IsSmi(%IS_VAR(arg)) || ((arg == arg) && (arg != 1/0) && (arg != -1/0)));
macro TO_BOOLEAN(arg) = (!!(arg)); macro TO_BOOLEAN(arg) = (!!(arg));
macro TO_INTEGER(arg) = (%_ToInteger(arg)); macro TO_INTEGER(arg) = (%_ToInteger(arg));
macro INVERT_NEG_ZERO(arg) = ((arg) + 0);
macro TO_LENGTH(arg) = (%_ToLength(arg)); macro TO_LENGTH(arg) = (%_ToLength(arg));
macro TO_STRING(arg) = (%_ToString(arg)); macro TO_STRING(arg) = (%_ToString(arg));
macro TO_NUMBER(arg) = (%_ToNumber(arg)); macro TO_NUMBER(arg) = (%_ToNumber(arg));
macro TO_OBJECT(arg) = (%_ToObject(arg)); macro TO_OBJECT(arg) = (%_ToObject(arg));
macro HAS_OWN_PROPERTY(obj, key) = (%_Call(ObjectHasOwnProperty, obj, key)); macro HAS_OWN_PROPERTY(obj, key) = (%_Call(ObjectHasOwnProperty, obj, key));
# Private names.
macro GET_PRIVATE(obj, sym) = (obj[sym]);
macro SET_PRIVATE(obj, sym, val) = (obj[sym] = val);
# To avoid ES2015 Function name inference.
macro ANONYMOUS_FUNCTION(fn) = (0, (fn));
macro DEFINE_METHODS_LEN(obj, class_def, len) = %DefineMethodsInternal(obj, class class_def, len); macro DEFINE_METHODS_LEN(obj, class_def, len) = %DefineMethodsInternal(obj, class class_def, len);
macro DEFINE_METHOD_LEN(obj, method_def, len) = %DefineMethodsInternal(obj, class { method_def }, len); macro DEFINE_METHOD_LEN(obj, method_def, len) = %DefineMethodsInternal(obj, class { method_def }, len);
macro DEFINE_METHODS(obj, class_def) = DEFINE_METHODS_LEN(obj, class_def, -1); macro DEFINE_METHODS(obj, class_def) = DEFINE_METHODS_LEN(obj, class_def, -1);
...@@ -106,9 +82,3 @@ macro DEFINE_METHOD(obj, method_def) = DEFINE_METHOD_LEN(obj, method_def, -1); ...@@ -106,9 +82,3 @@ macro DEFINE_METHOD(obj, method_def) = DEFINE_METHOD_LEN(obj, method_def, -1);
# Constants. The compiler constant folds them. # Constants. The compiler constant folds them.
define INFINITY = (1/0); define INFINITY = (1/0);
define UNDEFINED = (void 0); define UNDEFINED = (void 0);
# Must match PropertyFilter in property-details.h
define PROPERTY_FILTER_NONE = 0;
# Check whether debug is active.
define DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0);
...@@ -49,6 +49,18 @@ endmacro ...@@ -49,6 +49,18 @@ endmacro
TYPED_ARRAYS(DECLARE_GLOBALS) TYPED_ARRAYS(DECLARE_GLOBALS)
macro IS_ARRAYBUFFER(arg)
(%_ClassOf(arg) === 'ArrayBuffer')
endmacro
macro IS_SHAREDARRAYBUFFER(arg)
(%_ClassOf(arg) === 'SharedArrayBuffer')
endmacro
macro IS_TYPEDARRAY(arg)
(%_IsTypedArray(arg))
endmacro
var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array); var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array);
utils.Import(function(from) { utils.Import(function(from) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment