Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 6a460e2412094dc2ec1fc5b7c2a02f38998b7f56..c0f324e30b42fd9d7955ce687638d4157fda6f74 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -13219,19 +13219,49 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { |
} |
-// Retrieve the raw stack trace collected on stack overflow and delete |
-// it since it is used only once to avoid keeping it alive. |
-RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedRawStackTrace) { |
+// Mark a function to recognize when called after GC to format the stack trace. |
+RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) { |
+ ASSERT_EQ(args.length(), 1); |
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
+ HandleScope scope(isolate); |
+ Handle<String> key = isolate->factory()->hidden_stack_trace_symbol(); |
+ JSObject::SetHiddenProperty(fun, key, key); |
+ return *fun; |
+} |
+ |
+ |
+// Retrieve the stack trace. This could be the raw stack trace collected |
+// on stack overflow or the already formatted stack trace string. |
+RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) { |
+ HandleScope scope(isolate); |
ASSERT_EQ(args.length(), 1); |
CONVERT_ARG_CHECKED(JSObject, error_object, 0); |
String* key = isolate->heap()->hidden_stack_trace_symbol(); |
Object* result = error_object->GetHiddenProperty(key); |
- RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); |
- error_object->DeleteHiddenProperty(key); |
+ RUNTIME_ASSERT(result->IsJSArray() || |
+ result->IsString() || |
+ result->IsUndefined()); |
return result; |
} |
+// Set or clear the stack trace attached to an stack overflow error object. |
+RUNTIME_FUNCTION(MaybeObject*, Runtime_SetOverflowedStackTrace) { |
+ HandleScope scope(isolate); |
+ ASSERT_EQ(args.length(), 2); |
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(HeapObject, value, 1); |
+ Handle<String> key = isolate->factory()->hidden_stack_trace_symbol(); |
+ if (value->IsUndefined()) { |
+ error_object->DeleteHiddenProperty(*key); |
+ } else { |
+ RUNTIME_ASSERT(value->IsString()); |
+ JSObject::SetHiddenProperty(error_object, key, value); |
+ } |
+ return *error_object; |
+} |
+ |
+ |
// Returns V8 version as a string. |
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
ASSERT_EQ(args.length(), 0); |