Simplify usage of runtime hashing functions in weak-collection.js
This also removes the IS_GLOBAL macro from macros.py, which did not work correctly for Remote objects/contexts. Bug: v8:6413 Change-Id: I90690bdd0d8e8fed581bc4c9f5c60168d785f096 Reviewed-on: https://chromium-review.googlesource.com/633872 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#47585}
This commit is contained in:
parent
46cb812fa1
commit
f9a3a5af2a
@ -51,7 +51,6 @@ macro IS_DATE(arg) = (%IsDate(arg));
|
||||
macro IS_ERROR(arg) = (%_ClassOf(arg) === 'Error');
|
||||
macro IS_FUNCTION(arg) = (%IsFunction(arg));
|
||||
macro IS_GENERATOR(arg) = (%_ClassOf(arg) === 'Generator');
|
||||
macro IS_GLOBAL(arg) = (%_ClassOf(arg) === 'global');
|
||||
macro IS_MAP(arg) = (%_IsJSMap(arg));
|
||||
macro IS_MAP_ITERATOR(arg) = (%_ClassOf(arg) === 'Map Iterator');
|
||||
macro IS_NULL(arg) = (arg === null);
|
||||
|
@ -15,23 +15,6 @@ var GlobalWeakMap = global.WeakMap;
|
||||
var GlobalWeakSet = global.WeakSet;
|
||||
var MathRandom = global.Math.random;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function GetExistingHash(key) {
|
||||
if (IS_RECEIVER(key) && !IS_PROXY(key) && !IS_GLOBAL(key)) {
|
||||
return %GetExistingHash(key);
|
||||
}
|
||||
return %GenericHash(key);
|
||||
}
|
||||
%SetForceInlineFlag(GetExistingHash);
|
||||
|
||||
|
||||
function GetHash(key) {
|
||||
return %GenericHash(key);
|
||||
}
|
||||
%SetForceInlineFlag(GetHash);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Harmony WeakMap
|
||||
|
||||
@ -67,7 +50,7 @@ DEFINE_METHODS(
|
||||
'WeakMap.prototype.set', this);
|
||||
}
|
||||
if (!IS_RECEIVER(key)) throw %make_type_error(kInvalidWeakMapKey);
|
||||
return %WeakCollectionSet(this, key, value, GetHash(key));
|
||||
return %WeakCollectionSet(this, key, value, %GenericHash(key));
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
@ -76,7 +59,7 @@ DEFINE_METHODS(
|
||||
'WeakMap.prototype.delete', this);
|
||||
}
|
||||
if (!IS_RECEIVER(key)) return false;
|
||||
var hash = GetExistingHash(key);
|
||||
var hash = %GetExistingHash(key);
|
||||
if (IS_UNDEFINED(hash)) return false;
|
||||
return %WeakCollectionDelete(this, key, hash);
|
||||
}
|
||||
@ -120,7 +103,7 @@ DEFINE_METHODS(
|
||||
'WeakSet.prototype.add', this);
|
||||
}
|
||||
if (!IS_RECEIVER(value)) throw %make_type_error(kInvalidWeakSetValue);
|
||||
return %WeakCollectionSet(this, value, true, GetHash(value));
|
||||
return %WeakCollectionSet(this, value, true, %GenericHash(value));
|
||||
}
|
||||
|
||||
delete(value) {
|
||||
@ -129,7 +112,7 @@ DEFINE_METHODS(
|
||||
'WeakSet.prototype.delete', this);
|
||||
}
|
||||
if (!IS_RECEIVER(value)) return false;
|
||||
var hash = GetExistingHash(value);
|
||||
var hash = %GetExistingHash(value);
|
||||
if (IS_UNDEFINED(hash)) return false;
|
||||
return %WeakCollectionDelete(this, value, hash);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ RUNTIME_FUNCTION(Runtime_TheHole) {
|
||||
RUNTIME_FUNCTION(Runtime_GetExistingHash) {
|
||||
SealHandleScope shs(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
|
||||
return object->GetHash();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user