Path: blob/master/runtime/compiler/x/i386/codegen/J9CodeGenerator.cpp
6004 views
/*******************************************************************************1* Copyright (c) 2000, 2020 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#include "codegen/CodeGenerator.hpp"23#include "codegen/CodeGenerator_inlines.hpp"24#include "codegen/X86PrivateLinkage.hpp"25#include "compile/Compilation.hpp"26#include "x/codegen/X86HelperLinkage.hpp"27#include "codegen/IA32PrivateLinkage.hpp"28#include "codegen/IA32J9SystemLinkage.hpp"29#include "codegen/IA32JNILinkage.hpp"30#include "codegen/Linkage_inlines.hpp"31#include "il/Node_inlines.hpp"3233void34J9::X86::I386::CodeGenerator::initialize()35{36self()->J9::X86::CodeGenerator::initialize();37}383940TR::Linkage *41J9::X86::I386::CodeGenerator::createLinkage(TR_LinkageConventions lc)42{43TR::Compilation *comp = self()->comp();44TR::Linkage *linkage = NULL;4546switch (lc)47{48case TR_CHelper:49linkage = new (self()->trHeapMemory()) J9::X86::HelperLinkage(self());50break;51case TR_Helper:52case TR_Private:53{54J9::X86::PrivateLinkage *p = NULL;55p = new (self()->trHeapMemory()) J9::X86::I386::PrivateLinkage(self());56p->IPicParameters.roundedSizeOfSlot = 6+2+5+2+1;57p->IPicParameters.defaultNumberOfSlots = 2;58p->IPicParameters.defaultSlotAddress = -1;59p->VPicParameters.roundedSizeOfSlot = 6+2+5+2+1;60p->VPicParameters.defaultNumberOfSlots = 1;61p->VPicParameters.defaultSlotAddress = -1;62linkage = p;63}64break;6566case TR_J9JNILinkage:67if (comp->target().isWindows() || comp->target().isLinux())68{69linkage = new (self()->trHeapMemory()) J9::X86::I386::JNILinkage(self());70}71else72{73TR_ASSERT(0, "linkage not supported: %d\n", lc);74linkage = NULL;75}76break;7778case TR_System:79if (comp->target().isWindows() || comp->target().isLinux())80{81linkage = new (self()->trHeapMemory()) TR::IA32J9SystemLinkage(self());82}83else84{85TR_ASSERT(0, "linkage not supported: %d\n", lc);86linkage = NULL;87}88break;8990default :91TR_ASSERT(0, "\nTestarossa error: Illegal linkage convention %d\n", lc);92}9394self()->setLinkage(lc, linkage);95return linkage;96}979899void100J9::X86::I386::CodeGenerator::lowerTreesPreTreeTopVisit(TR::TreeTop *tt, vcount_t visitCount)101{102J9::X86::CodeGenerator::lowerTreesPreTreeTopVisit(tt, visitCount);103104TR::Node *node = tt->getNode();105106// On IA32 there are a reduced number of registers available on system107// linkage dispatch sequences, so some kinds of expressions can't be108// evaluated at that point. We must extract them into their own treetops109// to satisfy the required register dependencies.110//111if (node->getOpCodeValue() == TR::treetop)112{113TR::Node *child = node->getFirstChild();114115if ((child->getOpCode().isCall() && child->getSymbol()->getMethodSymbol() &&116(child->isPreparedForDirectJNI() ||117child->getSymbol()->getMethodSymbol()->isSystemLinkageDispatch())))118{119self()->setRemoveRegisterHogsInLowerTreesWalk();120}121}122123}124125126void127J9::X86::I386::CodeGenerator::lowerTreesPostTreeTopVisit(TR::TreeTop *tt, vcount_t visitCount)128{129J9::X86::CodeGenerator::lowerTreesPostTreeTopVisit(tt, visitCount);130131TR::Node *node = tt->getNode();132133// On IA32 there are a reduced number of registers available on system134// linkage dispatch sequences, so some kinds of expressions can't be135// evaluated at that point. We must extract them into their own treetops136// to satisfy the required register dependencies.137//138if (node->getOpCodeValue() == TR::treetop)139{140TR::Node *child = node->getFirstChild();141142if ((child->getOpCode().isCall() && child->getSymbol()->getMethodSymbol() &&143(child->isPreparedForDirectJNI() ||144child->getSymbol()->getMethodSymbol()->isSystemLinkageDispatch())))145{146self()->resetRemoveRegisterHogsInLowerTreesWalk();147}148}149150}151152153void154J9::X86::I386::CodeGenerator::lowerTreesPreChildrenVisit(TR::Node * parent, TR::TreeTop * treeTop, vcount_t visitCount)155{156J9::X86::CodeGenerator::lowerTreesPreChildrenVisit(parent, treeTop, visitCount);157158}159160161void162J9::X86::I386::CodeGenerator::lowerTreesPostChildrenVisit(TR::Node * parent, TR::TreeTop * treeTop, vcount_t visitCount)163{164J9::X86::CodeGenerator::lowerTreesPostChildrenVisit(parent, treeTop, visitCount);165166}167168169