From 7036a876788ebaeae90222b564d58928eca1a563 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 9 Sep 2014 17:36:33 +0300 Subject: [PATCH] fix the address for calls to jump past the method object header --- lib/arm/call_instruction.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/arm/call_instruction.rb b/lib/arm/call_instruction.rb index 2c017a3a..167684c5 100644 --- a/lib/arm/call_instruction.rb +++ b/lib/arm/call_instruction.rb @@ -35,8 +35,11 @@ module Arm arg = Virtual::IntegerConstant.new( arg ) end if arg.is_a?(Virtual::Block) or arg.is_a?(Virtual::CompiledMethod) - diff = arg.position - 8 - diff -= self.position + #relative addressing for jumps/calls + diff = arg.position - self.position + # but because of the arm "theoretical" 3- stage pipeline, we have to subtract 2 words (fetch/decode) + # But, for methods, this happens to be the size of the object header, so there it balances out, but not blocks + diff -= 8 if arg.is_a?(Virtual::Block) arg = Virtual::IntegerConstant.new(diff) end if (arg.is_a?(Virtual::IntegerConstant))