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

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

Issue 2708743003: [wasm] Remove remaining occurences of the context in wasm code (Closed)
Patch Set: Remove unused variables 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
« src/compiler/wasm-compiler.cc ('K') | « src/compiler/wasm-compiler.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 #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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return *isolate->factory()->NewNumberFromInt( 48 return *isolate->factory()->NewNumberFromInt(
49 wasm::GetInstanceMemorySize(isolate, instance)); 49 wasm::GetInstanceMemorySize(isolate, instance));
50 } 50 }
51 51
52 RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { 52 RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
53 HandleScope scope(isolate); 53 HandleScope scope(isolate);
54 DCHECK_EQ(1, args.length()); 54 DCHECK_EQ(1, args.length());
55 CONVERT_UINT32_ARG_CHECKED(delta_pages, 0); 55 CONVERT_UINT32_ARG_CHECKED(delta_pages, 0);
56 Handle<WasmInstanceObject> instance(GetWasmInstanceOnStackTop(isolate), 56 Handle<WasmInstanceObject> instance(GetWasmInstanceOnStackTop(isolate),
57 isolate); 57 isolate);
58
59 // Set the current isolate's context.
60 DCHECK_NULL(isolate->context());
61 isolate->set_context(instance->compiled_module()->ptr_to_native_context());
62
58 return *isolate->factory()->NewNumberFromInt( 63 return *isolate->factory()->NewNumberFromInt(
59 wasm::GrowMemory(isolate, instance, delta_pages)); 64 wasm::GrowMemory(isolate, instance, delta_pages));
60 } 65 }
61 66
62 Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset, 67 Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset,
63 bool patch_source_position) { 68 bool patch_source_position) {
64 HandleScope scope(isolate); 69 HandleScope scope(isolate);
65 DCHECK_NULL(isolate->context()); 70 DCHECK_NULL(isolate->context());
66 isolate->set_context(GetWasmContextOnStackTop(isolate)); 71 isolate->set_context(GetWasmContextOnStackTop(isolate));
67 Handle<Object> error_obj = isolate->factory()->NewWasmRuntimeError( 72 Handle<Object> error_obj = isolate->factory()->NewWasmRuntimeError(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 145 }
141 146
142 RUNTIME_FUNCTION(Runtime_WasmThrow) { 147 RUNTIME_FUNCTION(Runtime_WasmThrow) {
143 HandleScope scope(isolate); 148 HandleScope scope(isolate);
144 DCHECK_EQ(2, args.length()); 149 DCHECK_EQ(2, args.length());
145 CONVERT_SMI_ARG_CHECKED(lower, 0); 150 CONVERT_SMI_ARG_CHECKED(lower, 0);
146 CONVERT_SMI_ARG_CHECKED(upper, 1); 151 CONVERT_SMI_ARG_CHECKED(upper, 1);
147 152
148 const int32_t thrown_value = (upper << 16) | lower; 153 const int32_t thrown_value = (upper << 16) | lower;
149 154
155 // Set the current isolate's context.
156 DCHECK_NULL(isolate->context());
157 isolate->set_context(GetWasmContextOnStackTop(isolate));
158
150 return isolate->Throw(*isolate->factory()->NewNumberFromInt(thrown_value)); 159 return isolate->Throw(*isolate->factory()->NewNumberFromInt(thrown_value));
151 } 160 }
152 161
153 RUNTIME_FUNCTION(Runtime_WasmGetCaughtExceptionValue) { 162 RUNTIME_FUNCTION(Runtime_WasmGetCaughtExceptionValue) {
154 HandleScope scope(isolate); 163 HandleScope scope(isolate);
155 DCHECK_EQ(1, args.length()); 164 DCHECK_EQ(1, args.length());
156 Object* exception = args[0]; 165 Object* exception = args[0];
157 // The unwinder will only deliver exceptions to wasm if the exception is a 166 // The unwinder will only deliver exceptions to wasm if the exception is a
158 // Number or a Smi (which we have just converted to a Number.) This logic 167 // Number or a Smi (which we have just converted to a Number.) This logic
159 // lives in Isolate::is_catchable_by_wasm(Object*). 168 // lives in Isolate::is_catchable_by_wasm(Object*).
(...skipping 11 matching lines...) Expand all
171 Handle<WasmInstanceObject> instance = 180 Handle<WasmInstanceObject> instance =
172 Handle<WasmInstanceObject>::cast(instance_obj); 181 Handle<WasmInstanceObject>::cast(instance_obj);
173 182
174 // The arg buffer is the raw pointer to the caller's stack. It looks like a 183 // The arg buffer is the raw pointer to the caller's stack. It looks like a
175 // Smi (lowest bit not set, as checked by IsSmi), but is no valid Smi. We just 184 // Smi (lowest bit not set, as checked by IsSmi), but is no valid Smi. We just
176 // cast it back to the raw pointer. 185 // cast it back to the raw pointer.
177 CHECK(!arg_buffer_obj->IsHeapObject()); 186 CHECK(!arg_buffer_obj->IsHeapObject());
178 CHECK(arg_buffer_obj->IsSmi()); 187 CHECK(arg_buffer_obj->IsSmi());
179 uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj); 188 uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj);
180 189
181 DCHECK_EQ(isolate->context(), 190 // Set the current isolate's context.
182 instance->compiled_module()->ptr_to_native_context()); 191 DCHECK_NULL(isolate->context());
192 isolate->set_context(instance->compiled_module()->ptr_to_native_context());
183 193
184 instance->debug_info()->RunInterpreter(func_index, arg_buffer); 194 instance->debug_info()->RunInterpreter(func_index, arg_buffer);
185 return isolate->heap()->undefined_value(); 195 return isolate->heap()->undefined_value();
186 } 196 }
187 197
188 RUNTIME_FUNCTION(Runtime_WasmStackGuard) { 198 RUNTIME_FUNCTION(Runtime_WasmStackGuard) {
189 SealHandleScope shs(isolate); 199 SealHandleScope shs(isolate);
190 DCHECK_EQ(0, args.length()); 200 DCHECK_EQ(0, args.length());
191 201
192 // Set the current isolate's context. 202 // Set the current isolate's context.
193 DCHECK_NULL(isolate->context()); 203 DCHECK_NULL(isolate->context());
194 isolate->set_context(GetWasmContextOnStackTop(isolate)); 204 isolate->set_context(GetWasmContextOnStackTop(isolate));
195 205
196 // Check if this is a real stack overflow. 206 // Check if this is a real stack overflow.
197 StackLimitCheck check(isolate); 207 StackLimitCheck check(isolate);
198 if (check.JsHasOverflowed()) return isolate->StackOverflow(); 208 if (check.JsHasOverflowed()) return isolate->StackOverflow();
199 209
200 return isolate->stack_guard()->HandleInterrupts(); 210 return isolate->stack_guard()->HandleInterrupts();
201 } 211 }
202 212
203 } // namespace internal 213 } // namespace internal
204 } // namespace v8 214 } // namespace v8
OLDNEW
« src/compiler/wasm-compiler.cc ('K') | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698