Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph based code generation #32

Closed
14 of 21 tasks
0x7CFE opened this issue Oct 5, 2013 · 1 comment
Closed
14 of 21 tasks

Graph based code generation #32

0x7CFE opened this issue Oct 5, 2013 · 1 comment
Assignees
Milestone

Comments

@0x7CFE
Copy link
Owner

0x7CFE commented Oct 5, 2013

Current JIT compiler implementation does not parse Smalltalk instructions in any way. Instructions are processed directly in a switch-case blocks.

This is simple but not beautiful. Currently we need to traverse the method instruction array at least 3 times. One pass per scanForBranches() and scanForBlockReturn() and one in the main processing loop in writeFunctionBody().

The idea is to make a single pass which will then parse bytecodes and convert them into TSmalltalkInstruction entities which will hold all corresponding info. The same approach is used in LLVM itself.

This will help us write clean code and perform various operations with the instructions much like it is done with LLVM IR code.

Base API stuff:

  • Convinient abstraction for Smalltalk instructions
  • Abstractions for BasicBlock, ParsedMethod & ParsedBlock
  • Iterators over instructions, basic blocks and smalltalk blocks
  • Visitors that make iteration easy
  • Protect TMethod* pointer in parsed entities
  • Provide a way to compare relative position of basic blocks and instructions

Control graph:

  • Base datatypes for graph node, graph domain, etc.
  • Graph generation code
  • Node and Domain Visitors
  • Recursive argument access through empty domain
  • Create and link tau nodes (related to type inference)

Refactoring stuff:

  • Use TSmalltalkInstruction in soft VM
  • Refactor scanForBlockReturn()
  • Refactor scanForBranches()
  • Rename TSmalltalkInstruction::serialize() to unpack()
  • Rename ControlNode::getNodeType() to getType()
  • Rename TControlGraph::buildGraph() to build()
  • Refactor main codegen loop
  • Eliminate direct bytePointer references
  • Cleanup structures and (now) redundant fields
  • Eliminate opcode::extended as a placeholder in default instruction init

Tests:

Name Written Passed
TSmalltalkInstruction
InstructionDecoder
ABAB (#2)
Stack semantics
Stack underflow
Decode all methods
Visitors
Method visualization
ControlGraph visualization
0x7CFE added a commit that referenced this issue Mar 16, 2014
Commit provides basic data structures for
operating Smalltalk bytecodes in a friendly way.

Base concept is stolen drom the LLVM and other
software which deals with basic blocks and so on.

Currently only very simple read-only interface is provided.

Issue: #32
0x7CFE added a commit that referenced this issue Mar 17, 2014
Commit provides basic data structures for
operating Smalltalk bytecodes in a friendly way.

Base concept is stolen drom the LLVM and other
software which deals with basic blocks and so on.

Currently only very simple read-only interface is provided.

Issue: #32
0x7CFE added a commit that referenced this issue Mar 17, 2014
0x7CFE added a commit that referenced this issue Mar 19, 2014
0x7CFE added a commit that referenced this issue Mar 19, 2014
Commit provides basic data structures for
operating Smalltalk bytecodes in a friendly way.

Base concept is stolen drom the LLVM and other
software which deals with basic blocks and so on.

Issue: #32
0x7CFE added a commit that referenced this issue Mar 19, 2014
Parse method provides a way for translating
compiled Smalltalk method into intermediate
form convinient for analysis and modification.

After method is parsed, one may traverse it
using basic block or instruction iterators.

Issue: #32
@0x7CFE 0x7CFE added this to the Version 0.3 milestone Mar 19, 2014
0x7CFE added a commit that referenced this issue Mar 22, 2014
0x7CFE added a commit that referenced this issue Mar 22, 2014
0x7CFE added a commit that referenced this issue Mar 22, 2014
0x7CFE added a commit that referenced this issue Mar 22, 2014
This pass may be used to find the location of the very first
temporary assignment within the provided method.

Typically such writes are used to initialize the counters or
instantiate temporary objects that are used in method later.

This information may be used by type inference system to
provide more accurate result.

Issue: #32
0x7CFE added a commit that referenced this issue Mar 23, 2014
0x7CFE added a commit that referenced this issue Mar 23, 2014
0x7CFE added a commit that referenced this issue Mar 23, 2014
0x7CFE added a commit that referenced this issue Mar 23, 2014
0x7CFE added a commit that referenced this issue Mar 23, 2014
0x7CFE added a commit that referenced this issue Mar 23, 2014
0x7CFE added a commit that referenced this issue Mar 24, 2014
This allows reuse of TSmalltalkInstruction which was allocated once
act as an instruction storage for current operation in VM.

Issue: #32
0x7CFE added a commit that referenced this issue Mar 24, 2014
0x7CFE added a commit that referenced this issue Mar 25, 2014
Previous implementation of soft VM decoded instructions manually.
Parts of instructions were parsed in the actual code being executed.
This was not clean and error prone.

Current commit removes all pointer arithmetic because all is done
within decoder of TSmalltalkInstruction.

Issue: #32
0x7CFE added a commit that referenced this issue Mar 25, 2014
Redundant fields will be refactored later

Issue: #32
0x7CFE added a commit that referenced this issue Mar 26, 2014
0x7CFE added a commit that referenced this issue Apr 12, 2015
* feature/32/stapi_tests: (39 commits)
  Disables stack underflow test
  Adds test to check whether all incomings of Phi are unique
  Fixes unregistered methods in image
  Fixes tests due to new requirements
  Fixes ABAB test due to new requirements
  Fixes ControlGraphVisualizer 1. It throws exception if file can't be created 2. It escapes chars in filename 3. If literals can't be accessed, it generates a name for the node by default
  Adds test to check behaviour of graph builder on stack underflow
  Fixes the correct order of arguments for EXPECT_*
  Fixes segfault in stack_semantics
  Removes check whether branch should jump on branches
  Adds tests for duplicate opcode
  Fixes TSmalltalkInstruction::isValueProvider (primitives provide values)
  Fixes test for TSmalltalkInstruction (primitives are value providers)
  Fixes TSmalltalkInstruction::isValueConsumer (selfReturn doesn't consume value)
  Fixes test for TSmalltalkInstruction (selfReturn doesn't consume value)
  Adds tests which checks whether branches jump not on terminators
  Adds test to check whether instructions linked with value providers
  Adds newline at EOF in ParsedBytecode.cpp
  Adds fixes after rebase
  Removes stringstream(to format message) from tests
  ...

Conflicts:
	CMakeLists.txt
	image/imageSource.st
	tests/CMakeLists.txt

Issue: #32
0x7CFE added a commit that referenced this issue Apr 12, 2015
* feature/32/codegen_into_ir_func:
  Forces IR functions to be inlined
  Rewrites doAssignInstance with `@setInstanceInContext'
  Rewrites doAssignInstance using cached `@getObjectFieldPtr'
  Fixes using of `@getTempsFromContext'
  Rewrites primitive::arrayAtPut using cached `@getObjectFieldPtr'
  Rewrites doPushInstance using cached `@getInstanceFromContext'
  Rewrites doPushArgument using cached `@getArgFromContext'
  Rewrites doPushLiteral using TJITContext::getLiteral
  Rewrites TJITContext::getLiteral using cached `@getLiteralFromContext'
  Rewrites doAssignTemporary with `@setTemporaryInContext'
  Rewrites doPushArgument with `@getTemporaryFromContext'
  Adds function to_string to format names of llvm values
  Removes extra space in `@setObjectField'
  Rewrites `@getObjectFields' using `@getObjectFieldPtr'

Issue: #32
0x7CFE added a commit that referenced this issue Apr 12, 2015
* feature/32/stapi_tests: (39 commits)
  Disables stack underflow test
  Adds test to check whether all incomings of Phi are unique
  Fixes unregistered methods in image
  Fixes tests due to new requirements
  Fixes ABAB test due to new requirements
  Fixes ControlGraphVisualizer 1. It throws exception if file can't be created 2. It escapes chars in filename 3. If literals can't be accessed, it generates a name for the node by default
  Adds test to check behaviour of graph builder on stack underflow
  Fixes the correct order of arguments for EXPECT_*
  Fixes segfault in stack_semantics
  Removes check whether branch should jump on branches
  Adds tests for duplicate opcode
  Fixes TSmalltalkInstruction::isValueProvider (primitives provide values)
  Fixes test for TSmalltalkInstruction (primitives are value providers)
  Fixes TSmalltalkInstruction::isValueConsumer (selfReturn doesn't consume value)
  Fixes test for TSmalltalkInstruction (selfReturn doesn't consume value)
  Adds tests which checks whether branches jump not on terminators
  Adds test to check whether instructions linked with value providers
  Adds newline at EOF in ParsedBytecode.cpp
  Adds fixes after rebase
  Removes stringstream(to format message) from tests
  ...

Conflicts:
	CMakeLists.txt
	image/imageSource.st
	tests/CMakeLists.txt

Issue: #32
0x7CFE added a commit that referenced this issue Apr 12, 2015
* feature/32/codegen_into_ir_func:
  Forces IR functions to be inlined
  Rewrites doAssignInstance with `@setInstanceInContext'
  Rewrites doAssignInstance using cached `@getObjectFieldPtr'
  Fixes using of `@getTempsFromContext'
  Rewrites primitive::arrayAtPut using cached `@getObjectFieldPtr'
  Rewrites doPushInstance using cached `@getInstanceFromContext'
  Rewrites doPushArgument using cached `@getArgFromContext'
  Rewrites doPushLiteral using TJITContext::getLiteral
  Rewrites TJITContext::getLiteral using cached `@getLiteralFromContext'
  Rewrites doAssignTemporary with `@setTemporaryInContext'
  Rewrites doPushArgument with `@getTemporaryFromContext'
  Adds function to_string to format names of llvm values
  Removes extra space in `@setObjectField'
  Rewrites `@getObjectFields' using `@getObjectFieldPtr'

Issue: #32
0x7CFE added a commit that referenced this issue Apr 12, 2015
* feature/32/stapi_tests: (39 commits)
  Disables stack underflow test
  Adds test to check whether all incomings of Phi are unique
  Fixes unregistered methods in image
  Fixes tests due to new requirements
  Fixes ABAB test due to new requirements
  Fixes ControlGraphVisualizer 1. It throws exception if file can't be created 2. It escapes chars in filename 3. If literals can't be accessed, it generates a name for the node by default
  Adds test to check behaviour of graph builder on stack underflow
  Fixes the correct order of arguments for EXPECT_*
  Fixes segfault in stack_semantics
  Removes check whether branch should jump on branches
  Adds tests for duplicate opcode
  Fixes TSmalltalkInstruction::isValueProvider (primitives provide values)
  Fixes test for TSmalltalkInstruction (primitives are value providers)
  Fixes TSmalltalkInstruction::isValueConsumer (selfReturn doesn't consume value)
  Fixes test for TSmalltalkInstruction (selfReturn doesn't consume value)
  Adds tests which checks whether branches jump not on terminators
  Adds test to check whether instructions linked with value providers
  Adds newline at EOF in ParsedBytecode.cpp
  Adds fixes after rebase
  Removes stringstream(to format message) from tests
  ...

Conflicts:
	CMakeLists.txt
	image/imageSource.st
	tests/CMakeLists.txt

Issue: #32
0x7CFE added a commit that referenced this issue Apr 12, 2015
* feature/32/codegen_into_ir_func:
  Forces IR functions to be inlined
  Rewrites doAssignInstance with `@setInstanceInContext'
  Rewrites doAssignInstance using cached `@getObjectFieldPtr'
  Fixes using of `@getTempsFromContext'
  Rewrites primitive::arrayAtPut using cached `@getObjectFieldPtr'
  Rewrites doPushInstance using cached `@getInstanceFromContext'
  Rewrites doPushArgument using cached `@getArgFromContext'
  Rewrites doPushLiteral using TJITContext::getLiteral
  Rewrites TJITContext::getLiteral using cached `@getLiteralFromContext'
  Rewrites doAssignTemporary with `@setTemporaryInContext'
  Rewrites doPushArgument with `@getTemporaryFromContext'
  Adds function to_string to format names of llvm values
  Removes extra space in `@setObjectField'
  Rewrites `@getObjectFields' using `@getObjectFieldPtr'

Issue: #32
@0x7CFE
Copy link
Owner Author

0x7CFE commented Apr 19, 2015

In order to increase granularity and maitainability, remaining tasks from the list should be processed in separate tasks.

Among them, base functionality is considered to be working.

@0x7CFE 0x7CFE closed this as completed Apr 19, 2015
0x7CFE added a commit that referenced this issue May 2, 2015
0x7CFE added a commit that referenced this issue May 2, 2015
0x7CFE added a commit that referenced this issue Apr 18, 2016
0x7CFE added a commit that referenced this issue Apr 18, 2016
0x7CFE added a commit that referenced this issue Apr 22, 2016
Also branch optimization technique is proposed,
however it is currently lead to a malformed graph

Issue: #32
0x7CFE added a commit that referenced this issue Apr 22, 2016
0x7CFE added a commit that referenced this issue Apr 24, 2016
0x7CFE added a commit that referenced this issue Apr 24, 2016
Also branch optimization technique is proposed,
however it is currently lead to a malformed graph

Issue: #32
0x7CFE added a commit that referenced this issue Apr 24, 2016
0x7CFE added a commit that referenced this issue Apr 24, 2016
0x7CFE added a commit that referenced this issue Apr 24, 2016
0x7CFE added a commit that referenced this issue May 21, 2016
0x7CFE added a commit that referenced this issue May 21, 2016
0x7CFE added a commit that referenced this issue May 21, 2016
Also branch optimization technique is proposed,
however it is currently lead to a malformed graph

Issue: #32
0x7CFE added a commit that referenced this issue May 21, 2016
0x7CFE added a commit that referenced this issue Jun 18, 2016
…to develop

* origin/feature/32/fast_block_return:
  Fixes constness and indentation in MethodCompiler and soft VM
  Adds logic to support MRV ABI
  Implements call propagation method of block return
  Removes usage of Opts.JITExceptionHandling
  Uses llvm-3.4

Issue: #32
0x7CFE added a commit that referenced this issue Jun 18, 2016
Also branch optimization technique is proposed,
however it is currently lead to a malformed graph

Issue: #32
0x7CFE added a commit that referenced this issue Jun 18, 2016
0x7CFE added a commit that referenced this issue Jun 18, 2016
Also branch optimization technique is proposed,
however it is currently lead to a malformed graph

Issue: #32
0x7CFE added a commit that referenced this issue Jun 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants