Skip to content

Commit

Permalink
Showing 4 changed files with 2,090 additions and 103 deletions.
6 changes: 4 additions & 2 deletions machine/test/test.hpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ class VMTest {
Configuration config;


void setup_call_frame(CallFrame* cf, int size) {
void setup_call_frame(CallFrame* cf, StackVariables* scope, int size) {
scope->initialize(cNil, cNil, Module::create(state), 0);

cf->prepare(size);
cf->stack_ptr_ = cf->stk - 1;
cf->previous = NULL;
@@ -34,7 +36,7 @@ class VMTest {
cf->compiled_code = nil<CompiledCode>();
cf->flags = 0;
cf->top_scope_ = NULL;
cf->scope = NULL;
cf->scope = scope;
cf->arguments = NULL;
}

297 changes: 196 additions & 101 deletions machine/test/test_instructions.hpp

Large diffs are not rendered by default.

1,840 changes: 1,840 additions & 0 deletions machine/test/test_interpreter.hpp

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions rakelib/instruction_parser.rb
Original file line number Diff line number Diff line change
@@ -859,6 +859,56 @@ def generate_prototypes(filename)
end
end

def generate_interpreter_tests(filename)
insns = objects.select { |x| x.kind_of? Instruction }
File.open filename, "wb" do |file|
file.puts <<-EOD
\#include "machine/test/test.hpp"
\#include "call_frame.hpp"
\#include "object_utils.hpp"
\#include "interpreter.hpp"
class TestInterpreter : public CxxTest::TestSuite, public VMTest {
public:
void setUp() {
create();
}
void tearDown() {
destroy();
}
EOD

insns.each do |obj|
file.puts <<-EOD
void test_interpreter_#{obj.name}() {
CallFrame* call_frame = ALLOCA_CALL_FRAME(1);
StackVariables* scope = ALLOCA_STACKVARIABLES(0);
setup_call_frame(call_frame, scope, 1);
intptr_t opcodes[#{obj.arguments.size+2}];
opcodes[0] =
reinterpret_cast<intptr_t>(instructions::data_#{obj.name}.interpreter_address);#{obj.arguments.map.with_index { |x, i| "\n opcodes[#{i+1}] = 0; // #{x}" }.join}
opcodes[#{obj.arguments.size+1}] =
reinterpret_cast<intptr_t>(instructions::data_ret.interpreter_address);
// TODO: instructions
// interpreter::#{obj.name}(state, call_frame, opcodes);
TS_ASSERT(true);
// TS_ASSERT_EQUALS(call_frame->ip(), instructions::data_#{obj.name}.width);
}
EOD
end

file.puts "};"
end
end

def generate_instruction_data(filename)
File.open filename, "wb" do |file|
file.puts '#ifndef RBX_INSTRUCTIONS_DATA_HPP'

0 comments on commit d403e49

Please sign in to comment.