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

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

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Feedback from mseaborn 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
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 #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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 HandleScope scope(isolate); 146 HandleScope scope(isolate);
146 DCHECK_EQ(1, args.length()); 147 DCHECK_EQ(1, args.length());
147 Object* exception = args[0]; 148 Object* exception = args[0];
148 // The unwinder will only deliver exceptions to wasm if the exception is a 149 // The unwinder will only deliver exceptions to wasm if the exception is a
149 // Number or a Smi (which we have just converted to a Number.) This logic 150 // Number or a Smi (which we have just converted to a Number.) This logic
150 // lives in Isolate::is_catchable_by_wasm(Object*). 151 // lives in Isolate::is_catchable_by_wasm(Object*).
151 CHECK(exception->IsNumber()); 152 CHECK(exception->IsNumber());
152 return exception; 153 return exception;
153 } 154 }
154 155
156 RUNTIME_FUNCTION(Runtime_SetThreadInWasm) {
157 DCHECK(!trap_handler::IsThreadInWasm());
158 trap_handler::SetThreadInWasm();
159 return isolate->heap()->undefined_value();
160 }
161
162 RUNTIME_FUNCTION(Runtime_ClearThreadInWasm) {
163 DCHECK(trap_handler::IsThreadInWasm());
164 trap_handler::ClearThreadInWasm();
165 return isolate->heap()->undefined_value();
166 }
167
155 RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { 168 RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
156 DCHECK(args.length() == 3); 169 DCHECK(args.length() == 3);
157 HandleScope scope(isolate); 170 HandleScope scope(isolate);
158 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); 171 CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0);
159 CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[1]); 172 CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[1]);
160 CONVERT_ARG_HANDLE_CHECKED(Object, arg_buffer_obj, 2); 173 CONVERT_ARG_HANDLE_CHECKED(Object, arg_buffer_obj, 2);
161 CHECK(WasmInstanceObject::IsWasmInstanceObject(*instance_obj)); 174 CHECK(WasmInstanceObject::IsWasmInstanceObject(*instance_obj));
162 Handle<WasmInstanceObject> instance = 175 Handle<WasmInstanceObject> instance =
163 Handle<WasmInstanceObject>::cast(instance_obj); 176 Handle<WasmInstanceObject>::cast(instance_obj);
164 177
165 // The arg buffer is the raw pointer to the caller's stack. It looks like a 178 // The arg buffer is the raw pointer to the caller's stack. It looks like a
166 // Smi (lowest bit not set, as checked by IsSmi), but is no valid Smi. We just 179 // Smi (lowest bit not set, as checked by IsSmi), but is no valid Smi. We just
167 // cast it back to the raw pointer. 180 // cast it back to the raw pointer.
168 CHECK(!arg_buffer_obj->IsHeapObject()); 181 CHECK(!arg_buffer_obj->IsHeapObject());
169 CHECK(arg_buffer_obj->IsSmi()); 182 CHECK(arg_buffer_obj->IsSmi());
170 uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj); 183 uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj);
171 184
172 instance->debug_info()->RunInterpreter(func_index, arg_buffer); 185 instance->debug_info()->RunInterpreter(func_index, arg_buffer);
173 return isolate->heap()->undefined_value(); 186 return isolate->heap()->undefined_value();
174 } 187 }
175 188
176 } // namespace internal 189 } // namespace internal
177 } // namespace v8 190 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698