Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "ast.h" | 9 #include "ast.h" |
| 10 #include "bootstrapper.h" | 10 #include "bootstrapper.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 // First element is reserved to store the number of sloppy frames. | 388 // First element is reserved to store the number of sloppy frames. |
| 389 int cursor = 1; | 389 int cursor = 1; |
| 390 int frames_seen = 0; | 390 int frames_seen = 0; |
| 391 int sloppy_frames = 0; | 391 int sloppy_frames = 0; |
| 392 bool encountered_strict_function = false; | 392 bool encountered_strict_function = false; |
| 393 for (StackFrameIterator iter(this); | 393 for (StackFrameIterator iter(this); |
| 394 !iter.done() && frames_seen < limit; | 394 !iter.done() && frames_seen < limit; |
| 395 iter.Advance()) { | 395 iter.Advance()) { |
| 396 StackFrame* raw_frame = iter.frame(); | 396 StackFrame* raw_frame = iter.frame(); |
| 397 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) { | 397 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) { |
| 398 frames_seen++; | |
| 399 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 398 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
| 400 // Set initial size to the maximum inlining level + 1 for the outermost | 399 // Set initial size to the maximum inlining level + 1 for the outermost |
| 401 // function. | 400 // function. |
| 402 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 401 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 403 frame->Summarize(&frames); | 402 frame->Summarize(&frames); |
| 404 for (int i = frames.length() - 1; i >= 0; i--) { | 403 for (int i = frames.length() - 1; i >= 0; i--) { |
| 404 Handle<JSFunction> fun = frames[i].function(); | |
| 405 // Filter out frames from other security contexts. | |
| 406 if (!this->context()->HasSameSecurityTokenAs(fun->context())) continue; | |
| 405 if (cursor + 4 > elements->length()) { | 407 if (cursor + 4 > elements->length()) { |
| 406 int new_capacity = JSObject::NewElementsCapacity(elements->length()); | 408 int new_capacity = JSObject::NewElementsCapacity(elements->length()); |
| 407 Handle<FixedArray> new_elements = | 409 Handle<FixedArray> new_elements = |
| 408 factory()->NewFixedArrayWithHoles(new_capacity); | 410 factory()->NewFixedArrayWithHoles(new_capacity); |
| 409 for (int i = 0; i < cursor; i++) { | 411 for (int i = 0; i < cursor; i++) { |
| 410 new_elements->set(i, elements->get(i)); | 412 new_elements->set(i, elements->get(i)); |
| 411 } | 413 } |
| 412 elements = new_elements; | 414 elements = new_elements; |
| 413 } | 415 } |
| 414 ASSERT(cursor + 4 <= elements->length()); | 416 ASSERT(cursor + 4 <= elements->length()); |
| 415 | 417 |
| 416 Handle<Object> recv = frames[i].receiver(); | 418 Handle<Object> recv = frames[i].receiver(); |
| 417 Handle<JSFunction> fun = frames[i].function(); | |
| 418 Handle<Code> code = frames[i].code(); | 419 Handle<Code> code = frames[i].code(); |
| 419 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); | 420 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); |
| 420 // The stack trace API should not expose receivers and function | 421 // The stack trace API should not expose receivers and function |
| 421 // objects on frames deeper than the top-most one with a strict | 422 // objects on frames deeper than the top-most one with a strict |
| 422 // mode function. The number of sloppy frames is stored as | 423 // mode function. The number of sloppy frames is stored as |
| 423 // first element in the result array. | 424 // first element in the result array. |
| 424 if (!encountered_strict_function) { | 425 if (!encountered_strict_function) { |
| 425 if (fun->shared()->strict_mode() == STRICT) { | 426 if (fun->shared()->strict_mode() == STRICT) { |
| 426 encountered_strict_function = true; | 427 encountered_strict_function = true; |
| 427 } else { | 428 } else { |
| 428 sloppy_frames++; | 429 sloppy_frames++; |
| 429 } | 430 } |
| 430 } | 431 } |
| 431 elements->set(cursor++, *recv); | 432 elements->set(cursor++, *recv); |
| 432 elements->set(cursor++, *fun); | 433 elements->set(cursor++, *fun); |
| 433 elements->set(cursor++, *code); | 434 elements->set(cursor++, *code); |
| 434 elements->set(cursor++, *offset); | 435 elements->set(cursor++, *offset); |
| 435 } | 436 } |
| 437 frames_seen++; | |
| 436 } | 438 } |
| 437 } | 439 } |
| 438 elements->set(0, Smi::FromInt(sloppy_frames)); | 440 elements->set(0, Smi::FromInt(sloppy_frames)); |
| 439 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); | 441 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); |
| 440 result->set_length(Smi::FromInt(cursor)); | 442 result->set_length(Smi::FromInt(cursor)); |
| 441 return result; | 443 return result; |
| 442 } | 444 } |
| 443 | 445 |
| 444 | 446 |
| 445 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) { | 447 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 | 482 |
| 481 StackTraceFrameIterator it(this); | 483 StackTraceFrameIterator it(this); |
| 482 int frames_seen = 0; | 484 int frames_seen = 0; |
| 483 while (!it.done() && (frames_seen < limit)) { | 485 while (!it.done() && (frames_seen < limit)) { |
| 484 JavaScriptFrame* frame = it.frame(); | 486 JavaScriptFrame* frame = it.frame(); |
| 485 // Set initial size to the maximum inlining level + 1 for the outermost | 487 // Set initial size to the maximum inlining level + 1 for the outermost |
| 486 // function. | 488 // function. |
| 487 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 489 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 488 frame->Summarize(&frames); | 490 frame->Summarize(&frames); |
| 489 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 491 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { |
| 492 Handle<JSFunction> fun = frames[i].function(); | |
| 493 // Filter frames from other security contexts. | |
| 494 if (!this->context()->HasSameSecurityTokenAs(fun->context())) continue; | |
|
yurys
2014/05/19 08:30:04
This change breaks DevTools debugger as e.g. when
dcarney
2014/05/19 09:33:16
got it. luckily, scriptdebugserver is written in
| |
| 495 | |
| 490 // Create a JSObject to hold the information for the StackFrame. | 496 // Create a JSObject to hold the information for the StackFrame. |
| 491 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function()); | 497 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function()); |
| 492 | 498 |
| 493 Handle<JSFunction> fun = frames[i].function(); | |
| 494 Handle<Script> script(Script::cast(fun->shared()->script())); | 499 Handle<Script> script(Script::cast(fun->shared()->script())); |
| 495 | 500 |
| 496 if (options & StackTrace::kLineNumber) { | 501 if (options & StackTrace::kLineNumber) { |
| 497 int script_line_offset = script->line_offset()->value(); | 502 int script_line_offset = script->line_offset()->value(); |
| 498 int position = frames[i].code()->SourcePosition(frames[i].pc()); | 503 int position = frames[i].code()->SourcePosition(frames[i].pc()); |
| 499 int line_number = Script::GetLineNumber(script, position); | 504 int line_number = Script::GetLineNumber(script, position); |
| 500 // line_number is already shifted by the script_line_offset. | 505 // line_number is already shifted by the script_line_offset. |
| 501 int relative_line_number = line_number - script_line_offset; | 506 int relative_line_number = line_number - script_line_offset; |
| 502 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { | 507 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { |
| 503 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 508 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| (...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2246 handle_scope_implementer()->IncrementCallDepth(); | 2251 handle_scope_implementer()->IncrementCallDepth(); |
| 2247 if (run_microtasks) Execution::RunMicrotasks(this); | 2252 if (run_microtasks) Execution::RunMicrotasks(this); |
| 2248 for (int i = 0; i < call_completed_callbacks_.length(); i++) { | 2253 for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
| 2249 call_completed_callbacks_.at(i)(); | 2254 call_completed_callbacks_.at(i)(); |
| 2250 } | 2255 } |
| 2251 handle_scope_implementer()->DecrementCallDepth(); | 2256 handle_scope_implementer()->DecrementCallDepth(); |
| 2252 } | 2257 } |
| 2253 | 2258 |
| 2254 | 2259 |
| 2255 } } // namespace v8::internal | 2260 } } // namespace v8::internal |
| OLD | NEW |