From 0d9c973763877502f815fc5723f203fe06441da7 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 31 Aug 2010 15:25:00 +0000 Subject: [PATCH] Exploit OBJECT->FIXNUM's independence of tag on i386 and x86-64. --- src/compiler/machines/i386/rulrew.scm | 10 ++++++++++ src/compiler/machines/x86-64/rulrew.scm | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/compiler/machines/i386/rulrew.scm b/src/compiler/machines/i386/rulrew.scm index 40276c26a..1b2dc8d23 100644 --- a/src/compiler/machines/i386/rulrew.scm +++ b/src/compiler/machines/i386/rulrew.scm @@ -150,6 +150,16 @@ USA. (QUALIFIER (rtl:constant-fixnum? source)) (rtl:make-object->fixnum source)) +(define-rule rewriting + (OBJECT->FIXNUM (REGISTER (? source register-known-value))) + (QUALIFIER (rtl:cons-non-pointer? source)) + (rtl:make-object->fixnum (rtl:cons-non-pointer-datum source))) + +(define-rule rewriting + (OBJECT->FIXNUM (REGISTER (? source register-known-value))) + (QUALIFIER (rtl:object->datum? source)) + (rtl:make-object->fixnum (rtl:object->datum-expression source))) + (define-rule rewriting (FIXNUM-2-ARGS MULTIPLY-FIXNUM (REGISTER (? operand-1 register-known-value)) diff --git a/src/compiler/machines/x86-64/rulrew.scm b/src/compiler/machines/x86-64/rulrew.scm index 8cec290c0..bbe0973ab 100644 --- a/src/compiler/machines/x86-64/rulrew.scm +++ b/src/compiler/machines/x86-64/rulrew.scm @@ -150,6 +150,16 @@ USA. (QUALIFIER (rtl:constant-fixnum? source)) (rtl:make-object->fixnum source)) +(define-rule rewriting + (OBJECT->FIXNUM (REGISTER (? source register-known-value))) + (QUALIFIER (rtl:cons-non-pointer? source)) + (rtl:make-object->fixnum (rtl:cons-non-pointer-datum source))) + +(define-rule rewriting + (OBJECT->FIXNUM (REGISTER (? source register-known-value))) + (QUALIFIER (rtl:object->datum? source)) + (rtl:make-object->fixnum (rtl:object->datum-expression source))) + (define-rule rewriting (FIXNUM-2-ARGS MULTIPLY-FIXNUM (REGISTER (? operand-1 register-known-value)) -- 2.25.1