Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/runtime.cc

Issue 160159: Handlified some stack trace code (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7407 matching lines...) Expand 10 before | Expand all | Expand 10 after
7418 // so we're leaving them in for now. 7418 // so we're leaving them in for now.
7419 return *seen_caller && !frame->receiver()->IsJSBuiltinsObject(); 7419 return *seen_caller && !frame->receiver()->IsJSBuiltinsObject();
7420 } 7420 }
7421 7421
7422 7422
7423 // Collect the raw data for a stack trace. Returns an array of three 7423 // Collect the raw data for a stack trace. Returns an array of three
7424 // element segments each containing a receiver, function and native 7424 // element segments each containing a receiver, function and native
7425 // code offset. 7425 // code offset.
7426 static Object* Runtime_CollectStackTrace(Arguments args) { 7426 static Object* Runtime_CollectStackTrace(Arguments args) {
7427 ASSERT_EQ(args.length(), 2); 7427 ASSERT_EQ(args.length(), 2);
7428 Object* caller = args[0]; 7428 Handle<Object> caller = args.at<Object>(0);
7429 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); 7429 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]);
7430 7430
7431 HandleScope scope; 7431 HandleScope scope;
7432 7432
7433 int initial_size = limit < 10 ? limit : 10; 7433 int initial_size = limit < 10 ? limit : 10;
7434 Handle<JSArray> result = Factory::NewJSArray(initial_size * 3); 7434 Handle<JSArray> result = Factory::NewJSArray(initial_size * 3);
7435 7435
7436 StackFrameIterator iter; 7436 StackFrameIterator iter;
7437 // If the caller parameter is a function we skip frames until we're 7437 // If the caller parameter is a function we skip frames until we're
7438 // under it before starting to collect. 7438 // under it before starting to collect.
7439 bool seen_caller = !caller->IsJSFunction(); 7439 bool seen_caller = !caller->IsJSFunction();
7440 int cursor = 0; 7440 int cursor = 0;
7441 int frames_seen = 0; 7441 int frames_seen = 0;
7442 while (!iter.done() && frames_seen < limit) { 7442 while (!iter.done() && frames_seen < limit) {
7443 StackFrame* raw_frame = iter.frame(); 7443 StackFrame* raw_frame = iter.frame();
7444 if (ShowFrameInStackTrace(raw_frame, caller, &seen_caller)) { 7444 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) {
7445 frames_seen++; 7445 frames_seen++;
7446 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); 7446 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
7447 Object* recv = frame->receiver(); 7447 Object* recv = frame->receiver();
7448 Object* fun = frame->function(); 7448 Object* fun = frame->function();
7449 Address pc = frame->pc(); 7449 Address pc = frame->pc();
7450 Address start = frame->code()->address(); 7450 Address start = frame->code()->address();
7451 Smi* offset = Smi::FromInt(pc - start); 7451 Smi* offset = Smi::FromInt(pc - start);
7452 FixedArray* elements = result->elements(); 7452 FixedArray* elements = result->elements();
7453 if (cursor + 2 < elements->length()) { 7453 if (cursor + 2 < elements->length()) {
7454 elements->set(cursor++, recv); 7454 elements->set(cursor++, recv);
7455 elements->set(cursor++, fun); 7455 elements->set(cursor++, fun);
7456 elements->set(cursor++, offset, SKIP_WRITE_BARRIER); 7456 elements->set(cursor++, offset, SKIP_WRITE_BARRIER);
7457 } else { 7457 } else {
7458 HandleScope scope; 7458 HandleScope scope;
7459 SetElement(result, cursor++, Handle<Object>(recv)); 7459 Handle<Object> recv_handle(recv);
7460 SetElement(result, cursor++, Handle<Object>(fun)); 7460 Handle<Object> fun_handle(fun);
7461 SetElement(result, cursor++, recv_handle);
7462 SetElement(result, cursor++, fun_handle);
7461 SetElement(result, cursor++, Handle<Smi>(offset)); 7463 SetElement(result, cursor++, Handle<Smi>(offset));
7462 } 7464 }
7463 } 7465 }
7464 iter.Advance(); 7466 iter.Advance();
7465 } 7467 }
7466 7468
7467 result->set_length(Smi::FromInt(cursor), SKIP_WRITE_BARRIER); 7469 result->set_length(Smi::FromInt(cursor), SKIP_WRITE_BARRIER);
7468 7470
7469 return *result; 7471 return *result;
7470 } 7472 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
7562 } else { 7564 } else {
7563 // Handle last resort GC and make sure to allow future allocations 7565 // Handle last resort GC and make sure to allow future allocations
7564 // to grow the heap without causing GCs (if possible). 7566 // to grow the heap without causing GCs (if possible).
7565 Counters::gc_last_resort_from_js.Increment(); 7567 Counters::gc_last_resort_from_js.Increment();
7566 Heap::CollectAllGarbage(); 7568 Heap::CollectAllGarbage();
7567 } 7569 }
7568 } 7570 }
7569 7571
7570 7572
7571 } } // namespace v8::internal 7573 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698