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

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

Issue 2191293002: Move FormatStackTrace to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add formatting_stack_trace to ISOLATE_INIT_LIST 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/builtins/builtins-callsite.cc ('k') | src/contexts.h » ('j') | no next file with comments »
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 3176f13f21307db5b6c499893aa3e468d3922d3e..43637060110df21c8ff878fcd197ec5c32212203 100644
--- a/src/builtins/builtins-error.cc
+++ b/src/builtins/builtins-error.cc
@@ -5,7 +5,6 @@
#include "src/builtins/builtins.h"
#include "src/builtins/builtins-utils.h"
-#include "src/bootstrapper.h"
#include "src/messages.h"
#include "src/property-descriptor.h"
#include "src/string-builder.h"
@@ -18,9 +17,9 @@ BUILTIN(ErrorConstructor) {
HandleScope scope(isolate);
RETURN_RESULT_OR_FAILURE(
isolate,
- ConstructError(isolate, args.target<JSFunction>(),
- Handle<Object>::cast(args.new_target()),
- args.atOrUndefined(isolate, 1), SKIP_FIRST, false));
+ ErrorUtils::Construct(isolate, args.target<JSFunction>(),
+ Handle<Object>::cast(args.new_target()),
+ args.atOrUndefined(isolate, 1), SKIP_FIRST, false));
}
// static
@@ -63,69 +62,11 @@ BUILTIN(ErrorCaptureStackTrace) {
return isolate->heap()->undefined_value();
}
-namespace {
-
-MaybeHandle<String> GetStringPropertyOrDefault(Isolate* isolate,
- Handle<JSReceiver> recv,
- Handle<String> key,
- Handle<String> default_str) {
- Handle<Object> obj;
- ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, JSObject::GetProperty(recv, key),
- String);
-
- Handle<String> str;
- if (obj->IsUndefined(isolate)) {
- str = default_str;
- } else {
- ASSIGN_RETURN_ON_EXCEPTION(isolate, str, Object::ToString(isolate, obj),
- String);
- }
-
- return str;
-}
-
-} // namespace
-
// ES6 section 19.5.3.4 Error.prototype.toString ( )
BUILTIN(ErrorPrototypeToString) {
HandleScope scope(isolate);
-
- // 1. Let O be the this value.
- // 2. If Type(O) is not Object, throw a TypeError exception.
- CHECK_RECEIVER(JSReceiver, receiver, "Error.prototype.toString");
-
- // 3. Let name be ? Get(O, "name").
- // 4. If name is undefined, let name be "Error"; otherwise let name be
- // ? ToString(name).
- Handle<String> name_key = isolate->factory()->name_string();
- Handle<String> name_default = isolate->factory()->Error_string();
- Handle<String> name;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, name,
- GetStringPropertyOrDefault(isolate, receiver, name_key, name_default));
-
- // 5. Let msg be ? Get(O, "message").
- // 6. If msg is undefined, let msg be the empty String; otherwise let msg be
- // ? ToString(msg).
- Handle<String> msg_key = isolate->factory()->message_string();
- Handle<String> msg_default = isolate->factory()->empty_string();
- Handle<String> msg;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, msg,
- GetStringPropertyOrDefault(isolate, receiver, msg_key, msg_default));
-
- // 7. If name is the empty String, return msg.
- // 8. If msg is the empty String, return name.
- if (name->length() == 0) return *msg;
- if (msg->length() == 0) return *name;
-
- // 9. Return the result of concatenating name, the code unit 0x003A (COLON),
- // the code unit 0x0020 (SPACE), and msg.
- IncrementalStringBuilder builder(isolate);
- builder.AppendString(name);
- builder.AppendCString(": ");
- builder.AppendString(msg);
- RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());
+ RETURN_RESULT_OR_FAILURE(isolate,
+ ErrorUtils::ToString(isolate, args.receiver()));
}
} // namespace internal
« no previous file with comments | « src/builtins/builtins-callsite.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698