Skip to content

Commit

Permalink
java: remove code_size argument from execute()
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Oct 9, 2020
1 parent 57bbfb5 commit 602575e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions bindings/java/c/evmc-vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ JNIEXPORT void JNICALL Java_org_ethereum_evmc_EvmcVm_execute(JNIEnv* jenv,
jint jrev,
jobject jmsg,
jobject jcode,
jint jcode_size,
jobject jresult)
{
(void)jcls;
struct evmc_message* msg = (struct evmc_message*)(*jenv)->GetDirectBufferAddress(jenv, jmsg);
assert(msg != NULL);
size_t code_size = (size_t)(*jenv)->GetDirectBufferCapacity(jenv, jcode);
const uint8_t* code = (uint8_t*)(*jenv)->GetDirectBufferAddress(jenv, jcode);
assert(code != NULL);
struct evmc_host_context context = {jcontext_index};
Expand All @@ -105,8 +105,7 @@ JNIEXPORT void JNICALL Java_org_ethereum_evmc_EvmcVm_execute(JNIEnv* jenv,
struct evmc_result* result =
(struct evmc_result*)(*jenv)->GetDirectBufferAddress(jenv, jresult);
assert(result != NULL);
*result =
evmc_execute(evm, host, &context, (enum evmc_revision)jrev, msg, code, (size_t)jcode_size);
*result = evmc_execute(evm, host, &context, (enum evmc_revision)jrev, msg, code, code_size);
}

JNIEXPORT jint JNICALL Java_org_ethereum_evmc_EvmcVm_get_1capabilities(JNIEnv* jenv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ native void execute(
int rev,
ByteBuffer msg,
ByteBuffer code,
int size,
ByteBuffer result);

/**
Expand All @@ -114,11 +113,11 @@ native void execute(
* <p>This allows the context to managed in one method
*/
public synchronized ByteBuffer execute(
HostContext context, int rev, ByteBuffer msg, ByteBuffer code, int size) {
HostContext context, int rev, ByteBuffer msg, ByteBuffer code) {
int context_index = addContext(context);
int resultSize = get_result_size();
ByteBuffer result = ByteBuffer.allocateDirect(resultSize);
execute(nativeVm, context_index, rev, msg, code, size, result);
execute(nativeVm, context_index, rev, msg, code, result);
removeContext(context_index);
return result;
}
Expand Down
12 changes: 6 additions & 6 deletions bindings/java/java/src/test/java/org/ethereum/evmc/EvmcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void testExecute_returnAddress() throws Exception {
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
vm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
vm.execute(context, BYZANTIUM, msg, bbcode).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
Expand Down Expand Up @@ -96,7 +96,7 @@ void testExecute_counter() throws Exception {
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
vm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
vm.execute(context, BYZANTIUM, msg, bbcode).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
Expand Down Expand Up @@ -126,7 +126,7 @@ void testExecute_returnBlockNumber() throws Exception {
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
vm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
vm.execute(context, BYZANTIUM, msg, bbcode).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
Expand Down Expand Up @@ -158,7 +158,7 @@ void testExecute_saveReturnBlockNumber() throws Exception {
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
vm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
vm.execute(context, BYZANTIUM, msg, bbcode).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
Expand Down Expand Up @@ -197,7 +197,7 @@ void testExecute_makeCall() throws Exception {
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
vm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
vm.execute(context, BYZANTIUM, msg, bbcode).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
Expand Down Expand Up @@ -225,7 +225,7 @@ void testExecute_EVMC_CREATE() throws Exception {
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
vm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
vm.execute(context, BYZANTIUM, msg, bbcode).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
Expand Down

0 comments on commit 602575e

Please sign in to comment.