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

Side by Side Diff: src/wasm/wasm-objects.cc

Issue 2536373007: [wasm] Make DisassembleFunction a method of WasmCompiledModule (Closed)
Patch Set: Created 4 years 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/wasm/wasm-objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/wasm/wasm-objects.h" 5 #include "src/wasm/wasm-objects.h"
6 6
7 #include "src/wasm/module-decoder.h" 7 #include "src/wasm/module-decoder.h"
8 #include "src/wasm/wasm-module.h" 8 #include "src/wasm/wasm-module.h"
9 #include "src/wasm/wasm-text.h"
9 10
10 #define TRACE(...) \ 11 #define TRACE(...) \
11 do { \ 12 do { \
12 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ 13 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \
13 } while (false) 14 } while (false)
14 15
15 #define TRACE_CHAIN(instance) \ 16 #define TRACE_CHAIN(instance) \
16 do { \ 17 do { \
17 instance->PrintInstancesChain(); \ 18 instance->PrintInstancesChain(); \
18 } while (false) 19 } while (false)
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 right = mid; 533 right = mid;
533 } 534 }
534 } 535 }
535 // There should be an entry for each position that could show up on the stack 536 // There should be an entry for each position that could show up on the stack
536 // trace: 537 // trace:
537 DCHECK_EQ(total_offset, 538 DCHECK_EQ(total_offset,
538 static_cast<uint32_t>(offset_table->get_int(2 * left))); 539 static_cast<uint32_t>(offset_table->get_int(2 * left)));
539 return offset_table->get_int(2 * left + 1); 540 return offset_table->get_int(2 * left + 1);
540 } 541 }
541 542
543 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>>
544 WasmCompiledModule::DisassembleFunction(int func_index) {
545 DisallowHeapAllocation no_gc;
546
547 if (func_index < 0 ||
548 static_cast<uint32_t>(func_index) >= module()->functions.size())
549 return {};
550
551 SeqOneByteString* module_bytes_str = ptr_to_module_bytes();
552 Vector<const byte> module_bytes(module_bytes_str->GetChars(),
553 module_bytes_str->length());
554
555 std::ostringstream disassembly_os;
556 std::vector<std::tuple<uint32_t, int, int>> offset_table;
557
558 PrintWasmText(module(), module_bytes, static_cast<uint32_t>(func_index),
559 disassembly_os, &offset_table);
560
561 return {disassembly_os.str(), std::move(offset_table)};
562 }
563
542 Handle<WasmInstanceWrapper> WasmInstanceWrapper::New( 564 Handle<WasmInstanceWrapper> WasmInstanceWrapper::New(
543 Isolate* isolate, Handle<WasmInstanceObject> instance) { 565 Isolate* isolate, Handle<WasmInstanceObject> instance) {
544 Handle<FixedArray> array = 566 Handle<FixedArray> array =
545 isolate->factory()->NewFixedArray(kWrapperPropertyCount, TENURED); 567 isolate->factory()->NewFixedArray(kWrapperPropertyCount, TENURED);
546 Handle<WasmInstanceWrapper> instance_wrapper( 568 Handle<WasmInstanceWrapper> instance_wrapper(
547 reinterpret_cast<WasmInstanceWrapper*>(*array), isolate); 569 reinterpret_cast<WasmInstanceWrapper*>(*array), isolate);
548 instance_wrapper->set_instance_object(instance, isolate); 570 instance_wrapper->set_instance_object(instance, isolate);
549 return instance_wrapper; 571 return instance_wrapper;
550 } 572 }
551 573
(...skipping 10 matching lines...) Expand all
562 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) 584 !array->get(kPreviousInstanceWrapper)->IsFixedArray())
563 return false; 585 return false;
564 return true; 586 return true;
565 } 587 }
566 588
567 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, 589 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance,
568 Isolate* isolate) { 590 Isolate* isolate) {
569 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); 591 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance);
570 set(kWrapperInstanceObject, *cell); 592 set(kWrapperInstanceObject, *cell);
571 } 593 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698