OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/messages.h" | 5 #include "src/messages.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 616 |
617 Handle<Script> JSStackFrame::GetScript() const { | 617 Handle<Script> JSStackFrame::GetScript() const { |
618 return handle(Script::cast(function_->shared()->script()), isolate_); | 618 return handle(Script::cast(function_->shared()->script()), isolate_); |
619 } | 619 } |
620 | 620 |
621 void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array, | 621 void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array, |
622 int frame_ix) { | 622 int frame_ix) { |
623 // This function is called for both wasm and asm.js->wasm frames. | 623 // This function is called for both wasm and asm.js->wasm frames. |
624 DCHECK(array->IsWasmFrame(frame_ix) || array->IsAsmJsWasmFrame(frame_ix)); | 624 DCHECK(array->IsWasmFrame(frame_ix) || array->IsAsmJsWasmFrame(frame_ix)); |
625 isolate_ = isolate; | 625 isolate_ = isolate; |
626 wasm_obj_ = handle(array->WasmObject(frame_ix), isolate); | 626 wasm_instance_ = handle(array->WasmInstance(frame_ix), isolate); |
627 wasm_func_index_ = array->WasmFunctionIndex(frame_ix)->value(); | 627 wasm_func_index_ = array->WasmFunctionIndex(frame_ix)->value(); |
628 code_ = handle(array->Code(frame_ix), isolate); | 628 code_ = handle(array->Code(frame_ix), isolate); |
629 offset_ = array->Offset(frame_ix)->value(); | 629 offset_ = array->Offset(frame_ix)->value(); |
630 } | 630 } |
631 | 631 |
632 Handle<Object> WasmStackFrame::GetFunction() const { | 632 Handle<Object> WasmStackFrame::GetFunction() const { |
633 Handle<Object> obj(Smi::FromInt(wasm_func_index_), isolate_); | 633 Handle<Object> obj(Smi::FromInt(wasm_func_index_), isolate_); |
634 return obj; | 634 return obj; |
635 } | 635 } |
636 | 636 |
637 Handle<Object> WasmStackFrame::GetFunctionName() { | 637 Handle<Object> WasmStackFrame::GetFunctionName() { |
638 return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_obj_, wasm_func_index_); | 638 return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_instance_, |
| 639 wasm_func_index_); |
639 } | 640 } |
640 | 641 |
641 MaybeHandle<String> WasmStackFrame::ToString() { | 642 MaybeHandle<String> WasmStackFrame::ToString() { |
642 IncrementalStringBuilder builder(isolate_); | 643 IncrementalStringBuilder builder(isolate_); |
643 | 644 |
644 Handle<Object> name = GetFunctionName(); | 645 Handle<Object> name = GetFunctionName(); |
645 if (name->IsNull(isolate_)) { | 646 if (name->IsNull(isolate_)) { |
646 builder.AppendCString("<WASM UNNAMED>"); | 647 builder.AppendCString("<WASM UNNAMED>"); |
647 } else { | 648 } else { |
648 DCHECK(name->IsString()); | 649 DCHECK(name->IsString()); |
(...skipping 26 matching lines...) Expand all Loading... |
675 return isolate_->global_proxy(); | 676 return isolate_->global_proxy(); |
676 } | 677 } |
677 | 678 |
678 Handle<Object> AsmJsWasmStackFrame::GetFunction() const { | 679 Handle<Object> AsmJsWasmStackFrame::GetFunction() const { |
679 // TODO(clemensh): Return lazily created JSFunction. | 680 // TODO(clemensh): Return lazily created JSFunction. |
680 return Null(); | 681 return Null(); |
681 } | 682 } |
682 | 683 |
683 Handle<Object> AsmJsWasmStackFrame::GetFileName() { | 684 Handle<Object> AsmJsWasmStackFrame::GetFileName() { |
684 Handle<Script> script = | 685 Handle<Script> script = |
685 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_obj_)); | 686 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); |
686 return handle(script->name(), isolate_); | 687 return handle(script->name(), isolate_); |
687 } | 688 } |
688 | 689 |
689 Handle<Object> AsmJsWasmStackFrame::GetFunctionName() { | 690 Handle<Object> AsmJsWasmStackFrame::GetFunctionName() { |
690 return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_obj_, wasm_func_index_); | 691 return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_instance_, |
| 692 wasm_func_index_); |
691 } | 693 } |
692 | 694 |
693 Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() { | 695 Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() { |
694 Handle<Script> script = | 696 Handle<Script> script = |
695 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_obj_)); | 697 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); |
696 return ScriptNameOrSourceUrl(script, isolate_); | 698 return ScriptNameOrSourceUrl(script, isolate_); |
697 } | 699 } |
698 | 700 |
699 int AsmJsWasmStackFrame::GetPosition() const { | 701 int AsmJsWasmStackFrame::GetPosition() const { |
700 DCHECK_LE(0, offset_); | 702 DCHECK_LE(0, offset_); |
701 int byte_offset = code_->SourcePosition(offset_); | 703 int byte_offset = code_->SourcePosition(offset_); |
702 return wasm::GetAsmWasmSourcePosition(Handle<JSObject>::cast(wasm_obj_), | 704 return wasm::GetAsmWasmSourcePosition(Handle<JSObject>::cast(wasm_instance_), |
703 wasm_func_index_, byte_offset); | 705 wasm_func_index_, byte_offset); |
704 } | 706 } |
705 | 707 |
706 int AsmJsWasmStackFrame::GetLineNumber() { | 708 int AsmJsWasmStackFrame::GetLineNumber() { |
707 DCHECK_LE(0, GetPosition()); | 709 DCHECK_LE(0, GetPosition()); |
708 Handle<Script> script = | 710 Handle<Script> script = |
709 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_obj_)); | 711 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); |
710 return Script::GetLineNumber(script, GetPosition()) + 1; | 712 return Script::GetLineNumber(script, GetPosition()) + 1; |
711 } | 713 } |
712 | 714 |
713 int AsmJsWasmStackFrame::GetColumnNumber() { | 715 int AsmJsWasmStackFrame::GetColumnNumber() { |
714 DCHECK_LE(0, GetPosition()); | 716 DCHECK_LE(0, GetPosition()); |
715 Handle<Script> script = | 717 Handle<Script> script = |
716 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_obj_)); | 718 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); |
717 return Script::GetColumnNumber(script, GetPosition()) + 1; | 719 return Script::GetColumnNumber(script, GetPosition()) + 1; |
718 } | 720 } |
719 | 721 |
720 MaybeHandle<String> AsmJsWasmStackFrame::ToString() { | 722 MaybeHandle<String> AsmJsWasmStackFrame::ToString() { |
721 // The string should look exactly as the respective javascript frame string. | 723 // The string should look exactly as the respective javascript frame string. |
722 // Keep this method in line to JSStackFrame::ToString(). | 724 // Keep this method in line to JSStackFrame::ToString(). |
723 | 725 |
724 IncrementalStringBuilder builder(isolate_); | 726 IncrementalStringBuilder builder(isolate_); |
725 | 727 |
726 Handle<Object> function_name = GetFunctionName(); | 728 Handle<Object> function_name = GetFunctionName(); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 DCHECK(mode != SKIP_UNTIL_SEEN); | 1180 DCHECK(mode != SKIP_UNTIL_SEEN); |
1179 | 1181 |
1180 Handle<Object> no_caller; | 1182 Handle<Object> no_caller; |
1181 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2); | 1183 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2); |
1182 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode, | 1184 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode, |
1183 no_caller, false); | 1185 no_caller, false); |
1184 } | 1186 } |
1185 | 1187 |
1186 } // namespace internal | 1188 } // namespace internal |
1187 } // namespace v8 | 1189 } // namespace v8 |
OLD | NEW |