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

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

Issue 2164903004: Eagerly format traces in captureStackTrace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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/accessors.cc ('k') | src/isolate.cc » ('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 0311f8c6827feb591e15aad3ca14f03ef393739f..25cd9a29e46326bd536f223520ff29f2a67c87c0 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/accessors.h"
#include "src/bootstrapper.h"
#include "src/messages.h"
#include "src/property-descriptor.h"
@@ -36,67 +35,24 @@ BUILTIN(ErrorCaptureStackTrace) {
Handle<Object> caller = args.atOrUndefined(isolate, 2);
FrameSkipMode mode = caller->IsJSFunction() ? SKIP_UNTIL_SEEN : SKIP_NONE;
- // TODO(jgruber): Eagerly format the stack trace and remove accessors.h
- // include.
-
- // Handle writes to the global object.
-
- if (object->IsJSGlobalProxy()) {
- Map* map = object->map();
- if (map->has_hidden_prototype()) {
- object = handle(JSGlobalObject::cast(map->prototype()), isolate);
- }
- }
-
- // Check if the stack property is read-only.
-
- bool is_extensible = true;
- if (!JSObject::IsExtensible(object)) {
- is_extensible = false;
- }
+ // Collect the stack trace.
- PropertyDescriptor desc;
- Maybe<bool> owned = JSReceiver::GetOwnPropertyDescriptor(
- isolate, object, isolate->factory()->stack_string(), &desc);
- if (owned.FromMaybe(false)) {
- if (!desc.configurable() || !desc.writable()) {
- is_extensible = false;
- }
- }
+ RETURN_FAILURE_ON_EXCEPTION(isolate,
+ isolate->CaptureAndSetDetailedStackTrace(object));
- if (!is_extensible) {
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewTypeError(MessageTemplate::kDefineDisallowed,
- isolate->factory()->stack_string(), object));
- }
+ // Eagerly format the stack trace and set the stack property.
- // Add stack accessors to the given object
-
- Handle<Map> map(object->map());
- PropertyAttributes attribs = DONT_ENUM;
- Handle<AccessorInfo> error_stack =
- Accessors::ErrorStackInfo(isolate, attribs);
- {
- AccessorConstantDescriptor d(Handle<Name>(Name::cast(error_stack->name())),
- error_stack, attribs);
- Handle<DescriptorArray> old_descriptors(map->instance_descriptors());
- int index = old_descriptors->SearchWithCache(isolate, *d.GetKey(), *map);
- if (index == DescriptorArray::kNotFound) {
- // TODO(jgruber): This ensures we do not crash when CaptureStackTrace is
- // called on an object with an existing "stack" property. This will be
- // removed as soon as we move to eager trace formatting.
- Handle<Map> new_map =
- Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION);
- JSObject::MigrateToMap(object, new_map, 1);
- }
- }
+ Handle<Object> stack_trace =
+ isolate->CaptureSimpleStackTrace(object, mode, caller);
- // Collect the stack trace.
+ Handle<Object> formatted_stack_trace;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, formatted_stack_trace,
+ FormatStackTrace(isolate, object, stack_trace));
- RETURN_FAILURE_ON_EXCEPTION(isolate,
- isolate->CaptureAndSetDetailedStackTrace(object));
RETURN_FAILURE_ON_EXCEPTION(
- isolate, isolate->CaptureAndSetSimpleStackTrace(object, mode, caller));
+ isolate, JSObject::SetProperty(object, isolate->factory()->stack_string(),
+ formatted_stack_trace, STRICT));
return *isolate->factory()->undefined_value();
}
« no previous file with comments | « src/accessors.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698