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

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

Issue 2161953003: Remove stack overflow boilerplate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | src/contexts.h » ('j') | src/isolate.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-error.cc
diff --git a/src/builtins/builtins-error.cc b/src/builtins/builtins-error.cc
index d798a5fca90ff8c341fb8bc62401e91d0ca31775..d1072d29e05bbad629bad5f41e95f0b7b6668628 100644
--- a/src/builtins/builtins-error.cc
+++ b/src/builtins/builtins-error.cc
@@ -7,6 +7,7 @@
#include "src/accessors.h"
#include "src/bootstrapper.h"
+#include "src/messages.h"
#include "src/property-descriptor.h"
#include "src/string-builder.h"
@@ -16,53 +17,9 @@ namespace internal {
// ES6 section 19.5.1.1 Error ( message )
BUILTIN(ErrorConstructor) {
HandleScope scope(isolate);
-
- // 1. If NewTarget is undefined, let newTarget be the active function object,
- // else let newTarget be NewTarget.
-
- Handle<JSFunction> target = args.target<JSFunction>();
- Handle<JSReceiver> new_target;
- if (args.new_target()->IsJSReceiver()) {
- new_target = Handle<JSReceiver>::cast(args.new_target());
- } else {
- new_target = target;
- }
-
- // 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%ErrorPrototype%",
- // « [[ErrorData]] »).
- Handle<JSObject> err;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, err,
- JSObject::New(target, new_target));
-
- // 3. If message is not undefined, then
- // a. Let msg be ? ToString(message).
- // b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]:
- // true, [[Enumerable]]: false, [[Configurable]]: true}.
- // c. Perform ! DefinePropertyOrThrow(O, "message", msgDesc).
- // 4. Return O.
-
- Handle<Object> msg = args.atOrUndefined(isolate, 1);
- if (!msg->IsUndefined(isolate)) {
- Handle<String> msg_string;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, msg_string,
- Object::ToString(isolate, msg));
- RETURN_FAILURE_ON_EXCEPTION(
- isolate,
- JSObject::SetOwnPropertyIgnoreAttributes(
- err, isolate->factory()->message_string(), msg_string, DONT_ENUM));
- }
-
- // Capture the stack trace unless we're setting up.
- if (!isolate->bootstrapper()->IsActive()) {
- // Optionally capture a more detailed stack trace for the message.
- RETURN_FAILURE_ON_EXCEPTION(isolate,
- isolate->CaptureAndSetDetailedStackTrace(err));
- // Capture a simple stack trace for the stack property.
- RETURN_FAILURE_ON_EXCEPTION(isolate,
- isolate->CaptureAndSetSimpleStackTrace(err));
- }
-
- return *err;
+ return ConstructError(isolate, args.target<JSFunction>(),
+ Handle<Object>::cast(args.new_target()),
+ args.atOrUndefined(isolate, 1));
}
// static
« no previous file with comments | « no previous file | src/contexts.h » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698