src/share/vm/classfile/classFileStream.cpp

Tue, 02 Apr 2013 11:28:33 +0200

author
mgerdin
date
Tue, 02 Apr 2013 11:28:33 +0200
changeset 4850
ede380e13960
parent 4398
ade95d680b42
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8009763: Add WB test for String.intern()
Summary: Add convenience method in StringTable, add WhiteBox method and simple sanity test
Reviewed-by: mgerdin, zgu
Contributed-by: leonid.mesnik@oracle.com

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/classFileStream.hpp"
stefank@2314 27 #include "classfile/vmSymbols.hpp"
duke@435 28
duke@435 29 void ClassFileStream::truncated_file_error(TRAPS) {
duke@435 30 THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Truncated class file");
duke@435 31 }
duke@435 32
duke@435 33 ClassFileStream::ClassFileStream(u1* buffer, int length, char* source) {
duke@435 34 _buffer_start = buffer;
duke@435 35 _buffer_end = buffer + length;
duke@435 36 _current = buffer;
duke@435 37 _source = source;
duke@435 38 _need_verify = false;
duke@435 39 }
duke@435 40
duke@435 41 u1 ClassFileStream::get_u1(TRAPS) {
duke@435 42 if (_need_verify) {
duke@435 43 guarantee_more(1, CHECK_0);
duke@435 44 } else {
duke@435 45 assert(1 <= _buffer_end - _current, "buffer overflow");
duke@435 46 }
duke@435 47 return *_current++;
duke@435 48 }
duke@435 49
duke@435 50 u2 ClassFileStream::get_u2(TRAPS) {
duke@435 51 if (_need_verify) {
duke@435 52 guarantee_more(2, CHECK_0);
duke@435 53 } else {
duke@435 54 assert(2 <= _buffer_end - _current, "buffer overflow");
duke@435 55 }
duke@435 56 u1* tmp = _current;
duke@435 57 _current += 2;
duke@435 58 return Bytes::get_Java_u2(tmp);
duke@435 59 }
duke@435 60
duke@435 61 u4 ClassFileStream::get_u4(TRAPS) {
duke@435 62 if (_need_verify) {
duke@435 63 guarantee_more(4, CHECK_0);
duke@435 64 } else {
duke@435 65 assert(4 <= _buffer_end - _current, "buffer overflow");
duke@435 66 }
duke@435 67 u1* tmp = _current;
duke@435 68 _current += 4;
duke@435 69 return Bytes::get_Java_u4(tmp);
duke@435 70 }
duke@435 71
duke@435 72 u8 ClassFileStream::get_u8(TRAPS) {
duke@435 73 if (_need_verify) {
duke@435 74 guarantee_more(8, CHECK_0);
duke@435 75 } else {
duke@435 76 assert(8 <= _buffer_end - _current, "buffer overflow");
duke@435 77 }
duke@435 78 u1* tmp = _current;
duke@435 79 _current += 8;
duke@435 80 return Bytes::get_Java_u8(tmp);
duke@435 81 }
duke@435 82
duke@435 83 void ClassFileStream::skip_u1(int length, TRAPS) {
duke@435 84 if (_need_verify) {
duke@435 85 guarantee_more(length, CHECK);
duke@435 86 }
duke@435 87 _current += length;
duke@435 88 }
duke@435 89
duke@435 90 void ClassFileStream::skip_u2(int length, TRAPS) {
duke@435 91 if (_need_verify) {
duke@435 92 guarantee_more(length * 2, CHECK);
duke@435 93 }
duke@435 94 _current += length * 2;
duke@435 95 }
coleenp@4398 96
coleenp@4398 97 void ClassFileStream::skip_u4(int length, TRAPS) {
coleenp@4398 98 if (_need_verify) {
coleenp@4398 99 guarantee_more(length * 4, CHECK);
coleenp@4398 100 }
coleenp@4398 101 _current += length * 4;
coleenp@4398 102 }

mercurial