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

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2676513008: [wasm] Managed<T> ensures T's lifetime does not leak past Isolate's (Closed)
Patch Set: renamed to ManagedObjectFinalizer, and using "finalizer"` Created 3 years, 10 months 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 | « test/cctest/wasm/test-managed.cc ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <setjmp.h> 8 #include <setjmp.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 {type, true, WasmInitExpr(), global_offset, false, false}); 324 {type, true, WasmInitExpr(), global_offset, false, false});
325 global_offset += size; 325 global_offset += size;
326 // limit number of globals. 326 // limit number of globals.
327 CHECK_LT(global_offset, kMaxGlobalsSize); 327 CHECK_LT(global_offset, kMaxGlobalsSize);
328 return &module->globals.back(); 328 return &module->globals.back();
329 } 329 }
330 330
331 Handle<WasmInstanceObject> InitInstanceObject() { 331 Handle<WasmInstanceObject> InitInstanceObject() {
332 Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast( 332 Handle<SeqOneByteString> empty_string = Handle<SeqOneByteString>::cast(
333 isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked()); 333 isolate_->factory()->NewStringFromOneByte({}).ToHandleChecked());
334 Handle<Managed<wasm::WasmModule>> module_wrapper = 334 // The lifetime of the wasm module is tied to this object's, and we cannot
335 Managed<wasm::WasmModule>::New(isolate_, &module_, false); 335 // rely on the mechanics of Managed<T>.
336 Handle<Foreign> module_wrapper =
337 isolate_->factory()->NewForeign(reinterpret_cast<Address>(&module));
336 Handle<Script> script = 338 Handle<Script> script =
337 isolate_->factory()->NewScript(isolate_->factory()->empty_string()); 339 isolate_->factory()->NewScript(isolate_->factory()->empty_string());
338 script->set_type(Script::TYPE_WASM); 340 script->set_type(Script::TYPE_WASM);
339 Handle<WasmSharedModuleData> shared_module_data = 341 Handle<WasmSharedModuleData> shared_module_data =
340 WasmSharedModuleData::New(isolate_, module_wrapper, empty_string, 342 WasmSharedModuleData::New(isolate_, module_wrapper, empty_string,
341 script, Handle<ByteArray>::null()); 343 script, Handle<ByteArray>::null());
342 Handle<WasmCompiledModule> compiled_module = 344 Handle<WasmCompiledModule> compiled_module =
343 WasmCompiledModule::New(isolate_, shared_module_data); 345 WasmCompiledModule::New(isolate_, shared_module_data);
344 // Minimally initialize the compiled module such that IsWasmCompiledModule 346 // Minimally initialize the compiled module such that IsWasmCompiledModule
345 // passes. 347 // passes.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 void RunWasm_##name(WasmExecutionMode execution_mode) 828 void RunWasm_##name(WasmExecutionMode execution_mode)
827 829
828 #define WASM_EXEC_COMPILED_TEST(name) \ 830 #define WASM_EXEC_COMPILED_TEST(name) \
829 void RunWasm_##name(WasmExecutionMode execution_mode); \ 831 void RunWasm_##name(WasmExecutionMode execution_mode); \
830 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 832 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
831 void RunWasm_##name(WasmExecutionMode execution_mode) 833 void RunWasm_##name(WasmExecutionMode execution_mode)
832 834
833 } // namespace 835 } // namespace
834 836
835 #endif 837 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-managed.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698