Skip to content

Commit

Permalink
Fixed BytecodeVerifier for CompiledCode#literals change.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Apr 8, 2016
1 parent ec57d31 commit 5676194
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 390 deletions.
23 changes: 5 additions & 18 deletions machine/builtin/compiled_code.cpp
@@ -1,5 +1,5 @@
#include "arguments.hpp"
#include "bytecode_verification.hpp"
#include "bytecode_verifier.hpp"
#include "call_frame.hpp"
#include "configuration.hpp"
#include "instruments/timing.hpp"
Expand Down Expand Up @@ -112,9 +112,7 @@ namespace rubinius {
return as<Fixnum>(lines()->at(fin+1))->to_native();
}

MachineCode* CompiledCode::internalize(STATE,
const char** reason, int* ip)
{
MachineCode* CompiledCode::internalize(STATE) {
MachineCode* mcode = machine_code();

atomic::memory_barrier();
Expand All @@ -129,13 +127,8 @@ namespace rubinius {
mcode = self->machine_code();
if(!mcode) {
{
BytecodeVerification bv(self);
if(!bv.verify(state)) {
if(reason) *reason = bv.failure_reason();
if(ip) *ip = bv.failure_ip();
std::cerr << "Error validating bytecode: " << bv.failure_reason() << "\n";
return 0;
}
BytecodeVerifier bytecode_verifier(self);
bytecode_verifier.verify(state);
}

mcode = new MachineCode(state, self);
Expand Down Expand Up @@ -197,18 +190,12 @@ namespace rubinius {
{
CompiledCode* code = as<CompiledCode>(exec);
if(code->execute == default_executor) {
const char* reason = 0;
int ip = -1;

OnStack<5> os(state, code, exec, mod, args.recv_location(), args.block_location());

memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
&args.arguments_location(), args.total());

if(!code->internalize(state, &reason, &ip)) {
Exception::bytecode_error(state, code, ip, reason);
return 0;
}
if(!code->internalize(state)) return 0;
}

return code->execute(state, exec, mod, args);
Expand Down
2 changes: 1 addition & 1 deletion machine/builtin/compiled_code.hpp
Expand Up @@ -103,7 +103,7 @@ namespace rubinius {

void post_marshal(STATE);
size_t number_of_locals();
MachineCode* internalize(STATE, const char** failure_reason=0, int* ip=0);
MachineCode* internalize(STATE);
void specialize(STATE, TypeInfo* ti);

static Object* default_executor(STATE, Executable* exec, Module* mod, Arguments& args);
Expand Down
5 changes: 1 addition & 4 deletions machine/builtin/system.cpp
Expand Up @@ -1254,10 +1254,7 @@ namespace rubinius {
if(Class* cls = try_as<Class>(mod)) {
OnStack<5> o2(state, mod, cc, scope, vis, cls);

if(!cc->internalize(state)) {
Exception::raise_argument_error(state, "invalid bytecode method");
return 0;
}
if(!cc->internalize(state)) return 0;

object_type type = (object_type)cls->instance_type()->to_native();
TypeInfo* ti = state->memory()->type_info[type];
Expand Down
309 changes: 0 additions & 309 deletions machine/bytecode_verification.cpp

This file was deleted.

0 comments on commit 5676194

Please sign in to comment.