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

Unified Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2588763002: [wasm] Implement GetPossibleBreakpoints (Closed)
Patch Set: Address comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/wasm/test-wasm-breakpoints.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/wasm-run-utils.h
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h
index 47e4bf7f0e8831cf2bd8a96885d5db0af70d1e64..4b24ca38e20ba65a380115878c40d2388ee7c566 100644
--- a/test/cctest/wasm/wasm-run-utils.h
+++ b/test/cctest/wasm/wasm-run-utils.h
@@ -266,6 +266,19 @@ class TestingModule : public ModuleEnv {
}
}
+ uint32_t AddBytes(Vector<const byte> bytes) {
+ Handle<SeqOneByteString> old_bytes =
+ instance_object_->get_compiled_module()->module_bytes();
+ uint32_t old_size = static_cast<uint32_t>(old_bytes->length());
+ ScopedVector<byte> new_bytes(old_size + bytes.length());
+ memcpy(new_bytes.start(), old_bytes->GetChars(), old_size);
+ memcpy(new_bytes.start() + old_size, bytes.start(), bytes.length());
+ Handle<SeqOneByteString> new_bytes_str = Handle<SeqOneByteString>::cast(
+ isolate_->factory()->NewStringFromOneByte(new_bytes).ToHandleChecked());
+ instance_object_->get_compiled_module()->set_module_bytes(new_bytes_str);
+ return old_size;
+ }
+
WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; }
WasmInterpreter* interpreter() { return interpreter_; }
@@ -294,19 +307,6 @@ class TestingModule : public ModuleEnv {
return &module->globals.back();
}
- uint32_t AddBytes(Vector<const byte> bytes) {
- Handle<SeqOneByteString> old_bytes =
- instance_object_->get_compiled_module()->module_bytes();
- uint32_t old_size = static_cast<uint32_t>(old_bytes->length());
- ScopedVector<byte> new_bytes(old_size + bytes.length());
- memcpy(new_bytes.start(), old_bytes->GetChars(), old_size);
- memcpy(new_bytes.start() + old_size, bytes.start(), bytes.length());
- Handle<SeqOneByteString> new_bytes_str = Handle<SeqOneByteString>::cast(
- isolate_->factory()->NewStringFromOneByte(new_bytes).ToHandleChecked());
- instance_object_->get_compiled_module()->set_module_bytes(new_bytes_str);
- return old_size;
- }
-
Handle<WasmInstanceObject> InitInstanceObject() {
Handle<Managed<wasm::WasmModule>> module_wrapper =
Managed<wasm::WasmModule>::New(isolate_, &module_, false);
@@ -498,6 +498,13 @@ class WasmFunctionCompiler : private GraphAndBuilders {
void Build(const byte* start, const byte* end) {
local_decls.Prepend(zone(), &start, &end);
+
+ CHECK_GE(kMaxInt, end - start);
+ int len = static_cast<int>(end - start);
+ function_->code_start_offset =
+ testing_module_->AddBytes(Vector<const byte>(start, len));
+ function_->code_end_offset = function_->code_start_offset + len;
+
if (interpreter_) {
// Add the code to the interpreter.
CHECK(interpreter_->SetFunctionCodeForTesting(function_, start, end));
« no previous file with comments | « test/cctest/wasm/test-wasm-breakpoints.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698