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

Side by Side Diff: src/messages.cc

Issue 2493823003: [wasm] Allocate a single script per wasm module (Closed)
Patch Set: rebase Created 4 years, 1 month 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/messages.h ('k') | src/objects.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 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"
11 #include "src/isolate-inl.h" 11 #include "src/isolate-inl.h"
12 #include "src/keys.h" 12 #include "src/keys.h"
13 #include "src/string-builder.h" 13 #include "src/string-builder.h"
14 #include "src/wasm/wasm-module.h" 14 #include "src/wasm/wasm-module.h"
15 #include "src/wasm/wasm-objects.h"
15 16
16 namespace v8 { 17 namespace v8 {
17 namespace internal { 18 namespace internal {
18 19
19 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, 20 MessageLocation::MessageLocation(Handle<Script> script, int start_pos,
20 int end_pos) 21 int end_pos)
21 : script_(script), start_pos_(start_pos), end_pos_(end_pos) {} 22 : script_(script), start_pos_(start_pos), end_pos_(end_pos) {}
22 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, 23 MessageLocation::MessageLocation(Handle<Script> script, int start_pos,
23 int end_pos, Handle<JSFunction> function) 24 int end_pos, Handle<JSFunction> function)
24 : script_(script), 25 : script_(script),
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 code_ = handle(array->Code(frame_ix), isolate); 629 code_ = handle(array->Code(frame_ix), isolate);
629 offset_ = array->Offset(frame_ix)->value(); 630 offset_ = array->Offset(frame_ix)->value();
630 } 631 }
631 632
632 Handle<Object> WasmStackFrame::GetFunction() const { 633 Handle<Object> WasmStackFrame::GetFunction() const {
633 Handle<Object> obj(Smi::FromInt(wasm_func_index_), isolate_); 634 Handle<Object> obj(Smi::FromInt(wasm_func_index_), isolate_);
634 return obj; 635 return obj;
635 } 636 }
636 637
637 Handle<Object> WasmStackFrame::GetFunctionName() { 638 Handle<Object> WasmStackFrame::GetFunctionName() {
638 return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_instance_, 639 Handle<Object> name;
639 wasm_func_index_); 640 Handle<WasmCompiledModule> compiled_module(
641 Handle<WasmInstanceObject>::cast(wasm_instance_)->get_compiled_module(),
642 isolate_);
643 if (!WasmCompiledModule::GetFunctionName(compiled_module, wasm_func_index_)
644 .ToHandle(&name)) {
645 name = isolate_->factory()->null_value();
646 }
647 return name;
640 } 648 }
641 649
642 MaybeHandle<String> WasmStackFrame::ToString() { 650 MaybeHandle<String> WasmStackFrame::ToString() {
643 IncrementalStringBuilder builder(isolate_); 651 IncrementalStringBuilder builder(isolate_);
644 652
645 Handle<Object> name = GetFunctionName(); 653 Handle<Object> name = GetFunctionName();
646 if (name->IsNull(isolate_)) { 654 if (name->IsNull(isolate_)) {
647 builder.AppendCString("<WASM UNNAMED>"); 655 builder.AppendCString("<WASM UNNAMED>");
648 } else { 656 } else {
649 DCHECK(name->IsString()); 657 DCHECK(name->IsString());
(...skipping 26 matching lines...) Expand all
676 return isolate_->global_proxy(); 684 return isolate_->global_proxy();
677 } 685 }
678 686
679 Handle<Object> AsmJsWasmStackFrame::GetFunction() const { 687 Handle<Object> AsmJsWasmStackFrame::GetFunction() const {
680 // TODO(clemensh): Return lazily created JSFunction. 688 // TODO(clemensh): Return lazily created JSFunction.
681 return Null(); 689 return Null();
682 } 690 }
683 691
684 Handle<Object> AsmJsWasmStackFrame::GetFileName() { 692 Handle<Object> AsmJsWasmStackFrame::GetFileName() {
685 Handle<Script> script = 693 Handle<Script> script =
686 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); 694 wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
695 DCHECK_EQ(Script::TYPE_NORMAL, script->type());
687 return handle(script->name(), isolate_); 696 return handle(script->name(), isolate_);
688 } 697 }
689 698
690 Handle<Object> AsmJsWasmStackFrame::GetFunctionName() {
691 return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_instance_,
692 wasm_func_index_);
693 }
694
695 Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() { 699 Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() {
696 Handle<Script> script = 700 Handle<Script> script =
697 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); 701 wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
702 DCHECK_EQ(Script::TYPE_NORMAL, script->type());
698 return ScriptNameOrSourceUrl(script, isolate_); 703 return ScriptNameOrSourceUrl(script, isolate_);
699 } 704 }
700 705
701 int AsmJsWasmStackFrame::GetPosition() const { 706 int AsmJsWasmStackFrame::GetPosition() const {
702 DCHECK_LE(0, offset_); 707 DCHECK_LE(0, offset_);
703 int byte_offset = code_->SourcePosition(offset_); 708 int byte_offset = code_->SourcePosition(offset_);
704 return wasm::GetAsmWasmSourcePosition(Handle<JSObject>::cast(wasm_instance_), 709 return wasm::GetAsmWasmSourcePosition(Handle<JSObject>::cast(wasm_instance_),
705 wasm_func_index_, byte_offset); 710 wasm_func_index_, byte_offset);
706 } 711 }
707 712
708 int AsmJsWasmStackFrame::GetLineNumber() { 713 int AsmJsWasmStackFrame::GetLineNumber() {
709 DCHECK_LE(0, GetPosition()); 714 DCHECK_LE(0, GetPosition());
710 Handle<Script> script = 715 Handle<Script> script =
711 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); 716 wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
717 DCHECK_EQ(Script::TYPE_NORMAL, script->type());
712 return Script::GetLineNumber(script, GetPosition()) + 1; 718 return Script::GetLineNumber(script, GetPosition()) + 1;
713 } 719 }
714 720
715 int AsmJsWasmStackFrame::GetColumnNumber() { 721 int AsmJsWasmStackFrame::GetColumnNumber() {
716 DCHECK_LE(0, GetPosition()); 722 DCHECK_LE(0, GetPosition());
717 Handle<Script> script = 723 Handle<Script> script =
718 wasm::GetAsmWasmScript(Handle<JSObject>::cast(wasm_instance_)); 724 wasm::GetScript(Handle<JSObject>::cast(wasm_instance_));
725 DCHECK_EQ(Script::TYPE_NORMAL, script->type());
719 return Script::GetColumnNumber(script, GetPosition()) + 1; 726 return Script::GetColumnNumber(script, GetPosition()) + 1;
720 } 727 }
721 728
722 MaybeHandle<String> AsmJsWasmStackFrame::ToString() { 729 MaybeHandle<String> AsmJsWasmStackFrame::ToString() {
723 // The string should look exactly as the respective javascript frame string. 730 // The string should look exactly as the respective javascript frame string.
724 // Keep this method in line to JSStackFrame::ToString(). 731 // Keep this method in line to JSStackFrame::ToString().
725 732
726 IncrementalStringBuilder builder(isolate_); 733 IncrementalStringBuilder builder(isolate_);
727 734
728 Handle<Object> function_name = GetFunctionName(); 735 Handle<Object> function_name = GetFunctionName();
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 DCHECK(mode != SKIP_UNTIL_SEEN); 1187 DCHECK(mode != SKIP_UNTIL_SEEN);
1181 1188
1182 Handle<Object> no_caller; 1189 Handle<Object> no_caller;
1183 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2); 1190 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2);
1184 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode, 1191 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode,
1185 no_caller, false); 1192 no_caller, false);
1186 } 1193 }
1187 1194
1188 } // namespace internal 1195 } // namespace internal
1189 } // namespace v8 1196 } // namespace v8
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698