src/share/vm/interpreter/interpreter.hpp

Fri, 27 Feb 2009 13:27:09 -0800

author
twisti
date
Fri, 27 Feb 2009 13:27:09 -0800
changeset 1040
98cb887364d3
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never

duke@435 1 /*
duke@435 2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
twisti@1040 25 // This file contains the platform-independent parts
duke@435 26 // of the interpreter and the interpreter generator.
duke@435 27
duke@435 28 //------------------------------------------------------------------------------------------------------------------------
duke@435 29 // An InterpreterCodelet is a piece of interpreter code. All
duke@435 30 // interpreter code is generated into little codelets which
duke@435 31 // contain extra information for debugging and printing purposes.
duke@435 32
duke@435 33 class InterpreterCodelet: public Stub {
duke@435 34 friend class VMStructs;
duke@435 35 private:
duke@435 36 int _size; // the size in bytes
duke@435 37 const char* _description; // a description of the codelet, for debugging & printing
duke@435 38 Bytecodes::Code _bytecode; // associated bytecode if any
duke@435 39
duke@435 40 public:
duke@435 41 // Initialization/finalization
duke@435 42 void initialize(int size) { _size = size; }
duke@435 43 void finalize() { ShouldNotCallThis(); }
duke@435 44
duke@435 45 // General info/converters
duke@435 46 int size() const { return _size; }
duke@435 47 static int code_size_to_size(int code_size) { return round_to(sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; }
duke@435 48
duke@435 49 // Code info
duke@435 50 address code_begin() const { return (address)this + round_to(sizeof(InterpreterCodelet), CodeEntryAlignment); }
duke@435 51 address code_end() const { return (address)this + size(); }
duke@435 52
duke@435 53 // Debugging
duke@435 54 void verify();
duke@435 55 void print();
duke@435 56
duke@435 57 // Interpreter-specific initialization
duke@435 58 void initialize(const char* description, Bytecodes::Code bytecode);
duke@435 59
duke@435 60 // Interpreter-specific attributes
duke@435 61 int code_size() const { return code_end() - code_begin(); }
duke@435 62 const char* description() const { return _description; }
duke@435 63 Bytecodes::Code bytecode() const { return _bytecode; }
duke@435 64 };
duke@435 65
duke@435 66 // Define a prototype interface
duke@435 67 DEF_STUB_INTERFACE(InterpreterCodelet);
duke@435 68
duke@435 69
duke@435 70 //------------------------------------------------------------------------------------------------------------------------
duke@435 71 // A CodeletMark serves as an automatic creator/initializer for Codelets
duke@435 72 // (As a subclass of ResourceMark it automatically GC's the allocated
duke@435 73 // code buffer and assemblers).
duke@435 74
duke@435 75 class CodeletMark: ResourceMark {
duke@435 76 private:
duke@435 77 InterpreterCodelet* _clet;
duke@435 78 InterpreterMacroAssembler** _masm;
duke@435 79 CodeBuffer _cb;
duke@435 80
duke@435 81 int codelet_size() {
duke@435 82 // Request the whole code buffer (minus a little for alignment).
duke@435 83 // The commit call below trims it back for each codelet.
duke@435 84 int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
duke@435 85
duke@435 86 // Guarantee there's a little bit of code space left.
duke@435 87 guarantee (codelet_size > 0 && (size_t)codelet_size > 2*K,
duke@435 88 "not enough space for interpreter generation");
duke@435 89
duke@435 90 return codelet_size;
duke@435 91 }
duke@435 92
duke@435 93 public:
duke@435 94 CodeletMark(
duke@435 95 InterpreterMacroAssembler*& masm,
duke@435 96 const char* description,
duke@435 97 Bytecodes::Code bytecode = Bytecodes::_illegal):
duke@435 98 _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())),
duke@435 99 _cb(_clet->code_begin(), _clet->code_size())
duke@435 100
duke@435 101 { // request all space (add some slack for Codelet data)
duke@435 102 assert (_clet != NULL, "we checked not enough space already");
duke@435 103
duke@435 104 // initialize Codelet attributes
duke@435 105 _clet->initialize(description, bytecode);
duke@435 106 // create assembler for code generation
duke@435 107 masm = new InterpreterMacroAssembler(&_cb);
duke@435 108 _masm = &masm;
duke@435 109 }
duke@435 110
duke@435 111 ~CodeletMark() {
duke@435 112 // align so printing shows nop's instead of random code at the end (Codelets are aligned)
duke@435 113 (*_masm)->align(wordSize);
duke@435 114 // make sure all code is in code buffer
duke@435 115 (*_masm)->flush();
duke@435 116
duke@435 117
duke@435 118 // commit Codelet
duke@435 119 AbstractInterpreter::code()->commit((*_masm)->code()->pure_code_size());
duke@435 120 // make sure nobody can use _masm outside a CodeletMark lifespan
duke@435 121 *_masm = NULL;
duke@435 122 }
duke@435 123 };
duke@435 124
duke@435 125 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
duke@435 126 // the c++ interpreter or the template interpreter.
duke@435 127
duke@435 128 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
duke@435 129
duke@435 130 public:
duke@435 131 // Debugging/printing
duke@435 132 static InterpreterCodelet* codelet_containing(address pc) { return (InterpreterCodelet*)_code->stub_containing(pc); }
duke@435 133 #include "incls/_interpreter_pd.hpp.incl"
duke@435 134 };

mercurial