Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: src/builtins/builtins-error.cc

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/builtins/builtins-error.cc
diff --git a/src/builtins/builtins-error.cc b/src/builtins/builtins-error.cc
index 66293ee9ac0d02c875325cfb2585c6de99b5adc9..c9150b85159237ebb7ea13b4fc4e78311410c74f 100644
--- a/src/builtins/builtins-error.cc
+++ b/src/builtins/builtins-error.cc
@@ -81,23 +81,54 @@ BUILTIN(ErrorPrototypeToString) {
ErrorUtils::ToString(isolate, args.receiver()));
}
-BUILTIN(MakeGenericError) {
- HandleScope scope(isolate);
+namespace {
- Handle<Object> constructor = args.atOrUndefined(isolate, 1);
- Handle<Object> template_index = args.atOrUndefined(isolate, 2);
- Handle<Object> arg0 = args.atOrUndefined(isolate, 3);
- Handle<Object> arg1 = args.atOrUndefined(isolate, 4);
- Handle<Object> arg2 = args.atOrUndefined(isolate, 5);
+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(constructor->IsJSFunction());
DCHECK(template_index->IsSmi());
RETURN_RESULT_OR_FAILURE(
+ isolate, ErrorUtils::MakeGenericError(isolate, constructor,
+ Smi::cast(*template_index)->value(),
+ 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();
+ const int template_index = MessageTemplate::kURIMalformed;
+ RETURN_RESULT_OR_FAILURE(
isolate,
- ErrorUtils::MakeGenericError(
- isolate, Handle<JSFunction>::cast(constructor),
- Smi::cast(*template_index)->value(), arg0, arg1, arg2, SKIP_FIRST));
+ ErrorUtils::MakeGenericError(isolate, constructor, template_index,
+ undefined, undefined, undefined, SKIP_NONE));
}
} // namespace internal
« src/bootstrapper.cc ('K') | « src/builtins/builtins.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698