OLD | NEW |
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 "src/isolate-inl.h" | 7 #include "src/isolate-inl.h" |
8 | 8 |
9 #include "src/base/platform/elapsed-timer.h" | 9 #include "src/base/platform/elapsed-timer.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 } | 2068 } |
2069 | 2069 |
2070 | 2070 |
2071 void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code, | 2071 void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code, |
2072 wasm::FunctionSig* sig) { | 2072 wasm::FunctionSig* sig) { |
2073 int params = static_cast<int>(sig->parameter_count()); | 2073 int params = static_cast<int>(sig->parameter_count()); |
2074 int count = params + 3; | 2074 int count = params + 3; |
2075 Node** args = Buffer(count); | 2075 Node** args = Buffer(count); |
2076 | 2076 |
2077 // Build the start and the JS parameter nodes. | 2077 // Build the start and the JS parameter nodes. |
2078 Node* start = Start(params + 3); | 2078 Node* start = Start(params + 5); |
2079 *control_ = start; | 2079 *control_ = start; |
2080 *effect_ = start; | 2080 *effect_ = start; |
2081 // JS context is the last parameter. | 2081 // Create the context parameter |
2082 Node* context = graph()->NewNode( | 2082 Node* context = graph()->NewNode( |
2083 jsgraph()->common()->Parameter(params + 1, "context"), start); | 2083 jsgraph()->common()->Parameter( |
| 2084 Linkage::GetJSCallContextParamIndex(params + 1), "%context"), |
| 2085 graph()->start()); |
2084 | 2086 |
2085 int pos = 0; | 2087 int pos = 0; |
2086 args[pos++] = Constant(wasm_code); | 2088 args[pos++] = Constant(wasm_code); |
2087 | 2089 |
2088 // Convert JS parameters to WASM numbers. | 2090 // Convert JS parameters to WASM numbers. |
2089 for (int i = 0; i < params; i++) { | 2091 for (int i = 0; i < params; i++) { |
2090 Node* param = graph()->NewNode(jsgraph()->common()->Parameter(i), start); | 2092 Node* param = |
| 2093 graph()->NewNode(jsgraph()->common()->Parameter(i + 1), start); |
2091 args[pos++] = FromJS(param, context, sig->GetParam(i)); | 2094 args[pos++] = FromJS(param, context, sig->GetParam(i)); |
2092 } | 2095 } |
2093 | 2096 |
2094 args[pos++] = *effect_; | 2097 args[pos++] = *effect_; |
2095 args[pos++] = *control_; | 2098 args[pos++] = *control_; |
2096 | 2099 |
2097 // Call the WASM code. | 2100 // Call the WASM code. |
2098 CallDescriptor* desc = | 2101 CallDescriptor* desc = |
2099 wasm::ModuleEnv::GetWasmCallDescriptor(jsgraph()->zone(), sig); | 2102 wasm::ModuleEnv::GetWasmCallDescriptor(jsgraph()->zone(), sig); |
2100 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args); | 2103 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index) { | 2380 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index) { |
2378 wasm::WasmFunction* func = &module->module->functions[index]; | 2381 wasm::WasmFunction* func = &module->module->functions[index]; |
2379 | 2382 |
2380 //---------------------------------------------------------------------------- | 2383 //---------------------------------------------------------------------------- |
2381 // Create the JSFunction object. | 2384 // Create the JSFunction object. |
2382 //---------------------------------------------------------------------------- | 2385 //---------------------------------------------------------------------------- |
2383 Handle<SharedFunctionInfo> shared = | 2386 Handle<SharedFunctionInfo> shared = |
2384 isolate->factory()->NewSharedFunctionInfo(name, wasm_code, false); | 2387 isolate->factory()->NewSharedFunctionInfo(name, wasm_code, false); |
2385 int params = static_cast<int>(func->sig->parameter_count()); | 2388 int params = static_cast<int>(func->sig->parameter_count()); |
2386 shared->set_length(params); | 2389 shared->set_length(params); |
2387 shared->set_internal_formal_parameter_count(1 + params); | 2390 shared->set_internal_formal_parameter_count(params); |
2388 Handle<JSFunction> function = isolate->factory()->NewFunction( | 2391 Handle<JSFunction> function = isolate->factory()->NewFunction( |
2389 isolate->wasm_function_map(), name, MaybeHandle<Code>()); | 2392 isolate->wasm_function_map(), name, MaybeHandle<Code>()); |
2390 function->SetInternalField(0, *module_object); | 2393 function->SetInternalField(0, *module_object); |
2391 function->set_shared(*shared); | 2394 function->set_shared(*shared); |
2392 | 2395 |
2393 //---------------------------------------------------------------------------- | 2396 //---------------------------------------------------------------------------- |
2394 // Create the Graph | 2397 // Create the Graph |
2395 //---------------------------------------------------------------------------- | 2398 //---------------------------------------------------------------------------- |
2396 Zone zone; | 2399 Zone zone; |
2397 Graph graph(&zone); | 2400 Graph graph(&zone); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2655 static_cast<int>(function.code_end_offset - function.code_start_offset), | 2658 static_cast<int>(function.code_end_offset - function.code_start_offset), |
2656 decode_ms, static_cast<int>(graph.NodeCount()), compile_ms); | 2659 decode_ms, static_cast<int>(graph.NodeCount()), compile_ms); |
2657 } | 2660 } |
2658 return code; | 2661 return code; |
2659 } | 2662 } |
2660 | 2663 |
2661 | 2664 |
2662 } // namespace compiler | 2665 } // namespace compiler |
2663 } // namespace internal | 2666 } // namespace internal |
2664 } // namespace v8 | 2667 } // namespace v8 |
OLD | NEW |