Skip to content

Commit 5676194

Browse files
committed
Fixed BytecodeVerifier for CompiledCode#literals change.
1 parent ec57d31 commit 5676194

File tree

7 files changed

+409
-390
lines changed

7 files changed

+409
-390
lines changed

machine/builtin/compiled_code.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "arguments.hpp"
2-
#include "bytecode_verification.hpp"
2+
#include "bytecode_verifier.hpp"
33
#include "call_frame.hpp"
44
#include "configuration.hpp"
55
#include "instruments/timing.hpp"
@@ -112,9 +112,7 @@ namespace rubinius {
112112
return as<Fixnum>(lines()->at(fin+1))->to_native();
113113
}
114114

115-
MachineCode* CompiledCode::internalize(STATE,
116-
const char** reason, int* ip)
117-
{
115+
MachineCode* CompiledCode::internalize(STATE) {
118116
MachineCode* mcode = machine_code();
119117

120118
atomic::memory_barrier();
@@ -129,13 +127,8 @@ namespace rubinius {
129127
mcode = self->machine_code();
130128
if(!mcode) {
131129
{
132-
BytecodeVerification bv(self);
133-
if(!bv.verify(state)) {
134-
if(reason) *reason = bv.failure_reason();
135-
if(ip) *ip = bv.failure_ip();
136-
std::cerr << "Error validating bytecode: " << bv.failure_reason() << "\n";
137-
return 0;
138-
}
130+
BytecodeVerifier bytecode_verifier(self);
131+
bytecode_verifier.verify(state);
139132
}
140133

141134
mcode = new MachineCode(state, self);
@@ -197,18 +190,12 @@ namespace rubinius {
197190
{
198191
CompiledCode* code = as<CompiledCode>(exec);
199192
if(code->execute == default_executor) {
200-
const char* reason = 0;
201-
int ip = -1;
202-
203193
OnStack<5> os(state, code, exec, mod, args.recv_location(), args.block_location());
204194

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

208-
if(!code->internalize(state, &reason, &ip)) {
209-
Exception::bytecode_error(state, code, ip, reason);
210-
return 0;
211-
}
198+
if(!code->internalize(state)) return 0;
212199
}
213200

214201
return code->execute(state, exec, mod, args);

machine/builtin/compiled_code.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace rubinius {
103103

104104
void post_marshal(STATE);
105105
size_t number_of_locals();
106-
MachineCode* internalize(STATE, const char** failure_reason=0, int* ip=0);
106+
MachineCode* internalize(STATE);
107107
void specialize(STATE, TypeInfo* ti);
108108

109109
static Object* default_executor(STATE, Executable* exec, Module* mod, Arguments& args);

machine/builtin/system.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,7 @@ namespace rubinius {
12541254
if(Class* cls = try_as<Class>(mod)) {
12551255
OnStack<5> o2(state, mod, cc, scope, vis, cls);
12561256

1257-
if(!cc->internalize(state)) {
1258-
Exception::raise_argument_error(state, "invalid bytecode method");
1259-
return 0;
1260-
}
1257+
if(!cc->internalize(state)) return 0;
12611258

12621259
object_type type = (object_type)cls->instance_type()->to_native();
12631260
TypeInfo* ti = state->memory()->type_info[type];

machine/bytecode_verification.cpp

Lines changed: 0 additions & 309 deletions
This file was deleted.

0 commit comments

Comments
 (0)