Commit 8c6f9067 authored by Gus Caplan's avatar Gus Caplan Committed by Commit Bot

[Torque] port some Object.prototype methods to torque

Bug: v8:9891
Change-Id: I5e561e1ef93f0ed6712ea6477cbee0205f72e1c1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2145192Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67118}
parent 67ea6211
......@@ -1428,7 +1428,7 @@ macro ClampToIndexRange(indexNumber: Number, limit: uintptr): uintptr {
}
}
extern builtin ObjectToString(Context, JSAny): JSAny;
extern builtin ObjectToString(Context, JSAny): String;
extern builtin StringRepeat(Context, String, Number): String;
@export
......
......@@ -678,18 +678,12 @@ namespace internal {
TFJ(ObjectKeys, 1, kReceiver, kObject) \
CPP(ObjectLookupGetter) \
CPP(ObjectLookupSetter) \
/* ES6 #sec-object.prototype.tostring */ \
TFJ(ObjectPrototypeToString, 0, kReceiver) \
/* ES6 #sec-object.prototype.valueof */ \
TFJ(ObjectPrototypeValueOf, 0, kReceiver) \
/* ES6 #sec-object.prototype.hasownproperty */ \
TFJ(ObjectPrototypeHasOwnProperty, 1, kReceiver, kKey) \
TFJ(ObjectPrototypeIsPrototypeOf, 1, kReceiver, kValue) \
CPP(ObjectPrototypePropertyIsEnumerable) \
CPP(ObjectPrototypeGetProto) \
CPP(ObjectPrototypeSetProto) \
/* ES #sec-object.prototype.tolocalestring */ \
TFJ(ObjectPrototypeToLocaleString, 0, kReceiver) \
CPP(ObjectSeal) \
TFS(ObjectToString, kReceiver) \
TFJ(ObjectValues, 1, kReceiver, kObject) \
......
......@@ -350,22 +350,6 @@ ObjectEntriesValuesBuiltinsAssembler::FinalizeValuesOrEntriesJSArray(
return TNode<JSArray>::UncheckedCast(array);
}
TF_BUILTIN(ObjectPrototypeToLocaleString, CodeStubAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Label if_null_or_undefined(this, Label::kDeferred);
GotoIf(IsNullOrUndefined(receiver), &if_null_or_undefined);
TNode<Object> method =
GetProperty(context, receiver, factory()->toString_string());
Return(Call(context, method, receiver));
BIND(&if_null_or_undefined);
ThrowTypeError(context, MessageTemplate::kCalledOnNullOrUndefined,
"Object.prototype.toLocaleString");
}
TF_BUILTIN(ObjectPrototypeHasOwnProperty, ObjectBuiltinsAssembler) {
TNode<Object> object = CAST(Parameter(Descriptor::kReceiver));
TNode<Object> key = CAST(Parameter(Descriptor::kKey));
......@@ -724,13 +708,6 @@ TF_BUILTIN(ObjectPrototypeIsPrototypeOf, ObjectBuiltinsAssembler) {
Return(FalseConstant());
}
// ES #sec-object.prototype.tostring
TF_BUILTIN(ObjectPrototypeToString, CodeStubAssembler) {
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(CallBuiltin(Builtins::kObjectToString, context, receiver));
}
TF_BUILTIN(ObjectToString, ObjectBuiltinsAssembler) {
Label checkstringtag(this), if_apiobject(this, Label::kDeferred),
if_arguments(this), if_array(this), if_boolean(this), if_date(this),
......@@ -1053,14 +1030,6 @@ TF_BUILTIN(ObjectToString, ObjectBuiltinsAssembler) {
}
}
// ES6 #sec-object.prototype.valueof
TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) {
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(ToObject_Inline(context, receiver));
}
// ES #sec-object.create
TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
int const kPrototypeArg = 0;
......
......@@ -178,4 +178,31 @@ namespace object {
}
}
}
// ES #sec-object.prototype.tostring
transitioning javascript builtin ObjectPrototypeToString(
js-implicit context: Context, receiver: JSAny)(): String {
return ObjectToString(context, receiver);
}
// ES #sec-object.prototype.valueof
transitioning javascript builtin ObjectPrototypeValueOf(
js-implicit context: Context, receiver: JSAny)(): JSReceiver {
// 1. Return ? ToObject(this value).
return ToObject_Inline(context, receiver);
}
// ES #sec-object.prototype.tolocalestring
transitioning javascript builtin ObjectPrototypeToLocaleString(
js-implicit context: Context, receiver: JSAny)(): JSAny {
// 1. Let O be the this value.
// 2. Return ? Invoke(O, "toString").
if (receiver == Null || receiver == Undefined) deferred {
ThrowTypeError(
MessageTemplate::kCalledOnNullOrUndefined,
'Object.prototype.toLocaleString');
}
const method = GetProperty(receiver, 'toString');
return Call(context, method, receiver);
}
} // namespace object
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