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

Side by Side Diff: src/runtime.cc

Issue 15960016: Provide list of step-in source positions in JS Debug API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 11556 matching lines...) Expand 10 before | Expand all | Expand 10 after
11567 for (ScopeIterator it(isolate, frame, 0); 11567 for (ScopeIterator it(isolate, frame, 0);
11568 !it.Done(); 11568 !it.Done();
11569 it.Next()) { 11569 it.Next()) {
11570 n++; 11570 n++;
11571 } 11571 }
11572 11572
11573 return Smi::FromInt(n); 11573 return Smi::FromInt(n);
11574 } 11574 }
11575 11575
11576 11576
11577 // Returns the list of step-in positions (text offset) in a function of the
11578 // stack frame in a range from the current debug break position to the end
11579 // of the corresponding statement.
11580 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetStepInPositions) {
11581 HandleScope scope(isolate);
11582 ASSERT(args.length() == 2);
11583
11584 // Check arguments.
11585 Object* check;
11586 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11587 RUNTIME_ARGUMENTS(isolate, args));
11588 if (!maybe_check->ToObject(&check)) return maybe_check;
11589 }
11590 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
11591
11592 // Get the frame where the debugging is performed.
11593 StackFrame::Id id = UnwrapFrameId(wrapped_id);
11594 JavaScriptFrameIterator frame_it(isolate, id);
11595 JavaScriptFrame* frame = frame_it.frame();
11596
11597 Handle<SharedFunctionInfo> shared =
11598 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
11599 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared);
11600
11601 int len = 0;
11602 Handle<JSArray> array(isolate->factory()->NewJSArray(10));
11603 // Find the break point where execution has stopped.
11604 BreakLocationIterator break_location_iterator(debug_info,
11605 ALL_BREAK_LOCATIONS);
11606
11607 break_location_iterator.FindBreakLocationFromAddress(frame->pc());
11608 int current_statement_pos = break_location_iterator.statement_position();
11609
11610 while (!break_location_iterator.Done()) {
11611 if (break_location_iterator.IsStepInLocation(isolate)) {
11612 Smi* position_value = Smi::FromInt(break_location_iterator.position());
11613 JSObject::SetElement(array, len,
11614 Handle<Object>(position_value, isolate),
11615 NONE, kNonStrictMode);
11616 len++;
11617 }
11618 // Advance iterator.
11619 break_location_iterator.Next();
11620 if (current_statement_pos !=
11621 break_location_iterator.statement_position()) {
11622 break;
11623 }
11624 }
11625 return *array;
11626 }
11627
11628
11577 static const int kScopeDetailsTypeIndex = 0; 11629 static const int kScopeDetailsTypeIndex = 0;
11578 static const int kScopeDetailsObjectIndex = 1; 11630 static const int kScopeDetailsObjectIndex = 1;
11579 static const int kScopeDetailsSize = 2; 11631 static const int kScopeDetailsSize = 2;
11580 11632
11581 11633
11582 static MaybeObject* MaterializeScopeDetails(Isolate* isolate, 11634 static MaybeObject* MaterializeScopeDetails(Isolate* isolate,
11583 ScopeIterator* it) { 11635 ScopeIterator* it) {
11584 // Calculate the size of the result. 11636 // Calculate the size of the result.
11585 int details_size = kScopeDetailsSize; 11637 int details_size = kScopeDetailsSize;
11586 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); 11638 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after
13643 // Handle last resort GC and make sure to allow future allocations 13695 // Handle last resort GC and make sure to allow future allocations
13644 // to grow the heap without causing GCs (if possible). 13696 // to grow the heap without causing GCs (if possible).
13645 isolate->counters()->gc_last_resort_from_js()->Increment(); 13697 isolate->counters()->gc_last_resort_from_js()->Increment();
13646 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13698 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13647 "Runtime::PerformGC"); 13699 "Runtime::PerformGC");
13648 } 13700 }
13649 } 13701 }
13650 13702
13651 13703
13652 } } // namespace v8::internal 13704 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698