Commit 5bf5b79f authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[cleanup] Remove unnecessary MakeFooError builtins

They were installed as builtins for historical reasons (see
https://codereview.chromium.org/2222893002 ).

But they're pretty much unnecessary, as they were mostly dead code,
except MakeTypeError - but that work can be delegated to Runtime_NewTypeError.

Change-Id: I0c3b361accf9a96da5cd00cc62b7f018186dad17
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2150597Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67164}
parent 32b6d39f
......@@ -498,11 +498,6 @@ namespace internal {
CPP(ErrorConstructor) \
CPP(ErrorCaptureStackTrace) \
CPP(ErrorPrototypeToString) \
CPP(MakeError) \
CPP(MakeRangeError) \
CPP(MakeSyntaxError) \
CPP(MakeTypeError) \
CPP(MakeURIError) \
\
/* Function */ \
CPP(FunctionConstructor) \
......
......@@ -85,53 +85,5 @@ BUILTIN(ErrorPrototypeToString) {
ErrorUtils::ToString(isolate, args.receiver()));
}
namespace {
Object MakeGenericError(Isolate* isolate, BuiltinArguments args,
Handle<JSFunction> constructor) {
Handle<Object> template_index = args.atOrUndefined(isolate, 1);
Handle<Object> arg0 = args.atOrUndefined(isolate, 2);
Handle<Object> arg1 = args.atOrUndefined(isolate, 3);
Handle<Object> arg2 = args.atOrUndefined(isolate, 4);
DCHECK(template_index->IsSmi());
return *ErrorUtils::MakeGenericError(
isolate, constructor, MessageTemplateFromInt(Smi::ToInt(*template_index)),
arg0, arg1, arg2, SKIP_NONE);
}
} // namespace
BUILTIN(MakeError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->error_function());
}
BUILTIN(MakeRangeError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->range_error_function());
}
BUILTIN(MakeSyntaxError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->syntax_error_function());
}
BUILTIN(MakeTypeError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->type_error_function());
}
BUILTIN(MakeURIError) {
HandleScope scope(isolate);
Handle<JSFunction> constructor = isolate->uri_error_function();
Handle<Object> undefined = isolate->factory()->undefined_value();
MessageTemplate template_index = MessageTemplate::kURIMalformed;
return *ErrorUtils::MakeGenericError(isolate, constructor, template_index,
undefined, undefined, undefined,
SKIP_NONE);
}
} // namespace internal
} // namespace v8
......@@ -3669,10 +3669,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<HeapObject> MakeTypeError(MessageTemplate message,
TNode<Context> context, TArgs... args) {
STATIC_ASSERT(sizeof...(TArgs) <= 3);
const TNode<Object> make_type_error = LoadContextElement(
LoadNativeContext(context), Context::MAKE_TYPE_ERROR_INDEX);
return CAST(Call(context, make_type_error, UndefinedConstant(),
SmiConstant(message), args...));
return CAST(CallRuntime(Runtime::kNewTypeError, context,
SmiConstant(message), args...));
}
void Abort(AbortReason reason) {
......
......@@ -782,11 +782,6 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
case Builtins::kFunctionPrototypeApply:
// Error builtins.
case Builtins::kErrorConstructor:
case Builtins::kMakeError:
case Builtins::kMakeTypeError:
case Builtins::kMakeSyntaxError:
case Builtins::kMakeRangeError:
case Builtins::kMakeURIError:
// RegExp builtins.
case Builtins::kRegExpConstructor:
// Internal.
......
......@@ -1396,20 +1396,6 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
}
}
namespace {
void InstallMakeError(Isolate* isolate, int builtin_id, int context_index) {
NewFunctionArgs args = NewFunctionArgs::ForBuiltinWithPrototype(
isolate->factory()->empty_string(), isolate->factory()->the_hole_value(),
JS_OBJECT_TYPE, JSObject::kHeaderSize, 0, builtin_id, MUTABLE);
Handle<JSFunction> function = isolate->factory()->NewFunction(args);
function->shared().DontAdaptArguments();
isolate->native_context()->set(context_index, *function);
}
} // namespace
// This is only called if we are not using snapshots. The equivalent
// work in the snapshot case is done in HookUpGlobalObject.
void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
......@@ -2703,49 +2689,33 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
regexp_string_iterator_function->initial_map());
}
{ // -- E r r o r
InstallError(isolate_, global, factory->Error_string(),
Context::ERROR_FUNCTION_INDEX);
InstallMakeError(isolate_, Builtins::kMakeError, Context::MAKE_ERROR_INDEX);
}
// -- E r r o r
InstallError(isolate_, global, factory->Error_string(),
Context::ERROR_FUNCTION_INDEX);
{ // -- E v a l E r r o r
InstallError(isolate_, global, factory->EvalError_string(),
Context::EVAL_ERROR_FUNCTION_INDEX);
}
// -- E v a l E r r o r
InstallError(isolate_, global, factory->EvalError_string(),
Context::EVAL_ERROR_FUNCTION_INDEX);
{ // -- R a n g e E r r o r
InstallError(isolate_, global, factory->RangeError_string(),
Context::RANGE_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate_, Builtins::kMakeRangeError,
Context::MAKE_RANGE_ERROR_INDEX);
}
// -- R a n g e E r r o r
InstallError(isolate_, global, factory->RangeError_string(),
Context::RANGE_ERROR_FUNCTION_INDEX);
{ // -- R e f e r e n c e E r r o r
InstallError(isolate_, global, factory->ReferenceError_string(),
Context::REFERENCE_ERROR_FUNCTION_INDEX);
}
// -- R e f e r e n c e E r r o r
InstallError(isolate_, global, factory->ReferenceError_string(),
Context::REFERENCE_ERROR_FUNCTION_INDEX);
{ // -- S y n t a x E r r o r
InstallError(isolate_, global, factory->SyntaxError_string(),
Context::SYNTAX_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate_, Builtins::kMakeSyntaxError,
Context::MAKE_SYNTAX_ERROR_INDEX);
}
// -- S y n t a x E r r o r
InstallError(isolate_, global, factory->SyntaxError_string(),
Context::SYNTAX_ERROR_FUNCTION_INDEX);
{ // -- T y p e E r r o r
InstallError(isolate_, global, factory->TypeError_string(),
Context::TYPE_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate_, Builtins::kMakeTypeError,
Context::MAKE_TYPE_ERROR_INDEX);
}
// -- T y p e E r r o r
InstallError(isolate_, global, factory->TypeError_string(),
Context::TYPE_ERROR_FUNCTION_INDEX);
{ // -- U R I E r r o r
InstallError(isolate_, global, factory->URIError_string(),
Context::URI_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate_, Builtins::kMakeURIError,
Context::MAKE_URI_ERROR_INDEX);
}
// -- U R I E r r o r
InstallError(isolate_, global, factory->URIError_string(),
Context::URI_ERROR_FUNCTION_INDEX);
{ // -- C o m p i l e E r r o r
Handle<JSObject> dummy = factory->NewJSObject(isolate_->object_function());
......
......@@ -42,11 +42,6 @@ enum ContextLookupFlags {
V(GENERATOR_NEXT_INTERNAL, JSFunction, generator_next_internal) \
V(ASYNC_MODULE_EVALUATE_INTERNAL, JSFunction, \
async_module_evaluate_internal) \
V(MAKE_ERROR_INDEX, JSFunction, make_error) \
V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error) \
V(MAKE_SYNTAX_ERROR_INDEX, JSFunction, make_syntax_error) \
V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error) \
V(MAKE_URI_ERROR_INDEX, JSFunction, make_uri_error) \
V(OBJECT_CREATE, JSFunction, object_create) \
V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply) \
V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \
......
......@@ -209,11 +209,29 @@ RUNTIME_FUNCTION(Runtime_NewError) {
RUNTIME_FUNCTION(Runtime_NewTypeError) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
DCHECK_LE(args.length(), 4);
DCHECK_GE(args.length(), 1);
CONVERT_INT32_ARG_CHECKED(template_index, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, arg0, 1);
MessageTemplate message_template = MessageTemplateFromInt(template_index);
return *isolate->factory()->NewTypeError(message_template, arg0);
Handle<Object> arg0;
if (args.length() >= 2) {
CHECK(args[1].IsObject());
arg0 = args.at<Object>(1);
}
Handle<Object> arg1;
if (args.length() >= 3) {
CHECK(args[2].IsObject());
arg1 = args.at<Object>(2);
}
Handle<Object> arg2;
if (args.length() >= 4) {
CHECK(args[3].IsObject());
arg2 = args.at<Object>(3);
}
return *isolate->factory()->NewTypeError(message_template, arg0, arg1, arg2);
}
RUNTIME_FUNCTION(Runtime_NewReferenceError) {
......
......@@ -222,7 +222,7 @@ namespace internal {
F(NewError, 2, 1) \
F(NewReferenceError, 2, 1) \
F(NewSyntaxError, 2, 1) \
F(NewTypeError, 2, 1) \
F(NewTypeError, -1 /* [1, 4] */, 1) \
F(OrdinaryHasInstance, 2, 1) \
F(PromoteScheduledException, 0, 1) \
F(ReportMessage, 1, 1) \
......
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