Fix exception handling in masm backend
authorSimon Hausmann <simon.hausmann@digia.com>
Sun, 20 Jan 2013 19:38:35 +0000 (20:38 +0100)
committerLars Knoll <lars.knoll@digia.com>
Sun, 20 Jan 2013 21:19:08 +0000 (22:19 +0100)
The return value of setjmp is an int, which we interpret as a boolean later. We
cannot put it directly into a VM::Value, because it isn't one. Instead we have
to store it properly with value and tag.

This worked by "accident" on x86-64 where the return value is in eax and not
clobbered until we do the type test. But on ia32 we do rely on a proper value
representation.

Change-Id: Id54072c31baf6ad4607626dad939c715d2092d3d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qv4isel_masm.cpp

index 73a8c62..29bd3ec 100644 (file)
@@ -486,7 +486,11 @@ void InstructionSelection::callBuiltinRethrow()
 void InstructionSelection::callBuiltinCreateExceptionHandler(IR::Temp *result)
 {
     generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_create_exception_handler, Assembler::ContextRegister);
-    generateFunctionCall(result, setjmp, Assembler::ReturnValueRegister);
+    generateFunctionCall(Assembler::ReturnValueRegister, setjmp, Assembler::ReturnValueRegister);
+    Address addr = _asm->loadTempAddress(Assembler::ScratchRegister, result);
+    _asm->store32(Assembler::ReturnValueRegister, addr);
+    addr.offset += 4;
+    _asm->store32(Assembler::TrustedImm32(Value::Boolean_Type), addr);
 }
 
 void InstructionSelection::callBuiltinDeleteExceptionHandler()