| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13199 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); | 13199 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); |
| 13200 | 13200 |
| 13201 HandleScope scope(isolate); | 13201 HandleScope scope(isolate); |
| 13202 // Optionally capture a more detailed stack trace for the message. | 13202 // Optionally capture a more detailed stack trace for the message. |
| 13203 isolate->CaptureAndSetDetailedStackTrace(error_object); | 13203 isolate->CaptureAndSetDetailedStackTrace(error_object); |
| 13204 // Capture a simple stack trace for the stack property. | 13204 // Capture a simple stack trace for the stack property. |
| 13205 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); | 13205 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); |
| 13206 } | 13206 } |
| 13207 | 13207 |
| 13208 | 13208 |
| 13209 // Mark a function to recognize when called after GC to format the stack trace. | 13209 // Retrieve the raw stack trace collected on stack overflow and delete |
| 13210 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) { | 13210 // it since it is used only once to avoid keeping it alive. |
| 13211 ASSERT_EQ(args.length(), 1); | 13211 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedRawStackTrace) { |
| 13212 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | |
| 13213 HandleScope scope(isolate); | |
| 13214 Handle<String> key = isolate->factory()->hidden_stack_trace_symbol(); | |
| 13215 JSObject::SetHiddenProperty(fun, key, key); | |
| 13216 return *fun; | |
| 13217 } | |
| 13218 | |
| 13219 | |
| 13220 // Retrieve the stack trace. This could be the raw stack trace collected | |
| 13221 // on stack overflow or the already formatted stack trace string. | |
| 13222 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) { | |
| 13223 HandleScope scope(isolate); | |
| 13224 ASSERT_EQ(args.length(), 1); | 13212 ASSERT_EQ(args.length(), 1); |
| 13225 CONVERT_ARG_CHECKED(JSObject, error_object, 0); | 13213 CONVERT_ARG_CHECKED(JSObject, error_object, 0); |
| 13226 String* key = isolate->heap()->hidden_stack_trace_symbol(); | 13214 String* key = isolate->heap()->hidden_stack_trace_symbol(); |
| 13227 Object* result = error_object->GetHiddenProperty(key); | 13215 Object* result = error_object->GetHiddenProperty(key); |
| 13228 RUNTIME_ASSERT(result->IsJSArray() || | 13216 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); |
| 13229 result->IsString() || | 13217 error_object->DeleteHiddenProperty(key); |
| 13230 result->IsUndefined()); | |
| 13231 return result; | 13218 return result; |
| 13232 } | 13219 } |
| 13233 | 13220 |
| 13234 | 13221 |
| 13235 // Set or clear the stack trace attached to an stack overflow error object. | |
| 13236 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetOverflowedStackTrace) { | |
| 13237 HandleScope scope(isolate); | |
| 13238 ASSERT_EQ(args.length(), 2); | |
| 13239 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | |
| 13240 CONVERT_ARG_HANDLE_CHECKED(HeapObject, value, 1); | |
| 13241 Handle<String> key = isolate->factory()->hidden_stack_trace_symbol(); | |
| 13242 if (value->IsUndefined()) { | |
| 13243 error_object->DeleteHiddenProperty(*key); | |
| 13244 } else { | |
| 13245 RUNTIME_ASSERT(value->IsString()); | |
| 13246 JSObject::SetHiddenProperty(error_object, key, value); | |
| 13247 } | |
| 13248 return *error_object; | |
| 13249 } | |
| 13250 | |
| 13251 | |
| 13252 // Returns V8 version as a string. | 13222 // Returns V8 version as a string. |
| 13253 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 13223 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
| 13254 ASSERT_EQ(args.length(), 0); | 13224 ASSERT_EQ(args.length(), 0); |
| 13255 | 13225 |
| 13256 NoHandleAllocation ha; | 13226 NoHandleAllocation ha; |
| 13257 | 13227 |
| 13258 const char* version_string = v8::V8::GetVersion(); | 13228 const char* version_string = v8::V8::GetVersion(); |
| 13259 | 13229 |
| 13260 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), | 13230 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), |
| 13261 NOT_TENURED); | 13231 NOT_TENURED); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13651 // Handle last resort GC and make sure to allow future allocations | 13621 // Handle last resort GC and make sure to allow future allocations |
| 13652 // to grow the heap without causing GCs (if possible). | 13622 // to grow the heap without causing GCs (if possible). |
| 13653 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13623 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13654 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13624 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13655 "Runtime::PerformGC"); | 13625 "Runtime::PerformGC"); |
| 13656 } | 13626 } |
| 13657 } | 13627 } |
| 13658 | 13628 |
| 13659 | 13629 |
| 13660 } } // namespace v8::internal | 13630 } } // namespace v8::internal |
| OLD | NEW |