Index: src/runtime/runtime-wasm.cc |
diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc |
index 3ed63879add0dd24a128c273ff0075f92070f276..2e579753363e5aedb322ebc9b0d5e23a8caafafb 100644 |
--- a/src/runtime/runtime-wasm.cc |
+++ b/src/runtime/runtime-wasm.cc |
@@ -12,6 +12,7 @@ |
#include "src/factory.h" |
#include "src/frames-inl.h" |
#include "src/objects-inl.h" |
+#include "src/runtime/runtime.h" |
#include "src/v8memory.h" |
#include "src/wasm/wasm-module.h" |
#include "src/wasm/wasm-objects.h" |
@@ -21,7 +22,7 @@ namespace v8 { |
namespace internal { |
namespace { |
-Handle<WasmInstanceObject> GetWasmInstanceOnStackTop(Isolate* isolate) { |
+WasmInstanceObject* GetWasmInstanceOnStackTop(Isolate* isolate) { |
DisallowHeapAllocation no_allocation; |
const Address entry = Isolate::c_entry_fp(isolate->thread_local_top()); |
Address pc = |
@@ -30,7 +31,7 @@ Handle<WasmInstanceObject> GetWasmInstanceOnStackTop(Isolate* isolate) { |
DCHECK_EQ(Code::WASM_FUNCTION, code->kind()); |
WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code); |
CHECK_NOT_NULL(owning_instance); |
- return handle(owning_instance, isolate); |
+ return owning_instance; |
} |
} // namespace |
@@ -38,7 +39,8 @@ RUNTIME_FUNCTION(Runtime_WasmMemorySize) { |
HandleScope scope(isolate); |
DCHECK_EQ(0, args.length()); |
- Handle<WasmInstanceObject> instance = GetWasmInstanceOnStackTop(isolate); |
+ Handle<WasmInstanceObject> instance(GetWasmInstanceOnStackTop(isolate), |
+ isolate); |
return *isolate->factory()->NewNumberFromInt( |
wasm::GetInstanceMemorySize(isolate, instance)); |
} |
@@ -47,7 +49,8 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { |
HandleScope scope(isolate); |
DCHECK_EQ(1, args.length()); |
CONVERT_UINT32_ARG_CHECKED(delta_pages, 0); |
- Handle<WasmInstanceObject> instance = GetWasmInstanceOnStackTop(isolate); |
+ Handle<WasmInstanceObject> instance(GetWasmInstanceOnStackTop(isolate), |
+ isolate); |
return *isolate->factory()->NewNumberFromInt( |
wasm::GrowMemory(isolate, instance, delta_pages)); |
} |
@@ -161,7 +164,7 @@ RUNTIME_FUNCTION(Runtime_WasmGetCaughtExceptionValue) { |
} |
RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { |
- DCHECK(args.length() == 3); |
+ DCHECK_EQ(3, args.length()); |
HandleScope scope(isolate); |
CONVERT_ARG_HANDLE_CHECKED(JSObject, instance_obj, 0); |
CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[1]); |
@@ -177,13 +180,27 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { |
CHECK(arg_buffer_obj->IsSmi()); |
uint8_t* arg_buffer = reinterpret_cast<uint8_t*>(*arg_buffer_obj); |
- // Set the current isolate's context, saving the previous one. |
- SaveContext save(isolate); |
+ // Set the current isolate's context. |
isolate->set_context(*instance->compiled_module()->native_context()); |
ahaas
2017/02/14 14:45:38
nit: Can you add a DCHECK_NULL(isolate->context())
Clemens Hammacher
2017/02/14 17:23:14
Done.
|
instance->debug_info()->RunInterpreter(func_index, arg_buffer); |
return isolate->heap()->undefined_value(); |
} |
+RUNTIME_FUNCTION(Runtime_WasmStackGuard) { |
+ SealHandleScope shs(isolate); |
+ DCHECK_EQ(0, args.length()); |
+ |
+ // Set the current isolate's context. |
+ WasmInstanceObject* instance = GetWasmInstanceOnStackTop(isolate); |
+ isolate->set_context(instance->compiled_module()->ptr_to_native_context()); |
ahaas
2017/02/14 14:45:38
nit: Can you add a DCHECK_NULL(isolate->context())
Clemens Hammacher
2017/02/14 17:23:14
Done.
|
+ |
+ // Check if this is a real stack overflow. |
+ StackLimitCheck check(isolate); |
+ if (check.JsHasOverflowed()) return isolate->StackOverflow(); |
+ |
+ return isolate->stack_guard()->HandleInterrupts(); |
+} |
+ |
} // namespace internal |
} // namespace v8 |