| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 RUNTIME_ASSERT(code->IsJSFunction()); | 2109 RUNTIME_ASSERT(code->IsJSFunction()); |
| 2110 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); | 2110 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); |
| 2111 Handle<SharedFunctionInfo> shared(fun->shared()); | 2111 Handle<SharedFunctionInfo> shared(fun->shared()); |
| 2112 | 2112 |
| 2113 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) { | 2113 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) { |
| 2114 return Failure::Exception(); | 2114 return Failure::Exception(); |
| 2115 } | 2115 } |
| 2116 // Since we don't store the source for this we should never | 2116 // Since we don't store the source for this we should never |
| 2117 // optimize this. | 2117 // optimize this. |
| 2118 shared->code()->set_optimizable(false); | 2118 shared->code()->set_optimizable(false); |
| 2119 | |
| 2120 // Set the code, scope info, formal parameter count, | 2119 // Set the code, scope info, formal parameter count, |
| 2121 // and the length of the target function. | 2120 // and the length of the target function. |
| 2122 target->shared()->set_code(shared->code()); | 2121 target->shared()->set_code(shared->code()); |
| 2123 target->ReplaceCode(shared->code()); | 2122 target->ReplaceCode(shared->code()); |
| 2124 target->shared()->set_scope_info(shared->scope_info()); | 2123 target->shared()->set_scope_info(shared->scope_info()); |
| 2125 target->shared()->set_length(shared->length()); | 2124 target->shared()->set_length(shared->length()); |
| 2126 target->shared()->set_formal_parameter_count( | 2125 target->shared()->set_formal_parameter_count( |
| 2127 shared->formal_parameter_count()); | 2126 shared->formal_parameter_count()); |
| 2128 // Set the source code of the target function to undefined. | 2127 // Set the source code of the target function to undefined. |
| 2129 // SetCode is only used for built-in constructors like String, | 2128 // SetCode is only used for built-in constructors like String, |
| (...skipping 10787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12917 // Determines whether the given stack frame should be displayed in | 12916 // Determines whether the given stack frame should be displayed in |
| 12918 // a stack trace. The caller is the error constructor that asked | 12917 // a stack trace. The caller is the error constructor that asked |
| 12919 // for the stack trace to be collected. The first time a construct | 12918 // for the stack trace to be collected. The first time a construct |
| 12920 // call to this function is encountered it is skipped. The seen_caller | 12919 // call to this function is encountered it is skipped. The seen_caller |
| 12921 // in/out parameter is used to remember if the caller has been seen | 12920 // in/out parameter is used to remember if the caller has been seen |
| 12922 // yet. | 12921 // yet. |
| 12923 static bool ShowFrameInStackTrace(StackFrame* raw_frame, | 12922 static bool ShowFrameInStackTrace(StackFrame* raw_frame, |
| 12924 Object* caller, | 12923 Object* caller, |
| 12925 bool* seen_caller) { | 12924 bool* seen_caller) { |
| 12926 // Only display JS frames. | 12925 // Only display JS frames. |
| 12927 if (!raw_frame->is_java_script()) | 12926 if (!raw_frame->is_java_script()) { |
| 12928 return false; | 12927 return false; |
| 12928 } |
| 12929 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 12929 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
| 12930 Object* raw_fun = frame->function(); | 12930 Object* raw_fun = frame->function(); |
| 12931 // Not sure when this can happen but skip it just in case. | 12931 // Not sure when this can happen but skip it just in case. |
| 12932 if (!raw_fun->IsJSFunction()) | 12932 if (!raw_fun->IsJSFunction()) { |
| 12933 return false; | 12933 return false; |
| 12934 } |
| 12934 if ((raw_fun == caller) && !(*seen_caller)) { | 12935 if ((raw_fun == caller) && !(*seen_caller)) { |
| 12935 *seen_caller = true; | 12936 *seen_caller = true; |
| 12936 return false; | 12937 return false; |
| 12937 } | 12938 } |
| 12938 // Skip all frames until we've seen the caller. | 12939 // Skip all frames until we've seen the caller. |
| 12939 if (!(*seen_caller)) return false; | 12940 if (!(*seen_caller)) return false; |
| 12940 // Also, skip the most obvious builtin calls. We recognize builtins | 12941 // Also, skip non-visible built-in functions and any call with the builtins |
| 12941 // as (1) functions called with the builtins object as the receiver and | 12942 // object as receiver, so as to not reveal either the builtins object or |
| 12942 // as (2) functions from native scripts called with undefined as the | 12943 // an internal function. |
| 12943 // receiver (direct calls to helper functions in the builtins | 12944 // The --builtins-in-stack-traces command line flag allows including |
| 12944 // code). Some builtin calls (such as Number.ADD which is invoked | 12945 // internal call sites in the stack trace for debugging purposes. |
| 12945 // using 'call') are very difficult to recognize so we're leaving | 12946 if (!FLAG_builtins_in_stack_traces) { |
| 12946 // them in for now. | 12947 JSFunction* fun = JSFunction::cast(raw_fun); |
| 12947 if (frame->receiver()->IsJSBuiltinsObject()) { | 12948 if (frame->receiver()->IsJSBuiltinsObject() || |
| 12948 return false; | 12949 (fun->IsBuiltin() && !fun->shared()->native())) { |
| 12949 } | 12950 return false; |
| 12950 JSFunction* fun = JSFunction::cast(raw_fun); | 12951 } |
| 12951 Object* raw_script = fun->shared()->script(); | |
| 12952 if (frame->receiver()->IsUndefined() && raw_script->IsScript()) { | |
| 12953 int script_type = Script::cast(raw_script)->type()->value(); | |
| 12954 return script_type != Script::TYPE_NATIVE; | |
| 12955 } | 12952 } |
| 12956 return true; | 12953 return true; |
| 12957 } | 12954 } |
| 12958 | 12955 |
| 12959 | 12956 |
| 12960 // Collect the raw data for a stack trace. Returns an array of 4 | 12957 // Collect the raw data for a stack trace. Returns an array of 4 |
| 12961 // element segments each containing a receiver, function, code and | 12958 // element segments each containing a receiver, function, code and |
| 12962 // native code offset. | 12959 // native code offset. |
| 12963 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { | 12960 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { |
| 12964 ASSERT_EQ(args.length(), 2); | 12961 ASSERT_EQ(args.length(), 2); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13345 } else { | 13342 } else { |
| 13346 // Handle last resort GC and make sure to allow future allocations | 13343 // Handle last resort GC and make sure to allow future allocations |
| 13347 // to grow the heap without causing GCs (if possible). | 13344 // to grow the heap without causing GCs (if possible). |
| 13348 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13345 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13349 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13346 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13350 } | 13347 } |
| 13351 } | 13348 } |
| 13352 | 13349 |
| 13353 | 13350 |
| 13354 } } // namespace v8::internal | 13351 } } // namespace v8::internal |
| OLD | NEW |