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

Unified Diff: src/messages.cc

Issue 2161953003: Remove stack overflow boilerplate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Satisfy older mips/arm gcc versions 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 | « src/messages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.cc
diff --git a/src/messages.cc b/src/messages.cc
index c007f069dda69ff51f963f53a6600cb72edec7c2..3213d2cbb93b0160fb174609840fe7efae656f89 100644
--- a/src/messages.cc
+++ b/src/messages.cc
@@ -5,6 +5,7 @@
#include "src/messages.h"
#include "src/api.h"
+#include "src/bootstrapper.h"
#include "src/execution.h"
#include "src/isolate-inl.h"
#include "src/keys.h"
@@ -445,6 +446,52 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
return builder.Finish();
}
+MaybeHandle<Object> ConstructError(Isolate* isolate, Handle<JSFunction> target,
+ Handle<Object> new_target,
+ Handle<Object> message, FrameSkipMode mode,
+ bool suppress_detailed_trace) {
+ // 1. If NewTarget is undefined, let newTarget be the active function object,
+ // else let newTarget be NewTarget.
+
+ Handle<JSReceiver> new_target_recv =
+ new_target->IsJSReceiver() ? Handle<JSReceiver>::cast(new_target)
+ : Handle<JSReceiver>::cast(target);
+
+ // 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%ErrorPrototype%",
+ // « [[ErrorData]] »).
+ Handle<JSObject> err;
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, err,
+ JSObject::New(target, new_target_recv), Object);
+
+ // 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.
+
+ if (!message->IsUndefined(isolate)) {
+ Handle<String> msg_string;
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, msg_string,
+ Object::ToString(isolate, message), Object);
+ RETURN_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
+ err, isolate->factory()->message_string(),
+ msg_string, DONT_ENUM),
+ Object);
+ }
+
+ // Optionally capture a more detailed stack trace for the message.
+ if (!suppress_detailed_trace) {
+ RETURN_ON_EXCEPTION(isolate, isolate->CaptureAndSetDetailedStackTrace(err),
+ Object);
+ }
+ // Capture a simple stack trace for the stack property.
+ RETURN_ON_EXCEPTION(isolate, isolate->CaptureAndSetSimpleStackTrace(
+ err, mode, Handle<Object>()),
+ Object);
+
+ return err;
+}
} // namespace internal
} // namespace v8
« no previous file with comments | « src/messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698