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/platform.h" | 9 #include "src/base/platform/platform.h" |
10 | 10 |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 const size_t extra = 2; // effect and control inputs. | 1477 const size_t extra = 2; // effect and control inputs. |
1478 const size_t count = 1 + params + extra; | 1478 const size_t count = 1 + params + extra; |
1479 | 1479 |
1480 // Reallocate the buffer to make space for extra inputs. | 1480 // Reallocate the buffer to make space for extra inputs. |
1481 args = Realloc(args, count); | 1481 args = Realloc(args, count); |
1482 | 1482 |
1483 // Add effect and control inputs. | 1483 // Add effect and control inputs. |
1484 args[params + 1] = *effect_; | 1484 args[params + 1] = *effect_; |
1485 args[params + 2] = *control_; | 1485 args[params + 2] = *control_; |
1486 | 1486 |
1487 const Operator* op = jsgraph()->common()->Call( | 1487 CallDescriptor* descriptor = |
1488 module_->GetWasmCallDescriptor(jsgraph()->zone(), sig)); | 1488 module_->GetWasmCallDescriptor(jsgraph()->zone(), sig); |
| 1489 const Operator* op = jsgraph()->common()->Call(descriptor); |
1489 Node* call = graph()->NewNode(op, static_cast<int>(count), args); | 1490 Node* call = graph()->NewNode(op, static_cast<int>(count), args); |
1490 | 1491 |
1491 *effect_ = call; | 1492 *effect_ = call; |
1492 return call; | 1493 return call; |
1493 } | 1494 } |
1494 | 1495 |
1495 | 1496 |
1496 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args) { | 1497 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args) { |
1497 DCHECK_NULL(args[0]); | 1498 DCHECK_NULL(args[0]); |
1498 | 1499 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 | 1903 |
1903 Node* WasmGraphBuilder::String(const char* string) { | 1904 Node* WasmGraphBuilder::String(const char* string) { |
1904 return jsgraph()->Constant( | 1905 return jsgraph()->Constant( |
1905 jsgraph()->isolate()->factory()->NewStringFromAsciiChecked(string)); | 1906 jsgraph()->isolate()->factory()->NewStringFromAsciiChecked(string)); |
1906 } | 1907 } |
1907 | 1908 |
1908 | 1909 |
1909 Graph* WasmGraphBuilder::graph() { return jsgraph()->graph(); } | 1910 Graph* WasmGraphBuilder::graph() { return jsgraph()->graph(); } |
1910 | 1911 |
1911 void WasmGraphBuilder::Int64LoweringForTesting() { | 1912 void WasmGraphBuilder::Int64LoweringForTesting() { |
1912 #if !WASM_64 | 1913 if (kPointerSize == 4) { |
1913 Int64Lowering r(jsgraph()->graph(), jsgraph()->machine(), jsgraph()->common(), | 1914 Int64Lowering r(jsgraph()->graph(), jsgraph()->machine(), |
1914 jsgraph()->zone()); | 1915 jsgraph()->common(), jsgraph()->zone(), |
1915 r.ReduceGraph(); | 1916 function_signature_); |
1916 #endif | 1917 r.LowerGraph(); |
| 1918 } |
1917 } | 1919 } |
1918 | 1920 |
1919 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 1921 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
1920 CompilationInfo* info, | 1922 CompilationInfo* info, |
1921 const char* message, uint32_t index, | 1923 const char* message, uint32_t index, |
1922 const char* func_name) { | 1924 const char* func_name) { |
1923 Isolate* isolate = info->isolate(); | 1925 Isolate* isolate = info->isolate(); |
1924 if (isolate->logger()->is_logging_code_events() || | 1926 if (isolate->logger()->is_logging_code_events() || |
1925 isolate->cpu_profiler()->is_profiling()) { | 1927 isolate->cpu_profiler()->is_profiling()) { |
1926 ScopedVector<char> buffer(128); | 1928 ScopedVector<char> buffer(128); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 // Add the function as another context for the exception | 2122 // Add the function as another context for the exception |
2121 ScopedVector<char> buffer(128); | 2123 ScopedVector<char> buffer(128); |
2122 SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", | 2124 SNPrintF(buffer, "Compiling WASM function #%d:%s failed:", |
2123 function.func_index, | 2125 function.func_index, |
2124 module_env->module->GetName(function.name_offset)); | 2126 module_env->module->GetName(function.name_offset)); |
2125 thrower.Failed(buffer.start(), result); | 2127 thrower.Failed(buffer.start(), result); |
2126 return Handle<Code>::null(); | 2128 return Handle<Code>::null(); |
2127 } | 2129 } |
2128 | 2130 |
2129 // Run the compiler pipeline to generate machine code. | 2131 // Run the compiler pipeline to generate machine code. |
2130 CallDescriptor* descriptor = const_cast<CallDescriptor*>( | 2132 CallDescriptor* descriptor = |
2131 module_env->GetWasmCallDescriptor(&zone, function.sig)); | 2133 module_env->GetWasmCallDescriptor(&zone, function.sig); |
| 2134 if (kPointerSize == 4) { |
| 2135 descriptor = module_env->GetI32WasmCallDescriptor(&zone, descriptor); |
| 2136 } |
2132 Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); | 2137 Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION); |
2133 // add flags here if a meaningful name is helpful for debugging. | 2138 // add flags here if a meaningful name is helpful for debugging. |
2134 bool debugging = | 2139 bool debugging = |
2135 #if DEBUG | 2140 #if DEBUG |
2136 true; | 2141 true; |
2137 #else | 2142 #else |
2138 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; | 2143 FLAG_print_opt_code || FLAG_trace_turbo || FLAG_trace_turbo_graph; |
2139 #endif | 2144 #endif |
2140 const char* func_name = "wasm"; | 2145 const char* func_name = "wasm"; |
2141 Vector<char> buffer; | 2146 Vector<char> buffer; |
(...skipping 16 matching lines...) Expand all Loading... |
2158 module_env->module->GetName(function.name_offset)); | 2163 module_env->module->GetName(function.name_offset)); |
2159 } | 2164 } |
2160 | 2165 |
2161 return code; | 2166 return code; |
2162 } | 2167 } |
2163 | 2168 |
2164 | 2169 |
2165 } // namespace compiler | 2170 } // namespace compiler |
2166 } // namespace internal | 2171 } // namespace internal |
2167 } // namespace v8 | 2172 } // namespace v8 |
OLD | NEW |