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

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

Issue 2536763002: [inspector] [wasm] Implement GetPossibleBreakpoints (Closed)
Patch Set: Rebase 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') | test/inspector/debugger/wasm-get-breakable-locations.js » ('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 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/debug/debug-interface.h"
7 #include "src/wasm/module-decoder.h" 8 #include "src/wasm/module-decoder.h"
8 #include "src/wasm/wasm-module.h" 9 #include "src/wasm/wasm-module.h"
9 #include "src/wasm/wasm-text.h" 10 #include "src/wasm/wasm-text.h"
10 11
11 #define TRACE(...) \ 12 #define TRACE(...) \
12 do { \ 13 do { \
13 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ 14 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \
14 } while (false) 15 } while (false)
15 16
16 #define TRACE_CHAIN(instance) \ 17 #define TRACE_CHAIN(instance) \
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 555
555 std::ostringstream disassembly_os; 556 std::ostringstream disassembly_os;
556 std::vector<std::tuple<uint32_t, int, int>> offset_table; 557 std::vector<std::tuple<uint32_t, int, int>> offset_table;
557 558
558 PrintWasmText(module(), module_bytes, static_cast<uint32_t>(func_index), 559 PrintWasmText(module(), module_bytes, static_cast<uint32_t>(func_index),
559 disassembly_os, &offset_table); 560 disassembly_os, &offset_table);
560 561
561 return {disassembly_os.str(), std::move(offset_table)}; 562 return {disassembly_os.str(), std::move(offset_table)};
562 } 563 }
563 564
565 bool WasmCompiledModule::GetPossibleBreakpoints(
566 const v8::DebugInterface::Location& start,
567 const v8::DebugInterface::Location& end,
568 std::vector<v8::DebugInterface::Location>* locations) const {
569 DisallowHeapAllocation no_gc;
570
571 std::vector<WasmFunction>& functions = module()->functions;
572 if (start.GetLineNumber() < 0 || start.GetColumnNumber() < 0 ||
573 (!end.IsEmpty() &&
574 (end.GetLineNumber() < 0 || end.GetColumnNumber() < 0)))
575 return false;
576
577 DCHECK(!functions.empty());
578 // start_func_index, start_offset and end_func_index is inclusive.
579 // end_offset is exclusive.
580 // start_offset and end_offset are module-relative byte offsets.
581 uint32_t start_func_index = start.GetLineNumber();
582 if (start_func_index >= functions.size()) return false;
583 uint32_t start_offset =
584 functions[start_func_index].code_start_offset + start.GetColumnNumber();
585 uint32_t end_func_index;
586 uint32_t end_offset;
587 if (end.IsEmpty()) {
588 // Default: everything till the end of the Script.
589 end_func_index = static_cast<uint32_t>(functions.size() - 1);
590 end_offset = functions[end_func_index].code_end_offset;
591 } else {
592 // If end is specified: Use it and check for valid input.
593 end_func_index = static_cast<uint32_t>(end.GetLineNumber());
594
595 // Special case: Stop before the start of the next function. Change to: Stop
596 // at the end of the function before, such that we don't disassemble the
597 // next function also.
598 if (end.GetColumnNumber() == 0 && end_func_index > 0) {
599 --end_func_index;
600 end_offset = functions[end_func_index].code_end_offset;
601 } else {
602 if (end_func_index >= functions.size()) return false;
603 end_offset =
604 functions[end_func_index].code_start_offset + end.GetColumnNumber();
605 if (end_offset > functions[end_func_index].code_end_offset) return false;
606 }
607 }
608
609 AccountingAllocator alloc;
610 Zone tmp(&alloc, ZONE_NAME);
611 const byte* module_start = ptr_to_module_bytes()->GetChars();
612
613 for (uint32_t func_idx = start_func_index; func_idx <= end_func_index;
614 ++func_idx) {
615 WasmFunction& func = functions[func_idx];
616 if (func.code_start_offset == func.code_end_offset) continue;
617
618 AstLocalDecls locals(&tmp);
619 BytecodeIterator iterator(module_start + func.code_start_offset,
620 module_start + func.code_end_offset, &locals);
621 DCHECK_LT(0u, locals.decls_encoded_size);
622 for (; iterator.has_next(); iterator.next()) {
623 uint32_t offset = func.code_start_offset + iterator.pc_offset();
624 if (offset >= end_offset) {
625 DCHECK_EQ(end_func_index, func_idx);
626 break;
627 }
628 if (offset < start_offset) continue;
629 locations->push_back(
630 v8::DebugInterface::Location(func_idx, iterator.pc_offset()));
631 }
632 }
633 return true;
634 }
635
564 Handle<WasmInstanceWrapper> WasmInstanceWrapper::New( 636 Handle<WasmInstanceWrapper> WasmInstanceWrapper::New(
565 Isolate* isolate, Handle<WasmInstanceObject> instance) { 637 Isolate* isolate, Handle<WasmInstanceObject> instance) {
566 Handle<FixedArray> array = 638 Handle<FixedArray> array =
567 isolate->factory()->NewFixedArray(kWrapperPropertyCount, TENURED); 639 isolate->factory()->NewFixedArray(kWrapperPropertyCount, TENURED);
568 Handle<WasmInstanceWrapper> instance_wrapper( 640 Handle<WasmInstanceWrapper> instance_wrapper(
569 reinterpret_cast<WasmInstanceWrapper*>(*array), isolate); 641 reinterpret_cast<WasmInstanceWrapper*>(*array), isolate);
570 instance_wrapper->set_instance_object(instance, isolate); 642 instance_wrapper->set_instance_object(instance, isolate);
571 return instance_wrapper; 643 return instance_wrapper;
572 } 644 }
573 645
(...skipping 10 matching lines...) Expand all
584 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) 656 !array->get(kPreviousInstanceWrapper)->IsFixedArray())
585 return false; 657 return false;
586 return true; 658 return true;
587 } 659 }
588 660
589 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, 661 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance,
590 Isolate* isolate) { 662 Isolate* isolate) {
591 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); 663 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance);
592 set(kWrapperInstanceObject, *cell); 664 set(kWrapperInstanceObject, *cell);
593 } 665 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-objects.h ('k') | test/inspector/debugger/wasm-get-breakable-locations.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698