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

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

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Restore signal mask at the right place 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 int pos = 0; 2800 int pos = 0;
2801 args[pos++] = HeapConstant(wasm_code); 2801 args[pos++] = HeapConstant(wasm_code);
2802 2802
2803 // Convert JS parameters to WASM numbers. 2803 // Convert JS parameters to WASM numbers.
2804 for (int i = 0; i < wasm_count; ++i) { 2804 for (int i = 0; i < wasm_count; ++i) {
2805 Node* param = Param(i + 1); 2805 Node* param = Param(i + 1);
2806 Node* wasm_param = FromJS(param, context, sig->GetParam(i)); 2806 Node* wasm_param = FromJS(param, context, sig->GetParam(i));
2807 args[pos++] = wasm_param; 2807 args[pos++] = wasm_param;
2808 } 2808 }
2809 2809
2810 // Set the ThreadInWasm flag before we do the actual call.
2811 if (trap_handler::ShouldEnableTrapHandler()) {
2812 BuildCallToRuntime(Runtime::kSetThreadInWasm, jsgraph(),
ahaas 2017/02/20 09:27:23 I wonder if we could set this flag without a runti
titzer 2017/02/20 09:50:08 +1. I think you can embed a store directly to a lo
Eric Holk 2017/02/23 02:16:55 TODO is added.
2813 jsgraph()->isolate()->native_context(), nullptr, 0,
2814 effect_, *control_);
2815 }
2816
2810 args[pos++] = *effect_; 2817 args[pos++] = *effect_;
2811 args[pos++] = *control_; 2818 args[pos++] = *control_;
2812 2819
2813 // Call the WASM code. 2820 // Call the WASM code.
2814 CallDescriptor* desc = 2821 CallDescriptor* desc =
2815 wasm::ModuleEnv::GetWasmCallDescriptor(jsgraph()->zone(), sig); 2822 wasm::ModuleEnv::GetWasmCallDescriptor(jsgraph()->zone(), sig);
2816 2823
2817 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args); 2824 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args);
2818 *effect_ = call; 2825 *effect_ = call;
2826
2827 // Clear the ThreadInWasmFlag
2828 if (trap_handler::ShouldEnableTrapHandler()) {
2829 BuildCallToRuntime(Runtime::kClearThreadInWasm, jsgraph(),
ahaas 2017/02/20 09:27:24 Is this runtime function called when WebAssembly t
Eric Holk 2017/02/23 02:16:55 The changes in isolate.cc will clear the flag when
2830 jsgraph()->isolate()->native_context(), nullptr, 0,
2831 effect_, *control_);
2832 }
2833
2819 Node* retval = call; 2834 Node* retval = call;
2820 Node* jsval = ToJS( 2835 Node* jsval = ToJS(
2821 retval, sig->return_count() == 0 ? wasm::kWasmStmt : sig->GetReturn()); 2836 retval, sig->return_count() == 0 ? wasm::kWasmStmt : sig->GetReturn());
2822 Return(jsval); 2837 Return(jsval);
2823 } 2838 }
2824 2839
2825 int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count, 2840 int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count,
2826 wasm::FunctionSig* sig) { 2841 wasm::FunctionSig* sig) {
2827 // Convert WASM numbers to JS values. 2842 // Convert WASM numbers to JS values.
2828 int param_index = 0; 2843 int param_index = 0;
(...skipping 24 matching lines...) Expand all
2853 jsgraph()->isolate()->native_context(), nullptr, 2868 jsgraph()->isolate()->native_context(), nullptr,
2854 0, effect_, *control_)); 2869 0, effect_, *control_));
2855 return; 2870 return;
2856 } 2871 }
2857 2872
2858 Node** args = Buffer(wasm_count + 7); 2873 Node** args = Buffer(wasm_count + 7);
2859 2874
2860 Node* call; 2875 Node* call;
2861 bool direct_call = false; 2876 bool direct_call = false;
2862 2877
2878 if (trap_handler::ShouldEnableTrapHandler()) {
2879 BuildCallToRuntime(Runtime::kClearThreadInWasm, jsgraph(),
2880 jsgraph()->isolate()->native_context(), nullptr, 0,
2881 effect_, *control_);
2882 }
2883
2863 if (target->IsJSFunction()) { 2884 if (target->IsJSFunction()) {
2864 Handle<JSFunction> function = Handle<JSFunction>::cast(target); 2885 Handle<JSFunction> function = Handle<JSFunction>::cast(target);
2865 if (function->shared()->internal_formal_parameter_count() == wasm_count) { 2886 if (function->shared()->internal_formal_parameter_count() == wasm_count) {
2866 direct_call = true; 2887 direct_call = true;
2867 int pos = 0; 2888 int pos = 0;
2868 args[pos++] = jsgraph()->Constant(target); // target callable. 2889 args[pos++] = jsgraph()->Constant(target); // target callable.
2869 // Receiver. 2890 // Receiver.
2870 if (is_sloppy(function->shared()->language_mode()) && 2891 if (is_sloppy(function->shared()->language_mode()) &&
2871 !function->shared()->native()) { 2892 !function->shared()->native()) {
2872 args[pos++] = 2893 args[pos++] =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 args[pos++] = HeapConstant(isolate->native_context()); 2938 args[pos++] = HeapConstant(isolate->native_context());
2918 args[pos++] = *effect_; 2939 args[pos++] = *effect_;
2919 args[pos++] = *control_; 2940 args[pos++] = *control_;
2920 2941
2921 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args); 2942 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args);
2922 } 2943 }
2923 2944
2924 *effect_ = call; 2945 *effect_ = call;
2925 SetSourcePosition(call, 0); 2946 SetSourcePosition(call, 0);
2926 2947
2948 if (trap_handler::ShouldEnableTrapHandler()) {
2949 BuildCallToRuntime(Runtime::kSetThreadInWasm, jsgraph(),
2950 jsgraph()->isolate()->native_context(), nullptr, 0,
2951 effect_, *control_);
2952 }
2953
2927 // Convert the return value back. 2954 // Convert the return value back.
2928 Node* i32_zero = jsgraph()->Int32Constant(0); 2955 Node* i32_zero = jsgraph()->Int32Constant(0);
2929 Node* val = sig->return_count() == 0 2956 Node* val = sig->return_count() == 0
2930 ? i32_zero 2957 ? i32_zero
2931 : FromJS(call, HeapConstant(isolate->native_context()), 2958 : FromJS(call, HeapConstant(isolate->native_context()),
2932 sig->GetReturn()); 2959 sig->GetReturn());
2933 Return(val); 2960 Return(val);
2934 } 2961 }
2935 2962
2936 void WasmGraphBuilder::BuildWasmInterpreterEntry( 2963 void WasmGraphBuilder::BuildWasmInterpreterEntry(
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 function_->code_start_offset), 4161 function_->code_start_offset),
4135 compile_ms); 4162 compile_ms);
4136 } 4163 }
4137 4164
4138 return code; 4165 return code;
4139 } 4166 }
4140 4167
4141 } // namespace compiler 4168 } // namespace compiler
4142 } // namespace internal 4169 } // namespace internal
4143 } // namespace v8 4170 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698