├── .clang-format ├── .clang-tidy ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── .project ├── CMakeLists.txt ├── Examples ├── LICENSE ├── README.md ├── SOM.xcodeproj ├── default.pbxuser └── project.pbxproj ├── Smalltalk ├── TestSuite ├── doc ├── styleguide.tex └── tab.c ├── gperftools-2.0 ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── README_windows.txt ├── TODO ├── aclocal.m4 ├── compile ├── config.guess ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── doc │ ├── cpuprofile-fileformat.html │ ├── cpuprofile.html │ ├── designstyle.css │ ├── heap_checker.html │ ├── heapprofile.html │ ├── index.html │ ├── overview.dot │ ├── overview.gif │ ├── pageheap.dot │ ├── pageheap.gif │ ├── pprof-test-big.gif │ ├── pprof-test.gif │ ├── pprof-vsnprintf-big.gif │ ├── pprof-vsnprintf.gif │ ├── pprof.1 │ ├── pprof_remote_servers.html │ ├── spanmap.dot │ ├── spanmap.gif │ ├── t-test1.times.txt │ ├── tcmalloc.html │ ├── threadheap.dot │ └── threadheap.gif ├── gperftools.sln ├── install-sh ├── libtool ├── ltmain.sh ├── m4 │ ├── ac_have_attribute.m4 │ ├── acx_nanosleep.m4 │ ├── acx_pthread.m4 │ ├── compiler_characteristics.m4 │ ├── install_prefix.m4 │ ├── libtool.m4 │ ├── ltoptions.m4 │ ├── ltsugar.m4 │ ├── ltversion.m4 │ ├── lt~obsolete.m4 │ ├── namespaces.m4 │ ├── pc_from_ucontext.m4 │ ├── program_invocation_name.m4 │ └── stl_namespace.m4 ├── missing ├── mkinstalldirs ├── packages │ ├── deb.sh │ ├── deb │ │ ├── README │ │ ├── changelog │ │ ├── compat │ │ ├── control │ │ ├── copyright │ │ ├── docs │ │ ├── libgperftools-dev.dirs │ │ ├── libgperftools-dev.install │ │ ├── libgperftools0.dirs │ │ ├── libgperftools0.install │ │ ├── libgperftools0.manpages │ │ └── rules │ ├── rpm.sh │ └── rpm │ │ └── rpm.spec ├── src │ ├── addressmap-inl.h │ ├── base │ │ ├── arm_instruction_set_select.h │ │ ├── atomicops-internals-arm-generic.h │ │ ├── atomicops-internals-arm-v6plus.h │ │ ├── atomicops-internals-linuxppc.h │ │ ├── atomicops-internals-macosx.h │ │ ├── atomicops-internals-windows.h │ │ ├── atomicops-internals-x86.cc │ │ ├── atomicops-internals-x86.h │ │ ├── atomicops.h │ │ ├── basictypes.h │ │ ├── commandlineflags.h │ │ ├── cycleclock.h │ │ ├── dynamic_annotations.c │ │ ├── dynamic_annotations.h │ │ ├── elf_mem_image.cc │ │ ├── elf_mem_image.h │ │ ├── elfcore.h │ │ ├── googleinit.h │ │ ├── linux_syscall_support.h │ │ ├── linuxthreads.cc │ │ ├── linuxthreads.h │ │ ├── logging.cc │ │ ├── logging.h │ │ ├── low_level_alloc.cc │ │ ├── low_level_alloc.h │ │ ├── simple_mutex.h │ │ ├── spinlock.cc │ │ ├── spinlock.h │ │ ├── spinlock_internal.cc │ │ ├── spinlock_internal.h │ │ ├── spinlock_linux-inl.h │ │ ├── spinlock_posix-inl.h │ │ ├── spinlock_win32-inl.h │ │ ├── stl_allocator.h │ │ ├── synchronization_profiling.h │ │ ├── sysinfo.cc │ │ ├── sysinfo.h │ │ ├── thread_annotations.h │ │ ├── thread_lister.c │ │ ├── thread_lister.h │ │ ├── vdso_support.cc │ │ └── vdso_support.h │ ├── central_freelist.cc │ ├── central_freelist.h │ ├── common.cc │ ├── common.h │ ├── config.h.in │ ├── config_for_unittests.h │ ├── debugallocation.cc │ ├── getpc.h │ ├── google │ │ ├── heap-checker.h │ │ ├── heap-profiler.h │ │ ├── malloc_extension.h │ │ ├── malloc_extension_c.h │ │ ├── malloc_hook.h │ │ ├── malloc_hook_c.h │ │ ├── profiler.h │ │ ├── stacktrace.h │ │ └── tcmalloc.h │ ├── gperftools │ │ ├── heap-checker.h │ │ ├── heap-profiler.h │ │ ├── malloc_extension.h │ │ ├── malloc_extension_c.h │ │ ├── malloc_hook.h │ │ ├── malloc_hook_c.h │ │ ├── profiler.h │ │ ├── stacktrace.h │ │ └── tcmalloc.h.in │ ├── heap-checker-bcad.cc │ ├── heap-checker.cc │ ├── heap-profile-table.cc │ ├── heap-profile-table.h │ ├── heap-profiler.cc │ ├── internal_logging.cc │ ├── internal_logging.h │ ├── libc_override.h │ ├── libc_override_gcc_and_weak.h │ ├── libc_override_glibc.h │ ├── libc_override_osx.h │ ├── libc_override_redefine.h │ ├── linked_list.h │ ├── malloc_extension.cc │ ├── malloc_hook-inl.h │ ├── malloc_hook.cc │ ├── malloc_hook_mmap_freebsd.h │ ├── malloc_hook_mmap_linux.h │ ├── maybe_threads.cc │ ├── maybe_threads.h │ ├── memfs_malloc.cc │ ├── memory_region_map.cc │ ├── memory_region_map.h │ ├── packed-cache-inl.h │ ├── page_heap.cc │ ├── page_heap.h │ ├── page_heap_allocator.h │ ├── pagemap.h │ ├── pprof │ ├── profile-handler.cc │ ├── profile-handler.h │ ├── profiledata.cc │ ├── profiledata.h │ ├── profiler.cc │ ├── raw_printer.cc │ ├── raw_printer.h │ ├── sampler.cc │ ├── sampler.h │ ├── solaris │ │ └── libstdc++.la │ ├── span.cc │ ├── span.h │ ├── stack_trace_table.cc │ ├── stack_trace_table.h │ ├── stacktrace.cc │ ├── stacktrace_arm-inl.h │ ├── stacktrace_config.h │ ├── stacktrace_generic-inl.h │ ├── stacktrace_libunwind-inl.h │ ├── stacktrace_powerpc-inl.h │ ├── stacktrace_win32-inl.h │ ├── stacktrace_x86-inl.h │ ├── static_vars.cc │ ├── static_vars.h │ ├── symbolize.cc │ ├── symbolize.h │ ├── system-alloc.cc │ ├── system-alloc.h │ ├── tcmalloc.cc │ ├── tcmalloc.h │ ├── tcmalloc_guard.h │ ├── tests │ │ ├── addressmap_unittest.cc │ │ ├── atomicops_unittest.cc │ │ ├── current_allocated_bytes_test.cc │ │ ├── debugallocation_test.cc │ │ ├── debugallocation_test.sh │ │ ├── frag_unittest.cc │ │ ├── getpc_test.cc │ │ ├── heap-checker-death_unittest.sh │ │ ├── heap-checker_unittest.cc │ │ ├── heap-checker_unittest.sh │ │ ├── heap-profiler_unittest.cc │ │ ├── heap-profiler_unittest.sh │ │ ├── low_level_alloc_unittest.cc │ │ ├── malloc_extension_c_test.c │ │ ├── malloc_extension_test.cc │ │ ├── malloc_hook_test.cc │ │ ├── markidle_unittest.cc │ │ ├── maybe_threads_unittest.sh │ │ ├── memalign_unittest.cc │ │ ├── packed-cache_test.cc │ │ ├── page_heap_test.cc │ │ ├── pagemap_unittest.cc │ │ ├── profile-handler_unittest.cc │ │ ├── profiledata_unittest.cc │ │ ├── profiler_unittest.cc │ │ ├── profiler_unittest.sh │ │ ├── raw_printer_test.cc │ │ ├── realloc_unittest.cc │ │ ├── sampler_test.cc │ │ ├── sampling_test.cc │ │ ├── sampling_test.sh │ │ ├── simple_compat_test.cc │ │ ├── stack_trace_table_test.cc │ │ ├── stacktrace_unittest.cc │ │ ├── system-alloc_unittest.cc │ │ ├── tcmalloc_large_unittest.cc │ │ ├── tcmalloc_unittest.cc │ │ ├── testutil.cc │ │ ├── testutil.h │ │ └── thread_dealloc_unittest.cc │ ├── third_party │ │ └── valgrind.h │ ├── thread_cache.cc │ ├── thread_cache.h │ └── windows │ │ ├── addr2line-pdb.c │ │ ├── auto_testing_hook.h │ │ ├── config.h │ │ ├── get_mangled_names.cc │ │ ├── google │ │ └── tcmalloc.h │ │ ├── gperftools │ │ ├── tcmalloc.h │ │ └── tcmalloc.h.in │ │ ├── ia32_modrm_map.cc │ │ ├── ia32_opcode_map.cc │ │ ├── mingw.h │ │ ├── mini_disassembler.cc │ │ ├── mini_disassembler.h │ │ ├── mini_disassembler_types.h │ │ ├── nm-pdb.c │ │ ├── override_functions.cc │ │ ├── patch_functions.cc │ │ ├── port.cc │ │ ├── port.h │ │ ├── preamble_patcher.cc │ │ ├── preamble_patcher.h │ │ ├── preamble_patcher_test.cc │ │ ├── preamble_patcher_with_stub.cc │ │ └── shortproc.asm └── vsprojects │ ├── addr2line-pdb │ └── addr2line-pdb.vcproj │ ├── addressmap_unittest │ └── addressmap_unittest.vcproj │ ├── current_allocated_bytes_test │ └── current_allocated_bytes_test.vcproj │ ├── frag_unittest │ └── frag_unittest.vcproj │ ├── libtcmalloc_minimal │ └── libtcmalloc_minimal.vcproj │ ├── low_level_alloc_unittest │ └── low_level_alloc_unittest.vcproj │ ├── malloc_extension_test │ └── malloc_extension_test.vcproj │ ├── malloc_hook_test │ └── malloc_hook_test.vcproj │ ├── markidle_unittest │ └── markidle_unittest.vcproj │ ├── nm-pdb │ └── nm-pdb.vcproj │ ├── packed-cache_test │ └── packed-cache_test.vcproj │ ├── page_heap_test │ └── page_heap_test.vcproj │ ├── pagemap_unittest │ └── pagemap_unittest.vcproj │ ├── preamble_patcher_test │ └── preamble_patcher_test.vcproj │ ├── realloc_unittest │ └── realloc_unittest.vcproj │ ├── sampler_test │ └── sampler_test.vcproj │ ├── stack_trace_table_test │ └── stack_trace_table_test.vcproj │ ├── tcmalloc_minimal_large │ └── tcmalloc_minimal_large_unittest.vcproj │ ├── tcmalloc_minimal_unittest │ └── tcmalloc_minimal_unittest.vcproj │ ├── thread_dealloc_unittest │ └── thread_dealloc_unittest.vcproj │ └── tmu-static │ └── tmu-static.vcproj ├── lint.sh ├── rebench.conf ├── scripts ├── Benchmark.py ├── BenchmarkRunner.py ├── allocation_statistics_no_template.gpl ├── allocation_statistics_size_template.gpl ├── build_all.sh ├── create_plots.py ├── gc_times_gcbench.gp ├── gc_times_richards.gp ├── gc_times_som.gp ├── gcbench_additional_allocation.gp ├── gcbench_bad_cache_generational.gp ├── gcbench_bad_cache_mark.gp ├── gcbench_no_cache.gp ├── gcbench_with_cache.gp ├── generate_allocation_statistics.py ├── integer_histogram_gcbench.gp ├── integer_histogram_richards.gp ├── integer_histogram_som.gp ├── prepare_gc_csv.py ├── receiver_types_gcbench.gp ├── receiver_types_richards.gp ├── receiver_types_som.gp ├── richards_benchmark_additional_allocation.gp ├── richards_benchmark_bad_cache_generational.gp ├── richards_benchmark_bad_cache_mark.gp ├── richards_benchmark_no_cache.gp ├── richards_benchmark_with_cache.gp ├── run_benchmarks.py ├── send_types_gcbench.gp ├── send_types_richards.gp ├── send_types_som.gp ├── som_benchmarks_additional_allocation.gp ├── som_benchmarks_bad_cache_generational.gp ├── som_benchmarks_bad_cache_mark.gp ├── som_benchmarks_no_cache.gp └── som_benchmarks_with_cache.gp ├── som.sh └── src ├── Main.cpp ├── compiler ├── BytecodeGenerator.cpp ├── BytecodeGenerator.h ├── ClassGenerationContext.cpp ├── ClassGenerationContext.h ├── Disassembler.cpp ├── Disassembler.h ├── Lexer.cpp ├── Lexer.h ├── LexicalScope.h ├── MethodGenerationContext.cpp ├── MethodGenerationContext.h ├── Parser.cpp ├── Parser.h ├── SourceCoordinate.h ├── SourcecodeCompiler.cpp ├── SourcecodeCompiler.h ├── Variable.cpp └── Variable.h ├── cppsom_dll.vcproj ├── interpreter ├── Interpreter.cpp ├── Interpreter.h ├── bytecodes.cpp └── bytecodes.h ├── memory ├── CopyingCollector.cpp ├── CopyingCollector.h ├── CopyingHeap.cpp ├── CopyingHeap.h ├── DebugCopyingCollector.cpp ├── DebugCopyingCollector.h ├── DebugCopyingHeap.cpp ├── DebugCopyingHeap.h ├── GarbageCollector.h ├── GenerationalCollector.cpp ├── GenerationalCollector.h ├── GenerationalHeap.cpp ├── GenerationalHeap.h ├── Heap.cpp ├── Heap.h ├── MarkSweepCollector.cpp ├── MarkSweepCollector.h ├── MarkSweepHeap.cpp └── MarkSweepHeap.h ├── misc ├── ParseInteger.cpp ├── ParseInteger.h ├── StringUtil.h ├── Timer.cpp ├── Timer.h ├── VectorUtil.h ├── debug.cpp ├── debug.h ├── defs.h └── gettimeofday.h ├── primitives ├── Array.cpp ├── Array.h ├── Block.cpp ├── Block.h ├── Class.cpp ├── Class.h ├── Double.cpp ├── Double.h ├── Integer.cpp ├── Integer.h ├── Method.cpp ├── Method.h ├── Object.cpp ├── Object.h ├── Primitive.cpp ├── Primitive.h ├── String.cpp ├── String.h ├── Symbol.cpp ├── Symbol.h ├── System.cpp └── System.h ├── primitivesCore ├── PrimitiveContainer.cpp ├── PrimitiveContainer.h ├── PrimitiveLoader.cpp ├── PrimitiveLoader.h └── Primitives.h ├── unitTests ├── BasicInterpreterTests.h ├── BytecodeGenerationTest.cpp ├── BytecodeGenerationTest.h ├── CloneObjectsTest.cpp ├── CloneObjectsTest.h ├── TestWithParsing.cpp ├── TestWithParsing.h ├── TrivialMethodTest.cpp ├── TrivialMethodTest.h ├── WalkObjectsTest.cpp ├── WalkObjectsTest.h ├── WriteBarrierTest.cpp ├── WriteBarrierTest.h └── main.cpp ├── vm ├── Globals.cpp ├── Globals.h ├── IsValidObject.cpp ├── IsValidObject.h ├── LogAllocation.cpp ├── LogAllocation.h ├── Print.cpp ├── Print.h ├── Shell.cpp ├── Shell.h ├── Symbols.cpp ├── Symbols.h ├── Universe.cpp └── Universe.h └── vmobjects ├── AbstractObject.cpp ├── AbstractObject.h ├── IntegerBox.cpp ├── IntegerBox.h ├── ObjectFormats.h ├── Signature.cpp ├── Signature.h ├── VMArray.cpp ├── VMArray.h ├── VMBlock.cpp ├── VMBlock.h ├── VMClass.cpp ├── VMClass.h ├── VMDouble.cpp ├── VMDouble.h ├── VMEvaluationPrimitive.cpp ├── VMEvaluationPrimitive.h ├── VMFrame.cpp ├── VMFrame.h ├── VMInteger.cpp ├── VMInteger.h ├── VMInvokable.cpp ├── VMInvokable.h ├── VMMethod.cpp ├── VMMethod.h ├── VMObject.cpp ├── VMObject.h ├── VMObjectBase.h ├── VMPrimitive.cpp ├── VMPrimitive.h ├── VMSafePrimitive.cpp ├── VMSafePrimitive.h ├── VMString.cpp ├── VMString.h ├── VMSymbol.cpp ├── VMSymbol.h ├── VMTrivialMethod.cpp └── VMTrivialMethod.h /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.o 3 | *.so 4 | *.pyc 5 | *.swp 6 | *.eps 7 | *.png 8 | *.orig 9 | bin 10 | CORE 11 | SOM++ 12 | *.csp 13 | unittest 14 | benchmark_results 15 | generated_images 16 | 17 | PrimitiveCore.dll 18 | SOM++.dll 19 | 20 | SOM.xcodeproj/project.xcworkspace 21 | SOM.xcodeproj/xcuserdata 22 | build/Debug 23 | build/Smalltalk 24 | build/SOM.build 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "core-lib"] 2 | path = core-lib 3 | url = https://github.com/SOM-st/SOM.git 4 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cppsom 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?name? 14 | 15 | 16 | 17 | org.eclipse.cdt.make.core.append_environment 18 | true 19 | 20 | 21 | org.eclipse.cdt.make.core.autoBuildTarget 22 | all 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | make 31 | 32 | 33 | org.eclipse.cdt.make.core.cleanBuildTarget 34 | clean 35 | 36 | 37 | org.eclipse.cdt.make.core.contents 38 | org.eclipse.cdt.make.core.activeConfigSettings 39 | 40 | 41 | org.eclipse.cdt.make.core.enableAutoBuild 42 | false 43 | 44 | 45 | org.eclipse.cdt.make.core.enableCleanBuild 46 | true 47 | 48 | 49 | org.eclipse.cdt.make.core.enableFullBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.fullBuildTarget 54 | all 55 | 56 | 57 | org.eclipse.cdt.make.core.stopOnError 58 | true 59 | 60 | 61 | org.eclipse.cdt.make.core.useDefaultBuildCmd 62 | true 63 | 64 | 65 | 66 | 67 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 68 | full,incremental, 69 | 70 | 71 | 72 | 73 | 74 | org.eclipse.cdt.core.cnature 75 | org.eclipse.cdt.core.ccnature 76 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 77 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 78 | 79 | 80 | -------------------------------------------------------------------------------- /Examples: -------------------------------------------------------------------------------- 1 | core-lib/Examples -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 2 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 3 | http://www.hpi.uni-potsdam.de/swa/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Smalltalk: -------------------------------------------------------------------------------- 1 | core-lib/Smalltalk -------------------------------------------------------------------------------- /TestSuite: -------------------------------------------------------------------------------- 1 | core-lib/TestSuite -------------------------------------------------------------------------------- /doc/tab.c: -------------------------------------------------------------------------------- 1 | // not this 2 | void foo(void) { 3 | int i; 4 | if(a==...) { 5 | while(true) { 6 | ... 7 | } 8 | ... 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gperftools-2.0/AUTHORS: -------------------------------------------------------------------------------- 1 | google-perftools@googlegroups.com 2 | 3 | -------------------------------------------------------------------------------- /gperftools-2.0/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /gperftools-2.0/TODO: -------------------------------------------------------------------------------- 1 | HEAP PROFILER 2 | 3 | 1) Fix heap profiling under all STLs 4 | * Find out how to force non-glibc STL libraries to call new() and 5 | delete() for every allocation / deallocation. 6 | * Make heap profiler ignore STL-internal allocations for those 7 | libraries under which we cannot profile accurately, so we only 8 | see object-level leaks. 9 | 2) Remove dependency on tcmalloc? 10 | 3) Port to non-linux O/Ses (right now code uses /proc for library info) 11 | 4) Port to non-x86 architectures (locking code in spinlock is x86-specific) 12 | 5) Port to C? 13 | 6) Figure out how to get setenv() to work properly before main() in 14 | shared libaries, and get rid of the profile-naming hack once we 15 | do. (See HeapProfiler::Init().) 16 | 17 | 18 | HEAP CHECKER 19 | 20 | 1) Remove requirement that the heap-checker must be linked last into 21 | an application (hard! -- it needs its global constructor to run 22 | first) 23 | 24 | TCMALLOC 25 | 26 | 1) Implement mallinfo/mallopt 27 | 2) Have tcmalloc work correctly when libpthread is not linked in 28 | (currently working for glibc, could use other libc's too) 29 | 3) Return memory to the system when requirements drop 30 | 4) Explore coloring allocated objects to avoid cache conflicts 31 | 5) Explore biasing reclamation to larger addresses 32 | 6) Add contention stats to a synchronization.cc (can do spinlocks, 33 | but threads? -- may have to provide our own thread implementation) 34 | 35 | CPU PROFILER 36 | 37 | 1) Figure out how to get setenv() to work properly before main() in 38 | shared libaries(), and get rid of the profile-naming hack once we 39 | do. (See Profiler::GetUniquePathFromEnv().) 40 | 2) Resolve crashing problems on x86_64 (see README) 41 | 42 | STACKTRACE 43 | 44 | 1) Remove dependency on linux/x86 45 | 46 | --- 47 | 11 March 2008 48 | -------------------------------------------------------------------------------- /gperftools-2.0/doc/designstyle.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #ffffff; 3 | color: black; 4 | margin-right: 1in; 5 | margin-left: 1in; 6 | } 7 | 8 | 9 | h1, h2, h3, h4, h5, h6 { 10 | color: #3366ff; 11 | font-family: sans-serif; 12 | } 13 | @media print { 14 | /* Darker version for printing */ 15 | h1, h2, h3, h4, h5, h6 { 16 | color: #000080; 17 | font-family: helvetica, sans-serif; 18 | } 19 | } 20 | 21 | h1 { 22 | text-align: center; 23 | font-size: 18pt; 24 | } 25 | h2 { 26 | margin-left: -0.5in; 27 | } 28 | h3 { 29 | margin-left: -0.25in; 30 | } 31 | h4 { 32 | margin-left: -0.125in; 33 | } 34 | hr { 35 | margin-left: -1in; 36 | } 37 | 38 | /* Definition lists: definition term bold */ 39 | dt { 40 | font-weight: bold; 41 | } 42 | 43 | address { 44 | text-align: right; 45 | } 46 | /* Use the tag for bits of code and for variables and objects. */ 47 | code,pre,samp,var { 48 | color: #006000; 49 | } 50 | /* Use the tag for file and directory paths and names. */ 51 | file { 52 | color: #905050; 53 | font-family: monospace; 54 | } 55 | /* Use the tag for stuff the user should type. */ 56 | kbd { 57 | color: #600000; 58 | } 59 | div.note p { 60 | float: right; 61 | width: 3in; 62 | margin-right: 0%; 63 | padding: 1px; 64 | border: 2px solid #6060a0; 65 | background-color: #fffff0; 66 | } 67 | 68 | UL.nobullets { 69 | list-style-type: none; 70 | list-style-image: none; 71 | margin-left: -1em; 72 | } 73 | 74 | /* pretty printing styles. See prettify.js */ 75 | .str { color: #080; } 76 | .kwd { color: #008; } 77 | .com { color: #800; } 78 | .typ { color: #606; } 79 | .lit { color: #066; } 80 | .pun { color: #660; } 81 | .pln { color: #000; } 82 | .tag { color: #008; } 83 | .atn { color: #606; } 84 | .atv { color: #080; } 85 | pre.prettyprint { padding: 2px; border: 1px solid #888; } 86 | 87 | .embsrc { background: #eee; } 88 | 89 | @media print { 90 | .str { color: #060; } 91 | .kwd { color: #006; font-weight: bold; } 92 | .com { color: #600; font-style: italic; } 93 | .typ { color: #404; font-weight: bold; } 94 | .lit { color: #044; } 95 | .pun { color: #440; } 96 | .pln { color: #000; } 97 | .tag { color: #006; font-weight: bold; } 98 | .atn { color: #404; } 99 | .atv { color: #060; } 100 | } 101 | 102 | /* Table Column Headers */ 103 | .hdr { 104 | color: #006; 105 | font-weight: bold; 106 | background-color: #dddddd; } 107 | .hdr2 { 108 | color: #006; 109 | background-color: #eeeeee; } -------------------------------------------------------------------------------- /gperftools-2.0/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Gperftools 5 | 6 | 7 | 8 | 14 | 15 |
16 | Last modified: Thu Feb 2 14:40:47 PST 2012 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /gperftools-2.0/doc/overview.dot: -------------------------------------------------------------------------------- 1 | digraph Overview { 2 | node [shape = box] 3 | 4 | {rank=same 5 | T1 [label="Thread Cache"] 6 | Tsep [label="...", shape=plaintext] 7 | Tn [label="Thread Cache"] 8 | T1 -> Tsep -> Tn [style=invis] 9 | } 10 | 11 | C [label="Central\nHeap"] 12 | T1 -> C [dir=both] 13 | Tn -> C [dir=both] 14 | 15 | } 16 | -------------------------------------------------------------------------------- /gperftools-2.0/doc/overview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/overview.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/pageheap.dot: -------------------------------------------------------------------------------- 1 | digraph PageHeap { 2 | rankdir=LR 3 | node [shape=box, width=0.3, height=0.3] 4 | nodesep=.05 5 | 6 | heap [shape=record, height=3, label="1 page|2 pages|3 pages|...|255 pages|rest"] 7 | O0 [shape=record, label=""] 8 | O1 [shape=record, label=""] 9 | O2 [shape=record, label="{|}"] 10 | O3 [shape=record, label="{|}"] 11 | O4 [shape=record, label="{||}"] 12 | O5 [shape=record, label="{||}"] 13 | O6 [shape=record, label="{|...|}"] 14 | O7 [shape=record, label="{|...|}"] 15 | O8 [shape=record, label="{|.....|}"] 16 | O9 [shape=record, label="{|.....|}"] 17 | sep1 [shape=plaintext, label="..."] 18 | sep2 [shape=plaintext, label="..."] 19 | sep3 [shape=plaintext, label="..."] 20 | sep4 [shape=plaintext, label="..."] 21 | sep5 [shape=plaintext, label="..."] 22 | 23 | heap:f0 -> O0 -> O1 -> sep1 24 | heap:f1 -> O2 -> O3 -> sep2 25 | heap:f2 -> O4 -> O5 -> sep3 26 | heap:f255 -> O6 -> O7 -> sep4 27 | heap:frest -> O8 -> O9 -> sep5 28 | 29 | } 30 | -------------------------------------------------------------------------------- /gperftools-2.0/doc/pageheap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/pageheap.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/pprof-test-big.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/pprof-test-big.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/pprof-test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/pprof-test.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/pprof-vsnprintf-big.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/pprof-vsnprintf-big.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/pprof-vsnprintf.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/pprof-vsnprintf.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/spanmap.dot: -------------------------------------------------------------------------------- 1 | digraph SpanMap { 2 | node [shape=box, width=0.3, height=0.3] 3 | nodesep=.05 4 | 5 | map [shape=record, width=6, label="||||||||||"] 6 | S0 [label="a"] 7 | S1 [label="b"] 8 | S2 [label="c"] 9 | S3 [label="d"] 10 | map:f0 -> S0 11 | map:f1 -> S0 12 | map:f2 -> S1 13 | map:f3 -> S2 14 | map:f4 -> S2 15 | map:f5 -> S2 16 | map:f6 -> S2 17 | map:f7 -> S2 18 | map:f8 -> S3 19 | map:f9 -> S3 20 | map:f10 -> S3 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gperftools-2.0/doc/spanmap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/spanmap.gif -------------------------------------------------------------------------------- /gperftools-2.0/doc/threadheap.dot: -------------------------------------------------------------------------------- 1 | digraph ThreadHeap { 2 | rankdir=LR 3 | node [shape=box, width=0.3, height=0.3] 4 | nodesep=.05 5 | 6 | heap [shape=record, height=2, label="class 0|class 1|class 2|..."] 7 | O0 [label=""] 8 | O1 [label=""] 9 | O2 [label=""] 10 | O3 [label=""] 11 | O4 [label=""] 12 | O5 [label=""] 13 | sep1 [shape=plaintext, label="..."] 14 | sep2 [shape=plaintext, label="..."] 15 | sep3 [shape=plaintext, label="..."] 16 | 17 | heap:f0 -> O0 -> O1 -> sep1 18 | heap:f1 -> O2 -> O3 -> sep2 19 | heap:f2 -> O4 -> O5 -> sep3 20 | 21 | } 22 | -------------------------------------------------------------------------------- /gperftools-2.0/doc/threadheap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/doc/threadheap.gif -------------------------------------------------------------------------------- /gperftools-2.0/m4/ac_have_attribute.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AX_C___ATTRIBUTE__], [ 2 | AC_MSG_CHECKING(for __attribute__) 3 | AC_CACHE_VAL(ac_cv___attribute__, [ 4 | AC_TRY_COMPILE( 5 | [#include 6 | static void foo(void) __attribute__ ((unused)); 7 | void foo(void) { exit(1); }], 8 | [], 9 | ac_cv___attribute__=yes, 10 | ac_cv___attribute__=no 11 | )]) 12 | if test "$ac_cv___attribute__" = "yes"; then 13 | AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) 14 | fi 15 | AC_MSG_RESULT($ac_cv___attribute__) 16 | ]) 17 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/acx_nanosleep.m4: -------------------------------------------------------------------------------- 1 | # Check for support for nanosleep. It's defined in , but on 2 | # some systems, such as solaris, you need to link in a library to use it. 3 | # We set acx_nanosleep_ok if nanosleep is supported; in that case, 4 | # NANOSLEEP_LIBS is set to whatever libraries are needed to support 5 | # nanosleep. 6 | 7 | AC_DEFUN([ACX_NANOSLEEP], 8 | [AC_MSG_CHECKING(if nanosleep requires any libraries) 9 | AC_LANG_SAVE 10 | AC_LANG_C 11 | acx_nanosleep_ok="no" 12 | NANOSLEEP_LIBS= 13 | # For most folks, this should just work 14 | AC_TRY_LINK([#include ], 15 | [static struct timespec ts; nanosleep(&ts, NULL);], 16 | [acx_nanosleep_ok=yes]) 17 | # For solaris, we may need -lrt 18 | if test "x$acx_nanosleep_ok" != "xyes"; then 19 | OLD_LIBS="$LIBS" 20 | LIBS="-lrt $LIBS" 21 | AC_TRY_LINK([#include ], 22 | [static struct timespec ts; nanosleep(&ts, NULL);], 23 | [acx_nanosleep_ok=yes]) 24 | if test "x$acx_nanosleep_ok" = "xyes"; then 25 | NANOSLEEP_LIBS="-lrt" 26 | fi 27 | LIBS="$OLD_LIBS" 28 | fi 29 | if test "x$acx_nanosleep_ok" != "xyes"; then 30 | AC_MSG_ERROR([cannot find the nanosleep function]) 31 | else 32 | AC_MSG_RESULT(${NANOSLEEP_LIBS:-no}) 33 | fi 34 | AC_LANG_RESTORE 35 | ]) 36 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/compiler_characteristics.m4: -------------------------------------------------------------------------------- 1 | # Check compiler characteristics (e.g. type sizes, PRIxx macros, ...) 2 | 3 | # If types $1 and $2 are compatible, perform action $3 4 | AC_DEFUN([AC_TYPES_COMPATIBLE], 5 | [AC_TRY_COMPILE([#include ], [$1 v1 = 0; $2 v2 = 0; return (&v1 - &v2)], $3)]) 6 | 7 | define(AC_PRIUS_COMMENT, [printf format code for printing a size_t and ssize_t]) 8 | 9 | AC_DEFUN([AC_COMPILER_CHARACTERISTICS], 10 | [AC_CACHE_CHECK(AC_PRIUS_COMMENT, ac_cv_formatting_prius_prefix, 11 | [AC_TYPES_COMPATIBLE(unsigned int, size_t, 12 | ac_cv_formatting_prius_prefix=; ac_cv_prius_defined=1) 13 | AC_TYPES_COMPATIBLE(unsigned long, size_t, 14 | ac_cv_formatting_prius_prefix=l; ac_cv_prius_defined=1) 15 | AC_TYPES_COMPATIBLE(unsigned long long, size_t, 16 | ac_cv_formatting_prius_prefix=ll; ac_cv_prius_defined=1 17 | )]) 18 | if test -z "$ac_cv_prius_defined"; then 19 | ac_cv_formatting_prius_prefix=z; 20 | fi 21 | AC_DEFINE_UNQUOTED(PRIuS, "${ac_cv_formatting_prius_prefix}u", AC_PRIUS_COMMENT) 22 | AC_DEFINE_UNQUOTED(PRIxS, "${ac_cv_formatting_prius_prefix}x", AC_PRIUS_COMMENT) 23 | AC_DEFINE_UNQUOTED(PRIdS, "${ac_cv_formatting_prius_prefix}d", AC_PRIUS_COMMENT) 24 | ]) 25 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/install_prefix.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AC_INSTALL_PREFIX], 2 | [ac_cv_install_prefix="$prefix"; 3 | if test x"$ac_cv_install_prefix" = x"NONE" ; then 4 | ac_cv_install_prefix="$ac_default_prefix"; 5 | fi 6 | AC_DEFINE_UNQUOTED(INSTALL_PREFIX, "$ac_cv_install_prefix", 7 | [prefix where we look for installed files]) 8 | ]) 9 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/namespaces.m4: -------------------------------------------------------------------------------- 1 | # Checks whether the compiler implements namespaces 2 | AC_DEFUN([AC_CXX_NAMESPACES], 3 | [AC_CACHE_CHECK(whether the compiler implements namespaces, 4 | ac_cv_cxx_namespaces, 5 | [AC_LANG_SAVE 6 | AC_LANG_CPLUSPLUS 7 | AC_TRY_COMPILE([namespace Outer { 8 | namespace Inner { int i = 0; }}], 9 | [using namespace Outer::Inner; return i;], 10 | ac_cv_cxx_namespaces=yes, 11 | ac_cv_cxx_namespaces=no) 12 | AC_LANG_RESTORE]) 13 | if test "$ac_cv_cxx_namespaces" = yes; then 14 | AC_DEFINE(HAVE_NAMESPACES, 1, [define if the compiler implements namespaces]) 15 | fi]) 16 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/program_invocation_name.m4: -------------------------------------------------------------------------------- 1 | # We need to be careful to avoid having the reference to 2 | # program_invocation_name optimized out. We do that by 3 | # returning the value. 4 | 5 | AC_DEFUN([AC_PROGRAM_INVOCATION_NAME], 6 | [AC_CACHE_CHECK( 7 | for program_invocation_name, 8 | ac_cv_have_program_invocation_name, 9 | AC_TRY_LINK([extern char* program_invocation_name;], 10 | [return *program_invocation_name;], 11 | [ac_cv_have_program_invocation_name=yes], 12 | [ac_cv_have_program_invocation_name=no]) 13 | ) 14 | if test "$ac_cv_have_program_invocation_name" = "yes"; then 15 | AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME, 1, 16 | [define if libc has program_invocation_name]) 17 | fi 18 | ]) 19 | 20 | -------------------------------------------------------------------------------- /gperftools-2.0/m4/stl_namespace.m4: -------------------------------------------------------------------------------- 1 | # We check what namespace stl code like vector expects to be executed in 2 | 3 | AC_DEFUN([AC_CXX_STL_NAMESPACE], 4 | [AC_CACHE_CHECK( 5 | what namespace STL code is in, 6 | ac_cv_cxx_stl_namespace, 7 | [AC_REQUIRE([AC_CXX_NAMESPACES]) 8 | AC_LANG_SAVE 9 | AC_LANG_CPLUSPLUS 10 | AC_TRY_COMPILE([#include ], 11 | [vector t; return 0;], 12 | ac_cv_cxx_stl_namespace=none) 13 | AC_TRY_COMPILE([#include ], 14 | [std::vector t; return 0;], 15 | ac_cv_cxx_stl_namespace=std) 16 | AC_LANG_RESTORE]) 17 | if test "$ac_cv_cxx_stl_namespace" = none; then 18 | AC_DEFINE(STL_NAMESPACE,, 19 | [the namespace where STL code like vector<> is defined]) 20 | fi 21 | if test "$ac_cv_cxx_stl_namespace" = std; then 22 | AC_DEFINE(STL_NAMESPACE,std, 23 | [the namespace where STL code like vector<> is defined]) 24 | fi 25 | ]) 26 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/README: -------------------------------------------------------------------------------- 1 | The list of files here isn't complete. For a step-by-step guide on 2 | how to set this package up correctly, check out 3 | http://www.debian.org/doc/maint-guide/ 4 | 5 | Most of the files that are in this directory are boilerplate. 6 | However, you may need to change the list of binary-arch dependencies 7 | in 'rules'. 8 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/compat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/control: -------------------------------------------------------------------------------- 1 | Source: gperftools 2 | Priority: optional 3 | Maintainer: Google Inc. and others 4 | Build-Depends: debhelper (>= 4.0.0), binutils 5 | Standards-Version: 3.6.1 6 | 7 | Package: libgperftools-dev 8 | Section: libdevel 9 | Architecture: any 10 | Depends: libgperftools0 (= ${Source-Version}) 11 | Description: libraries for CPU and heap analysis, plus an efficient thread-caching malloc 12 | The gperftools package contains some utilities to improve and 13 | analyze the performance of C++ programs. This includes an optimized 14 | thread-caching malloc() and cpu and heap profiling utilities. The 15 | devel package contains static and debug libraries and header files 16 | for developing applications that use the gperftools package. 17 | 18 | Package: libgperftools0 19 | Section: libs 20 | Architecture: any 21 | Depends: ${shlibs:Depends} 22 | Description: libraries for CPU and heap analysis, plus an efficient thread-caching malloc 23 | The gperftools package contains some utilities to improve and 24 | analyze the performance of C++ programs. This includes an optimized 25 | thread-caching malloc() and cpu and heap profiling utilities. 26 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Craig Silverstein 2 | on Fri, 03 Feb 2012 15:40:45 -0800. 3 | 4 | It was downloaded from http://code.google.com/p/gperftools/downloads/list 5 | 6 | Upstream Author: google-perftools@googlegroups.com 7 | 8 | Copyright (c) 2005, Google Inc. 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are 13 | met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above 18 | copyright notice, this list of conditions and the following disclaimer 19 | in the documentation and/or other materials provided with the 20 | distribution. 21 | * Neither the name of Google Inc. nor the names of its 22 | contributors may be used to endorse or promote products derived from 23 | this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | COPYING 3 | ChangeLog 4 | INSTALL 5 | NEWS 6 | README 7 | TODO 8 | doc/cpuprofile.html 9 | doc/cpuprofile-fileformat.html 10 | doc/designstyle.css 11 | doc/heap-example1.png 12 | doc/heap_checker.html 13 | doc/heapprofile.html 14 | doc/index.html 15 | doc/overview.gif 16 | doc/pageheap.gif 17 | doc/pprof-test-big.gif 18 | doc/pprof-test.gif 19 | doc/pprof-vsnprintf-big.gif 20 | doc/pprof-vsnprintf.gif 21 | doc/pprof.1 22 | doc/pprof_remote_servers.html 23 | doc/spanmap.gif 24 | doc/t-test1.times.txt 25 | doc/tcmalloc-opspercpusec.vs.threads.1024.bytes.png 26 | doc/tcmalloc-opspercpusec.vs.threads.128.bytes.png 27 | doc/tcmalloc-opspercpusec.vs.threads.131072.bytes.png 28 | doc/tcmalloc-opspercpusec.vs.threads.16384.bytes.png 29 | doc/tcmalloc-opspercpusec.vs.threads.2048.bytes.png 30 | doc/tcmalloc-opspercpusec.vs.threads.256.bytes.png 31 | doc/tcmalloc-opspercpusec.vs.threads.32768.bytes.png 32 | doc/tcmalloc-opspercpusec.vs.threads.4096.bytes.png 33 | doc/tcmalloc-opspercpusec.vs.threads.512.bytes.png 34 | doc/tcmalloc-opspercpusec.vs.threads.64.bytes.png 35 | doc/tcmalloc-opspercpusec.vs.threads.65536.bytes.png 36 | doc/tcmalloc-opspercpusec.vs.threads.8192.bytes.png 37 | doc/tcmalloc-opspersec.vs.size.1.threads.png 38 | doc/tcmalloc-opspersec.vs.size.12.threads.png 39 | doc/tcmalloc-opspersec.vs.size.16.threads.png 40 | doc/tcmalloc-opspersec.vs.size.2.threads.png 41 | doc/tcmalloc-opspersec.vs.size.20.threads.png 42 | doc/tcmalloc-opspersec.vs.size.3.threads.png 43 | doc/tcmalloc-opspersec.vs.size.4.threads.png 44 | doc/tcmalloc-opspersec.vs.size.5.threads.png 45 | doc/tcmalloc-opspersec.vs.size.8.threads.png 46 | doc/tcmalloc.html 47 | doc/threadheap.gif 48 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/libgperftools-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/lib/pkgconfig 3 | usr/include 4 | usr/include/google 5 | usr/include/gperftools 6 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/libgperftools-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/google/* 2 | usr/include/gperftools/* 3 | usr/lib/lib*.so 4 | usr/lib/lib*.a 5 | usr/lib/*.la 6 | usr/lib/pkgconfig/*.pc 7 | debian/tmp/usr/include/google/* 8 | debian/tmp/usr/include/gperftools/* 9 | debian/tmp/usr/lib/lib*.so 10 | debian/tmp/usr/lib/lib*.a 11 | debian/tmp/usr/lib/*.la 12 | debian/tmp/usr/lib/pkgconfig/*.pc 13 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/libgperftools0.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/bin 3 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/libgperftools0.install: -------------------------------------------------------------------------------- 1 | usr/lib/lib*.so.* 2 | usr/bin/pprof* 3 | debian/tmp/usr/lib/lib*.so.* 4 | debian/tmp/usr/bin/pprof* 5 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/deb/libgperftools0.manpages: -------------------------------------------------------------------------------- 1 | doc/pprof.1 2 | -------------------------------------------------------------------------------- /gperftools-2.0/packages/rpm/rpm.spec: -------------------------------------------------------------------------------- 1 | %define RELEASE 1 2 | %define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE} 3 | %define prefix /usr 4 | 5 | Name: %NAME 6 | Summary: Performance tools for C++ 7 | Version: %VERSION 8 | Release: %rel 9 | Group: Development/Libraries 10 | URL: http://code.google.com/p/gperftools/ 11 | License: BSD 12 | Vendor: Google Inc. and others 13 | Packager: Google Inc. and others 14 | Source: http://%{NAME}.googlecode.com/files/%{NAME}-%{VERSION}.tar.gz 15 | Distribution: Redhat 7 and above. 16 | Buildroot: %{_tmppath}/%{name}-root 17 | Prefix: %prefix 18 | 19 | %description 20 | The %name packages contains some utilities to improve and analyze the 21 | performance of C++ programs. This includes an optimized thread-caching 22 | malloc() and cpu and heap profiling utilities. 23 | 24 | %package devel 25 | Summary: Performance tools for C++ 26 | Group: Development/Libraries 27 | Requires: %{NAME} = %{VERSION} 28 | 29 | %description devel 30 | The %name-devel package contains static and debug libraries and header 31 | files for developing applications that use the %name package. 32 | 33 | %changelog 34 | * Mon Apr 20 2009 35 | - Change build rule to use a configure line more like '%configure' 36 | - Change install to use DESTDIR instead of prefix for configure 37 | - Use wildcards for doc/ and lib/ directories 38 | 39 | * Fri Mar 11 2005 40 | - First draft 41 | 42 | %prep 43 | %setup 44 | 45 | %build 46 | # I can't use '% configure', because it defines -m32 which breaks some 47 | # of the low-level atomicops files in this package. But I do take 48 | # as much from % configure (in /usr/lib/rpm/macros) as I can. 49 | ./configure --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} --libexecdir=%{_libexecdir} --localstatedir=%{_localstatedir} --sharedstatedir=%{_sharedstatedir} --mandir=%{_mandir} --infodir=%{_infodir} 50 | make 51 | 52 | %install 53 | rm -rf $RPM_BUILD_ROOT 54 | make DESTDIR=$RPM_BUILD_ROOT install 55 | 56 | %clean 57 | rm -rf $RPM_BUILD_ROOT 58 | 59 | %files 60 | %defattr(-,root,root) 61 | 62 | %docdir %{prefix}/share/doc/%{NAME}-%{VERSION} 63 | %{prefix}/share/doc/%{NAME}-%{VERSION}/* 64 | 65 | %{_libdir}/*.so.* 66 | %{_bindir}/pprof 67 | %{_mandir}/man1/pprof.1* 68 | 69 | %files devel 70 | %defattr(-,root,root) 71 | 72 | %{_includedir}/google 73 | %{_includedir}/gperftools 74 | %{_libdir}/*.a 75 | %{_libdir}/*.la 76 | %{_libdir}/*.so 77 | %{_libdir}/pkgconfig/*.pc 78 | -------------------------------------------------------------------------------- /gperftools-2.0/src/base/linuxthreads.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2005-2007, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * --- 31 | * Author: Markus Gutschke 32 | */ 33 | 34 | #ifndef _LINUXTHREADS_H 35 | #define _LINUXTHREADS_H 36 | 37 | /* Include thread_lister.h to get the interface that we implement for linux. 38 | */ 39 | 40 | /* We currently only support x86-32 and x86-64 on Linux. Porting to other 41 | * related platforms should not be difficult. 42 | */ 43 | #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ 44 | defined(__mips__) || defined(__PPC__)) && defined(__linux) 45 | 46 | /* Define the THREADS symbol to make sure that there is exactly one core dumper 47 | * built into the library. 48 | */ 49 | #define THREADS "Linux /proc" 50 | 51 | #endif 52 | 53 | #endif /* _LINUXTHREADS_H */ 54 | -------------------------------------------------------------------------------- /gperftools-2.0/src/base/spinlock_posix-inl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * --- 31 | * This file is a Posix-specific part of spinlock_internal.cc 32 | */ 33 | 34 | #include 35 | #include 36 | #ifdef HAVE_SCHED_H 37 | #include /* For sched_yield() */ 38 | #endif 39 | #include /* For nanosleep() */ 40 | 41 | namespace base { 42 | namespace internal { 43 | 44 | void SpinLockDelay(volatile Atomic32 *w, int32 value, int loop) { 45 | int save_errno = errno; 46 | if (loop == 0) { 47 | } else if (loop == 1) { 48 | sched_yield(); 49 | } else { 50 | struct timespec tm; 51 | tm.tv_sec = 0; 52 | tm.tv_nsec = base::internal::SuggestedDelayNS(loop); 53 | nanosleep(&tm, NULL); 54 | } 55 | errno = save_errno; 56 | } 57 | 58 | void SpinLockWake(volatile Atomic32 *w, bool all) { 59 | } 60 | 61 | } // namespace internal 62 | } // namespace base 63 | -------------------------------------------------------------------------------- /gperftools-2.0/src/base/spinlock_win32-inl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * --- 31 | * This file is a Win32-specific part of spinlock_internal.cc 32 | */ 33 | 34 | 35 | #include 36 | 37 | namespace base { 38 | namespace internal { 39 | 40 | void SpinLockDelay(volatile Atomic32 *w, int32 value, int loop) { 41 | if (loop == 0) { 42 | } else if (loop == 1) { 43 | Sleep(0); 44 | } else { 45 | Sleep(base::internal::SuggestedDelayNS(loop) / 1000000); 46 | } 47 | } 48 | 49 | void SpinLockWake(volatile Atomic32 *w, bool all) { 50 | } 51 | 52 | } // namespace internal 53 | } // namespace base 54 | -------------------------------------------------------------------------------- /gperftools-2.0/src/base/synchronization_profiling.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * --- 31 | * Author: Chris Ruemmler 32 | */ 33 | 34 | #ifndef BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_ 35 | #define BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_ 36 | 37 | #include "base/basictypes.h" 38 | 39 | namespace base { 40 | 41 | // We can do contention-profiling of SpinLocks, but the code is in 42 | // mutex.cc, which is not always linked in with spinlock. Hence we 43 | // provide a weak definition, which are used if mutex.cc isn't linked in. 44 | 45 | // Submit the number of cycles the spinlock spent contending. 46 | ATTRIBUTE_WEAK extern void SubmitSpinLockProfileData(const void *, int64); 47 | extern void SubmitSpinLockProfileData(const void *contendedlock, 48 | int64 wait_cycles) {} 49 | } 50 | #endif // BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_ 51 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/heap-checker.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | /* The code has moved to gperftools/. Use that include-directory for 31 | * new code. 32 | */ 33 | #include 34 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/heap-profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2005, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* The code has moved to gperftools/. Use that include-directory for 32 | * new code. 33 | */ 34 | #include 35 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/malloc_extension.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | /* The code has moved to gperftools/. Use that include-directory for 31 | * new code. 32 | */ 33 | #include 34 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/malloc_extension_c.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* The code has moved to gperftools/. Use that include-directory for 32 | * new code. 33 | */ 34 | #include 35 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/malloc_hook.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | /* The code has moved to gperftools/. Use that include-directory for 31 | * new code. 32 | */ 33 | #include 34 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/malloc_hook_c.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* The code has moved to gperftools/. Use that include-directory for 32 | * new code. 33 | */ 34 | #include 35 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2005, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* The code has moved to gperftools/. Use that include-directory for 32 | * new code. 33 | */ 34 | #include 35 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/stacktrace.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | /* The code has moved to gperftools/. Use that include-directory for 31 | * new code. 32 | */ 33 | #include 34 | -------------------------------------------------------------------------------- /gperftools-2.0/src/google/tcmalloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2003, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* The code has moved to gperftools/. Use that include-directory for 32 | * new code. 33 | */ 34 | #include 35 | -------------------------------------------------------------------------------- /gperftools-2.0/src/maybe_threads.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // Author: Paul Menage 32 | 33 | //------------------------------------------------------------------- 34 | // Some wrappers for pthread functions so that we can be LD_PRELOADed 35 | // against non-pthreads apps. 36 | //------------------------------------------------------------------- 37 | 38 | #ifndef GOOGLE_MAYBE_THREADS_H_ 39 | #define GOOGLE_MAYBE_THREADS_H_ 40 | 41 | #ifdef HAVE_PTHREAD 42 | #include 43 | #endif 44 | 45 | int perftools_pthread_key_create(pthread_key_t *key, 46 | void (*destr_function) (void *)); 47 | void *perftools_pthread_getspecific(pthread_key_t key); 48 | int perftools_pthread_setspecific(pthread_key_t key, void *val); 49 | int perftools_pthread_once(pthread_once_t *ctl, 50 | void (*init_routine) (void)); 51 | 52 | #endif /* GOOGLE_MAYBE_THREADS_H_ */ 53 | -------------------------------------------------------------------------------- /gperftools-2.0/src/solaris/libstdc++.la: -------------------------------------------------------------------------------- 1 | # libstdc++.la - a libtool library file 2 | # Generated by ltmain.sh - GNU libtool 1.4a-GCC3.0 (1.641.2.256 2001/05/28 20:09:07 with GCC-local changes) 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # --- 8 | # NOTE: This file lives in /usr/sfw/lib on Solaris 10. Unfortunately, 9 | # due to an apparent bug in the Solaris 10 6/06 release, 10 | # /usr/sfw/lib/libstdc++.la is empty. Below is the correct content, 11 | # according to 12 | # http://forum.java.sun.com/thread.jspa?threadID=5073150 13 | # By passing LDFLAGS='-Lsrc/solaris' to configure, make will pick up 14 | # this copy of the file rather than the empty copy in /usr/sfw/lib. 15 | # 16 | # Also see 17 | # http://www.technicalarticles.org/index.php/Compiling_MySQL_5.0_on_Solaris_10 18 | # 19 | # Note: this is for 32-bit systems. If you have a 64-bit system, 20 | # uncomment the appropriate dependency_libs line below. 21 | # ---- 22 | 23 | # The name that we can dlopen(3). 24 | dlname='libstdc++.so.6' 25 | 26 | # Names of this library. 27 | library_names='libstdc++.so.6.0.3 libstdc++.so.6 libstdc++.so' 28 | 29 | # The name of the static archive. 30 | old_library='libstdc++.a' 31 | 32 | # Libraries that this one depends upon. 33 | # 32-bit version: 34 | dependency_libs='-lc -lm -L/usr/sfw/lib -lgcc_s' 35 | # 64-bit version: 36 | #dependency_libs='-L/lib/64 -lc -lm -L/usr/sfw/lib/64 -lgcc_s' 37 | 38 | # Version information for libstdc++. 39 | current=6 40 | age=0 41 | revision=3 42 | 43 | # Is this an already installed library? 44 | installed=yes 45 | 46 | # Files to dlopen/dlpreopen 47 | dlopen='' 48 | dlpreopen='' 49 | 50 | # Directory that this library needs to be installed in: 51 | libdir='/usr/sfw/lib' 52 | -------------------------------------------------------------------------------- /gperftools-2.0/src/tcmalloc_guard.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // Author: Craig Silverstein 32 | // 33 | // We expose the TCMallocGuard class -- which initializes the tcmalloc 34 | // allocator -- so classes that need to be sure tcmalloc is loaded 35 | // before they do stuff -- notably heap-profiler -- can. To use this 36 | // create a static TCMallocGuard instance at the top of a file where 37 | // you need tcmalloc to be initialized before global constructors run. 38 | 39 | #ifndef TCMALLOC_TCMALLOC_GUARD_H_ 40 | #define TCMALLOC_TCMALLOC_GUARD_H_ 41 | 42 | class TCMallocGuard { 43 | public: 44 | TCMallocGuard(); 45 | ~TCMallocGuard(); 46 | }; 47 | 48 | #endif // TCMALLOC_TCMALLOC_GUARD_H_ 49 | -------------------------------------------------------------------------------- /gperftools-2.0/src/tests/packed-cache_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | // Author: Geoff Pike 32 | 33 | #include 34 | #include "base/logging.h" 35 | #include "packed-cache-inl.h" 36 | 37 | static const int kHashbits = PackedCache<64, uint64>::kHashbits; 38 | 39 | // A basic sanity test. 40 | void PackedCacheTest_basic() { 41 | PackedCache<32, uint32> cache(0); 42 | CHECK_EQ(cache.GetOrDefault(0, 1), 0); 43 | cache.Put(0, 17); 44 | CHECK(cache.Has(0)); 45 | CHECK_EQ(cache.GetOrDefault(0, 1), 17); 46 | cache.Put(19, 99); 47 | CHECK(cache.Has(0) && cache.Has(19)); 48 | CHECK_EQ(cache.GetOrDefault(0, 1), 17); 49 | CHECK_EQ(cache.GetOrDefault(19, 1), 99); 50 | // Knock <0, 17> out by using a conflicting key. 51 | cache.Put(1 << kHashbits, 22); 52 | CHECK(!cache.Has(0)); 53 | CHECK_EQ(cache.GetOrDefault(0, 1), 1); 54 | CHECK_EQ(cache.GetOrDefault(1 << kHashbits, 1), 22); 55 | } 56 | 57 | int main(int argc, char **argv) { 58 | PackedCacheTest_basic(); 59 | 60 | printf("PASS\n"); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /gperftools-2.0/src/tests/page_heap_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009 Google Inc. All Rights Reserved. 2 | // Author: fikes@google.com (Andrew Fikes) 3 | 4 | #include "config_for_unittests.h" 5 | #include "page_heap.h" 6 | #include 7 | #include "base/logging.h" 8 | #include "common.h" 9 | 10 | namespace { 11 | 12 | static void CheckStats(const tcmalloc::PageHeap* ph, 13 | uint64_t system_pages, 14 | uint64_t free_pages, 15 | uint64_t unmapped_pages) { 16 | tcmalloc::PageHeap::Stats stats = ph->stats(); 17 | EXPECT_EQ(system_pages, stats.system_bytes >> kPageShift); 18 | EXPECT_EQ(free_pages, stats.free_bytes >> kPageShift); 19 | EXPECT_EQ(unmapped_pages, stats.unmapped_bytes >> kPageShift); 20 | } 21 | 22 | static void TestPageHeap_Stats() { 23 | tcmalloc::PageHeap* ph = new tcmalloc::PageHeap(); 24 | 25 | // Empty page heap 26 | CheckStats(ph, 0, 0, 0); 27 | 28 | // Allocate a span 's1' 29 | tcmalloc::Span* s1 = ph->New(256); 30 | CheckStats(ph, 256, 0, 0); 31 | 32 | // Split span 's1' into 's1', 's2'. Delete 's2' 33 | tcmalloc::Span* s2 = ph->Split(s1, 128); 34 | Length s2_len = s2->length; 35 | ph->Delete(s2); 36 | CheckStats(ph, 256, 128, 0); 37 | 38 | // Unmap deleted span 's2' 39 | EXPECT_EQ(s2_len, ph->ReleaseAtLeastNPages(1)); 40 | CheckStats(ph, 256, 0, 128); 41 | 42 | // Delete span 's1' 43 | ph->Delete(s1); 44 | CheckStats(ph, 256, 128, 128); 45 | 46 | delete ph; 47 | } 48 | 49 | } // namespace 50 | 51 | int main(int argc, char **argv) { 52 | TestPageHeap_Stats(); 53 | printf("PASS\n"); 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /gperftools-2.0/src/tests/raw_printer_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009 Google Inc. All Rights Reserved. 2 | // Author: sanjay@google.com (Sanjay Ghemawat) 3 | 4 | #include "raw_printer.h" 5 | #include 6 | #include 7 | #include "base/logging.h" 8 | 9 | using std::string; 10 | 11 | #define TEST(a, b) void TEST_##a##_##b() 12 | #define RUN_TEST(a, b) TEST_##a##_##b() 13 | 14 | TEST(RawPrinter, Empty) { 15 | char buffer[1]; 16 | base::RawPrinter printer(buffer, arraysize(buffer)); 17 | CHECK_EQ(0, printer.length()); 18 | CHECK_EQ(string(""), buffer); 19 | CHECK_EQ(0, printer.space_left()); 20 | printer.Printf("foo"); 21 | CHECK_EQ(string(""), string(buffer)); 22 | CHECK_EQ(0, printer.length()); 23 | CHECK_EQ(0, printer.space_left()); 24 | } 25 | 26 | TEST(RawPrinter, PartiallyFilled) { 27 | char buffer[100]; 28 | base::RawPrinter printer(buffer, arraysize(buffer)); 29 | printer.Printf("%s %s", "hello", "world"); 30 | CHECK_EQ(string("hello world"), string(buffer)); 31 | CHECK_EQ(11, printer.length()); 32 | CHECK_LT(0, printer.space_left()); 33 | } 34 | 35 | TEST(RawPrinter, Truncated) { 36 | char buffer[3]; 37 | base::RawPrinter printer(buffer, arraysize(buffer)); 38 | printer.Printf("%d", 12345678); 39 | CHECK_EQ(string("12"), string(buffer)); 40 | CHECK_EQ(2, printer.length()); 41 | CHECK_EQ(0, printer.space_left()); 42 | } 43 | 44 | TEST(RawPrinter, ExactlyFilled) { 45 | char buffer[12]; 46 | base::RawPrinter printer(buffer, arraysize(buffer)); 47 | printer.Printf("%s %s", "hello", "world"); 48 | CHECK_EQ(string("hello world"), string(buffer)); 49 | CHECK_EQ(11, printer.length()); 50 | CHECK_EQ(0, printer.space_left()); 51 | } 52 | 53 | int main(int argc, char **argv) { 54 | RUN_TEST(RawPrinter, Empty); 55 | RUN_TEST(RawPrinter, PartiallyFilled); 56 | RUN_TEST(RawPrinter, Truncated); 57 | RUN_TEST(RawPrinter, ExactlyFilled); 58 | printf("PASS\n"); 59 | return 0; // 0 means success 60 | } 61 | -------------------------------------------------------------------------------- /gperftools-2.0/src/windows/google/tcmalloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2003, Google Inc. 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* The code has moved to gperftools/. Use that include-directory for 32 | * new code. 33 | */ 34 | #include 35 | -------------------------------------------------------------------------------- /gperftools-2.0/src/windows/ia32_modrm_map.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/src/windows/ia32_modrm_map.cc -------------------------------------------------------------------------------- /gperftools-2.0/src/windows/ia32_opcode_map.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/src/windows/ia32_opcode_map.cc -------------------------------------------------------------------------------- /gperftools-2.0/src/windows/mini_disassembler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SOM-st/SOMpp/a619100b94eb3d5d4bc205b627c6bd9a569bf1ea/gperftools-2.0/src/windows/mini_disassembler.h -------------------------------------------------------------------------------- /lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | clang-format-mp-19 -i --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h 3 | clang-tidy-mp-19 --config-file=.clang-tidy src/**/*.cpp \ 4 | --fix \ 5 | -- -I/opt/local/include/ -fdiagnostics-absolute-paths \ 6 | -DGC_TYPE=GENERATIONAL -DUSE_TAGGING=false -DCACHE_INTEGER=false -DUNITTESTS 7 | clang-format-mp-19 -i --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h 8 | -------------------------------------------------------------------------------- /scripts/BenchmarkRunner.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | from Benchmark import Benchmark 3 | 4 | class BenchmarkRunner(object): 5 | def __init__(self, target_path, no_iterations=10): 6 | self.no_iterations = no_iterations 7 | self.target_path = target_path 8 | self.benchmarks = [] 9 | self.csv = [self.get_csv_header()] 10 | 11 | def add_benchmark(self, bm_path): 12 | self.benchmarks.append(bm_path) 13 | 14 | def get_csv_header(self): 15 | header = ["#name", "avg_time", "avg_time_err", "avg_gc_time", 16 | "avg_gc_time_err"] 17 | for i in xrange(self.no_iterations): 18 | header.append("total_time_"+str(i)) 19 | header.append("gc_time_"+str(i)) 20 | return ", ".join(header) 21 | 22 | def get_csv(self): 23 | return "\n".join(self.csv) 24 | 25 | def run_benchmarks(self): 26 | print "Executing Benchmarks for " + self.target_path 27 | for bench_name in self.benchmarks: 28 | bench = Benchmark(self.target_path, self.target_path+"/"+bench_name, 29 | self.no_iterations) 30 | bench.run() 31 | self.csv.append(bench.get_csv()) 32 | -------------------------------------------------------------------------------- /scripts/allocation_statistics_no_template.gpl: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "out_file" 4 | set title "Allocation Statistics (bench_name)" font "Helvetica,26" 5 | set xtics rotate by -45 #rotate labels 6 | set datafile separator "," #csv is comma separated 7 | set style fill solid 1.00 border 0 8 | set grid ytics 9 | set boxwidth 0.6 10 | set ylabel "Number of allocated objects" font "Helvetica,20" 11 | set key left 12 | plot "csv_file" using 2:xtic(1) ti "Number of objects" with boxes 13 | -------------------------------------------------------------------------------- /scripts/allocation_statistics_size_template.gpl: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "out_file" 4 | set title "Allocation Statistics (bench_name)" font "Helvetica,26" 5 | set xtics rotate by -45 #rotate labels 6 | set datafile separator "," #csv is comma separated 7 | set style fill solid 1.00 border 0 8 | set grid ytics 9 | set boxwidth 0.6 10 | set ylabel "Size of allocated objects in MB" font "Helvetica,20" 11 | set key left 12 | plot "csv_file" using ($3/1024/1024):xtic(1) ti "Cumulated size" with boxes 13 | -------------------------------------------------------------------------------- /scripts/create_plots.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from os import listdir 3 | from os import rename 4 | from subprocess import call 5 | import argparse 6 | import shutil 7 | 8 | OUT_DIR = "generated_images/" 9 | 10 | if __name__=="__main__": 11 | parser = argparse.ArgumentParser(description='Run Benchmarks for all SOM++ VMs') 12 | parser.add_argument("output_types", nargs="*", default = ["eps"]) 13 | args = parser.parse_args() 14 | 15 | files=[s for s in listdir("scripts") if s.endswith(".gp")] 16 | for gp_file in files: 17 | src_file = "scripts/" + gp_file 18 | eps_file = OUT_DIR + gp_file.replace(".gp",".eps") 19 | png_file = OUT_DIR + gp_file.replace(".gp",".png") 20 | print "creating %s from %s" % (" and ".join(args.output_types), src_file) 21 | call(["gnuplot", src_file]) 22 | shutil.move(gp_file.replace(".gp",".eps"), eps_file) 23 | if "png" in args.output_types: 24 | call(["convert", "-density", "300", eps_file, png_file]) 25 | if "pdf" in args.output_types: 26 | print "epstopdf %s" % eps_file 27 | call(["epstopdf %s" % eps_file], shell=True) 28 | -------------------------------------------------------------------------------- /scripts/gc_times_gcbench.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gc_times_gcbench.eps" 3 | set style data histogram 4 | set style histogram rowstacked 5 | set style fill solid 1.00 border 0 #fill bars 6 | set boxwidth 0.5 7 | set ylabel "Average execution time (s)" font "Helvetica,20" 8 | set key invert samplen 0.2 9 | set key samplen 0.2 10 | set bmargin 3 11 | set offset 0,2,0,0 12 | unset xtics 13 | set grid ytics 14 | 15 | set title "Garbage collection times for GCBench" font "Helvetica,26" 16 | 17 | plot 'benchmark_results/gcbench.csv' using (($2-$4)/1000):xtic(1) title "remaining time", \ 18 | '' using ($4/1000) title "gc time" 19 | -------------------------------------------------------------------------------- /scripts/gc_times_richards.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gc_times_richards.eps" 3 | set style data histogram 4 | set style histogram rowstacked 5 | set style fill solid 1.00 border 0 #fill bars 6 | set boxwidth 0.5 7 | set ylabel "Average execution time (ms)" font "Helvetica,20" 8 | set key invert samplen 0.2 9 | set key samplen 0.2 10 | set bmargin 3 11 | set offset 0,2,0,0 12 | unset xtics 13 | set grid ytics 14 | 15 | set title "Garbage collection times for Richards benchmark" font "Helvetica,26" 16 | 17 | plot 'benchmark_results/richards_benchmark.csv' using ($2-$4):xtic(1) title "remaining time", \ 18 | '' using 4 title "gc time" 19 | -------------------------------------------------------------------------------- /scripts/gc_times_som.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gc_times_som.eps" 3 | set style data histogram 4 | set style histogram rowstacked 5 | set style fill solid 1.00 border 0 #fill bars 6 | set boxwidth 0.9 7 | set title "Garbage collection times for SOM benchmarks" font "Helvetica,26" 8 | set xlabel offset character 0, -2, 0 font "" textcolor lt -1 norotate 9 | set ylabel "Average execution time (ms)" font "Helvetica,20" 10 | set xtics nomirror rotate by -45 11 | 12 | set grid ytics 13 | 14 | set xtics ("Bounce" 0*7+2, "BubbleSort" 1*7+2, "Dispatch" 2*7+2, "Fibonacci" 3*7+2, "IntegerLoop" 4*7+2,\ 15 | "List" 5*7+2, "Loop" 6*7+2, "Permute" 7*7+2, "Queens" 8*7+2, "QuickSort" 9*7+2,\ 16 | "Recurse" 10*7+2, "Sieve" 11*7+2, "Storage" 12*7+2, "Sum" 13*7+2, "Towers" 14*7+2,\ 17 | "TreeSort" 15*7+2) 18 | 19 | plot newhistogram lt 1, \ 20 | "benchmark_results/som_benchmarks.csv" index 0 u ($2-$4) title "remaining time", \ 21 | "" index 0 u 4 title "gc time", \ 22 | newhistogram lt 1, \ 23 | "" index 1 u ($2-$4) notitle, \ 24 | "" index 1 u 4 notitle, \ 25 | newhistogram lt 1, \ 26 | "" index 2 u ($2-$4) notitle, \ 27 | "" index 2 u 4 notitle, \ 28 | newhistogram lt 1, \ 29 | "" index 3 u ($2-$4) notitle, \ 30 | "" index 3 u 4 notitle, \ 31 | newhistogram lt 1, \ 32 | "" index 4 u ($2-$4) notitle, \ 33 | "" index 4 u 4 notitle, \ 34 | newhistogram lt 1, \ 35 | "" index 5 u ($2-$4) notitle, \ 36 | "" index 5 u 4 notitle, \ 37 | newhistogram lt 1, \ 38 | "" index 6 u ($2-$4) notitle, \ 39 | "" index 6 u 4 notitle, \ 40 | newhistogram lt 1, \ 41 | "" index 7 u ($2-$4) notitle, \ 42 | "" index 7 u 4 notitle, \ 43 | newhistogram lt 1, \ 44 | "" index 8 u ($2-$4) notitle, \ 45 | "" index 8 u 4 notitle, \ 46 | newhistogram lt 1, \ 47 | "" index 9 u ($2-$4) notitle, \ 48 | "" index 9 u 4 notitle, \ 49 | newhistogram lt 1, \ 50 | "" index 10 u ($2-$4) notitle, \ 51 | "" index 10 u 4 notitle, \ 52 | newhistogram lt 1, \ 53 | "" index 11 u ($2-$4) notitle, \ 54 | "" index 11 u 4 notitle, \ 55 | newhistogram lt 1, \ 56 | "" index 12 u ($2-$4) notitle, \ 57 | "" index 12 u 4 notitle, \ 58 | newhistogram lt 1, \ 59 | "" index 13 u ($2-$4) notitle, \ 60 | "" index 13 u 4 notitle, \ 61 | newhistogram lt 1, \ 62 | "" index 14 u ($2-$4) notitle, \ 63 | "" index 14 u 4 notitle, \ 64 | newhistogram lt 1, \ 65 | "" index 15 u ($2-$4) notitle, \ 66 | "" index 15 u 4 notitle 67 | -------------------------------------------------------------------------------- /scripts/gcbench_additional_allocation.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gcbench_additional_allocation.eps" 3 | set title "GCBench Benchmark - additional allocation" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:350] #plot starting from 0 6 | set key left 7 | set ylabel "Average execution time (s)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000):xtic(1) ti "GCBench generational", \ 13 | "benchmark_results/generational_additional_allocation_gcbench.csv" using ($2/1000):($3/1000) ti "GCBench generational (tagging+allocation)", \ 14 | "benchmark_results/copying_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "GCBench copying", \ 15 | "benchmark_results/copying_additional_allocation_gcbench.csv" using ($2/1000):($3/1000) ti "GCBench copying (tagging+allocation)", \ 16 | "benchmark_results/mark_sweep_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "GCBench mark-sweep", \ 17 | "benchmark_results/mark_sweep_additional_allocation_gcbench.csv" using ($2/1000):($3/1000) ti "GCBench mark-sweep (tagging+allocation)" 18 | -------------------------------------------------------------------------------- /scripts/gcbench_bad_cache_generational.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gcbench_bad_cache_generational.eps" 3 | set title "GCBench - caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:120] #plot starting from 0 6 | set ylabel "Average execution time (s)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000):xtic(1) ti "SOM++ generational (no cache)", \ 13 | "benchmark_results/generational_badcache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ generational (bad cache)", \ 14 | "benchmark_results/generational_cache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ generational (good cache)" 15 | -------------------------------------------------------------------------------- /scripts/gcbench_bad_cache_mark.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gcbench_bad_cache_mark.eps" 3 | set title "GCBench - caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:300] #plot starting from 0 6 | set ylabel "Average execution time (s)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/mark_sweep_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000):xtic(1) ti "SOM++ mark sweep (no cache)", \ 13 | "benchmark_results/mark_sweep_badcache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ mark sweep (bad cache)", \ 14 | "benchmark_results/mark_sweep_cache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ mark sweep (good cache)" 15 | -------------------------------------------------------------------------------- /scripts/gcbench_no_cache.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gcbench_no_cache.eps" 3 | set title "GCBench Benchmark" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set key left 7 | set ylabel "Average execution time (s)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000):xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_nocache_tagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ generational (tagging)", \ 14 | "benchmark_results/copying_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ copying", \ 15 | "benchmark_results/copying_nocache_tagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ copying (tagging)", \ 16 | "benchmark_results/mark_sweep_nocache_noTagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_nocache_tagging_gcbench.csv" using ($2/1000):($3/1000) ti "SOM++ mark-sweep (tagging)" 18 | -------------------------------------------------------------------------------- /scripts/gcbench_with_cache.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "gcbench_with_cache.eps" 3 | set title "GCBench with integer caching" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set ylabel "Average execution time (ms)" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | plot "benchmark_results/generational_cache_noTagging_gcbench.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 12 | "benchmark_results/generational_cache_tagging_gcbench.csv" using 2:3 ti "SOM++ generational (tagging)", \ 13 | "benchmark_results/copying_cache_noTagging_gcbench.csv" using 2:3 ti "SOM++ copying", \ 14 | "benchmark_results/copying_cache_tagging_gcbench.csv" using 2:3 ti "SOM++ copying (tagging)", \ 15 | "benchmark_results/mark_sweep_cache_noTagging_gcbench.csv" using 2:3 ti "SOM++ mark-sweep", \ 16 | "benchmark_results/mark_sweep_cache_tagging_gcbench.csv" using 2:3 ti "SOM++ mark-sweep (tagging)" 17 | -------------------------------------------------------------------------------- /scripts/generate_allocation_statistics.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from os import listdir 3 | from os import rename 4 | from subprocess import call 5 | import argparse 6 | import shutil 7 | 8 | OUT_DIR = "generated_images/" 9 | 10 | if __name__=="__main__": 11 | parser = argparse.ArgumentParser(description='Run Benchmarks for all SOM++ VMs') 12 | parser.add_argument("output_types", nargs="*", default = ["eps"]) 13 | args = parser.parse_args() 14 | 15 | files=[s for s in listdir("benchmark_results") if 16 | s.endswith("allocation_statistics.csv")] 17 | for csv_file in files: 18 | name = csv_file[:csv_file.find("_")] 19 | csv_file = "benchmark_results/"+csv_file 20 | 21 | #generate no plots 22 | out_file = "allocation_statistics_no_" + name + ".eps" 23 | command = "sed 's/bench_name/%s/g;s/csv_file/%s/g;s/out_file/%s/g' < scripts/allocation_statistics_no_template.gpl | gnuplot" % (name, csv_file.replace("/","\/"), out_file) 24 | print "Executing: %s" % command 25 | call(command, shell=True) 26 | eps_file = OUT_DIR + out_file 27 | shutil.move(out_file, eps_file) 28 | if "png" in args.output_types: 29 | png_file = eps_file.replace(".eps", ".png") 30 | call(["convert", "-density", "300", eps_file, png_file]) 31 | if "pdf" in args.output_types: 32 | print "epstopdf %s" % eps_file 33 | call(["epstopdf %s" % eps_file], shell=True) 34 | 35 | # also generate size plots 36 | out_file = "allocation_statistics_size_" + name + ".eps" 37 | command = "sed 's/bench_name/%s/g;s/csv_file/%s/g;s/out_file/%s/g' < scripts/allocation_statistics_size_template.gpl | gnuplot" % (name, csv_file.replace("/","\/"), out_file) 38 | print "Executing: %s" % command 39 | call(command, shell=True) 40 | eps_file = OUT_DIR + out_file 41 | shutil.move(out_file, eps_file) 42 | if "png" in args.output_types: 43 | png_file = eps_file.replace(".eps", ".png") 44 | call(["convert", "-density", "300", eps_file, png_file]) 45 | if "pdf" in args.output_types: 46 | print "epstopdf %s" % eps_file 47 | call(["epstopdf %s" % eps_file], shell=True) 48 | -------------------------------------------------------------------------------- /scripts/integer_histogram_gcbench.gp: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "integer_histogram_gcbench.eps" 4 | set title "Integer histogram for GCBench" font "Helvetica,26" 5 | set datafile separator "," #csv is comma separated 6 | set yrange [0:] #plot starting from 0 7 | set ylabel "Number of integers created" font "Helvetiva,20" 8 | set xlabel "Integer value" font "Helvetiva,20" 9 | set logscale x 10 | set logscale y 11 | set yrange [1:] 12 | plot "benchmark_results/GCBench_integer_histogram.csv" using ($1 < 1 ? 1/0 : $1):2 ti "positive" with points, \ 13 | "" using (-$1):2 ti "negative" with points 14 | -------------------------------------------------------------------------------- /scripts/integer_histogram_richards.gp: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "integer_histogram_richards.eps" 4 | set title "Integer histogram for Richards benchmark" font "Helvetica,26" 5 | set datafile separator "," #csv is comma separated 6 | set yrange [0:] #plot starting from 0 7 | set ylabel "Number of integers created" font "Helvetiva,20" 8 | set xlabel "Integer value" font "Helvetiva,20" 9 | set logscale x 10 | set logscale y 11 | set yrange [1:] 12 | plot "benchmark_results/RichardsBenchmarks_integer_histogram.csv" using ($1 < 1 ? 1/0 : $1):2 ti "positive" with points, \ 13 | "" using (-$1):2 ti "negative" with points 14 | -------------------------------------------------------------------------------- /scripts/integer_histogram_som.gp: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "integer_histogram_som.eps" 4 | set title "Integer histogram for SOM benchmarks" font "Helvetica,26" 5 | set datafile separator "," #csv is comma separated 6 | set yrange [0:] #plot starting from 0 7 | set ylabel "Number of integers created" font "Helvetiva,20" 8 | set xlabel "Integer value" font "Helvetiva,20" 9 | set logscale x 10 | set logscale y 11 | set yrange [1:] 12 | plot "benchmark_results/All_integer_histogram.csv" using ($1 < 1 ? 1/0 : $1):2 ti "positive" with points, \ 13 | "" using (-$1):2 ti "negative" with points 14 | -------------------------------------------------------------------------------- /scripts/receiver_types_gcbench.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "receiver_types_gcbench.eps" 3 | set title "Receiver types (GCBench Benchmark)" 4 | set xtics rotate by -90 #rotate labels 5 | set datafile separator "," #csv is comma separated 6 | set style fill solid 1.00 border 0 #fill bars 7 | set boxwidth 0.6 8 | set ylabel "Number of sends" 9 | #set logscale y 10 | plot "benchmark_results/GCBench_receivers.csv" using 2:xtic(1) ti "number of sends" with boxes 11 | -------------------------------------------------------------------------------- /scripts/receiver_types_richards.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "receiver_types_richards.eps" 3 | set title "Receiver types (Richards Benchmark)" 4 | set xtics rotate by -90 #rotate labels 5 | set datafile separator "," #csv is comma separated 6 | set style fill solid 1.00 border 0 #fill bars 7 | set boxwidth 0.6 8 | set ylabel "Number of sends" 9 | #set logscale y 10 | plot "benchmark_results/RichardsBenchmarks_receivers.csv" using 2:xtic(1) ti "number of sends" with boxes 11 | -------------------------------------------------------------------------------- /scripts/receiver_types_som.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "receiver_types_som.eps" 3 | set title "Receiver types (Fibonacci Benchmarks)" 4 | set xtics rotate by -90 #rotate labels 5 | set datafile separator "," #csv is comma separated 6 | set style fill solid 1.00 border 0 #fill bars 7 | set boxwidth 0.6 8 | set ylabel "Number of sends" 9 | #set logscale y 10 | plot "benchmark_results/Fibonacci_receivers.csv" using 2:xtic(1) ti "number of sends" with boxes 11 | -------------------------------------------------------------------------------- /scripts/richards_benchmark_additional_allocation.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "richards_benchmark_additional_allocation.eps" 3 | set title "Richards Benchmark - additional allocation" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:5000] #plot starting from 0 6 | set ylabel "Average execution time (ms)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_richards.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_additional_allocation_richards.csv" using 2:3 ti "SOM++ generational (tagging+allocation)", \ 14 | "benchmark_results/copying_nocache_noTagging_richards.csv" using 2:3 ti "SOM++ copying", \ 15 | "benchmark_results/copying_additional_allocation_richards.csv" using 2:3 ti "SOM++ copying (tagging+allocation)", \ 16 | "benchmark_results/mark_sweep_nocache_noTagging_richards.csv" using 2:3 ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_additional_allocation_richards.csv" using 2:3 ti "SOM++ mark-sweep (tagging+allocation)" 18 | -------------------------------------------------------------------------------- /scripts/richards_benchmark_bad_cache_generational.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "richards_benchmark_bad_cache_generational.eps" 3 | set title "Richards - caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:2700] #plot starting from 0 6 | set ylabel "Average execution time (ms)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_richards.csv" using 2:3:xtic(1) ti "SOM++ generational (no cache)", \ 13 | "benchmark_results/generational_badcache_noTagging_richards.csv" using 2:3 ti "SOM++ generational (bad cache)", \ 14 | "benchmark_results/generational_cache_noTagging_richards.csv" using 2:3 ti "SOM++ generational (good cache)" 15 | -------------------------------------------------------------------------------- /scripts/richards_benchmark_bad_cache_mark.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "richards_benchmark_bad_cache_mark.eps" 3 | set title "Richards - caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:4500] #plot starting from 0 6 | set ylabel "Average execution time (ms)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/mark_sweep_nocache_noTagging_richards.csv" using 2:3:xtic(1) ti "SOM++ mark sweep (no cache)", \ 13 | "benchmark_results/mark_sweep_badcache_noTagging_richards.csv" using 2:3 ti "SOM++ mark sweep (bad cache)", \ 14 | "benchmark_results/mark_sweep_cache_noTagging_richards.csv" using 2:3 ti "SOM++ mark sweep (good cache)" 15 | -------------------------------------------------------------------------------- /scripts/richards_benchmark_no_cache.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "richards_benchmark_no_cache.eps" 3 | set title "Richards Benchmark" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:5000] #plot starting from 0 6 | set ylabel "Average execution time (ms)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_richards.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_nocache_tagging_richards.csv" using 2:3 ti "SOM++ generational (tagging)", \ 14 | "benchmark_results/copying_nocache_noTagging_richards.csv" using 2:3 ti "SOM++ copying", \ 15 | "benchmark_results/copying_nocache_tagging_richards.csv" using 2:3 ti "SOM++ copying (tagging)", \ 16 | "benchmark_results/mark_sweep_nocache_noTagging_richards.csv" using 2:3 ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_nocache_tagging_richards.csv" using 2:3 ti "SOM++ mark-sweep (tagging)" 18 | -------------------------------------------------------------------------------- /scripts/richards_benchmark_with_cache.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "richards_benchmark_with_cache.eps" 3 | set title "Richards Benchmark with integer caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set ylabel "Average execution time (ms)" font "Helvetica,20" 7 | set style data histograms #plot histogram style 8 | set style fill solid 1.00 border 0 #fill bars 9 | set style histogram errorbars gap 2 lw 1 10 | set key left 11 | set grid ytics 12 | plot "benchmark_results/generational_cache_noTagging_richards.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_cache_tagging_richards.csv" using 2:3 ti "SOM++ generational (tagging)", \ 14 | "benchmark_results/copying_cache_noTagging_richards.csv" using 2:3 ti "SOM++ copying", \ 15 | "benchmark_results/copying_cache_tagging_richards.csv" using 2:3 ti "SOM++ copying (tagging)", \ 16 | "benchmark_results/mark_sweep_cache_noTagging_richards.csv" using 2:3 ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_cache_tagging_richards.csv" using 2:3 ti "SOM++ mark-sweep (tagging)" 18 | -------------------------------------------------------------------------------- /scripts/send_types_gcbench.gp: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "send_types_gcbench.eps" 4 | set title "Types of sends for GCBench" font "Helvetica,26" 5 | set xtics rotate by -45 #rotate labels 6 | set datafile separator "," #csv is comma separated 7 | set style fill solid 1.00 border 0 8 | set grid ytics 9 | set boxwidth 0.6 10 | set ylabel "Number of sends" font "Helvetiva,20" 11 | plot "benchmark_results/GCBench_send_types.csv" using ($3+$4):xtic(1) ti "primitive" with boxes, \ 12 | "" using 4:xtic(1) ti "non primitive" with boxes 13 | -------------------------------------------------------------------------------- /scripts/send_types_richards.gp: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "send_types_richards.eps" 4 | set title "Types of sends for Richards Benchmark" font "Helvetica,26" 5 | set xtics rotate by -45 #rotate labels 6 | set datafile separator "," #csv is comma separated 7 | set style fill solid 1.00 border 0 8 | set grid ytics 9 | set boxwidth 0.6 10 | set ylabel "Number of sends" font "Helvetiva,20" 11 | plot "benchmark_results/RichardsBenchmarks_send_types.csv" using ($3+$4):xtic(1) ti "primitive" with boxes, \ 12 | "" using 4:xtic(1) ti "non primitive" with boxes 13 | -------------------------------------------------------------------------------- /scripts/send_types_som.gp: -------------------------------------------------------------------------------- 1 | reset 2 | set terminal postscript enhanced eps solid color 3 | set output "send_types_som.eps" 4 | set title "Types of sends for IntegerLoop" font "Helvetica,26" 5 | set xtics rotate by -45 #rotate labels 6 | set datafile separator "," #csv is comma separated 7 | set style fill solid 1.00 border 0 8 | set grid ytics 9 | set boxwidth 0.6 10 | set ylabel "Number of sends" font "Helvetiva,20" 11 | plot "benchmark_results/IntegerLoop_send_types.csv" using ($3+$4):xtic(1) ti "primitive" with boxes, \ 12 | "" using 4:xtic(1) ti "non primitive" with boxes 13 | -------------------------------------------------------------------------------- /scripts/som_benchmarks_additional_allocation.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "som_benchmarks_additional_allocation.eps" 3 | set title "SOM Benchmarks - additional allocation" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set xtics rotate by -45 #rotate labels 7 | set ylabel "Average execution time (ms)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_som.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_additional_allocation_som.csv" using 2:3 ti "SOM++ generational (tagging+allocation)", \ 14 | "benchmark_results/copying_nocache_noTagging_som.csv" using 2:3 ti "SOM++ copying", \ 15 | "benchmark_results/copying_additional_allocation_som.csv" using 2:3 ti "SOM++ copying (tagging+allocation)", \ 16 | "benchmark_results/mark_sweep_nocache_noTagging_som.csv" using 2:3 ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_additional_allocation_som.csv" using 2:3 ti "SOM++ mark-sweep (tagging+allocation)" 18 | -------------------------------------------------------------------------------- /scripts/som_benchmarks_bad_cache_generational.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "som_benchmarks_bad_cache_generational.eps" 3 | set title "SOM Benchmarks - caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set xtics rotate by -45 #rotate labels 7 | set ylabel "Average execution time (ms)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set key right 12 | set grid ytics 13 | plot "benchmark_results/generational_nocache_noTagging_som.csv" using 2:3:xtic(1) ti "SOM++ generational (no cache)", \ 14 | "benchmark_results/generational_badcache_noTagging_som.csv" using 2:3 ti "SOM++ generational (bad cache)", \ 15 | "benchmark_results/generational_cache_noTagging_som.csv" using 2:3 ti "SOM++ generational (good cache)" 16 | -------------------------------------------------------------------------------- /scripts/som_benchmarks_bad_cache_mark.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "som_benchmarks_bad_cache_mark.eps" 3 | set title "SOM Benchmarks - caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set xtics rotate by -45 #rotate labels 7 | set ylabel "Average execution time (ms)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set key right 12 | set grid ytics 13 | plot "benchmark_results/mark_sweep_nocache_noTagging_som.csv" using 2:3:xtic(1) ti "SOM++ mark-sweep (no cache)", \ 14 | "benchmark_results/mark_sweep_badcache_noTagging_som.csv" using 2:3 ti "SOM++ mark-sweep (bad cache)", \ 15 | "benchmark_results/mark_sweep_cache_noTagging_som.csv" using 2:3 ti "SOM++ mark-sweep (good cache)" 16 | -------------------------------------------------------------------------------- /scripts/som_benchmarks_no_cache.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "som_benchmarks_no_cache.eps" 3 | set title "SOM Benchmarks" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set xtics rotate by -45 #rotate labels 7 | set ylabel "Average execution time (ms)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set grid ytics 12 | plot "benchmark_results/generational_nocache_noTagging_som.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_nocache_tagging_som.csv" using 2:3 ti "SOM++ generational (tagging)", \ 14 | "benchmark_results/copying_nocache_noTagging_som.csv" using 2:3 ti "SOM++ copying", \ 15 | "benchmark_results/copying_nocache_tagging_som.csv" using 2:3 ti "SOM++ copying (tagging)", \ 16 | "benchmark_results/mark_sweep_nocache_noTagging_som.csv" using 2:3 ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_nocache_tagging_som.csv" using 2:3 ti "SOM++ mark-sweep (tagging)" 18 | -------------------------------------------------------------------------------- /scripts/som_benchmarks_with_cache.gp: -------------------------------------------------------------------------------- 1 | set terminal postscript eps enhanced solid color 2 | set output "som_benchmarks_with_cache.eps" 3 | set title "SOM Benchmarks with integer caching" font "Helvetica,26" 4 | set datafile separator "," #csv is comma separated 5 | set yrange [0:] #plot starting from 0 6 | set xtics rotate by -45 #rotate labels 7 | set ylabel "Average execution time (ms)" font "Helvetica,20" 8 | set style data histograms #plot histogram style 9 | set style fill solid 1.00 border 0 #fill bars 10 | set style histogram errorbars gap 2 lw 1 11 | set grid ytics 12 | plot "benchmark_results/generational_cache_noTagging_som.csv" using 2:3:xtic(1) ti "SOM++ generational", \ 13 | "benchmark_results/generational_cache_tagging_som.csv" using 2:3 ti "SOM++ generational (tagging)", \ 14 | "benchmark_results/copying_cache_noTagging_som.csv" using 2:3 ti "SOM++ copying", \ 15 | "benchmark_results/copying_cache_tagging_som.csv" using 2:3 ti "SOM++ copying (tagging)", \ 16 | "benchmark_results/mark_sweep_cache_noTagging_som.csv" using 2:3 ti "SOM++ mark-sweep", \ 17 | "benchmark_results/mark_sweep_cache_tagging_som.csv" using 2:3 ti "SOM++ mark-sweep (tagging)" 18 | -------------------------------------------------------------------------------- /som.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pushd `dirname $0` > /dev/null 3 | SCRIPT_PATH=`pwd` 4 | popd > /dev/null 5 | 6 | if [ "`uname`" = "Linux" ] 7 | then 8 | export LD_LIBRARY_PATH=${SCRIPT_PATH}/ 9 | fi 10 | ${SCRIPT_PATH}/SOM++ "$@" 11 | -------------------------------------------------------------------------------- /src/compiler/Disassembler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../vmobjects/VMClass.h" 30 | #include "../vmobjects/VMFrame.h" 31 | #include "../vmobjects/VMMethod.h" 32 | #include "MethodGenerationContext.h" 33 | 34 | class Disassembler { 35 | public: 36 | static void Dump(VMClass* cl); 37 | static void DumpMethod(VMMethod* method, const char* indent, 38 | bool printObjects = true); 39 | static void DumpMethod(MethodGenerationContext* mgenc, const char* indent); 40 | static void extracted(uint8_t bc1, uint8_t bc2, VMClass* cl, 41 | VMFrame* frame); 42 | 43 | static void DumpBytecode(VMFrame* frame, VMMethod* method, size_t bc_idx); 44 | 45 | private: 46 | static void dispatch(vm_oop_t o); 47 | 48 | static void dumpMethod(uint8_t* bytecodes, size_t numberOfBytecodes, 49 | const char* indent, VMMethod* method, 50 | bool printObjects); 51 | 52 | static void printArgument(uint8_t idx, uint8_t ctx, VMClass* cl, 53 | VMFrame* frame); 54 | static void printPopLocal(uint8_t idx, uint8_t ctx, VMFrame* frame); 55 | static void printNth(uint8_t idx, VMFrame* frame, const char* op); 56 | }; 57 | -------------------------------------------------------------------------------- /src/compiler/LexicalScope.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../vmobjects/ObjectFormats.h" 6 | #include "Variable.h" 7 | 8 | class LexicalScope { 9 | friend class MethodGenerationContext; 10 | 11 | public: 12 | LexicalScope(LexicalScope* outer, vector arguments, 13 | vector locals) 14 | : outer(outer), arguments(std::move(arguments)), 15 | locals(std::move(locals)) {} 16 | 17 | [[nodiscard]] inline uint8_t GetNumberOfArguments() const { 18 | return arguments.size(); 19 | } 20 | 21 | [[nodiscard]] inline size_t GetNumberOfLocals() const { 22 | return locals.size(); 23 | } 24 | 25 | void AddInlinedLocal(Variable& var) { 26 | assert(var.GetIndex() == locals.size()); 27 | locals.push_back(var); 28 | } 29 | 30 | const Variable* GetArgument(size_t index, size_t contextLevel) { 31 | if (contextLevel > 0) { 32 | return outer->GetArgument(index, contextLevel - 1); 33 | } 34 | 35 | return &arguments.at(index); 36 | } 37 | 38 | const Variable* GetLocal(size_t index, uint8_t ctxLevel) { 39 | if (ctxLevel > 0) { 40 | return outer->GetLocal(index, ctxLevel - 1); 41 | } 42 | return &locals.at(index); 43 | } 44 | 45 | /** 46 | * This removes the inlined scope from the chain. 47 | * Removal is done exactly once, after all embedded blocks 48 | * were adapted. 49 | */ 50 | void DropInlinedScope() { 51 | assert(outer != nullptr); 52 | assert(outer->outer != nullptr); 53 | 54 | LexicalScope* newOuter = outer->outer; 55 | outer = newOuter; 56 | } 57 | 58 | private: 59 | LexicalScope* outer; 60 | vector arguments; 61 | vector locals; 62 | }; 63 | -------------------------------------------------------------------------------- /src/compiler/SourceCoordinate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SourceCoordinate { 4 | public: 5 | SourceCoordinate(size_t line, size_t column) : line(line), column(column) {} 6 | SourceCoordinate() : line(0), column(0) {} 7 | 8 | [[nodiscard]] inline size_t GetLine() const { return line; } 9 | [[nodiscard]] inline size_t GetColumn() const { return column; } 10 | 11 | inline bool operator==(const SourceCoordinate& other) const { 12 | return line == other.line && column == other.column; 13 | } 14 | 15 | private: 16 | /* 1-based */ 17 | size_t line; 18 | 19 | /* 1-based */ 20 | size_t column; 21 | }; 22 | -------------------------------------------------------------------------------- /src/compiler/SourcecodeCompiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../misc/defs.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | #include "Parser.h" 32 | 33 | class SourcecodeCompiler { 34 | public: 35 | static VMClass* CompileClass(const std::string& path, 36 | const std::string& file, VMClass* systemClass); 37 | static VMClass* CompileClassString(const std::string& stream, 38 | VMClass* systemClass); 39 | 40 | private: 41 | static void showCompilationError(const std::string& filename, 42 | const char* message); 43 | static VMClass* compile(Parser& parser, VMClass* systemClass); 44 | }; 45 | -------------------------------------------------------------------------------- /src/compiler/Variable.cpp: -------------------------------------------------------------------------------- 1 | #include "Variable.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../vm/Print.h" 9 | #include "../vm/Symbols.h" 10 | #include "SourceCoordinate.h" 11 | 12 | std::string Variable::MakeQualifiedName() const { 13 | char qualified[100]; 14 | assert(name.size() < 80); 15 | 16 | if (snprintf(qualified, 100, "%.*s:%zu:%zu", (int)name.size(), name.data(), 17 | coord.GetLine(), coord.GetColumn()) < 0) { 18 | ErrorExit("failed to MakeQualifiedName"); 19 | } 20 | 21 | return {qualified}; 22 | } 23 | 24 | Variable Variable::CopyForInlining(size_t newIndex) const { 25 | if (isArgument) { 26 | if (name == strBlockSelf) { 27 | // that's invalid 28 | return {}; 29 | } 30 | } 31 | // arguments that are inlined need to turn into variables, too 32 | return {this, newIndex, false}; 33 | } 34 | -------------------------------------------------------------------------------- /src/compiler/Variable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../vmobjects/ObjectFormats.h" 6 | #include "../vmobjects/VMSymbol.h" 7 | #include "SourceCoordinate.h" 8 | 9 | class Variable { 10 | public: 11 | Variable(std::string& name, size_t index, bool isArgument, 12 | SourceCoordinate coord) 13 | : name(name), index(index), isArgument(isArgument), coord(coord) { 14 | assert(index != 0xff); 15 | } 16 | 17 | Variable() : name({}), index(0xff), isArgument(false) {} 18 | 19 | Variable(const Variable* old, size_t newIndex, bool isArgument) 20 | : name(old->name), index(newIndex), isArgument(isArgument), 21 | coord(old->coord) {} 22 | 23 | bool IsNamed(std::string& n) const { return name == n; } 24 | 25 | [[nodiscard]] bool IsSame(const Variable& other) const { 26 | return coord == other.coord; 27 | } 28 | 29 | [[nodiscard]] bool IsValid() const { return index != 0xff; } 30 | 31 | [[nodiscard]] inline uint8_t GetIndex() const { return index; } 32 | 33 | [[nodiscard]] const std::string* GetName() const { return &name; } 34 | 35 | [[nodiscard]] std::string MakeQualifiedName() const; 36 | 37 | [[nodiscard]] Variable CopyForInlining(size_t newIndex) const; 38 | 39 | [[nodiscard]] bool IsArgument() const { return isArgument; } 40 | 41 | protected: 42 | std::string name; 43 | uint8_t index; 44 | bool isArgument; 45 | SourceCoordinate coord; 46 | }; 47 | -------------------------------------------------------------------------------- /src/memory/CopyingCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GarbageCollector.h" 4 | 5 | class CopyingHeap; 6 | 7 | class CopyingCollector : public GarbageCollector { 8 | public: 9 | explicit CopyingCollector(CopyingHeap* h) : GarbageCollector(h) {}; 10 | 11 | private: 12 | void Collect() override; 13 | }; 14 | -------------------------------------------------------------------------------- /src/memory/CopyingHeap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Heap.h" 6 | 7 | class CopyingHeap : public Heap { 8 | friend class CopyingCollector; 9 | 10 | public: 11 | explicit CopyingHeap(size_t objectSpaceSize); 12 | AbstractVMObject* AllocateObject(size_t size); 13 | 14 | bool IsInCurrentBuffer(AbstractVMObject* obj); 15 | bool IsInOldBufferAndOldBufferIsValid(AbstractVMObject* obj); 16 | 17 | private: 18 | void switchBuffers(bool increaseMemory); 19 | void invalidateOldBuffer(); 20 | 21 | void* currentBuffer; 22 | void* collectionLimit; 23 | void* currentBufferEnd; 24 | 25 | void* oldBuffer; 26 | void* oldBufferEnd; 27 | 28 | void* nextFreePosition; 29 | bool oldBufferIsValid{false}; 30 | }; 31 | -------------------------------------------------------------------------------- /src/memory/DebugCopyingCollector.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "DebugCopyingCollector.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../memory/Heap.h" 9 | #include "../misc/Timer.h" 10 | #include "../misc/debug.h" 11 | #include "../misc/defs.h" 12 | #include "../vm/IsValidObject.h" 13 | #include "../vm/Universe.h" 14 | #include "../vmobjects/ObjectFormats.h" 15 | #include "DebugCopyingHeap.h" 16 | 17 | static gc_oop_t copy_if_necessary(gc_oop_t oop) { 18 | // don't process tagged objects 19 | if (IS_TAGGED(oop)) { 20 | return oop; 21 | } 22 | 23 | AbstractVMObject* obj = AS_OBJ(oop); 24 | assert(IsValidObject(obj)); 25 | 26 | size_t const gcField = obj->GetGCField(); 27 | // GCField is used as forwarding pointer here 28 | // if someone has moved before, return the moved object 29 | if (gcField != 0) { 30 | return (gc_oop_t)gcField; 31 | } 32 | 33 | assert(GetHeap()->IsInOldBufferAndOldBufferIsValid(obj)); 34 | assert(!obj->IsMarkedInvalid()); 35 | 36 | // we have to clone ourselves 37 | AbstractVMObject* newObj = obj->CloneForMovingGC(); 38 | 39 | assert(GetHeap()->IsInCurrentBuffer(newObj)); 40 | 41 | if (DEBUG) { 42 | obj->MarkObjectAsInvalid(); 43 | } 44 | 45 | obj->SetGCField((uintptr_t)newObj); 46 | return tmp_ptr(newObj); 47 | } 48 | 49 | void DebugCopyingCollector::Collect() { 50 | DebugLog("DebugCopyGC Collect\n"); 51 | 52 | // we assume the old heap is empty, because we want to switch to it 53 | assert(heap->oldHeap.empty()); 54 | 55 | Timer::GCTimer.Resume(); 56 | // reset collection trigger 57 | heap->resetGCTrigger(); 58 | 59 | static bool increaseMemory; 60 | heap->switchBuffers(increaseMemory); 61 | increaseMemory = false; 62 | 63 | Universe::WalkGlobals(copy_if_necessary); 64 | 65 | // now copy all objects that are referenced by the objects we have moved so 66 | // far 67 | for (size_t i = 0; i < heap->currentHeap.size(); i += 1) { 68 | heap->currentHeap.at(i)->WalkObjects(copy_if_necessary); 69 | } 70 | 71 | heap->invalidateOldBuffer(); 72 | 73 | // if semispace is still 50% full after collection, we have to realloc 74 | // bigger ones -> done in next collection 75 | size_t const freeSpace = heap->currentHeapSize - heap->currentHeapUsage; 76 | if (heap->currentHeapUsage > freeSpace) { 77 | increaseMemory = true; 78 | } 79 | 80 | Timer::GCTimer.Halt(); 81 | } 82 | -------------------------------------------------------------------------------- /src/memory/DebugCopyingCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GarbageCollector.h" 4 | 5 | class DebugCopyingHeap; 6 | 7 | class DebugCopyingCollector : public GarbageCollector { 8 | public: 9 | explicit DebugCopyingCollector(DebugCopyingHeap* h) 10 | : GarbageCollector(h) {}; 11 | 12 | private: 13 | void Collect() override; 14 | }; 15 | -------------------------------------------------------------------------------- /src/memory/DebugCopyingHeap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "DebugCopyingCollector.h" 6 | #include "Heap.h" 7 | 8 | class DebugCopyingHeap : public Heap { 9 | friend class DebugCopyingCollector; 10 | 11 | public: 12 | explicit DebugCopyingHeap(size_t objectSpaceSize) 13 | : Heap(new DebugCopyingCollector(this)), 14 | currentHeapSize(objectSpaceSize), 15 | collectionLimit((size_t)((double)objectSpaceSize * 0.9)) {} 16 | 17 | AbstractVMObject* AllocateObject(size_t size); 18 | 19 | bool IsInCurrentBuffer(AbstractVMObject* obj); 20 | bool IsInOldBufferAndOldBufferIsValid(AbstractVMObject* obj); 21 | 22 | private: 23 | void switchBuffers(bool increaseMemory); 24 | void invalidateOldBuffer(); 25 | 26 | vector currentHeap; 27 | size_t currentHeapSize; 28 | size_t currentHeapUsage{0}; 29 | size_t collectionLimit; 30 | 31 | vector oldHeap; 32 | size_t oldHeapSize{0}; 33 | 34 | bool oldHeapIsValid{false}; 35 | }; 36 | -------------------------------------------------------------------------------- /src/memory/GarbageCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../misc/defs.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | template 33 | class GarbageCollector { 34 | public: 35 | explicit GarbageCollector(HEAP_T* h) : heap(h) {} 36 | virtual ~GarbageCollector() = default; 37 | virtual void Collect() = 0; 38 | void PrintGCStat() const; 39 | void PrintCollectStat() const; 40 | 41 | protected: 42 | HEAP_T* const heap; 43 | }; 44 | -------------------------------------------------------------------------------- /src/memory/GenerationalCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../misc/defs.h" 4 | #include "GarbageCollector.h" 5 | 6 | class GenerationalHeap; 7 | class GenerationalCollector : public GarbageCollector { 8 | public: 9 | explicit GenerationalCollector(GenerationalHeap* heap); 10 | void Collect() override; 11 | 12 | private: 13 | uintptr_t majorCollectionThreshold; 14 | size_t matureObjectsSize{0}; 15 | void MajorCollection(); 16 | void MinorCollection(); 17 | }; 18 | -------------------------------------------------------------------------------- /src/memory/GenerationalHeap.cpp: -------------------------------------------------------------------------------- 1 | #include "GenerationalHeap.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../vm/Print.h" 9 | #include "../vmobjects/AbstractObject.h" 10 | #include "../vmobjects/ObjectFormats.h" 11 | #include "../vmobjects/VMObjectBase.h" 12 | #include "GenerationalCollector.h" 13 | #include "Heap.h" 14 | 15 | using namespace std; 16 | 17 | GenerationalHeap::GenerationalHeap(size_t objectSpaceSize) 18 | : Heap(new GenerationalCollector(this)), 19 | nursery(malloc(objectSpaceSize)), 20 | nursery_end((size_t)nursery + objectSpaceSize), 21 | nurserySize(objectSpaceSize), maxNurseryObjSize(objectSpaceSize / 2), 22 | nextFreePosition(nursery), 23 | 24 | // our initial collection limit is 90% of objectSpaceSize 25 | collectionLimit((void*)((size_t)nursery + 26 | ((size_t)((double)objectSpaceSize * 0.9)))) { 27 | memset(nursery, 0x0, objectSpaceSize); 28 | } 29 | 30 | AbstractVMObject* GenerationalHeap::AllocateNurseryObject(size_t size) { 31 | auto* newObject = (AbstractVMObject*)nextFreePosition; 32 | nextFreePosition = (void*)((size_t)nextFreePosition + size); 33 | if ((size_t)nextFreePosition > nursery_end) { 34 | ErrorPrint("\nFailed to allocate " + to_string(size) + 35 | " Bytes in nursery.\n"); 36 | Quit(-1); 37 | } 38 | // let's see if we have to trigger the GC 39 | if (nextFreePosition > collectionLimit) { 40 | requestGC(); 41 | } 42 | return newObject; 43 | } 44 | 45 | AbstractVMObject* GenerationalHeap::AllocateMatureObject(size_t size) { 46 | auto* newObject = (AbstractVMObject*)malloc(size); 47 | if (newObject == nullptr) { 48 | ErrorPrint("\nFailed to allocate " + to_string(size) + " Bytes.\n"); 49 | Quit(-1); 50 | } 51 | allocatedObjects.push_back(newObject); 52 | matureObjectsSize += size; 53 | return newObject; 54 | } 55 | 56 | void GenerationalHeap::writeBarrier_OldHolder(VMObjectBase* holder, 57 | vm_oop_t referencedObject) { 58 | if (isObjectInNursery(referencedObject)) { 59 | oldObjsWithRefToYoungObjs.push_back((size_t)holder); 60 | holder->SetGCField(holder->GetGCField() | MASK_SEEN_BY_WRITE_BARRIER); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/memory/GenerationalHeap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../misc/defs.h" 6 | #include "../vm/IsValidObject.h" 7 | #include "../vmobjects/VMObjectBase.h" 8 | #include "Heap.h" 9 | 10 | #ifdef UNITTESTS 11 | struct VMObjectCompare { 12 | bool operator()(pair lhs, pair rhs) 13 | const { 14 | return (size_t)lhs.first < (size_t)rhs.first && 15 | (size_t)lhs.second < (size_t)rhs.second; 16 | } 17 | }; 18 | #endif 19 | 20 | class GenerationalHeap : public Heap { 21 | friend class GenerationalCollector; 22 | 23 | public: 24 | explicit GenerationalHeap(size_t objectSpaceSize = 1048576); 25 | AbstractVMObject* AllocateNurseryObject(size_t size); 26 | AbstractVMObject* AllocateMatureObject(size_t size); 27 | [[nodiscard]] size_t GetMaxNurseryObjectSize() const; 28 | void writeBarrier(VMObjectBase* holder, vm_oop_t referencedObject); 29 | inline bool isObjectInNursery(vm_oop_t obj); 30 | #ifdef UNITTESTS 31 | std::set, VMObjectCompare> writeBarrierCalledOn; 32 | #endif 33 | private: 34 | void* nursery; 35 | size_t nursery_end; 36 | size_t nurserySize; 37 | size_t maxNurseryObjSize; 38 | size_t matureObjectsSize{0}; 39 | void* nextFreePosition; 40 | void writeBarrier_OldHolder(VMObjectBase* holder, 41 | vm_oop_t referencedObject); 42 | void* collectionLimit; 43 | vector oldObjsWithRefToYoungObjs; 44 | vector allocatedObjects; 45 | }; 46 | 47 | inline bool GenerationalHeap::isObjectInNursery(vm_oop_t obj) { 48 | assert(IsValidObject(obj)); 49 | 50 | return (size_t)obj >= (size_t)nursery && (size_t)obj < nursery_end; 51 | } 52 | 53 | inline size_t GenerationalHeap::GetMaxNurseryObjectSize() const { 54 | return maxNurseryObjSize; 55 | } 56 | 57 | inline void GenerationalHeap::writeBarrier(VMObjectBase* holder, 58 | vm_oop_t referencedObject) { 59 | #ifdef UNITTESTS 60 | writeBarrierCalledOn.insert(make_pair(holder, referencedObject)); 61 | #endif 62 | 63 | assert(IsValidObject(referencedObject)); 64 | assert(IsValidObject(holder)); 65 | 66 | const size_t gcfield = *(((size_t*)holder) + 1); 67 | if ((gcfield & 6U /* MASK_OBJECT_IS_OLD + MASK_SEEN_BY_WRITE_BARRIER */) == 68 | 2U /* MASK_OBJECT_IS_OLD */) { 69 | writeBarrier_OldHolder(holder, referencedObject); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/memory/MarkSweepCollector.cpp: -------------------------------------------------------------------------------- 1 | #include "MarkSweepCollector.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "../memory/Heap.h" 7 | #include "../vm/Universe.h" 8 | #include "../vmobjects/AbstractObject.h" 9 | #include "../vmobjects/IntegerBox.h" 10 | #include "../vmobjects/ObjectFormats.h" 11 | #include "../vmobjects/VMFrame.h" 12 | #include "MarkSweepHeap.h" 13 | 14 | #define GC_MARKED 3456 15 | 16 | void MarkSweepCollector::Collect() { 17 | auto* heap = GetHeap(); 18 | Timer::GCTimer.Resume(); 19 | // reset collection trigger 20 | heap->resetGCTrigger(); 21 | 22 | // now mark all reachables 23 | markReachableObjects(); 24 | 25 | // in this survivors stack we will remember all objects that survived 26 | auto* survivors = new vector(); 27 | size_t survivorsSize = 0; 28 | 29 | vector::iterator iter; 30 | for (iter = heap->allocatedObjects->begin(); 31 | iter != heap->allocatedObjects->end(); 32 | iter++) { 33 | if ((*iter)->GetGCField() == GC_MARKED) { 34 | // object ist marked -> let it survive 35 | survivors->push_back(*iter); 36 | survivorsSize += (*iter)->GetObjectSize(); 37 | (*iter)->SetGCField(0); 38 | } else { 39 | // not marked -> kill it 40 | heap->FreeObject(*iter); 41 | } 42 | } 43 | 44 | delete heap->allocatedObjects; 45 | heap->allocatedObjects = survivors; 46 | 47 | heap->spcAlloc = survivorsSize; 48 | // TODO(smarr): Maybe choose another constant to calculate new 49 | // collectionLimit here 50 | heap->collectionLimit = 2 * survivorsSize; 51 | Timer::GCTimer.Halt(); 52 | } 53 | 54 | static gc_oop_t mark_object(gc_oop_t oop) { 55 | if (IS_TAGGED(oop)) { 56 | return oop; 57 | } 58 | 59 | AbstractVMObject* obj = AS_OBJ(oop); 60 | 61 | if (obj->GetGCField() != 0) { 62 | return oop; 63 | } 64 | 65 | obj->SetGCField(GC_MARKED); 66 | obj->WalkObjects(mark_object); 67 | return oop; 68 | } 69 | 70 | void MarkSweepCollector::markReachableObjects() { 71 | // This walks the globals of the universe, and the interpreter 72 | Universe::WalkGlobals(mark_object); 73 | } 74 | -------------------------------------------------------------------------------- /src/memory/MarkSweepCollector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../misc/defs.h" 4 | #include "GarbageCollector.h" 5 | 6 | class MarkSweepHeap; 7 | class MarkSweepCollector : public GarbageCollector { 8 | public: 9 | explicit MarkSweepCollector(MarkSweepHeap* heap) : GarbageCollector(heap) {} 10 | void Collect() override; 11 | 12 | private: 13 | static void markReachableObjects(); 14 | }; 15 | -------------------------------------------------------------------------------- /src/memory/MarkSweepHeap.cpp: -------------------------------------------------------------------------------- 1 | #include "MarkSweepHeap.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../memory/Heap.h" 9 | #include "../vm/Print.h" 10 | #include "../vmobjects/AbstractObject.h" 11 | #include "MarkSweepCollector.h" 12 | 13 | MarkSweepHeap::MarkSweepHeap(size_t objectSpaceSize) 14 | : Heap(new MarkSweepCollector(this)), 15 | allocatedObjects(new vector()), 16 | // our initial collection limit is 90% of objectSpaceSize 17 | collectionLimit((size_t)((double)objectSpaceSize * 0.9)) {} 18 | 19 | AbstractVMObject* MarkSweepHeap::AllocateObject(size_t size) { 20 | auto* newObject = (AbstractVMObject*)malloc(size); 21 | if (newObject == nullptr) { 22 | ErrorPrint("\nFailed to allocate " + to_string(size) + " Bytes.\n"); 23 | Quit(-1); 24 | } 25 | spcAlloc += size; 26 | memset((void*)newObject, 0, size); 27 | // AbstractObjects (Integer,...) have no Size field anymore -> set within 28 | // VMObject's new operator 29 | allocatedObjects->push_back(newObject); 30 | // let's see if we have to trigger the GC 31 | if (spcAlloc >= collectionLimit) { 32 | requestGC(); 33 | } 34 | return newObject; 35 | } 36 | -------------------------------------------------------------------------------- /src/memory/MarkSweepHeap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../misc/defs.h" 4 | #include "Heap.h" 5 | 6 | class MarkSweepHeap : public Heap { 7 | friend class MarkSweepCollector; 8 | 9 | public: 10 | explicit MarkSweepHeap(size_t objectSpaceSize = 1048576); 11 | AbstractVMObject* AllocateObject(size_t size); 12 | 13 | private: 14 | vector* allocatedObjects; 15 | size_t spcAlloc{0}; 16 | size_t collectionLimit; 17 | }; 18 | -------------------------------------------------------------------------------- /src/misc/ParseInteger.cpp: -------------------------------------------------------------------------------- 1 | #include "ParseInteger.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../vm/Universe.h" // NOLINT(misc-include-cleaner) 9 | #include "../vmobjects/ObjectFormats.h" 10 | 11 | vm_oop_t ParseInteger(const char* str, int base, bool negateValue) { 12 | errno = 0; 13 | 14 | char* pEnd{}; 15 | 16 | const int64_t i = std::strtoll(str, &pEnd, base); 17 | 18 | if (str == pEnd) { 19 | // did not parse anything 20 | return NEW_INT(0); 21 | } 22 | 23 | const bool rangeError = errno == ERANGE; 24 | if (rangeError) { 25 | // TODO(smarr): try a big int library 26 | return NEW_INT(0); 27 | } 28 | 29 | // the normal case 30 | if (negateValue) { 31 | return NEW_INT(-i); 32 | } 33 | return NEW_INT(i); 34 | } 35 | 36 | vm_oop_t ParseInteger(std::string& str, int base, bool negateValue) { 37 | return ParseInteger(str.c_str(), base, negateValue); 38 | } 39 | -------------------------------------------------------------------------------- /src/misc/ParseInteger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../vmobjects/ObjectFormats.h" 6 | #include "defs.h" 7 | 8 | vm_oop_t ParseInteger(const char* str, int base, bool negateValue); 9 | vm_oop_t ParseInteger(std::string& str, int base, bool negateValue); 10 | -------------------------------------------------------------------------------- /src/misc/StringUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | inline bool ReplacePattern(std::string& str, const char* pattern, 6 | const char* replacement) { 7 | size_t const pos = str.find(pattern); 8 | if (pos == std::string::npos) { 9 | return false; 10 | } 11 | 12 | str.replace(pos, strlen(pattern), replacement); 13 | return true; 14 | } 15 | 16 | inline bool ReplacePattern(std::string& str, const char* pattern, 17 | std::string& replacement) { 18 | size_t const pos = str.find(pattern); 19 | if (pos == std::string::npos) { 20 | return false; 21 | } 22 | 23 | str.replace(pos, strlen(pattern), replacement); 24 | return true; 25 | } 26 | -------------------------------------------------------------------------------- /src/misc/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | 3 | Timer Timer::GCTimer{}; 4 | -------------------------------------------------------------------------------- /src/misc/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | static int64_t get_microseconds() { 8 | #if defined(CLOCK_PROCESS_CPUTIME_ID) 9 | // this is for Linux 10 | timespec now{}; 11 | if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &now) != 0) { 12 | return -1; 13 | } 14 | 15 | return (now.tv_sec * 1000 * 1000) + // seconds 16 | (now.tv_nsec / 1000); // nanoseconds 17 | #else 18 | // this is for OSX, might work on other platforms 19 | struct timeval now; 20 | gettimeofday(&now, nullptr); 21 | 22 | return (now.tv_sec * 1000 * 1000) + // seconds 23 | now.tv_usec; // microseconds 24 | #endif 25 | } 26 | 27 | class Timer { 28 | private: 29 | int64_t total; 30 | int64_t last_start; 31 | 32 | public: 33 | static Timer GCTimer; 34 | inline void Resume() { last_start = get_microseconds(); } 35 | inline void Halt() { 36 | const int64_t end = get_microseconds(); 37 | 38 | total = end - last_start; 39 | } 40 | 41 | [[nodiscard]] double GetTotalTime() const { return (double)total / 1000.0; } 42 | }; 43 | -------------------------------------------------------------------------------- /src/misc/VectorUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | template 8 | inline bool Contains(std::vector& vec, T elem) { 9 | auto it = std::find(vec.begin(), vec.end(), elem); 10 | return it != vec.end(); 11 | } 12 | 13 | template 14 | inline int64_t IndexOf(std::vector& vec, T elem) { 15 | auto it = std::find(vec.begin(), vec.end(), elem); 16 | if (it != vec.end()) { 17 | return it - vec.begin(); 18 | } 19 | return -1; 20 | } 21 | -------------------------------------------------------------------------------- /src/misc/debug.cpp: -------------------------------------------------------------------------------- 1 | #include "debug.h" 2 | 3 | #include 4 | 5 | #include "../compiler/Disassembler.h" 6 | #include "../compiler/MethodGenerationContext.h" 7 | #include "../vmobjects/ObjectFormats.h" 8 | #include "../vmobjects/VMClass.h" 9 | #include "../vmobjects/VMSymbol.h" 10 | 11 | std::string DebugGetClassName(vm_oop_t obj) { 12 | return CLASS_OF(obj)->GetName()->GetStdString(); 13 | } 14 | 15 | std::string DebugGetClassName(gc_oop_t obj) { 16 | return CLASS_OF(obj)->GetName()->GetStdString(); 17 | } 18 | 19 | void DebugDumpMethod(VMInvokable* method) { 20 | Disassembler::DumpMethod((VMMethod*)method, "", false); 21 | } 22 | 23 | void DebugDumpMethod(MethodGenerationContext* mgenc) { 24 | Disassembler::DumpMethod(mgenc, ""); 25 | } 26 | -------------------------------------------------------------------------------- /src/primitives/Array.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Array : public PrimitiveContainer { 33 | public: 34 | _Array(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/primitives/Block.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | -------------------------------------------------------------------------------- /src/primitives/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Block : public PrimitiveContainer { 33 | public: 34 | _Block() = default; 35 | }; 36 | -------------------------------------------------------------------------------- /src/primitives/Class.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "Class.h" 28 | 29 | #include "../vm/Universe.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | #include "../vmobjects/VMClass.h" 32 | #include "../vmobjects/VMFrame.h" 33 | #include "../vmobjects/VMSymbol.h" // NOLINT(misc-include-cleaner) it's required to make the types complete 34 | 35 | static vm_oop_t clsNew(vm_oop_t rcvr) { 36 | auto* self = static_cast(rcvr); 37 | return Universe::NewInstance(self); 38 | } 39 | 40 | static vm_oop_t clsName(vm_oop_t rcvr) { 41 | auto* self = static_cast(rcvr); 42 | return self->GetName(); 43 | } 44 | 45 | static vm_oop_t clsSuperclass(vm_oop_t rcvr) { 46 | auto* self = static_cast(rcvr); 47 | return self->GetSuperClass(); 48 | } 49 | 50 | static vm_oop_t clsMethods(vm_oop_t rcvr) { 51 | auto* self = static_cast(rcvr); 52 | return self->GetInstanceInvokables(); 53 | } 54 | 55 | static vm_oop_t clsFields(vm_oop_t rcvr) { 56 | auto* self = static_cast(rcvr); 57 | return self->GetInstanceFields(); 58 | } 59 | 60 | _Class::_Class() { 61 | Add("new", &clsNew, false); 62 | Add("name", &clsName, false); 63 | Add("superclass", &clsSuperclass, false); 64 | Add("fields", &clsFields, false); 65 | Add("methods", &clsMethods, false); 66 | } 67 | -------------------------------------------------------------------------------- /src/primitives/Class.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Class : public PrimitiveContainer { 33 | public: 34 | _Class(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/primitives/Double.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Double : public PrimitiveContainer { 33 | public: 34 | _Double(); 35 | }; 36 | 37 | double coerceDouble(vm_oop_t x); 38 | vm_oop_t dblPercent(vm_oop_t leftPtr, vm_oop_t rightObj); 39 | -------------------------------------------------------------------------------- /src/primitives/Integer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Integer : public PrimitiveContainer { 33 | public: 34 | _Integer(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/primitives/Method.cpp: -------------------------------------------------------------------------------- 1 | #include "Method.h" 2 | 3 | #include 4 | 5 | #include "../vmobjects/ObjectFormats.h" 6 | #include "../vmobjects/VMArray.h" 7 | #include "../vmobjects/VMClass.h" // NOLINT(misc-include-cleaner) it's required to make the types complete 8 | #include "../vmobjects/VMFrame.h" 9 | #include "../vmobjects/VMMethod.h" 10 | #include "../vmobjects/VMSymbol.h" // NOLINT(misc-include-cleaner) it's required to make the types complete 11 | 12 | static vm_oop_t mHolder(vm_oop_t rcvr) { 13 | auto* self = static_cast(rcvr); 14 | return self->GetHolder(); 15 | } 16 | 17 | static vm_oop_t mSignature(vm_oop_t rcvr) { 18 | auto* self = static_cast(rcvr); 19 | return self->GetSignature(); 20 | } 21 | 22 | static void mInvokeOnWith(VMFrame* frame) { 23 | // REM: this is a clone with _Primitive::InvokeOn_With_ 24 | auto* args = static_cast(frame->Pop()); 25 | auto* rcvr = frame->Pop(); 26 | auto* mthd = static_cast(frame->Pop()); 27 | 28 | frame->Push(rcvr); 29 | 30 | size_t const num_args = args->GetNumberOfIndexableFields(); 31 | for (size_t i = 0; i < num_args; i++) { 32 | vm_oop_t arg = args->GetIndexableField(i); 33 | frame->Push(arg); 34 | } 35 | mthd->Invoke(frame); 36 | } 37 | 38 | _Method::_Method() { 39 | Add("signature", &mSignature, false); 40 | Add("holder", &mHolder, false); 41 | Add("invokeOn:with:", &mInvokeOnWith, false); 42 | } 43 | -------------------------------------------------------------------------------- /src/primitives/Method.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../primitivesCore/PrimitiveContainer.h" 4 | #include "../vmobjects/ObjectFormats.h" 5 | 6 | class _Method : public PrimitiveContainer { 7 | public: 8 | _Method(); 9 | 10 | void InvokeOn_With_(VMFrame*); 11 | }; 12 | -------------------------------------------------------------------------------- /src/primitives/Object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Object : public PrimitiveContainer { 33 | public: 34 | _Object(); 35 | void Perform(VMFrame*); 36 | void PerformWithArguments(VMFrame*); 37 | void PerformInSuperclass(VMFrame*); 38 | void PerformWithArgumentsInSuperclass(VMFrame*); 39 | }; 40 | -------------------------------------------------------------------------------- /src/primitives/Primitive.cpp: -------------------------------------------------------------------------------- 1 | #include "Primitive.h" 2 | 3 | #include 4 | 5 | #include "../vmobjects/ObjectFormats.h" 6 | #include "../vmobjects/VMClass.h" // NOLINT(misc-include-cleaner) it's required to make the types complete 7 | #include "../vmobjects/VMFrame.h" 8 | #include "../vmobjects/VMSymbol.h" // NOLINT(misc-include-cleaner) it's required to make the types complete 9 | 10 | static vm_oop_t pHolder(vm_oop_t rcvr) { 11 | auto* self = static_cast(rcvr); 12 | return self->GetHolder(); 13 | } 14 | 15 | static vm_oop_t pSignature(vm_oop_t rcvr) { 16 | auto* self = static_cast(rcvr); 17 | return self->GetSignature(); 18 | } 19 | 20 | static void pInvokeOnWith(VMFrame* frame) { 21 | // REM: this is a clone with _Primitive::InvokeOn_With_ 22 | auto* args = static_cast(frame->Pop()); 23 | auto* rcvr = frame->Pop(); 24 | auto* mthd = static_cast(frame->Pop()); 25 | 26 | frame->Push(rcvr); 27 | 28 | size_t const num_args = args->GetNumberOfIndexableFields(); 29 | for (size_t i = 0; i < num_args; i++) { 30 | vm_oop_t arg = args->GetIndexableField(i); 31 | frame->Push(arg); 32 | } 33 | mthd->Invoke(frame); 34 | } 35 | 36 | _Primitive::_Primitive() { 37 | Add("signature", &pSignature, false); 38 | Add("holder", &pHolder, false); 39 | Add("invokeOn:with:", &pInvokeOnWith, false); 40 | } 41 | -------------------------------------------------------------------------------- /src/primitives/Primitive.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../primitivesCore/PrimitiveContainer.h" 4 | #include "../vmobjects/ObjectFormats.h" 5 | 6 | class _Primitive : public PrimitiveContainer { 7 | public: 8 | _Primitive(); 9 | 10 | void InvokeOn_With_(VMFrame*); 11 | }; 12 | -------------------------------------------------------------------------------- /src/primitives/String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _String : public PrimitiveContainer { 33 | public: 34 | _String(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/primitives/Symbol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "Symbol.h" 28 | 29 | #include 30 | 31 | #include "../vm/Universe.h" 32 | #include "../vmobjects/ObjectFormats.h" 33 | #include "../vmobjects/VMFrame.h" 34 | #include "../vmobjects/VMSymbol.h" 35 | 36 | static vm_oop_t symAsString(vm_oop_t rcvr) { 37 | auto* sym = static_cast(rcvr); 38 | 39 | std::string const str = sym->GetStdString(); 40 | return Universe::NewString(str); 41 | } 42 | 43 | _Symbol::_Symbol() { 44 | Add("asString", &symAsString, false); 45 | } 46 | -------------------------------------------------------------------------------- /src/primitives/Symbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class _Symbol : public PrimitiveContainer { 33 | public: 34 | _Symbol(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/primitives/System.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../primitivesCore/PrimitiveContainer.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | struct timeval; 33 | 34 | class _System : public PrimitiveContainer { 35 | public: 36 | _System(); 37 | ~_System() override; 38 | 39 | void PrintStackTrace(VMFrame*); 40 | }; 41 | -------------------------------------------------------------------------------- /src/primitivesCore/PrimitiveContainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include 30 | 31 | #include "../misc/defs.h" 32 | #include "Primitives.h" 33 | 34 | /// Base class for all container objects holding SOM++ primitives. 35 | // Primitive container classes need to initialize a std::map in order to map smalltalk message names to the method 37 | // to call. 38 | class PrimitiveContainer { 39 | public: 40 | PrimitiveContainer() = default; 41 | virtual ~PrimitiveContainer() = default; 42 | 43 | void InstallPrimitives(VMClass* clazz, bool classSide); 44 | 45 | void Add(const char* name, FramePrimitiveRoutine /*routine*/, 46 | bool classSide); 47 | void Add(const char* name, UnaryPrimitiveRoutine /*routine*/, 48 | bool classSide); 49 | void Add(const char* name, BinaryPrimitiveRoutine /*routine*/, 50 | bool classSide); 51 | void Add(const char* name, TernaryPrimitiveRoutine /*routine*/, 52 | bool classSide); 53 | 54 | private: 55 | std::map framePrims; 56 | std::map unaryPrims; 57 | std::map binaryPrims; 58 | std::map ternaryPrims; 59 | }; 60 | -------------------------------------------------------------------------------- /src/primitivesCore/Primitives.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../vmobjects/ObjectFormats.h" 4 | 5 | using FramePrimitiveRoutine = void(VMFrame*); 6 | using UnaryPrimitiveRoutine = vm_oop_t(vm_oop_t); 7 | using BinaryPrimitiveRoutine = vm_oop_t(vm_oop_t, vm_oop_t); 8 | using TernaryPrimitiveRoutine = vm_oop_t(vm_oop_t, vm_oop_t, vm_oop_t); 9 | 10 | class Prim { 11 | public: 12 | explicit Prim(bool classSide) : isClassSide(classSide) {} 13 | bool isClassSide; 14 | }; 15 | 16 | class FramePrim : public Prim { 17 | public: 18 | FramePrim(FramePrimitiveRoutine ptr, bool classSide) 19 | : Prim(classSide), pointer(ptr) {} 20 | explicit FramePrim() : Prim(false), pointer(nullptr) {} 21 | 22 | [[nodiscard]] bool IsValid() const { return pointer != nullptr; } 23 | void MarkObjectAsInvalid() { pointer = nullptr; } 24 | 25 | void (*pointer)(VMFrame*); 26 | }; 27 | 28 | class UnaryPrim : public Prim { 29 | public: 30 | UnaryPrim(UnaryPrimitiveRoutine ptr, bool classSide) 31 | : Prim(classSide), pointer(ptr) {} 32 | explicit UnaryPrim() : Prim(false), pointer(nullptr) {} 33 | 34 | [[nodiscard]] bool IsValid() const { return pointer != nullptr; } 35 | void MarkObjectAsInvalid() { pointer = nullptr; } 36 | 37 | vm_oop_t (*pointer)(vm_oop_t); 38 | }; 39 | 40 | class BinaryPrim : public Prim { 41 | public: 42 | BinaryPrim(BinaryPrimitiveRoutine ptr, bool classSide) 43 | : Prim(classSide), pointer(ptr) {} 44 | explicit BinaryPrim() : Prim(false), pointer(nullptr) {} 45 | 46 | [[nodiscard]] bool IsValid() const { return pointer != nullptr; } 47 | 48 | void MarkObjectAsInvalid() { pointer = nullptr; } 49 | 50 | vm_oop_t (*pointer)(vm_oop_t, vm_oop_t); 51 | }; 52 | 53 | class TernaryPrim : public Prim { 54 | public: 55 | TernaryPrim(TernaryPrimitiveRoutine ptr, bool classSide) 56 | : Prim(classSide), pointer(ptr) {} 57 | explicit TernaryPrim() : Prim(false), pointer(nullptr) {} 58 | 59 | [[nodiscard]] bool IsValid() const { return pointer != nullptr; } 60 | 61 | void MarkObjectAsInvalid() { pointer = nullptr; } 62 | 63 | vm_oop_t (*pointer)(vm_oop_t, vm_oop_t, vm_oop_t); 64 | }; 65 | -------------------------------------------------------------------------------- /src/unitTests/CloneObjectsTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | * CloneObjectsTest.h 4 | * 5 | * Created on: 21.01.2011 6 | * Author: christian 7 | */ 8 | 9 | #include 10 | 11 | class CloneObjectsTest : public CPPUNIT_NS::TestCase { 12 | CPPUNIT_TEST_SUITE(CloneObjectsTest); // NOLINT(misc-const-correctness) 13 | CPPUNIT_TEST(testCloneObject); 14 | CPPUNIT_TEST(testCloneInteger); 15 | CPPUNIT_TEST(testCloneDouble); 16 | CPPUNIT_TEST(testCloneString); 17 | CPPUNIT_TEST(testCloneSymbol); 18 | CPPUNIT_TEST(testCloneArray); 19 | CPPUNIT_TEST(testCloneMethod); 20 | CPPUNIT_TEST(testCloneBlock); 21 | CPPUNIT_TEST(testClonePrimitive); 22 | CPPUNIT_TEST(testCloneClass); 23 | CPPUNIT_TEST(testCloneFrame); 24 | CPPUNIT_TEST(testCloneEvaluationPrimitive); 25 | CPPUNIT_TEST_SUITE_END(); 26 | 27 | public: 28 | inline void setUp() override {} 29 | inline void tearDown() override {} 30 | 31 | private: 32 | static void testCloneObject(); 33 | static void testCloneInteger(); 34 | static void testCloneDouble(); 35 | static void testCloneString(); 36 | static void testCloneSymbol(); 37 | static void testCloneArray(); 38 | static void testCloneBlock(); 39 | static void testClonePrimitive(); 40 | static void testCloneClass(); 41 | static void testCloneFrame(); 42 | static void testCloneMethod(); 43 | static void testCloneEvaluationPrimitive(); 44 | }; 45 | -------------------------------------------------------------------------------- /src/unitTests/TestWithParsing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../compiler/ClassGenerationContext.h" 6 | #include "../compiler/MethodGenerationContext.h" 7 | 8 | class BC { 9 | public: 10 | // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions) 11 | BC(uint8_t bytecode) : bytecode(bytecode), arg1(0), arg2(0), size(1) {} 12 | 13 | BC(uint8_t bytecode, uint8_t arg1) 14 | : bytecode(bytecode), arg1(arg1), arg2(0), size(2) {} 15 | 16 | BC(uint8_t bytecode, uint8_t arg1, uint8_t arg2) 17 | : bytecode(bytecode), arg1(arg1), arg2(arg2), size(3) {} 18 | 19 | uint8_t bytecode; 20 | uint8_t arg1; 21 | uint8_t arg2; 22 | 23 | size_t size; 24 | }; 25 | 26 | class TestWithParsing : public CPPUNIT_NS::TestCase { 27 | public: 28 | inline void setUp() override {} 29 | 30 | inline void tearDown() override { 31 | delete _cgenc; 32 | _cgenc = nullptr; 33 | 34 | delete _mgenc; 35 | _mgenc = nullptr; 36 | 37 | delete _bgenc; 38 | _bgenc = nullptr; 39 | } 40 | 41 | protected: 42 | ClassGenerationContext* _cgenc = nullptr; 43 | MethodGenerationContext* _mgenc = nullptr; 44 | MethodGenerationContext* _bgenc = nullptr; 45 | 46 | void ensureCGenC(); 47 | void ensureMGenC(); 48 | void ensureBGenC(); 49 | void addField(const char* fieldName); 50 | 51 | std::vector methodToBytecode(const char* source, 52 | bool dumpBytecodes = false); 53 | std::vector blockToBytecode(const char* source, 54 | bool dumpBytecodes = false); 55 | 56 | void dump(MethodGenerationContext* mgenc = nullptr); 57 | void dump(VMMethod* method = nullptr); 58 | 59 | void check(std::vector actual, 60 | std::vector 61 | expected, 62 | VMMethod* toDump = nullptr); 63 | }; 64 | -------------------------------------------------------------------------------- /src/unitTests/TrivialMethodTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "TestWithParsing.h" 6 | 7 | class TrivialMethodTest : public TestWithParsing { 8 | CPPUNIT_TEST_SUITE(TrivialMethodTest); // NOLINT(misc-const-correctness) 9 | CPPUNIT_TEST(testLiteralReturn); 10 | CPPUNIT_TEST(testLiteralNoReturn); 11 | CPPUNIT_TEST(testBlockLiteralReturn); 12 | CPPUNIT_TEST(testNonTrivialLiteralReturn); 13 | CPPUNIT_TEST(testGlobalReturn); 14 | CPPUNIT_TEST(testNonTrivialGlobalReturn); 15 | CPPUNIT_TEST(testUnknownGlobalInBlock); 16 | CPPUNIT_TEST(testFieldGetter0); 17 | CPPUNIT_TEST(testFieldGetterN); 18 | CPPUNIT_TEST(testNonTrivialFieldGetter0); 19 | CPPUNIT_TEST(testNonTrivialFieldGetterN); 20 | CPPUNIT_TEST(testFieldSetter0); 21 | CPPUNIT_TEST(testFieldSetterN); 22 | CPPUNIT_TEST(testNonTrivialFieldSetter0); 23 | CPPUNIT_TEST(testNonTrivialFieldSetterN); 24 | CPPUNIT_TEST(testBlockReturn); 25 | CPPUNIT_TEST_SUITE_END(); 26 | 27 | private: 28 | void testLiteralReturn(); 29 | void literalReturn(const std::string& source); 30 | 31 | void testBlockLiteralReturn(); 32 | void blockLiteralReturn(const std::string& source); 33 | 34 | void testLiteralNoReturn(); 35 | void literalNoReturn(const std::string& source); 36 | 37 | void testNonTrivialLiteralReturn(); 38 | void nonTrivialLiteralReturn(const std::string& source); 39 | 40 | void testGlobalReturn(); 41 | void globalReturn(const std::string& source); 42 | 43 | void testNonTrivialGlobalReturn(); 44 | void testUnknownGlobalInBlock(); 45 | 46 | void testFieldGetter0(); 47 | void testFieldGetterN(); 48 | 49 | void testNonTrivialFieldGetter0(); 50 | void testNonTrivialFieldGetterN(); 51 | 52 | void testFieldSetter0(); 53 | void fieldSetter0(const std::string& source); 54 | void testFieldSetterN(); 55 | void fieldSetterN(const std::string& source); 56 | void testNonTrivialFieldSetter0(); 57 | void testNonTrivialFieldSetterN(); 58 | 59 | void testBlockReturn(); 60 | }; 61 | -------------------------------------------------------------------------------- /src/unitTests/WalkObjectsTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | * WalkObjectsTest.h 4 | * 5 | * Created on: 13.01.2011 6 | * Author: christian 7 | */ 8 | 9 | #include 10 | 11 | #include "../vmobjects/VMArray.h" 12 | #include "../vmobjects/VMBlock.h" 13 | #include "../vmobjects/VMClass.h" 14 | #include "../vmobjects/VMDouble.h" 15 | #include "../vmobjects/VMEvaluationPrimitive.h" 16 | #include "../vmobjects/VMFrame.h" 17 | #include "../vmobjects/VMInteger.h" 18 | #include "../vmobjects/VMMethod.h" 19 | #include "../vmobjects/VMPrimitive.h" 20 | #include "../vmobjects/VMSymbol.h" 21 | 22 | using namespace std; 23 | 24 | class WalkObjectsTest : public CPPUNIT_NS::TestCase { 25 | CPPUNIT_TEST_SUITE(WalkObjectsTest); // NOLINT(misc-const-correctness) 26 | CPPUNIT_TEST(testWalkArray); 27 | CPPUNIT_TEST(testWalkBlock); 28 | CPPUNIT_TEST(testWalkClass); 29 | CPPUNIT_TEST(testWalkDouble); 30 | CPPUNIT_TEST(testWalkEvaluationPrimitive); 31 | CPPUNIT_TEST(testWalkFrame); 32 | CPPUNIT_TEST(testWalkInteger); 33 | CPPUNIT_TEST(testWalkString); 34 | CPPUNIT_TEST(testWalkMethod); 35 | CPPUNIT_TEST(testWalkObject); 36 | CPPUNIT_TEST(testWalkPrimitive); 37 | CPPUNIT_TEST(testWalkSymbol); 38 | CPPUNIT_TEST_SUITE_END(); 39 | 40 | public: 41 | inline void setUp() override {} 42 | inline void tearDown() override {} 43 | 44 | private: 45 | static void testWalkArray(); 46 | static void testWalkBlock(); 47 | static void testWalkClass(); 48 | static void testWalkDouble(); 49 | static void testWalkEvaluationPrimitive(); 50 | static void testWalkFrame(); 51 | static void testWalkInteger(); 52 | static void testWalkString(); 53 | static void testWalkMethod(); 54 | static void testWalkObject(); 55 | static void testWalkPrimitive(); 56 | static void testWalkSymbol(); 57 | }; 58 | -------------------------------------------------------------------------------- /src/unitTests/WriteBarrierTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../vmobjects/VMArray.h" 6 | 7 | using namespace std; 8 | 9 | class WriteBarrierTest : public CPPUNIT_NS::TestCase { 10 | CPPUNIT_TEST_SUITE(WriteBarrierTest); // NOLINT(misc-const-correctness) 11 | CPPUNIT_TEST(testWriteArray); 12 | CPPUNIT_TEST(testWriteClass); 13 | CPPUNIT_TEST(testWriteBlock); 14 | CPPUNIT_TEST(testWriteFrame); 15 | CPPUNIT_TEST(testWriteEvaluationPrimitive); 16 | CPPUNIT_TEST(testWriteMethod); 17 | CPPUNIT_TEST_SUITE_END(); 18 | 19 | public: 20 | inline void setUp() override {} 21 | inline void tearDown() override {} 22 | 23 | private: 24 | static void testWriteArray(); 25 | static void testWriteClass(); 26 | static void testWriteBlock(); 27 | static void testWriteFrame(); 28 | static void testWriteMethod(); 29 | static void testWriteEvaluationPrimitive(); 30 | }; 31 | -------------------------------------------------------------------------------- /src/unitTests/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * main.cpp 3 | * 4 | * Created on: 12.01.2011 5 | * Author: christian 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "../misc/defs.h" 20 | #include "../vm/Universe.h" 21 | #include "BasicInterpreterTests.h" 22 | #include "BytecodeGenerationTest.h" 23 | #include "CloneObjectsTest.h" 24 | #include "TrivialMethodTest.h" 25 | #include "WalkObjectsTest.h" 26 | 27 | #if GC_TYPE == GENERATIONAL 28 | #include "WriteBarrierTest.h" 29 | #endif 30 | 31 | CPPUNIT_TEST_SUITE_REGISTRATION(WalkObjectsTest); 32 | CPPUNIT_TEST_SUITE_REGISTRATION(CloneObjectsTest); 33 | #if GC_TYPE == GENERATIONAL 34 | CPPUNIT_TEST_SUITE_REGISTRATION(WriteBarrierTest); 35 | #endif 36 | CPPUNIT_TEST_SUITE_REGISTRATION(BytecodeGenerationTest); 37 | CPPUNIT_TEST_SUITE_REGISTRATION(TrivialMethodTest); 38 | CPPUNIT_TEST_SUITE_REGISTRATION(BasicInterpreterTests); 39 | 40 | int32_t main(int32_t ac, char** av) { 41 | Universe::Start(ac, av); 42 | 43 | //--- Create the event manager and test controller 44 | CPPUNIT_NS::TestResult controller; 45 | 46 | //--- Add a listener that collects test result 47 | CPPUNIT_NS::TestResultCollector result; 48 | controller.addListener(&result); 49 | 50 | //--- Add a listener that print dots as test run. 51 | CPPUNIT_NS::BriefTestProgressListener progress; 52 | controller.addListener(&progress); 53 | 54 | //--- Add the top suite to the test runner 55 | CPPUNIT_NS::TestRunner runner; 56 | runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()); 57 | runner.run(controller); 58 | 59 | // output results in compiler-format 60 | CPPUNIT_NS::CompilerOutputter compileroutputter(&result, std::cerr); 61 | compileroutputter.write(); 62 | 63 | return result.wasSuccessful() ? 0 : 1; 64 | } 65 | -------------------------------------------------------------------------------- /src/vm/Globals.cpp: -------------------------------------------------------------------------------- 1 | #include "Globals.h" 2 | 3 | #include "../vmobjects/ObjectFormats.h" 4 | 5 | GCObject* nilObject; 6 | GCObject* trueObject; 7 | GCObject* falseObject; 8 | 9 | GCClass* objectClass; 10 | GCClass* classClass; 11 | GCClass* metaClassClass; 12 | 13 | GCClass* nilClass; 14 | GCClass* integerClass; 15 | GCClass* arrayClass; 16 | GCClass* methodClass; 17 | GCClass* symbolClass; 18 | GCClass* primitiveClass; 19 | GCClass* stringClass; 20 | GCClass* systemClass; 21 | GCClass* blockClass; 22 | GCClass* doubleClass; 23 | 24 | GCClass* trueClass; 25 | GCClass* falseClass; 26 | -------------------------------------------------------------------------------- /src/vm/Globals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../vmobjects/ObjectFormats.h" 4 | 5 | extern GCObject* nilObject; 6 | extern GCObject* trueObject; 7 | extern GCObject* falseObject; 8 | 9 | extern GCClass* objectClass; 10 | extern GCClass* classClass; 11 | extern GCClass* metaClassClass; 12 | 13 | extern GCClass* nilClass; 14 | extern GCClass* integerClass; 15 | extern GCClass* arrayClass; 16 | extern GCClass* methodClass; 17 | extern GCClass* symbolClass; 18 | extern GCClass* primitiveClass; 19 | extern GCClass* stringClass; 20 | extern GCClass* systemClass; 21 | extern GCClass* blockClass; 22 | extern GCClass* doubleClass; 23 | 24 | extern GCClass* trueClass; 25 | extern GCClass* falseClass; 26 | -------------------------------------------------------------------------------- /src/vm/IsValidObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../misc/defs.h" 4 | #include "../vmobjects/ObjectFormats.h" 5 | 6 | bool IsValidObject(vm_oop_t obj); 7 | 8 | bool IsVMInteger(vm_oop_t obj); 9 | bool IsVMMethod(vm_oop_t obj); 10 | bool IsVMSymbol(vm_oop_t obj); 11 | bool IsLiteralReturn(vm_oop_t obj); 12 | bool IsGlobalReturn(vm_oop_t obj); 13 | bool IsGetter(vm_oop_t obj); 14 | bool IsSetter(vm_oop_t obj); 15 | bool IsSafeUnaryPrim(vm_oop_t obj); 16 | 17 | void set_vt_to_null(); 18 | 19 | void obtain_vtables_of_known_classes(VMSymbol* someValidSymbol); 20 | -------------------------------------------------------------------------------- /src/vm/LogAllocation.cpp: -------------------------------------------------------------------------------- 1 | #ifdef GENERATE_ALLOCATION_STATISTICS 2 | #include "LogAllocation.h" 3 | 4 | #include 5 | #include 6 | 7 | std::map allocationStats; 8 | #endif 9 | 10 | void InitializeAllocationLog() { // NOLINT(misc-use-internal-linkage) 11 | #ifdef GENERATE_ALLOCATION_STATISTICS 12 | allocationStats["VMArray"] = {0, 0}; 13 | #endif 14 | } 15 | 16 | void OutputAllocationLogFile() { // NOLINT(misc-use-internal-linkage) 17 | #ifdef GENERATE_ALLOCATION_STATISTICS 18 | std::string file_name_allocation = std::string(bm_name); 19 | file_name_allocation.append("_allocation_statistics.csv"); 20 | 21 | fstream file_alloc_stats(file_name_allocation.c_str(), ios::out); 22 | map::iterator iter; 23 | for (iter = allocationStats.begin(); iter != allocationStats.end(); 24 | iter++) { 25 | file_alloc_stats << iter->first << ", " << iter->second.noObjects 26 | << ", " << iter->second.sizeObjects << std::endl; 27 | } 28 | #endif 29 | } 30 | -------------------------------------------------------------------------------- /src/vm/LogAllocation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef GENERATE_ALLOCATION_STATISTICS 4 | struct alloc_data { 5 | long noObjects; 6 | long sizeObjects; 7 | }; 8 | std::map allocationStats; 9 | #define LOG_ALLOCATION(TYPE, SIZE) \ 10 | { \ 11 | struct alloc_data tmp = allocationStats[TYPE]; \ 12 | tmp.noObjects++; \ 13 | tmp.sizeObjects += (SIZE); \ 14 | allocationStats[TYPE] = tmp; \ 15 | } 16 | #else 17 | #define LOG_ALLOCATION(TYPE, SIZE) 18 | #endif 19 | 20 | void InitializeAllocationLog(); 21 | void OutputAllocationLogFile(); 22 | -------------------------------------------------------------------------------- /src/vm/Print.cpp: -------------------------------------------------------------------------------- 1 | #include "Print.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "../misc/defs.h" 10 | #include "LogAllocation.h" 11 | #include "Universe.h" 12 | 13 | using namespace std; 14 | 15 | static mutex output_mutex; 16 | 17 | void Print(const std::string& str) { 18 | lock_guard const lock(output_mutex); 19 | cout << str << flush; 20 | } 21 | 22 | void ErrorPrint(const std::string& str) { 23 | lock_guard const lock(output_mutex); 24 | cerr << str << flush; 25 | } 26 | 27 | void Print(const char* str) { 28 | lock_guard const lock(output_mutex); 29 | cout << str << flush; 30 | } 31 | 32 | void ErrorPrint(const char* str) { 33 | lock_guard const lock(output_mutex); 34 | cerr << str << flush; 35 | } 36 | 37 | __attribute__((noreturn)) __attribute__((noinline)) void ErrorExit( 38 | const char* err) { 39 | ErrorPrint("Runtime error: " + std::string(err) + "\n"); 40 | Quit(ERR_FAIL); 41 | } 42 | 43 | __attribute__((noreturn)) __attribute__((noinline)) void Quit(int32_t err) { 44 | ErrorPrint("Time spent in GC: [" + 45 | to_string(Timer::GCTimer.GetTotalTime()) + "] msec\n"); 46 | 47 | Universe::Shutdown(); 48 | 49 | OutputAllocationLogFile(); 50 | exit(err); 51 | } 52 | -------------------------------------------------------------------------------- /src/vm/Print.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | void Print(const std::string& str); 6 | void Print(const char* str); 7 | void ErrorPrint(const std::string& str); 8 | void ErrorPrint(const char* str); 9 | 10 | __attribute__((noreturn)) __attribute__((noinline)) void Quit(int32_t err); 11 | __attribute__((noreturn)) __attribute__((noinline)) void ErrorExit( 12 | const char* /*err*/); 13 | -------------------------------------------------------------------------------- /src/vm/Shell.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../interpreter/Interpreter.h" 30 | #include "../vmobjects/ObjectFormats.h" 31 | 32 | class Shell { 33 | public: 34 | Shell(); 35 | explicit Shell(VMMethod* bsm); 36 | ~Shell() = default; 37 | 38 | void SetBootstrapMethod(VMMethod* bsm) { bootstrapMethod = bsm; }; 39 | [[nodiscard]] VMMethod* GetBootstrapMethod() const { 40 | return bootstrapMethod; 41 | }; 42 | void Start(); 43 | 44 | private: 45 | VMMethod* bootstrapMethod; 46 | }; 47 | -------------------------------------------------------------------------------- /src/vm/Symbols.cpp: -------------------------------------------------------------------------------- 1 | #include "Symbols.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../memory/Heap.h" 8 | #include "../misc/defs.h" 9 | #include "../vmobjects/ObjectFormats.h" 10 | #include "../vmobjects/VMSymbol.h" 11 | #include "LogAllocation.h" 12 | 13 | static map symbolsMap; 14 | 15 | GCSymbol* symbolSelf; 16 | GCSymbol* symbolSuper; 17 | GCSymbol* symbolBlockSelf; 18 | 19 | GCSymbol* symbolIfTrue; 20 | GCSymbol* symbolIfFalse; 21 | 22 | GCSymbol* symbolPlus; 23 | GCSymbol* symbolMinus; 24 | 25 | VMSymbol* NewSymbol(const size_t length, const char* str) { 26 | auto* result = 27 | new (GetHeap(), PADDED_SIZE(length)) VMSymbol(length, str); 28 | symbolsMap[std::string(str, length)] = store_root(result); 29 | 30 | LOG_ALLOCATION("VMSymbol", result->GetObjectSize()); 31 | return result; 32 | } 33 | 34 | VMSymbol* NewSymbol(const std::string& str) { 35 | return NewSymbol(str.length(), str.c_str()); 36 | } 37 | 38 | VMSymbol* SymbolFor(const std::string& str) { 39 | auto const it = symbolsMap.find(str); 40 | return (it == symbolsMap.end()) ? NewSymbol(str) : load_ptr(it->second); 41 | } 42 | 43 | void InitializeSymbols() { 44 | symbolSelf = store_root(SymbolFor("self")); 45 | symbolSuper = store_root(SymbolFor("super")); 46 | symbolBlockSelf = store_root(SymbolFor("$blockSelf")); 47 | symbolIfTrue = store_root(SymbolFor("ifTrue:")); 48 | symbolIfFalse = store_root(SymbolFor("ifFalse:")); 49 | 50 | symbolPlus = store_root(SymbolFor("+")); 51 | symbolMinus = store_root(SymbolFor("-")); 52 | } 53 | 54 | void WalkSymbols(walk_heap_fn walk) { 55 | // walk all entries in symbols map 56 | map::iterator symbolIter; 57 | for (symbolIter = symbolsMap.begin(); symbolIter != symbolsMap.end(); 58 | symbolIter++) { 59 | // insert overwrites old entries inside the internal map 60 | symbolIter->second = static_cast(walk(symbolIter->second)); 61 | } 62 | 63 | // reassign symbols 64 | symbolSelf = static_cast(walk(symbolSelf)); 65 | symbolSuper = static_cast(walk(symbolSuper)); 66 | symbolBlockSelf = static_cast(walk(symbolBlockSelf)); 67 | symbolIfTrue = static_cast(walk(symbolIfTrue)); 68 | symbolIfFalse = static_cast(walk(symbolIfFalse)); 69 | 70 | symbolPlus = static_cast(walk(symbolPlus)); 71 | symbolMinus = static_cast(walk(symbolMinus)); 72 | } 73 | -------------------------------------------------------------------------------- /src/vm/Symbols.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../vmobjects/VMSymbol.h" 6 | 7 | VMSymbol* SymbolFor(const std::string& str); 8 | 9 | void InitializeSymbols(); 10 | 11 | void WalkSymbols(walk_heap_fn walk); 12 | 13 | #ifdef UNITTESTS 14 | VMSymbol* NewSymbol(const std::string& str); 15 | VMSymbol* NewSymbol(size_t length, const char* str); 16 | #endif 17 | 18 | extern GCSymbol* symbolSelf; 19 | extern GCSymbol* symbolSuper; 20 | extern GCSymbol* symbolBlockSelf; 21 | 22 | extern GCSymbol* symbolIfTrue; 23 | extern GCSymbol* symbolIfFalse; 24 | 25 | extern GCSymbol* symbolPlus; 26 | extern GCSymbol* symbolMinus; 27 | 28 | const char* const strBlockSelf = "$blockSelf"; 29 | const char* const strSuper = "super"; 30 | const char* const strSelf = "self"; 31 | -------------------------------------------------------------------------------- /src/vmobjects/AbstractObject.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AbstractVMObject.cpp 3 | * 4 | * Created on: 10.03.2011 5 | * Author: christian 6 | */ 7 | 8 | #include "AbstractObject.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "../interpreter/Interpreter.h" 15 | #include "../vm/Symbols.h" 16 | #include "../vmobjects/ObjectFormats.h" 17 | #include "VMClass.h" 18 | #include "VMFrame.h" 19 | #include "VMInvokable.h" 20 | #include "VMSymbol.h" 21 | 22 | void AbstractVMObject::Send(const std::string& selectorString, 23 | vm_oop_t* arguments, size_t argc) { 24 | VMFrame* frame = Interpreter::GetFrame(); 25 | VMSymbol* selector = SymbolFor(selectorString); 26 | frame->Push(this); 27 | 28 | for (size_t i = 0; i < argc; ++i) { 29 | frame->Push(arguments[i]); 30 | } 31 | 32 | VMClass* cl = GetClass(); 33 | VMInvokable* invokable = cl->LookupInvokable(selector); 34 | invokable->Invoke(frame); 35 | } 36 | 37 | int64_t AbstractVMObject::GetFieldIndex(VMSymbol* fieldName) const { 38 | return GetClass()->LookupFieldIndex(fieldName); 39 | } 40 | -------------------------------------------------------------------------------- /src/vmobjects/IntegerBox.cpp: -------------------------------------------------------------------------------- 1 | #include "IntegerBox.h" 2 | 3 | #include "ObjectFormats.h" 4 | #include "VMInteger.h" 5 | 6 | GCInteger* GlobalBox::integerBox = nullptr; 7 | 8 | void GlobalBox::updateIntegerBox(VMInteger* newValue) { 9 | integerBox = store_root(newValue); 10 | } 11 | 12 | VMInteger* GlobalBox::IntegerBox() { 13 | return load_ptr(integerBox); 14 | } 15 | 16 | void GlobalBox::WalkGlobals(walk_heap_fn walk) { 17 | integerBox = static_cast(walk(integerBox)); 18 | } 19 | -------------------------------------------------------------------------------- /src/vmobjects/IntegerBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../vmobjects/ObjectFormats.h" 4 | 5 | class GlobalBox { 6 | public: 7 | static VMInteger* IntegerBox(); 8 | 9 | static void WalkGlobals(walk_heap_fn walk); 10 | 11 | private: 12 | static void updateIntegerBox(VMInteger* /*newValue*/); 13 | static GCInteger* integerBox; 14 | friend class Universe; 15 | }; 16 | -------------------------------------------------------------------------------- /src/vmobjects/Signature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "Signature.h" 28 | 29 | #include 30 | #include 31 | 32 | #include "VMSymbol.h" 33 | 34 | bool Signature::IsBinary(VMSymbol* sig) { 35 | return sig->numberOfArgumentsOfSignature == 2; 36 | } 37 | 38 | uint8_t Signature::DetermineNumberOfArguments(const char* sig, 39 | const size_t length) { 40 | // check default binaries 41 | if (Signature::IsBinary(sig, length)) { 42 | return 2; 43 | } 44 | 45 | // colons in str 46 | int numColons = 0; 47 | for (size_t i = 0; i < length; i++) { 48 | if (sig[i] == ':') { 49 | numColons++; 50 | } 51 | } 52 | return numColons + 1; 53 | } 54 | 55 | bool Signature::IsBinary(const char* sig, const size_t length) { 56 | if (length == 0) { 57 | return false; 58 | } 59 | switch (sig[0]) { 60 | case '~': 61 | case '&': 62 | case '|': 63 | case '*': 64 | case '/': 65 | case '@': 66 | case '+': 67 | case '-': 68 | case '=': 69 | case '>': 70 | case '<': 71 | case ',': 72 | case '%': 73 | case '\\': 74 | return true; 75 | default: 76 | break; 77 | } 78 | return false; 79 | } 80 | -------------------------------------------------------------------------------- /src/vmobjects/Signature.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include 30 | 31 | #include "../vmobjects/ObjectFormats.h" 32 | #include "../vmobjects/VMSymbol.h" 33 | 34 | class Signature { 35 | public: 36 | inline static uint8_t GetNumberOfArguments(VMSymbol* sig) { 37 | return sig->numberOfArgumentsOfSignature; 38 | } 39 | 40 | static bool IsBinary(VMSymbol* sig); 41 | 42 | static uint8_t DetermineNumberOfArguments(const char* sig, size_t length); 43 | static bool IsBinary(const char* sig, size_t length); 44 | }; 45 | -------------------------------------------------------------------------------- /src/vmobjects/VMBlock.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "VMBlock.h" 28 | 29 | #include 30 | 31 | #include "../memory/Heap.h" 32 | #include "../misc/defs.h" 33 | #include "ObjectFormats.h" 34 | #include "VMEvaluationPrimitive.h" 35 | #include "VMObject.h" 36 | 37 | const int VMBlock::VMBlockNumberOfFields = 2; 38 | 39 | VMBlock::VMBlock(VMInvokable* method, VMFrame* context) 40 | : VMObject(VMBlockNumberOfFields, sizeof(VMBlock)), 41 | blockMethod(store_with_separate_barrier(method)), 42 | context(store_with_separate_barrier(context)) { 43 | write_barrier(this, method); 44 | write_barrier(this, context); 45 | } 46 | 47 | VMBlock* VMBlock::CloneForMovingGC() const { 48 | VMBlock* clone = nullptr; 49 | clone = new (GetHeap(), 0 ALLOC_MATURE) VMBlock(*this); 50 | return clone; 51 | } 52 | 53 | VMInvokable* VMBlock::GetMethod() const { 54 | return load_ptr(blockMethod); 55 | } 56 | 57 | VMEvaluationPrimitive* VMBlock::GetEvaluationPrimitive(int numberOfArguments) { 58 | return new (GetHeap(), 0) 59 | VMEvaluationPrimitive(numberOfArguments); 60 | } 61 | 62 | std::string VMBlock::AsDebugString() const { 63 | return "Block(" + load_ptr(blockMethod)->AsDebugString() + ")"; 64 | } 65 | -------------------------------------------------------------------------------- /src/vmobjects/VMBlock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "VMFrame.h" 30 | #include "VMObject.h" 31 | 32 | class VMBlock : public VMObject { 33 | public: 34 | typedef GCBlock Stored; 35 | 36 | VMBlock(VMInvokable* method, VMFrame* context); 37 | 38 | [[nodiscard]] VMInvokable* GetMethod() const; 39 | 40 | [[nodiscard]] inline VMFrame* GetContext() const { 41 | return load_ptr(context); 42 | } 43 | 44 | [[nodiscard]] VMBlock* CloneForMovingGC() const override; 45 | 46 | [[nodiscard]] std::string AsDebugString() const override; 47 | 48 | static VMEvaluationPrimitive* GetEvaluationPrimitive( 49 | int /*numberOfArguments*/); 50 | 51 | private: 52 | make_testable(public); 53 | 54 | GCInvokable* blockMethod; 55 | GCFrame* context; 56 | 57 | private: 58 | static const int VMBlockNumberOfFields; 59 | }; 60 | -------------------------------------------------------------------------------- /src/vmobjects/VMDouble.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "VMDouble.h" 28 | 29 | #include 30 | 31 | #include "../memory/Heap.h" 32 | #include "../misc/defs.h" 33 | #include "../vm/Globals.h" 34 | #include "ObjectFormats.h" 35 | #include "VMClass.h" 36 | 37 | VMDouble* VMDouble::CloneForMovingGC() const { 38 | return new (GetHeap(), 0 ALLOC_MATURE) VMDouble(*this); 39 | } 40 | 41 | VMClass* VMDouble::GetClass() const { 42 | return load_ptr(doubleClass); 43 | } 44 | 45 | std::string VMDouble::AsDebugString() const { 46 | return "Double(" + to_string(embeddedDouble) + ")"; 47 | } 48 | 49 | #define INVALID_DBL_MARKER 9007000000000990 50 | 51 | void VMDouble::MarkObjectAsInvalid() { 52 | embeddedDouble = INVALID_DBL_MARKER; 53 | } 54 | 55 | bool VMDouble::IsMarkedInvalid() const { 56 | return embeddedDouble == INVALID_DBL_MARKER; 57 | } 58 | -------------------------------------------------------------------------------- /src/vmobjects/VMDouble.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "AbstractObject.h" 30 | 31 | class VMDouble : public AbstractVMObject { 32 | public: 33 | typedef GCDouble Stored; 34 | 35 | explicit VMDouble(double val) : embeddedDouble(val) {} 36 | 37 | [[nodiscard]] VMDouble* CloneForMovingGC() const override; 38 | [[nodiscard]] inline double GetEmbeddedDouble() const; 39 | [[nodiscard]] VMClass* GetClass() const override; 40 | [[nodiscard]] inline size_t GetObjectSize() const override; 41 | 42 | [[nodiscard]] inline int64_t GetHash() const override { 43 | // try to avoid a smart cast of the double value. 44 | // instead, try to get to the bit pattern as a int64_t 45 | return (*(int64_t*)&embeddedDouble); 46 | } 47 | 48 | void MarkObjectAsInvalid() override; 49 | [[nodiscard]] bool IsMarkedInvalid() const override; 50 | 51 | [[nodiscard]] std::string AsDebugString() const override; 52 | 53 | private: 54 | make_testable(public); 55 | 56 | double embeddedDouble; 57 | }; 58 | 59 | double VMDouble::GetEmbeddedDouble() const { 60 | return embeddedDouble; 61 | } 62 | 63 | size_t VMDouble::GetObjectSize() const { 64 | return sizeof(VMDouble); 65 | } 66 | -------------------------------------------------------------------------------- /src/vmobjects/VMInteger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "VMInteger.h" 28 | 29 | #include 30 | 31 | #include "../memory/Heap.h" 32 | #include "../misc/defs.h" 33 | #include "../vm/Globals.h" 34 | #include "ObjectFormats.h" 35 | #include "VMClass.h" 36 | 37 | VMInteger* VMInteger::CloneForMovingGC() const { 38 | return new (GetHeap(), 0 ALLOC_MATURE) VMInteger(*this); 39 | } 40 | 41 | VMClass* VMInteger::GetClass() const { 42 | return load_ptr(integerClass); 43 | } 44 | 45 | std::string VMInteger::AsDebugString() const { 46 | return "Integer(" + to_string(embeddedInteger) + ")"; 47 | } 48 | 49 | #define INVALID_INT_MARKER 9002002002002002002 50 | 51 | void VMInteger::MarkObjectAsInvalid() { 52 | embeddedInteger = INVALID_INT_MARKER; 53 | } 54 | 55 | bool VMInteger::IsMarkedInvalid() const { 56 | return embeddedInteger == INVALID_INT_MARKER; 57 | } 58 | -------------------------------------------------------------------------------- /src/vmobjects/VMInteger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * 5 | * 6 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 7 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 8 | http://www.hpi.uni-potsdam.de/swa/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | */ 28 | 29 | #include "../misc/defs.h" 30 | #include "AbstractObject.h" 31 | #include "IntegerBox.h" 32 | 33 | class VMInteger : public AbstractVMObject { 34 | public: 35 | typedef GCInteger Stored; 36 | 37 | explicit VMInteger(int64_t val) : embeddedInteger(val) {} 38 | ~VMInteger() override = default; 39 | 40 | [[nodiscard]] inline int64_t GetEmbeddedInteger() const; 41 | [[nodiscard]] VMInteger* CloneForMovingGC() const override; 42 | [[nodiscard]] VMClass* GetClass() const override; 43 | [[nodiscard]] inline size_t GetObjectSize() const override; 44 | 45 | [[nodiscard]] inline int64_t GetHash() const override { 46 | return (int64_t)embeddedInteger; 47 | } 48 | 49 | void MarkObjectAsInvalid() override; 50 | [[nodiscard]] bool IsMarkedInvalid() const override; 51 | 52 | [[nodiscard]] std::string AsDebugString() const override; 53 | 54 | make_testable(public); 55 | 56 | int64_t embeddedInteger; 57 | }; 58 | 59 | int64_t VMInteger::GetEmbeddedInteger() const { 60 | return embeddedInteger; 61 | } 62 | 63 | size_t VMInteger::GetObjectSize() const { 64 | // no need to pad -> sizeof returns padded size anyway 65 | return sizeof(VMInteger); 66 | } 67 | -------------------------------------------------------------------------------- /src/vmobjects/VMInvokable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "VMInvokable.h" 28 | 29 | #include 30 | 31 | #include "../vm/Print.h" 32 | #include "ObjectFormats.h" 33 | #include "VMClass.h" 34 | 35 | bool VMInvokable::IsPrimitive() const { 36 | return false; 37 | } 38 | 39 | void VMInvokable::WalkObjects(walk_heap_fn walk) { 40 | signature = static_cast(walk(signature)); 41 | if (holder != nullptr) { 42 | holder = static_cast(walk(holder)); 43 | } 44 | } 45 | 46 | void VMInvokable::SetHolder(VMClass* hld) { 47 | store_ptr(holder, hld); 48 | } 49 | 50 | const Variable* VMInvokable::GetArgument(size_t /*unused*/, size_t /*unused*/) { 51 | ErrorExit("VMInvokable::GetArgument not supported on anything VMMethod"); 52 | } 53 | -------------------------------------------------------------------------------- /src/vmobjects/VMObjectBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MASK_OBJECT_IS_MARKED (1U << 0U) 4 | #define MASK_OBJECT_IS_OLD (1U << 1U) 5 | #define MASK_SEEN_BY_WRITE_BARRIER (1U << 2U) 6 | #define MASK_BITS_ALL \ 7 | (MASK_OBJECT_IS_MARKED | MASK_OBJECT_IS_OLD | MASK_SEEN_BY_WRITE_BARRIER) 8 | 9 | #include 10 | 11 | class VMObjectBase : public VMOop { 12 | protected: 13 | size_t gcfield{0}; 14 | 15 | public: 16 | [[nodiscard]] inline size_t GetGCField() const; 17 | inline void SetGCField(size_t /*val*/); 18 | VMObjectBase() : VMOop() {} 19 | ~VMObjectBase() override = default; 20 | }; 21 | 22 | size_t VMObjectBase::GetGCField() const { 23 | return gcfield; 24 | } 25 | void VMObjectBase::SetGCField(size_t val) { 26 | // if gcfield is used as a forwarding pointer it should not be overwritten 27 | // with simple mark bits, because the object itself is garbage but the 28 | // forwarding address needs to be maintained incase any object still points 29 | // to the garbage object. 30 | #define GCFIELD_IS_NOT_FORWARDING_POINTER (gcfield <= MASK_BITS_ALL) 31 | #if GC_TYPE != MARK_SWEEP 32 | assert(GCFIELD_IS_NOT_FORWARDING_POINTER || val > MASK_BITS_ALL); 33 | #endif 34 | gcfield = val; 35 | } 36 | -------------------------------------------------------------------------------- /src/vmobjects/VMString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | Copyright (c) 2007 Michael Haupt, Tobias Pape, Arne Bergmann 5 | Software Architecture Group, Hasso Plattner Institute, Potsdam, Germany 6 | http://www.hpi.uni-potsdam.de/swa/ 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | #include "VMString.h" 28 | 29 | #include 30 | #include 31 | 32 | #include "../memory/Heap.h" 33 | #include "../misc/defs.h" 34 | #include "ObjectFormats.h" 35 | 36 | extern GCClass* stringClass; 37 | 38 | // this macro could replace the chars member variable 39 | // #define CHARS ((char*)&clazz+sizeof(VMObject*)) 40 | 41 | VMString* VMString::CloneForMovingGC() const { 42 | return new (GetHeap(), PADDED_SIZE(length) ALLOC_MATURE) 43 | VMString(length, chars); 44 | } 45 | 46 | size_t VMString::GetObjectSize() const { 47 | size_t const size = sizeof(VMString) + PADDED_SIZE(length); 48 | return size; 49 | } 50 | 51 | VMClass* VMString::GetClass() const { 52 | return load_ptr(stringClass); 53 | } 54 | 55 | std::string VMString::GetStdString() const { 56 | if (chars == nullptr) { 57 | return {""}; 58 | } 59 | return {chars, length}; 60 | } 61 | 62 | std::string VMString::AsDebugString() const { 63 | return "String(" + GetStdString() + ")"; 64 | } 65 | --------------------------------------------------------------------------------