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

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

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Addressing some of Jochen's feedback Created 3 years, 11 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 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after
2770 Node* param = Param(i + 1); 2770 Node* param = Param(i + 1);
2771 Node* wasm_param = FromJS(param, context, sig->GetParam(i)); 2771 Node* wasm_param = FromJS(param, context, sig->GetParam(i));
2772 args[pos++] = wasm_param; 2772 args[pos++] = wasm_param;
2773 if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64) { 2773 if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64) {
2774 // We make up the high word with SAR to get the proper sign extension. 2774 // We make up the high word with SAR to get the proper sign extension.
2775 args[pos++] = graph()->NewNode(jsgraph()->machine()->Word32Sar(), 2775 args[pos++] = graph()->NewNode(jsgraph()->machine()->Word32Sar(),
2776 wasm_param, jsgraph()->Int32Constant(31)); 2776 wasm_param, jsgraph()->Int32Constant(31));
2777 } 2777 }
2778 } 2778 }
2779 2779
2780 // Set the ThreadInWasm flag before we do the actual call.
2781 Node* parameters[] = {};
2782 BuildCallToRuntime(Runtime::kSetThreadInWasm, jsgraph(),
2783 jsgraph()->isolate()->native_context(), parameters, 0,
2784 effect_, *control_);
2785
2780 args[pos++] = *effect_; 2786 args[pos++] = *effect_;
2781 args[pos++] = *control_; 2787 args[pos++] = *control_;
2782 2788
2783 // Call the WASM code. 2789 // Call the WASM code.
2784 CallDescriptor* desc = 2790 CallDescriptor* desc =
2785 wasm::ModuleEnv::GetWasmCallDescriptor(jsgraph()->zone(), sig); 2791 wasm::ModuleEnv::GetWasmCallDescriptor(jsgraph()->zone(), sig);
2786 if (jsgraph()->machine()->Is32()) { 2792 if (jsgraph()->machine()->Is32()) {
2787 desc = wasm::ModuleEnv::GetI32WasmCallDescriptor(jsgraph()->zone(), desc); 2793 desc = wasm::ModuleEnv::GetI32WasmCallDescriptor(jsgraph()->zone(), desc);
2788 } 2794 }
2789 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args); 2795 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args);
2790 *effect_ = call; 2796 *effect_ = call;
2797
2798 // Clear the ThreadInWasmFlag
2799 BuildCallToRuntime(Runtime::kClearThreadInWasm, jsgraph(),
2800 jsgraph()->isolate()->native_context(), parameters, 0,
2801 effect_, *control_);
2802
2791 Node* retval = call; 2803 Node* retval = call;
2792 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 && 2804 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 &&
2793 sig->GetReturn(0) == wasm::kWasmI64) { 2805 sig->GetReturn(0) == wasm::kWasmI64) {
2794 // The return values comes as two values, we pick the low word. 2806 // The return values comes as two values, we pick the low word.
2795 retval = graph()->NewNode(jsgraph()->common()->Projection(0), retval, 2807 retval = graph()->NewNode(jsgraph()->common()->Projection(0), retval,
2796 graph()->start()); 2808 graph()->start());
2797 } 2809 }
2798 Node* jsval = ToJS( 2810 Node* jsval = ToJS(
2799 retval, sig->return_count() == 0 ? wasm::kWasmStmt : sig->GetReturn()); 2811 retval, sig->return_count() == 0 ? wasm::kWasmStmt : sig->GetReturn());
2800 Return(jsval); 2812 Return(jsval);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 Isolate* isolate = jsgraph()->isolate(); 2844 Isolate* isolate = jsgraph()->isolate();
2833 CallDescriptor* desc; 2845 CallDescriptor* desc;
2834 Node* start = Start(param_count + 3); 2846 Node* start = Start(param_count + 3);
2835 *effect_ = start; 2847 *effect_ = start;
2836 *control_ = start; 2848 *control_ = start;
2837 Node** args = Buffer(wasm_count + 7); 2849 Node** args = Buffer(wasm_count + 7);
2838 2850
2839 Node* call; 2851 Node* call;
2840 bool direct_call = false; 2852 bool direct_call = false;
2841 2853
2854 Node* parameters[] = {};
2855 BuildCallToRuntime(Runtime::kClearThreadInWasm, jsgraph(),
2856 jsgraph()->isolate()->native_context(), parameters, 0,
2857 effect_, *control_);
2858
2842 if (target->IsJSFunction()) { 2859 if (target->IsJSFunction()) {
2843 Handle<JSFunction> function = Handle<JSFunction>::cast(target); 2860 Handle<JSFunction> function = Handle<JSFunction>::cast(target);
2844 if (function->shared()->internal_formal_parameter_count() == wasm_count) { 2861 if (function->shared()->internal_formal_parameter_count() == wasm_count) {
2845 direct_call = true; 2862 direct_call = true;
2846 int pos = 0; 2863 int pos = 0;
2847 args[pos++] = jsgraph()->Constant(target); // target callable. 2864 args[pos++] = jsgraph()->Constant(target); // target callable.
2848 // Receiver. 2865 // Receiver.
2849 if (is_sloppy(function->shared()->language_mode()) && 2866 if (is_sloppy(function->shared()->language_mode()) &&
2850 !function->shared()->native()) { 2867 !function->shared()->native()) {
2851 args[pos++] = 2868 args[pos++] =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 args[pos++] = HeapConstant(isolate->native_context()); 2913 args[pos++] = HeapConstant(isolate->native_context());
2897 args[pos++] = *effect_; 2914 args[pos++] = *effect_;
2898 args[pos++] = *control_; 2915 args[pos++] = *control_;
2899 2916
2900 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args); 2917 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args);
2901 } 2918 }
2902 2919
2903 *effect_ = call; 2920 *effect_ = call;
2904 SetSourcePosition(call, 0); 2921 SetSourcePosition(call, 0);
2905 2922
2923 BuildCallToRuntime(Runtime::kSetThreadInWasm, jsgraph(),
2924 jsgraph()->isolate()->native_context(), parameters, 0,
2925 effect_, *control_);
2926
2906 // Convert the return value back. 2927 // Convert the return value back.
2907 Node* i32_zero = jsgraph()->Int32Constant(0); 2928 Node* i32_zero = jsgraph()->Int32Constant(0);
2908 Node* val = sig->return_count() == 0 2929 Node* val = sig->return_count() == 0
2909 ? i32_zero 2930 ? i32_zero
2910 : FromJS(call, HeapConstant(isolate->native_context()), 2931 : FromJS(call, HeapConstant(isolate->native_context()),
2911 sig->GetReturn()); 2932 sig->GetReturn());
2912 Return(val); 2933 Return(val);
2913 } 2934 }
2914 2935
2915 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) { 2936 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) {
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
3686 Smi::FromInt(instruction.instr_offset)); 3707 Smi::FromInt(instruction.instr_offset));
3687 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset, 3708 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset,
3688 Smi::FromInt(instruction.landing_offset)); 3709 Smi::FromInt(instruction.landing_offset));
3689 } 3710 }
3690 return fn_protected; 3711 return fn_protected;
3691 } 3712 }
3692 3713
3693 } // namespace compiler 3714 } // namespace compiler
3694 } // namespace internal 3715 } // namespace internal
3695 } // namespace v8 3716 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698