| 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 7396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7407 // Number.ADD which is invoked using 'call') are very difficult to | 7407 // Number.ADD which is invoked using 'call') are very difficult to |
| 7408 // recognize so we're leaving them in for now. | 7408 // recognize so we're leaving them in for now. |
| 7409 return !frame->receiver()->IsJSBuiltinsObject(); | 7409 return !frame->receiver()->IsJSBuiltinsObject(); |
| 7410 } | 7410 } |
| 7411 | 7411 |
| 7412 | 7412 |
| 7413 // Collect the raw data for a stack trace. Returns an array of three | 7413 // Collect the raw data for a stack trace. Returns an array of three |
| 7414 // element segments each containing a receiver, function and native | 7414 // element segments each containing a receiver, function and native |
| 7415 // code offset. | 7415 // code offset. |
| 7416 static Object* Runtime_CollectStackTrace(Arguments args) { | 7416 static Object* Runtime_CollectStackTrace(Arguments args) { |
| 7417 ASSERT_EQ(args.length(), 1); | 7417 ASSERT_EQ(args.length(), 2); |
| 7418 Object* caller = args[0]; | 7418 Object* caller = args[0]; |
| 7419 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); |
| 7420 |
| 7421 HandleScope scope; |
| 7422 |
| 7423 int initial_size = limit < 10 ? limit : 10; |
| 7424 Handle<JSArray> result = Factory::NewJSArray(initial_size * 3); |
| 7419 | 7425 |
| 7420 StackFrameIterator iter; | 7426 StackFrameIterator iter; |
| 7421 int frame_count = 0; | |
| 7422 bool seen_caller = false; | 7427 bool seen_caller = false; |
| 7423 while (!iter.done()) { | 7428 int cursor = 0; |
| 7424 if (ShowFrameInStackTrace(iter.frame(), caller, &seen_caller)) | 7429 int frames_seen = 0; |
| 7425 frame_count++; | 7430 while (!iter.done() && frames_seen < limit) { |
| 7431 StackFrame* raw_frame = iter.frame(); |
| 7432 if (ShowFrameInStackTrace(raw_frame, caller, &seen_caller)) { |
| 7433 frames_seen++; |
| 7434 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
| 7435 Object* recv = frame->receiver(); |
| 7436 Object* fun = frame->function(); |
| 7437 Address pc = frame->pc(); |
| 7438 Address start = frame->code()->address(); |
| 7439 Smi* offset = Smi::FromInt(pc - start); |
| 7440 FixedArray* elements = result->elements(); |
| 7441 if (cursor + 2 < elements->length()) { |
| 7442 elements->set(cursor++, recv); |
| 7443 elements->set(cursor++, fun); |
| 7444 elements->set(cursor++, offset, SKIP_WRITE_BARRIER); |
| 7445 } else { |
| 7446 HandleScope scope; |
| 7447 SetElement(result, cursor++, Handle<Object>(recv)); |
| 7448 SetElement(result, cursor++, Handle<Object>(fun)); |
| 7449 SetElement(result, cursor++, Handle<Smi>(offset)); |
| 7450 } |
| 7451 } |
| 7426 iter.Advance(); | 7452 iter.Advance(); |
| 7427 } | 7453 } |
| 7428 HandleScope scope; | 7454 |
| 7429 Handle<JSArray> result = Factory::NewJSArray(frame_count * 3); | 7455 result->set_length(Smi::FromInt(cursor), SKIP_WRITE_BARRIER); |
| 7430 int i = 0; | 7456 |
| 7431 seen_caller = false; | |
| 7432 for (iter.Reset(); !iter.done(); iter.Advance()) { | |
| 7433 StackFrame* raw_frame = iter.frame(); | |
| 7434 if (ShowFrameInStackTrace(raw_frame, caller, &seen_caller)) { | |
| 7435 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | |
| 7436 result->SetElement(i++, frame->receiver()); | |
| 7437 result->SetElement(i++, frame->function()); | |
| 7438 Address pc = frame->pc(); | |
| 7439 Address start = frame->code()->address(); | |
| 7440 result->SetElement(i++, Smi::FromInt(pc - start)); | |
| 7441 } | |
| 7442 } | |
| 7443 return *result; | 7457 return *result; |
| 7444 } | 7458 } |
| 7445 | 7459 |
| 7446 | 7460 |
| 7447 static Object* Runtime_Abort(Arguments args) { | 7461 static Object* Runtime_Abort(Arguments args) { |
| 7448 ASSERT(args.length() == 2); | 7462 ASSERT(args.length() == 2); |
| 7449 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + | 7463 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + |
| 7450 Smi::cast(args[1])->value()); | 7464 Smi::cast(args[1])->value()); |
| 7451 Top::PrintStack(); | 7465 Top::PrintStack(); |
| 7452 OS::Abort(); | 7466 OS::Abort(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7536 } else { | 7550 } else { |
| 7537 // Handle last resort GC and make sure to allow future allocations | 7551 // Handle last resort GC and make sure to allow future allocations |
| 7538 // to grow the heap without causing GCs (if possible). | 7552 // to grow the heap without causing GCs (if possible). |
| 7539 Counters::gc_last_resort_from_js.Increment(); | 7553 Counters::gc_last_resort_from_js.Increment(); |
| 7540 Heap::CollectAllGarbage(); | 7554 Heap::CollectAllGarbage(); |
| 7541 } | 7555 } |
| 7542 } | 7556 } |
| 7543 | 7557 |
| 7544 | 7558 |
| 7545 } } // namespace v8::internal | 7559 } } // namespace v8::internal |
| OLD | NEW |