OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 7866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7877 // Collect the raw data for a stack trace. Returns an array of three | 7877 // Collect the raw data for a stack trace. Returns an array of three |
7878 // element segments each containing a receiver, function and native | 7878 // element segments each containing a receiver, function and native |
7879 // code offset. | 7879 // code offset. |
7880 static Object* Runtime_CollectStackTrace(Arguments args) { | 7880 static Object* Runtime_CollectStackTrace(Arguments args) { |
7881 ASSERT_EQ(args.length(), 2); | 7881 ASSERT_EQ(args.length(), 2); |
7882 Handle<Object> caller = args.at<Object>(0); | 7882 Handle<Object> caller = args.at<Object>(0); |
7883 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); | 7883 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); |
7884 | 7884 |
7885 HandleScope scope; | 7885 HandleScope scope; |
7886 | 7886 |
7887 int initial_size = limit < 10 ? limit : 10; | 7887 limit = Max(limit, 0); // Ensure that limit is not negative. |
| 7888 int initial_size = Min(limit, 10); |
7888 Handle<JSArray> result = Factory::NewJSArray(initial_size * 3); | 7889 Handle<JSArray> result = Factory::NewJSArray(initial_size * 3); |
7889 | 7890 |
7890 StackFrameIterator iter; | 7891 StackFrameIterator iter; |
7891 // If the caller parameter is a function we skip frames until we're | 7892 // If the caller parameter is a function we skip frames until we're |
7892 // under it before starting to collect. | 7893 // under it before starting to collect. |
7893 bool seen_caller = !caller->IsJSFunction(); | 7894 bool seen_caller = !caller->IsJSFunction(); |
7894 int cursor = 0; | 7895 int cursor = 0; |
7895 int frames_seen = 0; | 7896 int frames_seen = 0; |
7896 while (!iter.done() && frames_seen < limit) { | 7897 while (!iter.done() && frames_seen < limit) { |
7897 StackFrame* raw_frame = iter.frame(); | 7898 StackFrame* raw_frame = iter.frame(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8038 } else { | 8039 } else { |
8039 // Handle last resort GC and make sure to allow future allocations | 8040 // Handle last resort GC and make sure to allow future allocations |
8040 // to grow the heap without causing GCs (if possible). | 8041 // to grow the heap without causing GCs (if possible). |
8041 Counters::gc_last_resort_from_js.Increment(); | 8042 Counters::gc_last_resort_from_js.Increment(); |
8042 Heap::CollectAllGarbage(false); | 8043 Heap::CollectAllGarbage(false); |
8043 } | 8044 } |
8044 } | 8045 } |
8045 | 8046 |
8046 | 8047 |
8047 } } // namespace v8::internal | 8048 } } // namespace v8::internal |
OLD | NEW |