make_procedure_object.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright (C) 2008, The EROS Group, LLC
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or
00007  * without modification, are permitted provided that the following
00008  * conditions are met:
00009  *
00010  *   - Redistributions of source code must contain the above 
00011  *     copyright notice, this list of conditions, and the following
00012  *     disclaimer. 
00013  *
00014  *   - Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions, and the following
00016  *     disclaimer in the documentation and/or other materials 
00017  *     provided with the distribution.
00018  *
00019  *   - Neither the names of the copyright holders nor the names of any
00020  *     of any contributors may be used to endorse or promote products
00021  *     derived from this software without specific prior written
00022  *     permission. 
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00027  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00028  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00029  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00030  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00031  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00032  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00033  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  **************************************************************************/
00037 
00038 #include <gc/gc.h>
00039 #include <inttypes.h>
00040 #include "BUILD/bitc-runtime.h"
00041 
00062 void *
00063 bitc_emit_procedure_object(void *stubP, void *envP)
00064 {
00065   uint64_t envW = (uint64_t) envP;
00066   uint64_t stubW = (uint64_t) stubP;
00067 
00068   bitc_Procedure* proc = GC_ALLOC(sizeof(bitc_Procedure));
00069 
00070   /* SETHI %hh(stubW), %g4 */
00071   proc->code[0] = 0x09000000u | (stubW >> 42);
00072   /* OR %g4, %hm(stubW), %g4 */
00073   proc->code[1] = 0x88112000u | ((stubW >> 32) & 0x3ffu);
00074   /* SETHI %lm(stubW), %g1 */
00075   proc->code[2] = 0x03000000u | (stubW >> 10) & 0x3fffffu;
00076   /* SLLX %g4, 31, %g4 */
00077   proc->code[3] = 0x89293020u;
00078   /* OR   %g4, %g1, %g1 */
00079   proc->code[4] = 0x82110011u;
00080   /* JMPL %g1 + %lo(stubW), %g1 */
00081   proc->code[5] = 0x83c06000 | (stubW & 0x3ffu);
00082   /* LD   [%g1 + 0xc], %g1 */
00083   proc->code[6] = 0xc200600c;
00084 
00085   proc->env.ptr = envP;
00086 
00087   return proc;
00088 
00089   /* On this architecture, no explicit iCache flush is required as
00090    * long as a branch appears. Return suffices for a branch, which is why
00091    * this must not be an inline procedure. */
00092 }
00093 

Generated on Fri Feb 10 07:59:22 2012 for BitC Runtime Library by  doxygen 1.4.7