OLD | NEW |
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 #include "test/common/wasm/wasm-module-runner.h" | 5 #include "test/common/wasm/wasm-module-runner.h" |
6 | 6 |
7 #include "src/handles.h" | 7 #include "src/handles.h" |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 #include "src/property-descriptor.h" | 10 #include "src/property-descriptor.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 Handle<JSObject> instance = CompileInstantiateWasmModuleForTesting( | 107 Handle<JSObject> instance = CompileInstantiateWasmModuleForTesting( |
108 isolate, &thrower, module_start, module_end, origin); | 108 isolate, &thrower, module_start, module_end, origin); |
109 if (instance.is_null()) { | 109 if (instance.is_null()) { |
110 return -1; | 110 return -1; |
111 } | 111 } |
112 return RunWasmModuleForTesting(isolate, instance, 0, nullptr, origin); | 112 return RunWasmModuleForTesting(isolate, instance, 0, nullptr, origin); |
113 } | 113 } |
114 | 114 |
115 int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower, | 115 int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower, |
116 const WasmModule* module, int function_index, | 116 const WasmModule* module, int function_index, |
117 WasmVal* args) { | 117 WasmVal* args, bool* possible_nondeterminism) { |
118 CHECK(module != nullptr); | 118 CHECK(module != nullptr); |
119 | 119 |
120 Zone zone(isolate->allocator(), ZONE_NAME); | 120 Zone zone(isolate->allocator(), ZONE_NAME); |
121 v8::internal::HandleScope scope(isolate); | 121 v8::internal::HandleScope scope(isolate); |
122 | 122 |
123 if (module->import_table.size() > 0) { | 123 if (module->import_table.size() > 0) { |
124 thrower->CompileError("Not supported: module has imports."); | 124 thrower->CompileError("Not supported: module has imports."); |
125 } | 125 } |
126 if (module->export_table.size() == 0) { | 126 if (module->export_table.size() == 0) { |
127 thrower->CompileError("Not supported: module has no exports."); | 127 thrower->CompileError("Not supported: module has no exports."); |
(...skipping 30 matching lines...) Expand all Loading... |
158 | 158 |
159 WasmInterpreter interpreter(&instance, isolate->allocator()); | 159 WasmInterpreter interpreter(&instance, isolate->allocator()); |
160 | 160 |
161 WasmInterpreter::Thread* thread = interpreter.GetThread(0); | 161 WasmInterpreter::Thread* thread = interpreter.GetThread(0); |
162 thread->Reset(); | 162 thread->Reset(); |
163 thread->PushFrame(&(module->functions[function_index]), args); | 163 thread->PushFrame(&(module->functions[function_index]), args); |
164 WasmInterpreter::State interpreter_result = thread->Run(); | 164 WasmInterpreter::State interpreter_result = thread->Run(); |
165 if (instance.mem_start) { | 165 if (instance.mem_start) { |
166 free(instance.mem_start); | 166 free(instance.mem_start); |
167 } | 167 } |
| 168 *possible_nondeterminism = thread->PossibleNondeterminism(); |
168 if (interpreter_result == WasmInterpreter::FINISHED) { | 169 if (interpreter_result == WasmInterpreter::FINISHED) { |
169 WasmVal val = thread->GetReturnValue(); | 170 WasmVal val = thread->GetReturnValue(); |
170 return val.to<int32_t>(); | 171 return val.to<int32_t>(); |
171 } else if (thread->state() == WasmInterpreter::TRAPPED) { | 172 } else if (thread->state() == WasmInterpreter::TRAPPED) { |
172 return 0xdeadbeef; | 173 return 0xdeadbeef; |
173 } else { | 174 } else { |
174 thrower->RangeError( | 175 thrower->RangeError( |
175 "Interpreter did not finish execution within its step bound"); | 176 "Interpreter did not finish execution within its step bound"); |
176 return -1; | 177 return -1; |
177 } | 178 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 222 |
222 void SetupIsolateForWasmModule(Isolate* isolate) { | 223 void SetupIsolateForWasmModule(Isolate* isolate) { |
223 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); | 224 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); |
224 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), | 225 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), |
225 isolate->native_context()); | 226 isolate->native_context()); |
226 } | 227 } |
227 } // namespace testing | 228 } // namespace testing |
228 } // namespace wasm | 229 } // namespace wasm |
229 } // namespace internal | 230 } // namespace internal |
230 } // namespace v8 | 231 } // namespace v8 |
OLD | NEW |