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 10828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12958 // Determines whether the given stack frame should be displayed in | 12957 // Determines whether the given stack frame should be displayed in |
12959 // a stack trace. The caller is the error constructor that asked | 12958 // a stack trace. The caller is the error constructor that asked |
12960 // for the stack trace to be collected. The first time a construct | 12959 // for the stack trace to be collected. The first time a construct |
12961 // call to this function is encountered it is skipped. The seen_caller | 12960 // call to this function is encountered it is skipped. The seen_caller |
12962 // in/out parameter is used to remember if the caller has been seen | 12961 // in/out parameter is used to remember if the caller has been seen |
12963 // yet. | 12962 // yet. |
12964 static bool ShowFrameInStackTrace(StackFrame* raw_frame, | 12963 static bool ShowFrameInStackTrace(StackFrame* raw_frame, |
12965 Object* caller, | 12964 Object* caller, |
12966 bool* seen_caller) { | 12965 bool* seen_caller) { |
12967 // Only display JS frames. | 12966 // Only display JS frames. |
12968 if (!raw_frame->is_java_script()) | 12967 if (!raw_frame->is_java_script()) { |
12969 return false; | 12968 return false; |
12969 } | |
12970 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 12970 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
12971 Object* raw_fun = frame->function(); | 12971 Object* raw_fun = frame->function(); |
12972 // Not sure when this can happen but skip it just in case. | 12972 // Not sure when this can happen but skip it just in case. |
12973 if (!raw_fun->IsJSFunction()) | 12973 if (!raw_fun->IsJSFunction()) |
Rico
2011/10/20 12:17:33
well you added them above, so how about a pair of
Lasse Reichstein
2011/10/20 12:26:09
Absolutely.
| |
12974 return false; | 12974 return false; |
12975 if ((raw_fun == caller) && !(*seen_caller)) { | 12975 if ((raw_fun == caller) && !(*seen_caller)) { |
12976 *seen_caller = true; | 12976 *seen_caller = true; |
12977 return false; | 12977 return false; |
12978 } | 12978 } |
12979 // Skip all frames until we've seen the caller. | 12979 // Skip all frames until we've seen the caller. |
12980 if (!(*seen_caller)) return false; | 12980 if (!(*seen_caller)) return false; |
12981 // Also, skip the most obvious builtin calls. We recognize builtins | 12981 // Also, skip non-visible built-in functions and any call with the builtins |
12982 // as (1) functions called with the builtins object as the receiver and | 12982 // object as receiver, so as to not reveal either the builtins object or |
12983 // as (2) functions from native scripts called with undefined as the | 12983 // an internal function. |
12984 // receiver (direct calls to helper functions in the builtins | 12984 // The --builtins-in-stack-traces command line flag allows including |
Rico
2011/10/20 12:17:33
--builtins-in-stack-traces -> --builtins-in-stack-
Lasse Reichstein
2011/10/20 12:26:09
I'm renaming it to -trace*s*. I've misspelled it c
| |
12985 // code). Some builtin calls (such as Number.ADD which is invoked | 12985 // internal call sites in the stack trace for debugging purposes. |
12986 // using 'call') are very difficult to recognize so we're leaving | 12986 if (!FLAG_builtins_in_stack_trace) { |
12987 // them in for now. | 12987 JSFunction* fun = JSFunction::cast(raw_fun); |
12988 if (frame->receiver()->IsJSBuiltinsObject()) { | 12988 if (frame->receiver()->IsJSBuiltinsObject() || |
12989 return false; | 12989 (fun->IsBuiltin() && !fun->shared()->native())) { |
12990 } | 12990 return false; |
12991 JSFunction* fun = JSFunction::cast(raw_fun); | 12991 } |
12992 Object* raw_script = fun->shared()->script(); | |
12993 if (frame->receiver()->IsUndefined() && raw_script->IsScript()) { | |
12994 int script_type = Script::cast(raw_script)->type()->value(); | |
12995 return script_type != Script::TYPE_NATIVE; | |
12996 } | 12992 } |
12997 return true; | 12993 return true; |
12998 } | 12994 } |
12999 | 12995 |
13000 | 12996 |
13001 // Collect the raw data for a stack trace. Returns an array of 4 | 12997 // Collect the raw data for a stack trace. Returns an array of 4 |
13002 // element segments each containing a receiver, function, code and | 12998 // element segments each containing a receiver, function, code and |
13003 // native code offset. | 12999 // native code offset. |
13004 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { | 13000 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { |
13005 ASSERT_EQ(args.length(), 2); | 13001 ASSERT_EQ(args.length(), 2); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13386 } else { | 13382 } else { |
13387 // Handle last resort GC and make sure to allow future allocations | 13383 // Handle last resort GC and make sure to allow future allocations |
13388 // to grow the heap without causing GCs (if possible). | 13384 // to grow the heap without causing GCs (if possible). |
13389 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13385 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13390 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13386 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13391 } | 13387 } |
13392 } | 13388 } |
13393 | 13389 |
13394 | 13390 |
13395 } } // namespace v8::internal | 13391 } } // namespace v8::internal |
OLD | NEW |