Commit 7b7a7164 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[Collections] Port Set.p.has to c++/csa

Bug: v8:5717
Change-Id: I5e46dbeee9e3383253c2fbebb9623325f5e4e01d
Reviewed-on: https://chromium-review.googlesource.com/520714Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45682}
parent 9c8f0f09
......@@ -2959,11 +2959,18 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
}
{ // -- S e t
Handle<JSFunction> js_set_fun = InstallFunction(
global, "Set", JS_SET_TYPE, JSSet::kSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
Handle<JSObject> prototype =
factory->NewJSObject(isolate->object_function(), TENURED);
Handle<JSFunction> js_set_fun =
InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, prototype,
Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, js_set_fun,
Context::JS_SET_FUN_INDEX);
Handle<JSFunction> set_has =
SimpleInstallFunction(prototype, "has", Builtins::kSetHas, 1, true);
InstallWithIntrinsicDefaultProto(isolate, set_has,
Context::SET_HAS_METHOD_INDEX);
InstallSpeciesGetter(js_set_fun);
}
......
......@@ -216,5 +216,16 @@ TF_BUILTIN(MapHas, CollectionsBuiltinsAssembler) {
Return(CallHasRaw<OrderedHashMap, 2>(table, key));
}
TF_BUILTIN(SetHas, CollectionsBuiltinsAssembler) {
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const key = Parameter(Descriptor::kKey);
Node* const context = Parameter(Descriptor::kContext);
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.has");
Node* const table = LoadObjectField(receiver, JSMap::kTableOffset);
Return(CallHasRaw<OrderedHashSet, 1>(table, key));
}
} // namespace internal
} // namespace v8
......@@ -815,6 +815,9 @@ namespace internal {
/* ES #sec-regexp.prototype-@@split */ \
TFJ(RegExpPrototypeSplit, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
\
/* Set */ \
TFJ(SetHas, 1, kKey) \
\
/* SharedArrayBuffer */ \
CPP(SharedArrayBufferPrototypeGetByteLength) \
CPP(SharedArrayBufferPrototypeSlice) \
......
......@@ -179,18 +179,6 @@ function SetAdd(key) {
}
function SetHas(key) {
if (!IS_SET(this)) {
throw %make_type_error(kIncompatibleMethodReceiver, 'Set.prototype.has', this);
}
var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
var hash = GetExistingHash(key);
if (IS_UNDEFINED(hash)) return false;
return SetFindEntry(table, numBuckets, key, hash) !== NOT_FOUND;
}
function SetDelete(key) {
if (!IS_SET(this)) {
throw %make_type_error(kIncompatibleMethodReceiver,
......@@ -254,7 +242,6 @@ function SetForEach(f, receiver) {
%SetCode(GlobalSet, SetConstructor);
%FunctionSetLength(GlobalSet, 0);
%FunctionSetPrototype(GlobalSet, new GlobalObject());
%AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM);
%AddNamedProperty(GlobalSet.prototype, toStringTagSymbol, "Set",
DONT_ENUM | READ_ONLY);
......@@ -265,7 +252,6 @@ function SetForEach(f, receiver) {
utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
"add", SetAdd,
"has", SetHas,
"delete", SetDelete,
"clear", SetClearJS,
"forEach", SetForEach
......@@ -401,7 +387,6 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
"map_set", MapSet,
"map_delete", MapDelete,
"set_add", SetAdd,
"set_has", SetHas,
"set_delete", SetDelete,
]);
......
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