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

Side by Side Diff: src/runtime.cc

Issue 429453005: Do not include native Javascript in ExecutionState frames. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/es6/debug-promises-new-event.js » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 11060 matching lines...) Expand 10 before | Expand all | Expand 10 after
11071 11071
11072 // Count all frames which are relevant to debugging stack trace. 11072 // Count all frames which are relevant to debugging stack trace.
11073 int n = 0; 11073 int n = 0;
11074 StackFrame::Id id = isolate->debug()->break_frame_id(); 11074 StackFrame::Id id = isolate->debug()->break_frame_id();
11075 if (id == StackFrame::NO_ID) { 11075 if (id == StackFrame::NO_ID) {
11076 // If there is no JavaScript stack frame count is 0. 11076 // If there is no JavaScript stack frame count is 0.
11077 return Smi::FromInt(0); 11077 return Smi::FromInt(0);
11078 } 11078 }
11079 11079
11080 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { 11080 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) {
11081 n += it.frame()->GetInlineCount(); 11081 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
11082 it.frame()->Summarize(&frames);
11083 for (int i = frames.length() - 1; i >= 0; i--) {
11084 // Omit functions from native scripts.
11085 if (!frames[i].function()->IsFromNativeScript()) n++;
11086 }
11082 } 11087 }
11083 return Smi::FromInt(n); 11088 return Smi::FromInt(n);
11084 } 11089 }
11085 11090
11086 11091
11087 class FrameInspector { 11092 class FrameInspector {
11088 public: 11093 public:
11089 FrameInspector(JavaScriptFrame* frame, 11094 FrameInspector(JavaScriptFrame* frame,
11090 int inlined_jsframe_index, 11095 int inlined_jsframe_index,
11091 Isolate* isolate) 11096 Isolate* isolate)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
11186 11191
11187 RUNTIME_FUNCTION(Runtime_IsOptimized) { 11192 RUNTIME_FUNCTION(Runtime_IsOptimized) {
11188 SealHandleScope shs(isolate); 11193 SealHandleScope shs(isolate);
11189 ASSERT(args.length() == 0); 11194 ASSERT(args.length() == 0);
11190 JavaScriptFrameIterator it(isolate); 11195 JavaScriptFrameIterator it(isolate);
11191 JavaScriptFrame* frame = it.frame(); 11196 JavaScriptFrame* frame = it.frame();
11192 return isolate->heap()->ToBoolean(frame->is_optimized()); 11197 return isolate->heap()->ToBoolean(frame->is_optimized());
11193 } 11198 }
11194 11199
11195 11200
11201 // Advances the iterator to to the frame that matches the index and returns
aandrey 2014/07/31 14:43:17 typo: to to
Yang 2014/07/31 15:27:10 Done.
11202 // the inlined frame index, or -1 if not found. Skips native JS functions.
11203 static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index) {
11204 int count = -1;
11205 for (; !it->done(); it->Advance()) {
11206 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
11207 it->frame()->Summarize(&frames);
11208 for (int i = frames.length() - 1; i >= 0; i--) {
11209 // Omit functions from native scripts.
11210 if (frames[i].function()->IsFromNativeScript()) continue;
11211 if (++count == index) return i;
11212 }
11213 }
11214 return -1;
11215 }
11216
11217
11196 // Return an array with frame details 11218 // Return an array with frame details
11197 // args[0]: number: break id 11219 // args[0]: number: break id
11198 // args[1]: number: frame index 11220 // args[1]: number: frame index
11199 // 11221 //
11200 // The array returned contains the following information: 11222 // The array returned contains the following information:
11201 // 0: Frame id 11223 // 0: Frame id
11202 // 1: Receiver 11224 // 1: Receiver
11203 // 2: Function 11225 // 2: Function
11204 // 3: Argument count 11226 // 3: Argument count
11205 // 4: Local count 11227 // 4: Local count
(...skipping 13 matching lines...) Expand all
11219 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 11241 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
11220 Heap* heap = isolate->heap(); 11242 Heap* heap = isolate->heap();
11221 11243
11222 // Find the relevant frame with the requested index. 11244 // Find the relevant frame with the requested index.
11223 StackFrame::Id id = isolate->debug()->break_frame_id(); 11245 StackFrame::Id id = isolate->debug()->break_frame_id();
11224 if (id == StackFrame::NO_ID) { 11246 if (id == StackFrame::NO_ID) {
11225 // If there are no JavaScript stack frames return undefined. 11247 // If there are no JavaScript stack frames return undefined.
11226 return heap->undefined_value(); 11248 return heap->undefined_value();
11227 } 11249 }
11228 11250
11229 int count = 0;
11230 JavaScriptFrameIterator it(isolate, id); 11251 JavaScriptFrameIterator it(isolate, id);
11231 for (; !it.done(); it.Advance()) { 11252 // Inlined frame index in optimized frame, starting from outer function.
11232 if (index < count + it.frame()->GetInlineCount()) break; 11253 int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index);
11233 count += it.frame()->GetInlineCount(); 11254 if (inlined_jsframe_index == -1) return heap->undefined_value();
11234 }
11235 if (it.done()) return heap->undefined_value();
11236 11255
11256 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
11237 bool is_optimized = it.frame()->is_optimized(); 11257 bool is_optimized = it.frame()->is_optimized();
11238 11258
11239 int inlined_jsframe_index = 0; // Inlined frame index in optimized frame.
11240 if (is_optimized) {
11241 inlined_jsframe_index =
11242 it.frame()->GetInlineCount() - (index - count) - 1;
11243 }
11244 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
11245
11246 // Traverse the saved contexts chain to find the active context for the 11259 // Traverse the saved contexts chain to find the active context for the
11247 // selected frame. 11260 // selected frame.
11248 SaveContext* save = FindSavedContextForFrame(isolate, it.frame()); 11261 SaveContext* save = FindSavedContextForFrame(isolate, it.frame());
11249 11262
11250 // Get the frame id. 11263 // Get the frame id.
11251 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); 11264 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
11252 11265
11253 // Find source position in unoptimized code. 11266 // Find source position in unoptimized code.
11254 int position = frame_inspector.GetSourcePosition(); 11267 int position = frame_inspector.GetSourcePosition();
11255 11268
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
13611 // Find the relevant frame with the requested index. 13624 // Find the relevant frame with the requested index.
13612 StackFrame::Id id = isolate->debug()->break_frame_id(); 13625 StackFrame::Id id = isolate->debug()->break_frame_id();
13613 if (id == StackFrame::NO_ID) { 13626 if (id == StackFrame::NO_ID) {
13614 // If there are no JavaScript stack frames return undefined. 13627 // If there are no JavaScript stack frames return undefined.
13615 return heap->undefined_value(); 13628 return heap->undefined_value();
13616 } 13629 }
13617 13630
13618 int count = 0; 13631 int count = 0;
13619 JavaScriptFrameIterator it(isolate, id); 13632 JavaScriptFrameIterator it(isolate, id);
13620 for (; !it.done(); it.Advance()) { 13633 for (; !it.done(); it.Advance()) {
13621 if (index < count + it.frame()->GetInlineCount()) break; 13634 if (index < count + it.frame()->GetInlineCount()) break;
aandrey 2014/07/31 14:43:17 I bet this should be fixed as well.
Yang 2014/07/31 15:27:10 Done.
13622 count += it.frame()->GetInlineCount(); 13635 count += it.frame()->GetInlineCount();
13623 } 13636 }
13624 if (it.done()) return heap->undefined_value(); 13637 if (it.done()) return heap->undefined_value();
13625 13638
13626 const char* error_message = LiveEdit::RestartFrame(it.frame()); 13639 const char* error_message = LiveEdit::RestartFrame(it.frame());
13627 if (error_message) { 13640 if (error_message) {
13628 return *(isolate->factory()->InternalizeUtf8String(error_message)); 13641 return *(isolate->factory()->InternalizeUtf8String(error_message));
13629 } 13642 }
13630 return heap->true_value(); 13643 return heap->true_value();
13631 } 13644 }
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
15598 } 15611 }
15599 return NULL; 15612 return NULL;
15600 } 15613 }
15601 15614
15602 15615
15603 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15616 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15604 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15617 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15605 } 15618 }
15606 15619
15607 } } // namespace v8::internal 15620 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/debug-promises-new-event.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698