Reland "[torque] Port some constructor builtins to Torque."

This is a reland of ce249dbb2f

As it's unchanged,
TBR=leszeks@chromium.org,tebbi@chromium.org

Original change's description:
> [torque] Port some constructor builtins to Torque.
>
> - FastNewFunctionContextEval
> - FastNewFunctionContextFunction
> - CreateEmptyLiteralObject
> - CreateRegExpLiteral
> - CreateEmptyArrayLiteral
> - CreateShallowArrayLiteral
> - CreateShallowObjectLiteral
> - NumberConstructor
> - ObjectConstructor
> - GenericLazyDeoptContinuation
>
> Bug: v8:9891
>
> Change-Id: Idd4bf035d8dbeec03b9ef727e1bfb80eab4bc43c
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2311411
> Commit-Queue: Bill Budge <bbudge@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#69082}

Bug: v8:9891
Change-Id: I566d4167c02488ef6a9a1c73015af5e2f484a31d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2330382
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69281}
This commit is contained in:
Bill Budge 2020-08-05 08:05:12 -07:00 committed by Commit Bot
parent 57f3f3d22d
commit 83e4c8b11d
21 changed files with 216 additions and 309 deletions

View File

@ -1115,6 +1115,7 @@ torque_files = [
"src/builtins/builtins-string.tq",
"src/builtins/cast.tq",
"src/builtins/collections.tq",
"src/builtins/constructor.tq",
"src/builtins/conversion.tq",
"src/builtins/convert.tq",
"src/builtins/console.tq",

View File

@ -1107,6 +1107,7 @@ class AggregateLiteral : public MaterializedLiteral {
kIsShallow = 1,
kDisableMementos = 1 << 1,
kNeedsInitialAllocationSite = 1 << 2,
kIsShallowAndDisableMementos = kIsShallow | kDisableMementos,
};
bool is_initialized() const { return 0 < depth_; }

View File

@ -523,6 +523,12 @@ transitioning macro ToInteger_Inline(implicit context: Context)(input: JSAny):
}
}
extern enum BigIntHandling extends int32
constexpr 'CodeStubAssembler::BigIntHandling' { kConvertToNumber, kThrow }
extern transitioning macro ToNumber(implicit context: Context)(
JSAny, constexpr BigIntHandling): Number;
extern transitioning macro ToLength_Inline(implicit context: Context)(JSAny):
Number;
extern transitioning macro ToNumber_Inline(implicit context: Context)(JSAny):

View File

@ -413,8 +413,7 @@ TNode<JSObject> BaseCollectionsAssembler::AllocateJSCollectionSlow(
TNode<Context> context, TNode<JSFunction> constructor,
TNode<JSReceiver> new_target) {
ConstructorBuiltinsAssembler constructor_assembler(this->state());
return constructor_assembler.EmitFastNewObject(context, constructor,
new_target);
return constructor_assembler.FastNewObject(context, constructor, new_target);
}
void BaseCollectionsAssembler::GenerateConstructor(

View File

@ -226,20 +226,20 @@ TF_BUILTIN(FastNewObject, ConstructorBuiltinsAssembler) {
Label call_runtime(this);
TNode<JSObject> result =
EmitFastNewObject(context, target, new_target, &call_runtime);
FastNewObject(context, target, new_target, &call_runtime);
Return(result);
BIND(&call_runtime);
TailCallRuntime(Runtime::kNewObject, context, target, new_target);
}
TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
TNode<JSObject> ConstructorBuiltinsAssembler::FastNewObject(
TNode<Context> context, TNode<JSFunction> target,
TNode<JSReceiver> new_target) {
TVARIABLE(JSObject, var_obj);
Label call_runtime(this), end(this);
var_obj = EmitFastNewObject(context, target, new_target, &call_runtime);
var_obj = FastNewObject(context, target, new_target, &call_runtime);
Goto(&end);
BIND(&call_runtime);
@ -250,7 +250,7 @@ TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
return var_obj.value();
}
TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
TNode<JSObject> ConstructorBuiltinsAssembler::FastNewObject(
TNode<Context> context, TNode<JSFunction> target,
TNode<JSReceiver> new_target, Label* call_runtime) {
// Verify that the new target is a JSFunction.
@ -292,7 +292,7 @@ TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
kNone, kWithSlackTracking);
}
TNode<Context> ConstructorBuiltinsAssembler::EmitFastNewFunctionContext(
TNode<Context> ConstructorBuiltinsAssembler::FastNewFunctionContext(
TNode<ScopeInfo> scope_info, TNode<Uint32T> slots, TNode<Context> context,
ScopeType scope_type) {
TNode<IntPtrT> slots_intptr = Signed(ChangeUint32ToWord(slots));
@ -341,23 +341,7 @@ TNode<Context> ConstructorBuiltinsAssembler::EmitFastNewFunctionContext(
return function_context;
}
TF_BUILTIN(FastNewFunctionContextEval, ConstructorBuiltinsAssembler) {
TNode<ScopeInfo> scope_info = CAST(Parameter(Descriptor::kScopeInfo));
TNode<Uint32T> slots = UncheckedCast<Uint32T>(Parameter(Descriptor::kSlots));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(EmitFastNewFunctionContext(scope_info, slots, context,
ScopeType::EVAL_SCOPE));
}
TF_BUILTIN(FastNewFunctionContextFunction, ConstructorBuiltinsAssembler) {
TNode<ScopeInfo> scope_info = CAST(Parameter(Descriptor::kScopeInfo));
TNode<Uint32T> slots = UncheckedCast<Uint32T>(Parameter(Descriptor::kSlots));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(EmitFastNewFunctionContext(scope_info, slots, context,
ScopeType::FUNCTION_SCOPE));
}
TNode<JSRegExp> ConstructorBuiltinsAssembler::EmitCreateRegExpLiteral(
TNode<JSRegExp> ConstructorBuiltinsAssembler::CreateRegExpLiteral(
TNode<HeapObject> maybe_feedback_vector, TNode<TaggedIndex> slot,
TNode<Object> pattern, TNode<Smi> flags, TNode<Context> context) {
Label call_runtime(this, Label::kDeferred), end(this);
@ -393,22 +377,10 @@ TNode<JSRegExp> ConstructorBuiltinsAssembler::EmitCreateRegExpLiteral(
return result.value();
}
TF_BUILTIN(CreateRegExpLiteral, ConstructorBuiltinsAssembler) {
TNode<HeapObject> maybe_feedback_vector =
CAST(Parameter(Descriptor::kFeedbackVector));
TNode<TaggedIndex> slot = CAST(Parameter(Descriptor::kSlot));
TNode<Object> pattern = CAST(Parameter(Descriptor::kPattern));
TNode<Smi> flags = CAST(Parameter(Descriptor::kFlags));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<JSRegExp> result = EmitCreateRegExpLiteral(maybe_feedback_vector, slot,
pattern, flags, context);
Return(result);
}
TNode<JSArray> ConstructorBuiltinsAssembler::EmitCreateShallowArrayLiteral(
TNode<JSArray> ConstructorBuiltinsAssembler::CreateShallowArrayLiteral(
TNode<FeedbackVector> feedback_vector, TNode<TaggedIndex> slot,
TNode<Context> context, Label* call_runtime,
AllocationSiteMode allocation_site_mode) {
TNode<Context> context, AllocationSiteMode allocation_site_mode,
Label* call_runtime) {
Label zero_capacity(this), cow_elements(this), fast_elements(this),
return_result(this);
@ -426,29 +398,7 @@ TNode<JSArray> ConstructorBuiltinsAssembler::EmitCreateShallowArrayLiteral(
}
}
TF_BUILTIN(CreateShallowArrayLiteral, ConstructorBuiltinsAssembler) {
TNode<FeedbackVector> feedback_vector =
CAST(Parameter(Descriptor::kFeedbackVector));
TNode<TaggedIndex> slot = CAST(Parameter(Descriptor::kSlot));
TNode<ArrayBoilerplateDescription> constant_elements =
CAST(Parameter(Descriptor::kConstantElements));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Label call_runtime(this, Label::kDeferred);
Return(EmitCreateShallowArrayLiteral(feedback_vector, slot, context,
&call_runtime,
DONT_TRACK_ALLOCATION_SITE));
BIND(&call_runtime);
{
Comment("call runtime");
int const flags =
AggregateLiteral::kDisableMementos | AggregateLiteral::kIsShallow;
Return(CallRuntime(Runtime::kCreateArrayLiteral, context, feedback_vector,
slot, constant_elements, SmiConstant(flags)));
}
}
TNode<JSArray> ConstructorBuiltinsAssembler::EmitCreateEmptyArrayLiteral(
TNode<JSArray> ConstructorBuiltinsAssembler::CreateEmptyArrayLiteral(
TNode<FeedbackVector> feedback_vector, TNode<TaggedIndex> slot,
TNode<Context> context) {
// Array literals always have a valid AllocationSite to properly track
@ -492,17 +442,7 @@ TNode<JSArray> ConstructorBuiltinsAssembler::EmitCreateEmptyArrayLiteral(
return result;
}
TF_BUILTIN(CreateEmptyArrayLiteral, ConstructorBuiltinsAssembler) {
TNode<FeedbackVector> feedback_vector =
CAST(Parameter(Descriptor::kFeedbackVector));
TNode<TaggedIndex> slot = CAST(Parameter(Descriptor::kSlot));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<JSArray> result =
EmitCreateEmptyArrayLiteral(feedback_vector, slot, context);
Return(result);
}
TNode<HeapObject> ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral(
TNode<HeapObject> ConstructorBuiltinsAssembler::CreateShallowObjectLiteral(
TNode<FeedbackVector> feedback_vector, TNode<TaggedIndex> slot,
Label* call_runtime) {
TNode<Object> maybe_allocation_site =
@ -679,26 +619,8 @@ TNode<HeapObject> ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral(
return copy;
}
TF_BUILTIN(CreateShallowObjectLiteral, ConstructorBuiltinsAssembler) {
Label call_runtime(this);
TNode<FeedbackVector> feedback_vector =
CAST(Parameter(Descriptor::kFeedbackVector));
TNode<TaggedIndex> slot = CAST(Parameter(Descriptor::kSlot));
TNode<HeapObject> copy =
EmitCreateShallowObjectLiteral(feedback_vector, slot, &call_runtime);
Return(copy);
BIND(&call_runtime);
TNode<ObjectBoilerplateDescription> object_boilerplate_description =
CAST(Parameter(Descriptor::kObjectBoilerplateDescription));
TNode<Smi> flags = CAST(Parameter(Descriptor::kFlags));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TailCallRuntime(Runtime::kCreateObjectLiteral, context, feedback_vector, slot,
object_boilerplate_description, flags);
}
// Used by the CreateEmptyObjectLiteral bytecode and the Object constructor.
TNode<JSObject> ConstructorBuiltinsAssembler::EmitCreateEmptyObjectLiteral(
TNode<JSObject> ConstructorBuiltinsAssembler::CreateEmptyObjectLiteral(
TNode<Context> context) {
TNode<NativeContext> native_context = LoadNativeContext(context);
TNode<JSFunction> object_function =
@ -715,115 +637,5 @@ TNode<JSObject> ConstructorBuiltinsAssembler::EmitCreateEmptyObjectLiteral(
return result;
}
// ES #sec-object-constructor
TF_BUILTIN(ObjectConstructor, ConstructorBuiltinsAssembler) {
int const kValueArg = 0;
TNode<IntPtrT> argc = ChangeInt32ToIntPtr(
UncheckedCast<Int32T>(Parameter(Descriptor::kJSActualArgumentsCount)));
CodeStubArguments args(this, argc);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> new_target = CAST(Parameter(Descriptor::kJSNewTarget));
TVARIABLE(Object, var_result);
Label if_subclass(this, Label::kDeferred), if_notsubclass(this),
return_result(this);
GotoIf(IsUndefined(new_target), &if_notsubclass);
TNode<JSFunction> target = CAST(Parameter(Descriptor::kJSTarget));
Branch(TaggedEqual(new_target, target), &if_notsubclass, &if_subclass);
BIND(&if_subclass);
{
var_result =
CallBuiltin(Builtins::kFastNewObject, context, target, new_target);
Goto(&return_result);
}
BIND(&if_notsubclass);
{
Label if_newobject(this, Label::kDeferred), if_toobject(this);
TNode<IntPtrT> value_index = IntPtrConstant(kValueArg);
GotoIf(UintPtrGreaterThanOrEqual(value_index, argc), &if_newobject);
TNode<Object> value = args.AtIndex(value_index);
GotoIf(IsNull(value), &if_newobject);
Branch(IsUndefined(value), &if_newobject, &if_toobject);
BIND(&if_newobject);
{
var_result = EmitCreateEmptyObjectLiteral(context);
Goto(&return_result);
}
BIND(&if_toobject);
{
var_result = CallBuiltin(Builtins::kToObject, context, value);
Goto(&return_result);
}
}
BIND(&return_result);
args.PopAndReturn(var_result.value());
}
TF_BUILTIN(CreateEmptyLiteralObject, ConstructorBuiltinsAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(EmitCreateEmptyObjectLiteral(context));
}
// ES #sec-number-constructor
TF_BUILTIN(NumberConstructor, ConstructorBuiltinsAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<IntPtrT> argc = ChangeInt32ToIntPtr(
UncheckedCast<Int32T>(Parameter(Descriptor::kJSActualArgumentsCount)));
CodeStubArguments args(this, argc);
// 1. If no arguments were passed to this function invocation, let n be +0.
TVARIABLE(Number, var_n, SmiConstant(0));
Label if_nloaded(this, &var_n);
GotoIf(IntPtrEqual(argc, IntPtrConstant(0)), &if_nloaded);
// 2. Else,
// a. Let prim be ? ToNumeric(value).
// b. If Type(prim) is BigInt, let n be the Number value for prim.
// c. Otherwise, let n be prim.
TNode<Object> value = args.AtIndex(0);
var_n = ToNumber(context, value, BigIntHandling::kConvertToNumber);
Goto(&if_nloaded);
BIND(&if_nloaded);
{
// 3. If NewTarget is undefined, return n.
TNode<Number> n_value = var_n.value();
TNode<Object> new_target = CAST(Parameter(Descriptor::kJSNewTarget));
Label return_n(this), constructnumber(this, Label::kDeferred);
Branch(IsUndefined(new_target), &return_n, &constructnumber);
BIND(&return_n);
{ args.PopAndReturn(n_value); }
BIND(&constructnumber);
{
// 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
// "%NumberPrototype%", « [[NumberData]] »).
// 5. Set O.[[NumberData]] to n.
// 6. Return O.
// We are not using Parameter(Descriptor::kJSTarget) and loading the value
// from the current frame here in order to reduce register pressure on the
// fast path.
TNode<JSFunction> target = LoadTargetFromFrame();
TNode<HeapObject> result = CAST(
CallBuiltin(Builtins::kFastNewObject, context, target, new_target));
StoreObjectField(result, JSPrimitiveWrapper::kValueOffset, n_value);
args.PopAndReturn(result);
}
}
}
TF_BUILTIN(GenericLazyDeoptContinuation, ConstructorBuiltinsAssembler) {
TNode<Object> result = CAST(Parameter(Descriptor::kResult));
Return(result);
}
} // namespace internal
} // namespace v8

View File

@ -15,37 +15,38 @@ class ConstructorBuiltinsAssembler : public CodeStubAssembler {
explicit ConstructorBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
TNode<Context> EmitFastNewFunctionContext(TNode<ScopeInfo> scope_info,
TNode<Uint32T> slots,
TNode<Context> context,
ScopeType scope_type);
TNode<Context> FastNewFunctionContext(TNode<ScopeInfo> scope_info,
TNode<Uint32T> slots,
TNode<Context> context,
ScopeType scope_type);
TNode<JSRegExp> EmitCreateRegExpLiteral(
TNode<HeapObject> maybe_feedback_vector, TNode<TaggedIndex> slot,
TNode<Object> pattern, TNode<Smi> flags, TNode<Context> context);
TNode<JSRegExp> CreateRegExpLiteral(TNode<HeapObject> maybe_feedback_vector,
TNode<TaggedIndex> slot,
TNode<Object> pattern, TNode<Smi> flags,
TNode<Context> context);
TNode<JSArray> EmitCreateShallowArrayLiteral(
TNode<JSArray> CreateShallowArrayLiteral(
TNode<FeedbackVector> feedback_vector, TNode<TaggedIndex> slot,
TNode<Context> context, Label* call_runtime,
AllocationSiteMode allocation_site_mode);
TNode<Context> context, AllocationSiteMode allocation_site_mode,
Label* call_runtime);
TNode<JSArray> EmitCreateEmptyArrayLiteral(
TNode<FeedbackVector> feedback_vector, TNode<TaggedIndex> slot,
TNode<Context> context);
TNode<JSArray> CreateEmptyArrayLiteral(TNode<FeedbackVector> feedback_vector,
TNode<TaggedIndex> slot,
TNode<Context> context);
TNode<HeapObject> EmitCreateShallowObjectLiteral(
TNode<HeapObject> CreateShallowObjectLiteral(
TNode<FeedbackVector> feedback_vector, TNode<TaggedIndex> slot,
Label* call_runtime);
TNode<JSObject> EmitCreateEmptyObjectLiteral(TNode<Context> context);
TNode<JSObject> CreateEmptyObjectLiteral(TNode<Context> context);
TNode<JSObject> EmitFastNewObject(TNode<Context> context,
TNode<JSFunction> target,
TNode<JSReceiver> new_target);
TNode<JSObject> FastNewObject(TNode<Context> context,
TNode<JSFunction> target,
TNode<JSReceiver> new_target);
TNode<JSObject> EmitFastNewObject(TNode<Context> context,
TNode<JSFunction> target,
TNode<JSReceiver> new_target,
Label* call_runtime);
TNode<JSObject> FastNewObject(TNode<Context> context,
TNode<JSFunction> target,
TNode<JSReceiver> new_target,
Label* call_runtime);
};
} // namespace internal

View File

@ -94,14 +94,6 @@ namespace internal {
ASM(JSBuiltinsConstructStub, Dummy) \
TFC(FastNewObject, FastNewObject) \
TFS(FastNewClosure, kSharedFunctionInfo, kFeedbackCell) \
TFC(FastNewFunctionContextEval, FastNewFunctionContext) \
TFC(FastNewFunctionContextFunction, FastNewFunctionContext) \
TFS(CreateEmptyLiteralObject) \
TFS(CreateRegExpLiteral, kFeedbackVector, kSlot, kPattern, kFlags) \
TFS(CreateEmptyArrayLiteral, kFeedbackVector, kSlot) \
TFS(CreateShallowArrayLiteral, kFeedbackVector, kSlot, kConstantElements) \
TFS(CreateShallowObjectLiteral, kFeedbackVector, kSlot, \
kObjectBoilerplateDescription, kFlags) \
/* ES6 section 9.5.14 [[Construct]] ( argumentsList, newTarget) */ \
TFC(ConstructProxy, JSTrampoline) \
\
@ -599,7 +591,6 @@ namespace internal {
TFS(MapIteratorToList, kSource) \
\
/* ES #sec-number-constructor */ \
TFJ(NumberConstructor, kDontAdaptArgumentsSentinel) \
CPP(NumberPrototypeToExponential) \
CPP(NumberPrototypeToFixed) \
CPP(NumberPrototypeToLocaleString) \
@ -637,7 +628,6 @@ namespace internal {
\
/* Object */ \
/* ES #sec-object-constructor */ \
TFJ(ObjectConstructor, kDontAdaptArgumentsSentinel) \
TFJ(ObjectAssign, kDontAdaptArgumentsSentinel) \
/* ES #sec-object.create */ \
TFJ(ObjectCreate, kDontAdaptArgumentsSentinel) \
@ -788,7 +778,6 @@ namespace internal {
/* TypedArray */ \
/* ES #sec-typedarray-constructors */ \
TFJ(TypedArrayBaseConstructor, 0, kReceiver) \
TFJ(GenericLazyDeoptContinuation, 1, kReceiver, kResult) \
TFJ(TypedArrayConstructor, kDontAdaptArgumentsSentinel) \
CPP(TypedArrayPrototypeBuffer) \
/* ES6 #sec-get-%typedarray%.prototype.bytelength */ \

View File

@ -1104,7 +1104,7 @@ TF_BUILTIN(RegExpConstructor, RegExpBuiltinsAssembler) {
BIND(&allocate_generic);
{
ConstructorBuiltinsAssembler constructor_assembler(this->state());
var_regexp = CAST(constructor_assembler.EmitFastNewObject(
var_regexp = CAST(constructor_assembler.FastNewObject(
context, regexp_function, CAST(var_new_target.value())));
Goto(&next);
}

157
src/builtins/constructor.tq Normal file
View File

@ -0,0 +1,157 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/ast/ast.h"
namespace runtime {
extern runtime CreateArrayLiteral(
Context, FeedbackVector, TaggedIndex, ArrayBoilerplateDescription,
Smi): HeapObject;
extern runtime CreateObjectLiteral(
Context, FeedbackVector, TaggedIndex, ObjectBoilerplateDescription,
Smi): HeapObject;
}
namespace constructor {
extern builtin FastNewObject(Context, JSFunction, JSReceiver): JSObject;
extern enum AllocationSiteMode constexpr 'AllocationSiteMode' {
DONT_TRACK_ALLOCATION_SITE,
TRACK_ALLOCATION_SITE
}
const kIsShallowAndDisableMementos: constexpr int31
generates 'AggregateLiteral::Flags::kIsShallowAndDisableMementos';
const kEvalScope: constexpr ScopeType generates 'ScopeType::EVAL_SCOPE';
const kFunctionScope:
constexpr ScopeType generates 'ScopeType::FUNCTION_SCOPE';
extern macro ConstructorBuiltinsAssembler::FastNewFunctionContext(
ScopeInfo, uint32, Context, constexpr ScopeType): Context;
extern macro ConstructorBuiltinsAssembler::CreateRegExpLiteral(
HeapObject, TaggedIndex, Object, Smi, Context): JSRegExp;
extern macro ConstructorBuiltinsAssembler::CreateShallowArrayLiteral(
FeedbackVector, TaggedIndex, Context,
constexpr AllocationSiteMode): HeapObject labels CallRuntime;
extern macro ConstructorBuiltinsAssembler::CreateEmptyArrayLiteral(
FeedbackVector, TaggedIndex, Context): HeapObject;
extern macro ConstructorBuiltinsAssembler::CreateShallowObjectLiteral(
FeedbackVector, TaggedIndex): HeapObject labels CallRuntime;
extern macro ConstructorBuiltinsAssembler::CreateEmptyObjectLiteral(Context):
JSObject;
builtin FastNewFunctionContextEval(implicit context: Context)(
scopeInfo: ScopeInfo, slots: uint32): Context {
return FastNewFunctionContext(scopeInfo, slots, context, kEvalScope);
}
builtin FastNewFunctionContextFunction(implicit context: Context)(
scopeInfo: ScopeInfo, slots: uint32): Context {
return FastNewFunctionContext(scopeInfo, slots, context, kFunctionScope);
}
builtin CreateRegExpLiteral(implicit context: Context)(
maybeFeedbackVector: HeapObject, slot: TaggedIndex, pattern: Object,
flags: Smi): JSRegExp {
return CreateRegExpLiteral(
maybeFeedbackVector, slot, pattern, flags, context);
}
builtin CreateShallowArrayLiteral(implicit context: Context)(
feedbackVector: FeedbackVector, slot: TaggedIndex,
constantElements: ArrayBoilerplateDescription): HeapObject {
try {
return CreateShallowArrayLiteral(
feedbackVector, slot, context,
AllocationSiteMode::DONT_TRACK_ALLOCATION_SITE)
otherwise CallRuntime;
} label CallRuntime deferred {
tail runtime::CreateArrayLiteral(
context, feedbackVector, slot, constantElements,
SmiConstant(kIsShallowAndDisableMementos));
}
}
builtin CreateEmptyArrayLiteral(implicit context: Context)(
feedbackVector: FeedbackVector, slot: TaggedIndex): HeapObject {
return CreateEmptyArrayLiteral(feedbackVector, slot, context);
}
builtin CreateShallowObjectLiteral(implicit context: Context)(
feedbackVector: FeedbackVector, slot: TaggedIndex,
desc: ObjectBoilerplateDescription, flags: Smi): HeapObject {
try {
return CreateShallowObjectLiteral(feedbackVector, slot)
otherwise CallRuntime;
} label CallRuntime deferred {
tail runtime::CreateObjectLiteral(
context, feedbackVector, slot, desc, flags);
}
}
// ES #sec-object-constructor
transitioning javascript builtin
ObjectConstructor(
js-implicit context: NativeContext, receiver: JSAny, newTarget: JSAny,
target: JSFunction)(...arguments): JSAny {
if (newTarget == Undefined || newTarget == target) {
// Not Subclass.
const value = arguments[0];
if (arguments.length <= 0 || value == Undefined || value == Null) {
// New object.
return CreateEmptyObjectLiteral(context);
} else {
return ToObject(context, value);
}
} else {
// Subclass.
return FastNewObject(context, target, UnsafeCast<JSReceiver>(newTarget));
}
}
builtin CreateEmptyLiteralObject(implicit context: Context)(): JSAny {
return CreateEmptyObjectLiteral(context);
}
// ES #sec-number-constructor
transitioning javascript builtin
NumberConstructor(
js-implicit context: NativeContext, receiver: JSAny, newTarget: JSAny,
target: JSFunction)(...arguments): JSAny {
// 1. If no arguments were passed to this function invocation, let n be +0.
let n: Number = 0;
if (arguments.length > 0) {
// 2. Else,
// a. Let prim be ? ToNumeric(value).
// b. If Type(prim) is BigInt, let n be the Number value for prim.
// c. Otherwise, let n be prim.
const value = arguments[0];
n = ToNumber(value, BigIntHandling::kConvertToNumber);
}
// 3. If NewTarget is undefined, return n.
if (newTarget == Undefined) return n;
// 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
// "%NumberPrototype%", « [[NumberData]] »).
// 5. Set O.[[NumberData]] to n.
// 6. Return O.
// We ignore the normal target parameter and load the value from the
// current frame here in order to reduce register pressure on the fast path.
const target: JSFunction = LoadTargetFromFrame();
const result = UnsafeCast<JSPrimitiveWrapper>(
FastNewObject(context, target, UnsafeCast<JSReceiver>(newTarget)));
result.value = n;
return result;
}
javascript builtin
GenericLazyDeoptContinuation(js-implicit context: NativeContext)(result: JSAny):
JSAny {
return result;
}
} // namespace constructor

View File

@ -36,7 +36,7 @@ HasAccessCheckFailed(implicit context: Context)(
return false;
}
extern macro ConstructorBuiltinsAssembler::EmitFastNewObject(
extern macro ConstructorBuiltinsAssembler::FastNewObject(
Context, JSFunction, JSReceiver): JSObject;
extern macro
@ -70,8 +70,8 @@ PromiseConstructor(
if (promiseFun == newTarget) {
result = NewJSPromise();
} else {
result = UnsafeCast<JSPromise>(EmitFastNewObject(
context, promiseFun, UnsafeCast<JSReceiver>(newTarget)));
result = UnsafeCast<JSPromise>(
FastNewObject(context, promiseFun, UnsafeCast<JSReceiver>(newTarget)));
PromiseInit(result);
if (IsPromiseHookEnabledOrHasAsyncEventDelegate()) {
runtime::PromiseHookInit(result, Undefined);

View File

@ -46,11 +46,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return r1;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return r0; }
const Register LoadDescriptor::ReceiverRegister() { return r1; }
const Register LoadDescriptor::NameRegister() { return r2; }
const Register LoadDescriptor::SlotRegister() { return r0; }

View File

@ -46,11 +46,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return x1;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return x0; }
const Register LoadDescriptor::ReceiverRegister() { return x1; }
const Register LoadDescriptor::NameRegister() { return x2; }
const Register LoadDescriptor::SlotRegister() { return x0; }

View File

@ -49,11 +49,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return edi;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return eax; }
const Register LoadDescriptor::ReceiverRegister() { return edx; }
const Register LoadDescriptor::NameRegister() { return ecx; }
const Register LoadDescriptor::SlotRegister() { return eax; }

View File

@ -177,12 +177,6 @@ void InterpreterCEntry2Descriptor::InitializePlatformSpecific(
InterpreterCEntryDescriptor_InitializePlatformSpecific(data);
}
void FastNewFunctionContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ScopeInfoRegister(), SlotsRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {TargetRegister(), NewTargetRegister()};

View File

@ -59,7 +59,6 @@ namespace internal {
V(ContextOnly) \
V(CppBuiltinAdaptor) \
V(EphemeronKeyBarrier) \
V(FastNewFunctionContext) \
V(FastNewObject) \
V(FrameDropperTrampoline) \
V(GetIteratorStackParameter) \
@ -837,17 +836,6 @@ class LoadGlobalWithVectorDescriptor : public LoadGlobalDescriptor {
#endif
};
class FastNewFunctionContextDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kScopeInfo, kSlots)
DEFINE_PARAMETER_TYPES(MachineType::AnyTagged(), // kScopeInfo
MachineType::Uint32()) // kSlots
DECLARE_DESCRIPTOR(FastNewFunctionContextDescriptor, CallInterfaceDescriptor)
static const Register ScopeInfoRegister();
static const Register SlotsRegister();
};
class FastNewObjectDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kTarget, kNewTarget)

View File

@ -72,11 +72,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return a1;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return a0; }
const Register LoadDescriptor::ReceiverRegister() { return a1; }
const Register LoadDescriptor::NameRegister() { return a2; }
const Register LoadDescriptor::SlotRegister() { return a0; }

View File

@ -72,11 +72,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return a1;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return a0; }
const Register LoadDescriptor::ReceiverRegister() { return a1; }
const Register LoadDescriptor::NameRegister() { return a2; }
const Register LoadDescriptor::SlotRegister() { return a0; }

View File

@ -46,11 +46,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return r4;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return r3; }
const Register LoadDescriptor::ReceiverRegister() { return r4; }
const Register LoadDescriptor::NameRegister() { return r5; }
const Register LoadDescriptor::SlotRegister() { return r3; }

View File

@ -46,11 +46,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return r3;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return r2; }
const Register LoadDescriptor::ReceiverRegister() { return r3; }
const Register LoadDescriptor::NameRegister() { return r4; }
const Register LoadDescriptor::SlotRegister() { return r2; }

View File

@ -48,11 +48,6 @@ void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
return rdi;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return rax; }
const Register LoadDescriptor::ReceiverRegister() { return rdx; }
const Register LoadDescriptor::NameRegister() { return rcx; }
const Register LoadDescriptor::SlotRegister() { return rax; }

View File

@ -2239,8 +2239,8 @@ IGNITION_HANDLER(CreateRegExpLiteral, InterpreterAssembler) {
TVARIABLE(JSRegExp, result);
ConstructorBuiltinsAssembler constructor_assembler(state());
result = constructor_assembler.EmitCreateRegExpLiteral(
feedback_vector, slot, pattern, flags, context);
result = constructor_assembler.CreateRegExpLiteral(feedback_vector, slot,
pattern, flags, context);
SetAccumulator(result.value());
Dispatch();
}
@ -2266,9 +2266,9 @@ IGNITION_HANDLER(CreateArrayLiteral, InterpreterAssembler) {
BIND(&fast_shallow_clone);
{
ConstructorBuiltinsAssembler constructor_assembler(state());
TNode<JSArray> result = constructor_assembler.EmitCreateShallowArrayLiteral(
CAST(feedback_vector), slot, context, &call_runtime,
TRACK_ALLOCATION_SITE);
TNode<JSArray> result = constructor_assembler.CreateShallowArrayLiteral(
CAST(feedback_vector), slot, context, TRACK_ALLOCATION_SITE,
&call_runtime);
SetAccumulator(result);
Dispatch();
}
@ -2301,7 +2301,7 @@ IGNITION_HANDLER(CreateEmptyArrayLiteral, InterpreterAssembler) {
GotoIf(IsUndefined(maybe_feedback_vector), &no_feedback);
ConstructorBuiltinsAssembler constructor_assembler(state());
result = constructor_assembler.EmitCreateEmptyArrayLiteral(
result = constructor_assembler.CreateEmptyArrayLiteral(
CAST(maybe_feedback_vector), slot, context);
Goto(&end);
@ -2356,9 +2356,8 @@ IGNITION_HANDLER(CreateObjectLiteral, InterpreterAssembler) {
{
// If we can do a fast clone do the fast-path in CreateShallowObjectLiteral.
ConstructorBuiltinsAssembler constructor_assembler(state());
TNode<HeapObject> result =
constructor_assembler.EmitCreateShallowObjectLiteral(
CAST(feedback_vector), slot, &if_not_fast_clone);
TNode<HeapObject> result = constructor_assembler.CreateShallowObjectLiteral(
CAST(feedback_vector), slot, &if_not_fast_clone);
SetAccumulator(result);
Dispatch();
}
@ -2391,7 +2390,7 @@ IGNITION_HANDLER(CreateEmptyObjectLiteral, InterpreterAssembler) {
TNode<Context> context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state());
TNode<JSObject> result =
constructor_assembler.EmitCreateEmptyObjectLiteral(context);
constructor_assembler.CreateEmptyObjectLiteral(context);
SetAccumulator(result);
Dispatch();
}
@ -2521,7 +2520,7 @@ IGNITION_HANDLER(CreateFunctionContext, InterpreterAssembler) {
TNode<Uint32T> slots = BytecodeOperandUImm(1);
TNode<Context> context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state());
SetAccumulator(constructor_assembler.EmitFastNewFunctionContext(
SetAccumulator(constructor_assembler.FastNewFunctionContext(
scope_info, slots, context, FUNCTION_SCOPE));
Dispatch();
}
@ -2535,7 +2534,7 @@ IGNITION_HANDLER(CreateEvalContext, InterpreterAssembler) {
TNode<Uint32T> slots = BytecodeOperandUImm(1);
TNode<Context> context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state());
SetAccumulator(constructor_assembler.EmitFastNewFunctionContext(
SetAccumulator(constructor_assembler.FastNewFunctionContext(
scope_info, slots, context, EVAL_SCOPE));
Dispatch();
}