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

Side by Side Diff: src/js/messages.js

Issue 1909353002: [wasm] Make wasm info available on the stack trace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-3
Patch Set: last changes Created 4 years, 7 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 | « src/isolate.cc ('k') | src/messages.h » ('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 // ------------------------------------------------------------------- 5 // -------------------------------------------------------------------
6 6
7 (function(global, utils) { 7 (function(global, utils) {
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var ArrayJoin; 14 var ArrayJoin;
15 var Bool16x8ToString; 15 var Bool16x8ToString;
16 var Bool32x4ToString; 16 var Bool32x4ToString;
17 var Bool8x16ToString; 17 var Bool8x16ToString;
18 var callSiteReceiverSymbol = 18 var callSiteReceiverSymbol =
19 utils.ImportNow("call_site_receiver_symbol"); 19 utils.ImportNow("call_site_receiver_symbol");
20 var callSiteFunctionSymbol = 20 var callSiteFunctionSymbol =
21 utils.ImportNow("call_site_function_symbol"); 21 utils.ImportNow("call_site_function_symbol");
22 var callSitePositionSymbol = 22 var callSitePositionSymbol =
23 utils.ImportNow("call_site_position_symbol"); 23 utils.ImportNow("call_site_position_symbol");
24 var callSiteStrictSymbol = 24 var callSiteStrictSymbol =
25 utils.ImportNow("call_site_strict_symbol"); 25 utils.ImportNow("call_site_strict_symbol");
26 var callSiteWasmObjectSymbol =
27 utils.ImportNow("call_site_wasm_obj_symbol");
28 var callSiteWasmFunctionIndexSymbol =
29 utils.ImportNow("call_site_wasm_func_index_symbol");
26 var Float32x4ToString; 30 var Float32x4ToString;
27 var formattedStackTraceSymbol = 31 var formattedStackTraceSymbol =
28 utils.ImportNow("formatted_stack_trace_symbol"); 32 utils.ImportNow("formatted_stack_trace_symbol");
29 var GlobalObject = global.Object; 33 var GlobalObject = global.Object;
30 var Int16x8ToString; 34 var Int16x8ToString;
31 var Int32x4ToString; 35 var Int32x4ToString;
32 var Int8x16ToString; 36 var Int8x16ToString;
33 var InternalArray = utils.InternalArray; 37 var InternalArray = utils.InternalArray;
34 var internalErrorSymbol = utils.ImportNow("internal_error_symbol"); 38 var internalErrorSymbol = utils.ImportNow("internal_error_symbol");
35 var ObjectHasOwnProperty; 39 var ObjectHasOwnProperty;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 550
547 551
548 function GetStackTraceLine(recv, fun, pos, isGlobal) { 552 function GetStackTraceLine(recv, fun, pos, isGlobal) {
549 return new CallSite(recv, fun, pos, false).toString(); 553 return new CallSite(recv, fun, pos, false).toString();
550 } 554 }
551 555
552 // ---------------------------------------------------------------------------- 556 // ----------------------------------------------------------------------------
553 // Error implementation 557 // Error implementation
554 558
555 function CallSite(receiver, fun, pos, strict_mode) { 559 function CallSite(receiver, fun, pos, strict_mode) {
556 if (!IS_FUNCTION(fun)) { 560 // For wasm frames, receiver is the wasm object and fun is the function index
561 // instead of an actual function.
562 if (!IS_FUNCTION(fun) && !IS_NUMBER(fun)) {
557 throw MakeTypeError(kCallSiteExpectsFunction, typeof fun); 563 throw MakeTypeError(kCallSiteExpectsFunction, typeof fun);
558 } 564 }
559 565
560 if (IS_UNDEFINED(new.target)) { 566 if (IS_UNDEFINED(new.target)) {
561 return new CallSite(receiver, fun, pos, strict_mode); 567 return new CallSite(receiver, fun, pos, strict_mode);
562 } 568 }
563 569
564 SET_PRIVATE(this, callSiteReceiverSymbol, receiver); 570 if (IS_FUNCTION(fun)) {
565 SET_PRIVATE(this, callSiteFunctionSymbol, fun); 571 SET_PRIVATE(this, callSiteReceiverSymbol, receiver);
572 SET_PRIVATE(this, callSiteFunctionSymbol, fun);
573 } else {
574 SET_PRIVATE(this, callSiteWasmObjectSymbol, receiver);
575 SET_PRIVATE(this, callSiteWasmFunctionIndexSymbol, TO_UINT32(fun));
576 }
566 SET_PRIVATE(this, callSitePositionSymbol, TO_INT32(pos)); 577 SET_PRIVATE(this, callSitePositionSymbol, TO_INT32(pos));
567 SET_PRIVATE(this, callSiteStrictSymbol, TO_BOOLEAN(strict_mode)); 578 SET_PRIVATE(this, callSiteStrictSymbol, TO_BOOLEAN(strict_mode));
568 } 579 }
569 580
570 function CheckCallSite(obj, name) { 581 function CheckCallSite(obj, name) {
571 if (!IS_RECEIVER(obj) || !HAS_PRIVATE(obj, callSiteFunctionSymbol)) { 582 if (!IS_RECEIVER(obj) || !HAS_PRIVATE(obj, callSitePositionSymbol)) {
572 throw MakeTypeError(kCallSiteMethod, name); 583 throw MakeTypeError(kCallSiteMethod, name);
573 } 584 }
574 } 585 }
575 586
576 function CallSiteGetThis() { 587 function CallSiteGetThis() {
577 CheckCallSite(this, "getThis"); 588 CheckCallSite(this, "getThis");
578 return GET_PRIVATE(this, callSiteStrictSymbol) 589 return GET_PRIVATE(this, callSiteStrictSymbol)
579 ? UNDEFINED : GET_PRIVATE(this, callSiteReceiverSymbol); 590 ? UNDEFINED : GET_PRIVATE(this, callSiteReceiverSymbol);
580 } 591 }
581 592
(...skipping 30 matching lines...) Expand all
612 } 623 }
613 624
614 function CallSiteGetScriptNameOrSourceURL() { 625 function CallSiteGetScriptNameOrSourceURL() {
615 CheckCallSite(this, "getScriptNameOrSourceURL"); 626 CheckCallSite(this, "getScriptNameOrSourceURL");
616 return %CallSiteGetScriptNameOrSourceUrlRT(this); 627 return %CallSiteGetScriptNameOrSourceUrlRT(this);
617 } 628 }
618 629
619 function CallSiteGetFunctionName() { 630 function CallSiteGetFunctionName() {
620 // See if the function knows its own name 631 // See if the function knows its own name
621 CheckCallSite(this, "getFunctionName"); 632 CheckCallSite(this, "getFunctionName");
633 if (HAS_PRIVATE(this, callSiteWasmObjectSymbol)) {
634 var wasm = GET_PRIVATE(this, callSiteWasmObjectSymbol);
635 var func_index = GET_PRIVATE(this, callSiteWasmFunctionIndexSymbol);
636 if (IS_UNDEFINED(wasm)) return "<WASM>";
637 return %WasmGetFunctionName(wasm, func_index);
638 }
622 return %CallSiteGetFunctionNameRT(this); 639 return %CallSiteGetFunctionNameRT(this);
623 } 640 }
624 641
625 function CallSiteGetMethodName() { 642 function CallSiteGetMethodName() {
626 // See if we can find a unique property on the receiver that holds 643 // See if we can find a unique property on the receiver that holds
627 // this function. 644 // this function.
628 CheckCallSite(this, "getMethodName"); 645 CheckCallSite(this, "getMethodName");
629 return %CallSiteGetMethodNameRT(this); 646 return %CallSiteGetMethodNameRT(this);
630 } 647 }
631 648
632 function CallSiteGetFileName() { 649 function CallSiteGetFileName() {
633 CheckCallSite(this, "getFileName"); 650 CheckCallSite(this, "getFileName");
634 return %CallSiteGetFileNameRT(this); 651 return %CallSiteGetFileNameRT(this);
635 } 652 }
636 653
637 function CallSiteGetLineNumber() { 654 function CallSiteGetLineNumber() {
655 if (HAS_PRIVATE(this, callSiteWasmObjectSymbol)) {
656 return GET_PRIVATE(this, callSiteWasmFunctionIndexSymbol);
657 }
638 CheckCallSite(this, "getLineNumber"); 658 CheckCallSite(this, "getLineNumber");
639 return %CallSiteGetLineNumberRT(this); 659 return %CallSiteGetLineNumberRT(this);
640 } 660 }
641 661
642 function CallSiteGetColumnNumber() { 662 function CallSiteGetColumnNumber() {
643 CheckCallSite(this, "getColumnNumber"); 663 CheckCallSite(this, "getColumnNumber");
644 return %CallSiteGetColumnNumberRT(this); 664 return %CallSiteGetColumnNumberRT(this);
645 } 665 }
646 666
647 function CallSiteIsNative() { 667 function CallSiteIsNative() {
648 CheckCallSite(this, "isNative"); 668 CheckCallSite(this, "isNative");
649 return %CallSiteIsNativeRT(this); 669 return %CallSiteIsNativeRT(this);
650 } 670 }
651 671
652 function CallSiteIsConstructor() { 672 function CallSiteIsConstructor() {
653 CheckCallSite(this, "isConstructor"); 673 CheckCallSite(this, "isConstructor");
654 return %CallSiteIsConstructorRT(this); 674 return %CallSiteIsConstructorRT(this);
655 } 675 }
656 676
657 function CallSiteToString() { 677 function CallSiteToString() {
678 if (HAS_PRIVATE(this, callSiteWasmObjectSymbol)) {
679 var funName = this.getFunctionName();
680 var funcIndex = GET_PRIVATE(this, callSiteWasmFunctionIndexSymbol);
681 var pos = this.getPosition();
682 return funName + " (<WASM>:" + funcIndex + ":" + pos + ")";
683 }
684
658 var fileName; 685 var fileName;
659 var fileLocation = ""; 686 var fileLocation = "";
660 if (this.isNative()) { 687 if (this.isNative()) {
661 fileLocation = "native"; 688 fileLocation = "native";
662 } else { 689 } else {
663 fileName = this.getScriptNameOrSourceURL(); 690 fileName = this.getScriptNameOrSourceURL();
664 if (!fileName && this.isEval()) { 691 if (!fileName && this.isEval()) {
665 fileLocation = this.getEvalOrigin(); 692 fileLocation = this.getEvalOrigin();
666 fileLocation += ", "; // Expecting source position to follow. 693 fileLocation += ", "; // Expecting source position to follow.
667 } 694 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 819
793 820
794 function GetStackFrames(raw_stack) { 821 function GetStackFrames(raw_stack) {
795 var frames = new InternalArray(); 822 var frames = new InternalArray();
796 var sloppy_frames = raw_stack[0]; 823 var sloppy_frames = raw_stack[0];
797 for (var i = 1; i < raw_stack.length; i += 4) { 824 for (var i = 1; i < raw_stack.length; i += 4) {
798 var recv = raw_stack[i]; 825 var recv = raw_stack[i];
799 var fun = raw_stack[i + 1]; 826 var fun = raw_stack[i + 1];
800 var code = raw_stack[i + 2]; 827 var code = raw_stack[i + 2];
801 var pc = raw_stack[i + 3]; 828 var pc = raw_stack[i + 3];
802 var pos = %_IsSmi(code) ? code : %FunctionGetPositionForOffset(code, pc); 829 var pos = %FunctionGetPositionForOffset(code, pc);
803 sloppy_frames--; 830 sloppy_frames--;
804 frames.push(new CallSite(recv, fun, pos, (sloppy_frames < 0))); 831 frames.push(new CallSite(recv, fun, pos, (sloppy_frames < 0)));
805 } 832 }
806 return frames; 833 return frames;
807 } 834 }
808 835
809 836
810 // Flag to prevent recursive call of Error.prepareStackTrace. 837 // Flag to prevent recursive call of Error.prepareStackTrace.
811 var formatting_custom_stack_trace = false; 838 var formatting_custom_stack_trace = false;
812 839
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 utils.Export(function(to) { 1042 utils.Export(function(to) {
1016 to.ErrorToString = ErrorToString; 1043 to.ErrorToString = ErrorToString;
1017 to.MakeError = MakeError; 1044 to.MakeError = MakeError;
1018 to.MakeRangeError = MakeRangeError; 1045 to.MakeRangeError = MakeRangeError;
1019 to.MakeSyntaxError = MakeSyntaxError; 1046 to.MakeSyntaxError = MakeSyntaxError;
1020 to.MakeTypeError = MakeTypeError; 1047 to.MakeTypeError = MakeTypeError;
1021 to.MakeURIError = MakeURIError; 1048 to.MakeURIError = MakeURIError;
1022 }); 1049 });
1023 1050
1024 }); 1051 });
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698