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 "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/compiler/wasm-compiler.h" | 9 #include "src/compiler/wasm-compiler.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
11 #include "src/debug/debug.h" | 11 #include "src/debug/debug.h" |
12 #include "src/factory.h" | 12 #include "src/factory.h" |
13 #include "src/frames-inl.h" | 13 #include "src/frames-inl.h" |
14 #include "src/objects-inl.h" | 14 #include "src/objects-inl.h" |
| 15 #include "src/trap-handler/trap-handler.h" |
15 #include "src/v8memory.h" | 16 #include "src/v8memory.h" |
16 #include "src/wasm/wasm-module.h" | 17 #include "src/wasm/wasm-module.h" |
17 #include "src/wasm/wasm-objects.h" | 18 #include "src/wasm/wasm-objects.h" |
18 #include "src/wasm/wasm-opcodes.h" | 19 #include "src/wasm/wasm-opcodes.h" |
19 | 20 |
20 namespace v8 { | 21 namespace v8 { |
21 namespace internal { | 22 namespace internal { |
22 | 23 |
23 namespace { | 24 namespace { |
24 Handle<WasmInstanceObject> GetWasmInstanceOnStackTop(Isolate* isolate) { | 25 Handle<WasmInstanceObject> GetWasmInstanceOnStackTop(Isolate* isolate) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 HandleScope scope(isolate); | 154 HandleScope scope(isolate); |
154 DCHECK_EQ(1, args.length()); | 155 DCHECK_EQ(1, args.length()); |
155 Object* exception = args[0]; | 156 Object* exception = args[0]; |
156 // The unwinder will only deliver exceptions to wasm if the exception is a | 157 // The unwinder will only deliver exceptions to wasm if the exception is a |
157 // Number or a Smi (which we have just converted to a Number.) This logic | 158 // Number or a Smi (which we have just converted to a Number.) This logic |
158 // lives in Isolate::is_catchable_by_wasm(Object*). | 159 // lives in Isolate::is_catchable_by_wasm(Object*). |
159 CHECK(exception->IsNumber()); | 160 CHECK(exception->IsNumber()); |
160 return exception; | 161 return exception; |
161 } | 162 } |
162 | 163 |
| 164 RUNTIME_FUNCTION(Runtime_SetThreadInWasm) { |
| 165 DCHECK(!trap_handler::IsThreadInWasm()); |
| 166 trap_handler::SetThreadInWasm(); |
| 167 return isolate->heap()->undefined_value(); |
| 168 } |
| 169 |
| 170 RUNTIME_FUNCTION(Runtime_ClearThreadInWasm) { |
| 171 DCHECK(trap_handler::IsThreadInWasm()); |
| 172 trap_handler::ClearThreadInWasm(); |
| 173 return isolate->heap()->undefined_value(); |
| 174 } |
| 175 |
163 RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { | 176 RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { |
164 DCHECK(args.length() == 3); | 177 DCHECK(args.length() == 3); |
165 HandleScope scope(isolate); | 178 HandleScope scope(isolate); |
166 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); | 179 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); |
167 CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[1]); | 180 CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[1]); |
168 CONVERT_ARG_HANDLE_CHECKED(Object, arg_buffer_obj, 2); | 181 CONVERT_ARG_HANDLE_CHECKED(Object, arg_buffer_obj, 2); |
169 CHECK(WasmInstanceObject::IsWasmInstanceObject(*instance_obj)); | 182 CHECK(WasmInstanceObject::IsWasmInstanceObject(*instance_obj)); |
170 Handle<WasmInstanceObject> instance = | 183 Handle<WasmInstanceObject> instance = |
171 Handle<WasmInstanceObject>::cast(instance_obj); | 184 Handle<WasmInstanceObject>::cast(instance_obj); |
172 | 185 |
173 // The arg buffer is the raw pointer to the caller's stack. It looks like a | 186 // The arg buffer is the raw pointer to the caller's stack. It looks like a |
174 // Smi (lowest bit not set, as checked by IsSmi), but is no valid Smi. We just | 187 // Smi (lowest bit not set, as checked by IsSmi), but is no valid Smi. We just |
175 // cast it back to the raw pointer. | 188 // cast it back to the raw pointer. |
176 CHECK(!arg_buffer_obj->IsHeapObject()); | 189 CHECK(!arg_buffer_obj->IsHeapObject()); |
177 CHECK(arg_buffer_obj->IsSmi()); | 190 CHECK(arg_buffer_obj->IsSmi()); |
178 uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj); | 191 uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj); |
179 | 192 |
180 // Set the current isolate's context, saving the previous one. | 193 // Set the current isolate's context, saving the previous one. |
181 SaveContext save(isolate); | 194 SaveContext save(isolate); |
182 isolate->set_context(*instance->compiled_module()->native_context()); | 195 isolate->set_context(*instance->compiled_module()->native_context()); |
183 | 196 |
184 instance->debug_info()->RunInterpreter(func_index, arg_buffer); | 197 instance->debug_info()->RunInterpreter(func_index, arg_buffer); |
185 return isolate->heap()->undefined_value(); | 198 return isolate->heap()->undefined_value(); |
186 } | 199 } |
187 | 200 |
188 } // namespace internal | 201 } // namespace internal |
189 } // namespace v8 | 202 } // namespace v8 |
OLD | NEW |