/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* iexpr.c -- instanced expression cache module
*
* this module provides a cache of fully instantized expressions.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include "alloc.h"
#include "out.h"
#include "lut.h"
#include "tree.h"
#include "ptree.h"
#include "itree.h"
#include "ipath.h"
#include "iexpr.h"
#include "stats.h"
#include "eval.h"
#include "config.h"
/* the cache is a hash table of these structs */
static struct iexpr {
int count;
/*
* iexpr_init -- initialize the iexpr module
*/
void
iexpr_init(void)
{
}
/*
* iexpr_hash -- produce a simple hash from an instanced expression tree
*/
static unsigned
{
return (1);
switch (np->t) {
case T_GLOBID:
case T_ASSIGN:
case T_CONDIF:
case T_CONDELSE:
case T_NE:
case T_EQ:
case T_LT:
case T_LE:
case T_GT:
case T_GE:
case T_BITAND:
case T_BITOR:
case T_BITXOR:
case T_BITNOT:
case T_LSHIFT:
case T_RSHIFT:
case T_LIST:
case T_AND:
case T_OR:
case T_NOT:
case T_ADD:
case T_SUB:
case T_MUL:
case T_DIV:
case T_MOD:
return ((int)np->t *
case T_NAME:
case T_EVENT:
case T_FUNC:
case T_QUOTE:
case T_NUM:
case T_TIMEVAL:
default:
"iexpr_hash: unexpected node type: %s",
ptree_nodetype2str(np->t));
}
/*NOTREACHED*/
return (1);
}
/*
* iexpr_cmp -- compare two instanced expression trees
*/
static int
{
int diff;
return (0);
return (1);
return (-1);
/* types match, need to see additional info matches */
switch (np1->t) {
case T_GLOBID:
case T_ASSIGN:
case T_CONDIF:
case T_CONDELSE:
case T_NE:
case T_EQ:
case T_LT:
case T_LE:
case T_GT:
case T_GE:
case T_BITAND:
case T_BITOR:
case T_BITXOR:
case T_BITNOT:
case T_LSHIFT:
case T_RSHIFT:
case T_LIST:
case T_AND:
case T_OR:
case T_NOT:
case T_ADD:
case T_SUB:
case T_MUL:
case T_DIV:
case T_MOD:
if (diff != 0)
return (diff);
case T_NAME:
if (diff != 0)
return (diff);
case T_EVENT:
if (diff != 0)
return (diff);
case T_FUNC:
case T_QUOTE:
case T_NUM:
case T_TIMEVAL:
return (1);
return (-1);
else
return (0);
default:
"iexpr_cmp: unexpected node type: %s",
ptree_nodetype2str(np1->t));
}
/*NOTREACHED*/
return (0);
}
/*
* iexpr -- find instanced expr in cache, or add it if necessary
*/
struct node *
{
/* search cache */
/* found it */
}
/* allocate new cache entry */
return (np);
}
void
{
/* search cache */
/* found it */
else
}
return;
}
}
}
/*
* iexpr_cached -- return true if np is in the iexpr cache
*/
int
{
/* search cache */
/* found it */
return (1);
}
return (0);
}
/*
* iexpr_fini -- free the iexpr cache
*/
void
iexpr_fini(void)
{
int i;
for (i = 0; i < IEXPRSZ; i++) {
}
}
}