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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 | 524 |
525 Node* rem = graph()->NewNode(m->Int64Mod(), left, right, d.if_false); | 525 Node* rem = graph()->NewNode(m->Int64Mod(), left, right, d.if_false); |
526 | 526 |
527 return d.Phi(MachineRepresentation::kWord64, jsgraph()->Int64Constant(0), | 527 return d.Phi(MachineRepresentation::kWord64, jsgraph()->Int64Constant(0), |
528 rem); | 528 rem); |
529 } | 529 } |
530 case wasm::kExprI64RemU: | 530 case wasm::kExprI64RemU: |
531 op = m->Uint64Mod(); | 531 op = m->Uint64Mod(); |
532 return graph()->NewNode(op, left, right, | 532 return graph()->NewNode(op, left, right, |
533 trap_->ZeroCheck64(kTrapRemByZero, right)); | 533 trap_->ZeroCheck64(kTrapRemByZero, right)); |
534 #endif | |
534 case wasm::kExprI64And: | 535 case wasm::kExprI64And: |
titzer
2016/02/02 10:14:35
Move this instead of adding more #ifdefs
ahaas
2016/02/02 13:32:48
Done.
| |
535 op = m->Word64And(); | 536 op = m->Word64And(); |
536 break; | 537 break; |
538 #if WASM_64 | |
537 case wasm::kExprI64Ior: | 539 case wasm::kExprI64Ior: |
538 op = m->Word64Or(); | 540 op = m->Word64Or(); |
539 break; | 541 break; |
540 case wasm::kExprI64Xor: | 542 case wasm::kExprI64Xor: |
541 op = m->Word64Xor(); | 543 op = m->Word64Xor(); |
542 break; | 544 break; |
543 case wasm::kExprI64Shl: | 545 case wasm::kExprI64Shl: |
544 op = m->Word64Shl(); | 546 op = m->Word64Shl(); |
545 break; | 547 break; |
546 case wasm::kExprI64ShrU: | 548 case wasm::kExprI64ShrU: |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 } | 807 } |
806 case wasm::kExprF64NearestInt: { | 808 case wasm::kExprF64NearestInt: { |
807 if (m->Float64RoundTiesEven().IsSupported()) { | 809 if (m->Float64RoundTiesEven().IsSupported()) { |
808 op = m->Float64RoundTiesEven().op(); | 810 op = m->Float64RoundTiesEven().op(); |
809 break; | 811 break; |
810 } else { | 812 } else { |
811 op = UnsupportedOpcode(opcode); | 813 op = UnsupportedOpcode(opcode); |
812 break; | 814 break; |
813 } | 815 } |
814 } | 816 } |
815 | 817 case wasm::kExprI32ConvertI64: |
818 op = m->TruncateInt64ToInt32(); | |
819 break; | |
816 #if WASM_64 | 820 #if WASM_64 |
817 // Opcodes only supported on 64-bit platforms. | 821 // Opcodes only supported on 64-bit platforms. |
818 // TODO(titzer): query the machine operator builder here instead of #ifdef. | 822 // TODO(titzer): query the machine operator builder here instead of #ifdef. |
819 case wasm::kExprI32ConvertI64: | |
820 op = m->TruncateInt64ToInt32(); | |
821 break; | |
822 case wasm::kExprI64SConvertI32: | 823 case wasm::kExprI64SConvertI32: |
823 op = m->ChangeInt32ToInt64(); | 824 op = m->ChangeInt32ToInt64(); |
824 break; | 825 break; |
825 case wasm::kExprI64UConvertI32: | 826 case wasm::kExprI64UConvertI32: |
826 op = m->ChangeUint32ToUint64(); | 827 op = m->ChangeUint32ToUint64(); |
827 break; | 828 break; |
828 case wasm::kExprF32SConvertI64: | 829 case wasm::kExprF32SConvertI64: |
829 op = m->RoundInt64ToFloat32(); | 830 op = m->RoundInt64ToFloat32(); |
830 break; | 831 break; |
831 case wasm::kExprF32UConvertI64: | 832 case wasm::kExprF32UConvertI64: |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1866 | 1867 |
1867 | 1868 |
1868 Node* WasmGraphBuilder::String(const char* string) { | 1869 Node* WasmGraphBuilder::String(const char* string) { |
1869 return jsgraph()->Constant( | 1870 return jsgraph()->Constant( |
1870 jsgraph()->isolate()->factory()->NewStringFromAsciiChecked(string)); | 1871 jsgraph()->isolate()->factory()->NewStringFromAsciiChecked(string)); |
1871 } | 1872 } |
1872 | 1873 |
1873 | 1874 |
1874 Graph* WasmGraphBuilder::graph() { return jsgraph()->graph(); } | 1875 Graph* WasmGraphBuilder::graph() { return jsgraph()->graph(); } |
1875 | 1876 |
1876 | |
1877 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 1877 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
1878 CompilationInfo* info, | 1878 CompilationInfo* info, |
1879 const char* message, uint32_t index, | 1879 const char* message, uint32_t index, |
1880 const char* func_name) { | 1880 const char* func_name) { |
1881 Isolate* isolate = info->isolate(); | 1881 Isolate* isolate = info->isolate(); |
1882 if (isolate->logger()->is_logging_code_events() || | 1882 if (isolate->logger()->is_logging_code_events() || |
1883 isolate->cpu_profiler()->is_profiling()) { | 1883 isolate->cpu_profiler()->is_profiling()) { |
1884 ScopedVector<char> buffer(128); | 1884 ScopedVector<char> buffer(128); |
1885 SNPrintF(buffer, "%s#%d:%s", message, index, func_name); | 1885 SNPrintF(buffer, "%s#%d:%s", message, index, func_name); |
1886 Handle<String> name_str = | 1886 Handle<String> name_str = |
1887 isolate->factory()->NewStringFromAsciiChecked(buffer.start()); | 1887 isolate->factory()->NewStringFromAsciiChecked(buffer.start()); |
1888 Handle<String> script_str = | 1888 Handle<String> script_str = |
1889 isolate->factory()->NewStringFromAsciiChecked("(WASM)"); | 1889 isolate->factory()->NewStringFromAsciiChecked("(WASM)"); |
1890 Handle<Code> code = info->code(); | 1890 Handle<Code> code = info->code(); |
1891 Handle<SharedFunctionInfo> shared = | 1891 Handle<SharedFunctionInfo> shared = |
1892 isolate->factory()->NewSharedFunctionInfo(name_str, code, false); | 1892 isolate->factory()->NewSharedFunctionInfo(name_str, code, false); |
1893 PROFILE(isolate, | 1893 PROFILE(isolate, |
1894 CodeCreateEvent(tag, *code, *shared, info, *script_str, 0, 0)); | 1894 CodeCreateEvent(tag, *code, *shared, info, *script_str, 0, 0)); |
1895 } | 1895 } |
1896 } | 1896 } |
1897 | 1897 |
1898 | |
1899 Handle<JSFunction> CompileJSToWasmWrapper( | 1898 Handle<JSFunction> CompileJSToWasmWrapper( |
1900 Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name, | 1899 Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name, |
1901 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index) { | 1900 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index) { |
1902 wasm::WasmFunction* func = &module->module->functions->at(index); | 1901 wasm::WasmFunction* func = &module->module->functions->at(index); |
1903 | 1902 |
1904 //---------------------------------------------------------------------------- | 1903 //---------------------------------------------------------------------------- |
1905 // Create the JSFunction object. | 1904 // Create the JSFunction object. |
1906 //---------------------------------------------------------------------------- | 1905 //---------------------------------------------------------------------------- |
1907 Handle<SharedFunctionInfo> shared = | 1906 Handle<SharedFunctionInfo> shared = |
1908 isolate->factory()->NewSharedFunctionInfo(name, wasm_code, false); | 1907 isolate->factory()->NewSharedFunctionInfo(name, wasm_code, false); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2115 module_env->module->GetName(function.name_offset)); | 2114 module_env->module->GetName(function.name_offset)); |
2116 } | 2115 } |
2117 | 2116 |
2118 return code; | 2117 return code; |
2119 } | 2118 } |
2120 | 2119 |
2121 | 2120 |
2122 } // namespace compiler | 2121 } // namespace compiler |
2123 } // namespace internal | 2122 } // namespace internal |
2124 } // namespace v8 | 2123 } // namespace v8 |
OLD | NEW |