From 05d0220dcd41d1c2346c5cbe321e7af0209571d4 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 9 Feb 2018 00:10:25 +0300 Subject: [PATCH] C backend: initial commit --- all-deps/all-deps.iml | 2 - .../org/teavm/classlib/PlatformDetector.java | 44 ++ .../org/teavm/classlib/impl/JCLPlugin.java | 2 +- .../classlib/impl/PlatformMarkerSupport.java | 24 +- .../org/teavm/classlib/java/lang/TClass.java | 4 +- .../org/teavm/classlib/java/lang/TObject.java | 20 +- .../org/teavm/classlib/java/lang/TSystem.java | 12 +- .../teavm/classlib/java/lang/TThrowable.java | 2 +- .../WasmMangling.java => ast/Mangling.java} | 58 +- .../java/org/teavm/ast/UnwrapArrayExpr.java | 7 +- .../ast/decompilation/StatementGenerator.java | 4 +- .../java/org/teavm/backend/c/CTarget.java | 440 ++++++++++++ .../java/org/teavm/backend/c/Example.java | 47 ++ .../c/TeaVMCHost.java} | 8 +- .../c/analyze/CDependencyListener.java | 60 ++ .../backend/c/analyze/Characteristics.java | 81 +++ .../backend/c/analyze/StringPoolFiller.java | 74 ++ .../c/analyze/TemporaryVariableEstimator.java | 43 ++ .../backend/c/analyze/TypeCollector.java | 118 +++ .../backend/c/generate/CallSiteGenerator.java | 164 +++++ .../backend/c/generate/ClassGenerator.java | 660 +++++++++++++++++ .../c/generate/CodeGenerationVisitor.java | 677 ++++++++++++++++++ .../backend/c/generate/CodeGenerator.java | 100 +++ .../teavm/backend/c/generate/CodeWriter.java | 151 ++++ .../backend/c/generate/GenerationContext.java | 79 ++ .../backend/c/generate/NameProvider.java | 229 ++++++ .../teavm/backend/c/generate/StringPool.java | 42 ++ .../c/generate/StringPoolGenerator.java | 100 +++ .../backend/c/intrinsic/AddressIntrinsic.java | 208 ++++++ .../c/intrinsic/AllocatorIntrinsic.java | 70 ++ .../intrinsic/ExceptionHandlingIntrinsic.java | 47 ++ .../c/intrinsic/FunctionIntrinsic.java | 57 ++ .../backend/c/intrinsic/GCIntrinsic.java | 47 ++ .../teavm/backend/c/intrinsic/Intrinsic.java | 25 + .../backend/c/intrinsic/IntrinsicContext.java | 34 + .../backend/c/intrinsic/MutatorIntrinsic.java | 45 ++ .../c/intrinsic/PlatformClassIntrinsic.java | 50 ++ .../PlatformClassMetadataIntrinsic.java | 49 ++ .../c/intrinsic/PlatformIntrinsic.java | 49 ++ .../c/intrinsic/PlatformObjectIntrinsic.java | 43 ++ .../c/intrinsic/ShadowStackIntrinsic.java | 106 +++ .../c/intrinsic/StructureIntrinsic.java | 97 +++ .../backend/javascript/JavaScriptTarget.java | 6 + .../java/org/teavm/backend/wasm/Example.java | 1 + .../org/teavm/backend/wasm/WasmTarget.java | 42 +- .../wasm/generate/WasmClassGenerator.java | 9 +- .../wasm/generate/WasmGenerationVisitor.java | 17 +- .../backend/wasm/generate/WasmGenerator.java | 7 +- .../wasm/intrinsics/AddressIntrinsic.java | 4 +- .../wasm/intrinsics/AllocatorIntrinsic.java | 6 +- core/src/main/java/org/teavm/cache/AstIO.java | 4 +- .../lowlevel/ClassInitializerTransformer.java | 2 +- .../lowlevel/ManagedMethodRepository.java | 7 +- .../transformation}/ClassPatch.java | 4 +- .../java/org/teavm/runtime/Allocator.java | 5 +- .../org/teavm/runtime/CallSiteLocation.java | 4 + .../org/teavm/runtime/ExceptionHandling.java | 16 +- core/src/main/java/org/teavm/runtime/GC.java | 12 +- .../java/org/teavm/runtime/RuntimeArray.java | 2 +- .../java/org/teavm/runtime/RuntimeClass.java | 4 +- .../java/org/teavm/runtime/RuntimeObject.java | 6 +- core/src/main/java/org/teavm/vm/TeaVM.java | 5 + .../main/java/org/teavm/vm/TeaVMTarget.java | 2 + .../main/java/org/teavm/vm/spi/TeaVMHost.java | 2 + .../org/teavm/backend/c/runtime-epilogue.c | 7 + .../resources/org/teavm/backend/c/runtime.c | 119 +++ .../org/teavm/interop/PlatformMarker.java | 1 + .../org/teavm/interop/PlatformMarkers.java | 26 + .../java/org/teavm/platform/Platform.java | 3 + .../org/teavm/platform/PlatformClass.java | 4 + .../org/teavm/platform/PlatformObject.java | 4 + .../main/java/org/teavm/cli/TeaVMRunner.java | 28 +- .../org/teavm/tooling/TeaVMTargetType.java | 3 +- .../java/org/teavm/tooling/TeaVMTool.java | 18 + 74 files changed, 4449 insertions(+), 110 deletions(-) create mode 100644 classlib/src/main/java/org/teavm/classlib/PlatformDetector.java rename core/src/main/java/org/teavm/{backend/wasm/generate/WasmMangling.java => ast/Mangling.java} (70%) create mode 100644 core/src/main/java/org/teavm/backend/c/CTarget.java create mode 100644 core/src/main/java/org/teavm/backend/c/Example.java rename core/src/main/java/org/teavm/{runtime/RuntimeJavaObject.java => backend/c/TeaVMCHost.java} (75%) create mode 100644 core/src/main/java/org/teavm/backend/c/analyze/CDependencyListener.java create mode 100644 core/src/main/java/org/teavm/backend/c/analyze/Characteristics.java create mode 100644 core/src/main/java/org/teavm/backend/c/analyze/StringPoolFiller.java create mode 100644 core/src/main/java/org/teavm/backend/c/analyze/TemporaryVariableEstimator.java create mode 100644 core/src/main/java/org/teavm/backend/c/analyze/TypeCollector.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/CallSiteGenerator.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/ClassGenerator.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/CodeGenerator.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/CodeWriter.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/GenerationContext.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/NameProvider.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/StringPool.java create mode 100644 core/src/main/java/org/teavm/backend/c/generate/StringPoolGenerator.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/AddressIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/AllocatorIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/ExceptionHandlingIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/FunctionIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/GCIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/Intrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/IntrinsicContext.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/MutatorIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/PlatformClassIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/PlatformClassMetadataIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/PlatformIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/PlatformObjectIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/ShadowStackIntrinsic.java create mode 100644 core/src/main/java/org/teavm/backend/c/intrinsic/StructureIntrinsic.java rename core/src/main/java/org/teavm/{backend/wasm/patches => model/transformation}/ClassPatch.java (97%) create mode 100644 core/src/main/resources/org/teavm/backend/c/runtime-epilogue.c create mode 100644 core/src/main/resources/org/teavm/backend/c/runtime.c create mode 100644 interop/core/src/main/java/org/teavm/interop/PlatformMarkers.java diff --git a/all-deps/all-deps.iml b/all-deps/all-deps.iml index 559978a27..f1e3f209a 100644 --- a/all-deps/all-deps.iml +++ b/all-deps/all-deps.iml @@ -21,8 +21,6 @@ - -