hotspot/src/share/vm/interpreter/interpreter.hpp
changeset 25715 d5a8dbdc5150
parent 22234 da823d78ad65
child 26432 9b974e2eae27
equal deleted inserted replaced
25469:3bcfa1db9717 25715:d5a8dbdc5150
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    34 #endif
    34 #endif
    35 #endif
    35 #endif
    36 
    36 
    37 // This file contains the platform-independent parts
    37 // This file contains the platform-independent parts
    38 // of the interpreter and the interpreter generator.
    38 // of the interpreter and the interpreter generator.
       
    39 
       
    40 class InterpreterMacroAssembler;
    39 
    41 
    40 //------------------------------------------------------------------------------------------------------------------------
    42 //------------------------------------------------------------------------------------------------------------------------
    41 // An InterpreterCodelet is a piece of interpreter code. All
    43 // An InterpreterCodelet is a piece of interpreter code. All
    42 // interpreter code is generated into little codelets which
    44 // interpreter code is generated into little codelets which
    43 // contain extra information for debugging and printing purposes.
    45 // contain extra information for debugging and printing purposes.
    97     // Request the whole code buffer (minus a little for alignment).
    99     // Request the whole code buffer (minus a little for alignment).
    98     // The commit call below trims it back for each codelet.
   100     // The commit call below trims it back for each codelet.
    99     int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
   101     int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
   100 
   102 
   101     // Guarantee there's a little bit of code space left.
   103     // Guarantee there's a little bit of code space left.
   102     guarantee (codelet_size > 0 && (size_t)codelet_size >  2*K,
   104     guarantee(codelet_size > 0 && (size_t)codelet_size > 2*K,
   103                "not enough space for interpreter generation");
   105               "not enough space for interpreter generation");
   104 
   106 
   105     return codelet_size;
   107     return codelet_size;
   106   }
   108   }
   107 
   109 
   108  public:
   110  public:
   109   CodeletMark(
   111   CodeletMark(InterpreterMacroAssembler*& masm,
   110     InterpreterMacroAssembler*& masm,
   112               const char* description,
   111     const char* description,
   113               Bytecodes::Code bytecode = Bytecodes::_illegal);
   112     Bytecodes::Code bytecode = Bytecodes::_illegal):
   114   ~CodeletMark();
   113     _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())),
       
   114     _cb(_clet->code_begin(), _clet->code_size())
       
   115 
       
   116   { // request all space (add some slack for Codelet data)
       
   117     assert (_clet != NULL, "we checked not enough space already");
       
   118 
       
   119     // initialize Codelet attributes
       
   120     _clet->initialize(description, bytecode);
       
   121     // create assembler for code generation
       
   122     masm  = new InterpreterMacroAssembler(&_cb);
       
   123     _masm = &masm;
       
   124   }
       
   125 
       
   126   ~CodeletMark() {
       
   127     // align so printing shows nop's instead of random code at the end (Codelets are aligned)
       
   128     (*_masm)->align(wordSize);
       
   129     // make sure all code is in code buffer
       
   130     (*_masm)->flush();
       
   131 
       
   132 
       
   133     // commit Codelet
       
   134     AbstractInterpreter::code()->commit((*_masm)->code()->pure_insts_size(), (*_masm)->code()->strings());
       
   135     // make sure nobody can use _masm outside a CodeletMark lifespan
       
   136     *_masm = NULL;
       
   137   }
       
   138 };
   115 };
   139 
   116 
   140 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
   117 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
   141 // the c++ interpreter or the template interpreter.
   118 // the c++ interpreter or the template interpreter.
   142 
   119 
   143 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
   120 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
   144 
   121 
   145   public:
   122  public:
   146   // Debugging/printing
   123   // Debugging/printing
   147   static InterpreterCodelet* codelet_containing(address pc)     { return (InterpreterCodelet*)_code->stub_containing(pc); }
   124   static InterpreterCodelet* codelet_containing(address pc) { return (InterpreterCodelet*)_code->stub_containing(pc); }
       
   125 
   148 #ifdef TARGET_ARCH_x86
   126 #ifdef TARGET_ARCH_x86
   149 # include "interpreter_x86.hpp"
   127 # include "interpreter_x86.hpp"
   150 #endif
   128 #endif
   151 #ifdef TARGET_ARCH_sparc
   129 #ifdef TARGET_ARCH_sparc
   152 # include "interpreter_sparc.hpp"
   130 # include "interpreter_sparc.hpp"