Expr* PrimInliner::obj_shallowCopy() { // temporary hack, fix when prims have type info // Fix this Robert, 10/24-95, Lars Expr* u = genCall(false); assert(u->isUnknownExpr(), "oops"); return new KlassExpr(parameter(0)->klass(), u->preg(), u->node()); }
Expr* PrimInliner::obj_new() { // replace generic allocation primitive by size-specific primitive, if possible Expr* rcvr = parameter(0); if (!rcvr->isConstantExpr() || !rcvr->constant()->is_klass()) return NULL; Klass* klass = klassOop(rcvr->constant())->klass_part(); // class being instantiated if (klass->oop_is_indexable()) return NULL; // would fail (extremely unlikely) int size = klass->non_indexable_size(); // size in words if (klass->can_inline_allocation()) { // These special compiler primitives only work for memOop klasses int number_of_instance_variables = size - memOopDesc::header_size(); switch (number_of_instance_variables) { case 0: _pdesc = primitives::new0(); break; case 1: _pdesc = primitives::new1(); break; case 2: _pdesc = primitives::new2(); break; case 3: _pdesc = primitives::new3(); break; case 4: _pdesc = primitives::new4(); break; case 5: _pdesc = primitives::new5(); break; case 6: _pdesc = primitives::new6(); break; case 7: _pdesc = primitives::new7(); break; case 8: _pdesc = primitives::new8(); break; case 9: _pdesc = primitives::new9(); break; default: ; // use generic primitives } } Expr* u = genCall(true); return new KlassExpr(klass->as_klassOop(), u->preg(), u->node()); }
void BlockCreateNode::gen() { BasicNode::gen(); if (block()->primFailBlockScope) { // must generate block (in primitive fail branch) assert(!isMemoized(), "shouldn't be memoized"); genCall(); } else if (isMemoized()) { // test if already created theAssembler->Comment("test memoized block"); Location t = genHelper->moveToReg(block(), Temp1); Location t2 = genHelper->loadImmediateOop(deadBlockPR, Temp2, false); theAssembler->SubCCR(t, t2, G0); Label* done = theAssembler->BneForward(false); genCall(); done->define(); } else { // block has already been created (by initial BlockClone node) } }
void PrimInliner::generate() { Expr* res = NULL; if (InlinePrims) { if (ConstantFoldPrims) { res = tryConstantFold(); } if (res == NULL) { res = tryTypeCheck(); } if (res == NULL) { res = tryInline(); } } if (res == NULL) { // primitive has not been constant-folded nor inlined // -> must call primitive at run-time res = genCall(_pdesc->can_fail()); } assert(res, "must have result expr"); _exprStack->pop(_pdesc->number_of_parameters()); // pop parameters _exprStack->push2nd(res, _scope, _bci); // push primitive result }
/* Generate code for a statement (vardecl, assign, funcall, * return, if/elseif/else, or while). */ void genStmt(node *stmtnode, codelabel *next) { switch (stmtnode->internal.type) { case Nvardecl: genVardecl(stmtnode); break; case Nassign: genAssign(stmtnode); break; case Nfuncall: /* later */ genCall(stmtnode); break; case Nreturn: genReturn(stmtnode, next); break; case Nif: case Nelseif: genIf(stmtnode, next); break; case Nelse: genStmtList(stmtnode->internal.child[0], next); break; case Nwhile: genWhile(stmtnode, next); break; default: assert(FALSE); /* should never get here */ } }
static void genFunctions(int tab, int expand, token_t * e1, char *mname, int allowed(), FILE *fp) { int i, n, t; int multiplexed; symentry_t *sym; for (i = 0; i < HSIZE; i++) for (sym = EiC_HTAB[i]; sym; sym = sym->next) { if ((t = EiC_gettype(sym->type)) == t_eic || sym->nspace != tab) continue; if(e1 && e1->Type && ! EiC_sametypes(e1->Type,sym->type)) continue; if(mname && strcmp(mname,sym->fname) != 0) continue; if(allowed && !allowed(t)) continue; n = 1; multiplexed = 0; while (n) { if(DoCallBackNames(EiC_getInf(sym->type),fp)) { int k = 0; if (!multiplexed) { multiplexed = 1; n = MULTIPLEX; } while(k<Ncalls) { genCallBackFunc(sym->type,k++,fp); } } --n; } fputs("static val_t eic_",fp); fputs(sym->id, fp); fputs("(void)\n",fp); fputs("{\n",fp); fputs("\tval_t v;\n",fp); /*fputs("\tstatic int nb = 0;\n",fp);*/ if (multiplexed) { genMultiCall(sym->type, sym->id, fp); } else { genCall(sym->type, sym->id, fp); } fputs("\n",fp); fputs("\treturn v;\n",fp); fputs("}\n\n",fp); } }