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

Side by Side Diff: src/isolate.cc

Issue 1618343002: [interpreter, debugger] abstraction for source position calculation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
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 "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 int new_capacity = JSObject::NewElementsCapacity(elements->length()); 383 int new_capacity = JSObject::NewElementsCapacity(elements->length());
384 Handle<FixedArray> new_elements = 384 Handle<FixedArray> new_elements =
385 factory()->NewFixedArrayWithHoles(new_capacity); 385 factory()->NewFixedArrayWithHoles(new_capacity);
386 for (int i = 0; i < cursor; i++) { 386 for (int i = 0; i < cursor; i++) {
387 new_elements->set(i, elements->get(i)); 387 new_elements->set(i, elements->get(i));
388 } 388 }
389 elements = new_elements; 389 elements = new_elements;
390 } 390 }
391 DCHECK(cursor + 4 <= elements->length()); 391 DCHECK(cursor + 4 <= elements->length());
392 392
393 Handle<Code> code = frames[i].code(); 393 Handle<AbstractCode> abstract_code = frames[i].abstract_code();
394 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); 394
395 Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this);
395 // The stack trace API should not expose receivers and function 396 // The stack trace API should not expose receivers and function
396 // objects on frames deeper than the top-most one with a strict 397 // objects on frames deeper than the top-most one with a strict
397 // mode function. The number of sloppy frames is stored as 398 // mode function. The number of sloppy frames is stored as
398 // first element in the result array. 399 // first element in the result array.
399 if (!encountered_strict_function) { 400 if (!encountered_strict_function) {
400 if (is_strict(fun->shared()->language_mode())) { 401 if (is_strict(fun->shared()->language_mode())) {
401 encountered_strict_function = true; 402 encountered_strict_function = true;
402 } else { 403 } else {
403 sloppy_frames++; 404 sloppy_frames++;
404 } 405 }
405 } 406 }
406 elements->set(cursor++, *recv); 407 elements->set(cursor++, *recv);
407 elements->set(cursor++, *fun); 408 elements->set(cursor++, *fun);
408 elements->set(cursor++, *code); 409 elements->set(cursor++, *abstract_code);
409 elements->set(cursor++, *offset); 410 elements->set(cursor++, *offset);
410 frames_seen++; 411 frames_seen++;
411 } 412 }
412 } 413 }
413 elements->set(0, Smi::FromInt(sloppy_frames)); 414 elements->set(0, Smi::FromInt(sloppy_frames));
414 elements->Shrink(cursor); 415 elements->Shrink(cursor);
415 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); 416 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements);
416 result->set_length(Smi::FromInt(cursor)); 417 result->set_length(Smi::FromInt(cursor));
417 // TODO(yangguo): Queue this structured stack trace for preprocessing on GC. 418 // TODO(yangguo): Queue this structured stack trace for preprocessing on GC.
418 return result; 419 return result;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 Handle<String> constructor_key_; 588 Handle<String> constructor_key_;
588 }; 589 };
589 590
590 591
591 int PositionFromStackTrace(Handle<FixedArray> elements, int index) { 592 int PositionFromStackTrace(Handle<FixedArray> elements, int index) {
592 DisallowHeapAllocation no_gc; 593 DisallowHeapAllocation no_gc;
593 Object* maybe_code = elements->get(index + 2); 594 Object* maybe_code = elements->get(index + 2);
594 if (maybe_code->IsSmi()) { 595 if (maybe_code->IsSmi()) {
595 return Smi::cast(maybe_code)->value(); 596 return Smi::cast(maybe_code)->value();
596 } else { 597 } else {
597 Code* code = Code::cast(maybe_code); 598 AbstractCode* abstract_code = AbstractCode::cast(maybe_code);
598 Address pc = code->address() + Smi::cast(elements->get(index + 3))->value(); 599 int code_offset = Smi::cast(elements->get(index + 3))->value();
599 return code->SourcePosition(pc); 600 return abstract_code->SourcePosition(code_offset);
600 } 601 }
601 } 602 }
602 603
603 604
604 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace( 605 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace(
605 Handle<JSObject> error_object) { 606 Handle<JSObject> error_object) {
606 Handle<Name> key = factory()->stack_trace_symbol(); 607 Handle<Name> key = factory()->stack_trace_symbol();
607 Handle<Object> property = JSReceiver::GetDataProperty(error_object, key); 608 Handle<Object> property = JSReceiver::GetDataProperty(error_object, key);
608 if (!property->IsJSArray()) return Handle<JSArray>(); 609 if (!property->IsJSArray()) return Handle<JSArray>();
609 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); 610 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 JavaScriptFrame* frame = it.frame(); 655 JavaScriptFrame* frame = it.frame();
655 // Set initial size to the maximum inlining level + 1 for the outermost 656 // Set initial size to the maximum inlining level + 1 for the outermost
656 // function. 657 // function.
657 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 658 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
658 frame->Summarize(&frames); 659 frame->Summarize(&frames);
659 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { 660 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
660 Handle<JSFunction> fun = frames[i].function(); 661 Handle<JSFunction> fun = frames[i].function();
661 // Filter frames from other security contexts. 662 // Filter frames from other security contexts.
662 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && 663 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) &&
663 !this->context()->HasSameSecurityTokenAs(fun->context())) continue; 664 !this->context()->HasSameSecurityTokenAs(fun->context())) continue;
664 int position = frames[i].code()->SourcePosition(frames[i].pc()); 665 int position =
666 frames[i].abstract_code()->SourcePosition(frames[i].code_offset());
665 Handle<JSObject> stack_frame = 667 Handle<JSObject> stack_frame =
666 helper.NewStackFrameObject(fun, position, frames[i].is_constructor()); 668 helper.NewStackFrameObject(fun, position, frames[i].is_constructor());
667 669
668 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame); 670 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame);
669 frames_seen++; 671 frames_seen++;
670 } 672 }
671 it.Advance(); 673 it.Advance();
672 } 674 }
673 675
674 stack_trace->set_length(Smi::FromInt(frames_seen)); 676 stack_trace->set_length(Smi::FromInt(frames_seen));
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 Object* script = fun->shared()->script(); 1313 Object* script = fun->shared()->script();
1312 if (script->IsScript() && 1314 if (script->IsScript() &&
1313 !(Script::cast(script)->source()->IsUndefined())) { 1315 !(Script::cast(script)->source()->IsUndefined())) {
1314 Handle<Script> casted_script(Script::cast(script)); 1316 Handle<Script> casted_script(Script::cast(script));
1315 // Compute the location from the function and the relocation info of the 1317 // Compute the location from the function and the relocation info of the
1316 // baseline code. For optimized code this will use the deoptimization 1318 // baseline code. For optimized code this will use the deoptimization
1317 // information to get canonical location information. 1319 // information to get canonical location information.
1318 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 1320 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
1319 it.frame()->Summarize(&frames); 1321 it.frame()->Summarize(&frames);
1320 FrameSummary& summary = frames.last(); 1322 FrameSummary& summary = frames.last();
1321 int pos = summary.code()->SourcePosition(summary.pc()); 1323 int pos = summary.abstract_code()->SourcePosition(summary.code_offset());
1322 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); 1324 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
1323 return true; 1325 return true;
1324 } 1326 }
1325 } 1327 }
1326 return false; 1328 return false;
1327 } 1329 }
1328 1330
1329 1331
1330 bool Isolate::ComputeLocationFromException(MessageLocation* target, 1332 bool Isolate::ComputeLocationFromException(MessageLocation* target,
1331 Handle<Object> exception) { 1333 Handle<Object> exception) {
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 // Then check whether this scope intercepts. 2851 // Then check whether this scope intercepts.
2850 if ((flag & intercept_mask_)) { 2852 if ((flag & intercept_mask_)) {
2851 intercepted_flags_ |= flag; 2853 intercepted_flags_ |= flag;
2852 return true; 2854 return true;
2853 } 2855 }
2854 return false; 2856 return false;
2855 } 2857 }
2856 2858
2857 } // namespace internal 2859 } // namespace internal
2858 } // namespace v8 2860 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698