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 13411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13422 Handle<Object> caller = args.at<Object>(1); | 13422 Handle<Object> caller = args.at<Object>(1); |
13423 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); | 13423 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); |
13424 | 13424 |
13425 // Optionally capture a more detailed stack trace for the message. | 13425 // Optionally capture a more detailed stack trace for the message. |
13426 isolate->CaptureAndSetDetailedStackTrace(error_object); | 13426 isolate->CaptureAndSetDetailedStackTrace(error_object); |
13427 // Capture a simple stack trace for the stack property. | 13427 // Capture a simple stack trace for the stack property. |
13428 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); | 13428 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); |
13429 } | 13429 } |
13430 | 13430 |
13431 | 13431 |
13432 // Mark a function to recognize when called after GC to format the stack trace. | 13432 // Retrieve the stack trace. This is the raw stack trace that yet has to |
13433 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) { | 13433 // be formatted. Since we only need this once, clear it afterwards. |
13434 HandleScope scope(isolate); | 13434 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { |
13435 ASSERT_EQ(args.length(), 1); | |
13436 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | |
13437 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); | |
13438 JSObject::SetHiddenProperty(fun, key, key); | |
13439 return *fun; | |
13440 } | |
13441 | |
13442 | |
13443 // Retrieve the stack trace. This could be the raw stack trace collected | |
13444 // on stack overflow or the already formatted stack trace string. | |
13445 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) { | |
13446 HandleScope scope(isolate); | 13435 HandleScope scope(isolate); |
13447 ASSERT_EQ(args.length(), 1); | 13436 ASSERT_EQ(args.length(), 1); |
13448 CONVERT_ARG_CHECKED(JSObject, error_object, 0); | 13437 CONVERT_ARG_CHECKED(JSObject, error_object, 0); |
13449 String* key = isolate->heap()->hidden_stack_trace_string(); | 13438 String* key = isolate->heap()->hidden_stack_trace_string(); |
13450 Object* result = error_object->GetHiddenProperty(key); | 13439 Object* result = error_object->GetHiddenProperty(key); |
13451 if (result->IsTheHole()) result = isolate->heap()->undefined_value(); | 13440 if (result->IsTheHole()) return isolate->heap()->undefined_value(); |
13452 RUNTIME_ASSERT(result->IsJSArray() || | 13441 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); |
13453 result->IsString() || | 13442 error_object->DeleteHiddenProperty(key); |
13454 result->IsUndefined()); | |
13455 return result; | 13443 return result; |
13456 } | 13444 } |
13457 | 13445 |
13458 | 13446 |
13459 // Set or clear the stack trace attached to an stack overflow error object. | |
13460 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetOverflowedStackTrace) { | |
13461 HandleScope scope(isolate); | |
13462 ASSERT_EQ(args.length(), 2); | |
13463 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | |
13464 CONVERT_ARG_HANDLE_CHECKED(HeapObject, value, 1); | |
13465 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); | |
13466 if (value->IsUndefined()) { | |
13467 error_object->DeleteHiddenProperty(*key); | |
13468 } else { | |
13469 RUNTIME_ASSERT(value->IsString()); | |
13470 JSObject::SetHiddenProperty(error_object, key, value); | |
13471 } | |
13472 return *error_object; | |
13473 } | |
13474 | |
13475 | |
13476 // Returns V8 version as a string. | 13447 // Returns V8 version as a string. |
13477 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 13448 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
13478 SealHandleScope shs(isolate); | 13449 SealHandleScope shs(isolate); |
13479 ASSERT_EQ(args.length(), 0); | 13450 ASSERT_EQ(args.length(), 0); |
13480 | 13451 |
13481 const char* version_string = v8::V8::GetVersion(); | 13452 const char* version_string = v8::V8::GetVersion(); |
13482 | 13453 |
13483 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), | 13454 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), |
13484 NOT_TENURED); | 13455 NOT_TENURED); |
13485 } | 13456 } |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13979 // Handle last resort GC and make sure to allow future allocations | 13950 // Handle last resort GC and make sure to allow future allocations |
13980 // to grow the heap without causing GCs (if possible). | 13951 // to grow the heap without causing GCs (if possible). |
13981 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13952 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13982 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13953 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13983 "Runtime::PerformGC"); | 13954 "Runtime::PerformGC"); |
13984 } | 13955 } |
13985 } | 13956 } |
13986 | 13957 |
13987 | 13958 |
13988 } } // namespace v8::internal | 13959 } } // namespace v8::internal |
OLD | NEW |