annotate src/share/vm/classfile/classFileStream.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children b92c45f2bc75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "utilities/top.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 # include "bytes_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 # include "bytes_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 # include "bytes_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Input stream for reading .class file
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // The entire input stream is present in a buffer allocated by the caller.
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // The caller is responsible for deallocating the buffer and for using
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // ResourceMarks appropriately when constructing streams.
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class ClassFileStream: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 u1* _buffer_start; // Buffer bottom
a61af66fc99e Initial load
duke
parents:
diff changeset
48 u1* _buffer_end; // Buffer top (one past last element)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 u1* _current; // Current buffer position
a61af66fc99e Initial load
duke
parents:
diff changeset
50 char* _source; // Source of stream (directory name, ZIP/JAR archive name)
a61af66fc99e Initial load
duke
parents:
diff changeset
51 bool _need_verify; // True if verification is on for the class file
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 void truncated_file_error(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
56 ClassFileStream(u1* buffer, int length, char* source);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Buffer access
a61af66fc99e Initial load
duke
parents:
diff changeset
59 u1* buffer() const { return _buffer_start; }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 int length() const { return _buffer_end - _buffer_start; }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 u1* current() const { return _current; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 void set_current(u1* pos) { _current = pos; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 char* source() const { return _source; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void set_verify(bool flag) { _need_verify = flag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void check_truncated_file(bool b, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 truncated_file_error(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void guarantee_more(int size, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 size_t remaining = (size_t)(_buffer_end - _current);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 unsigned int usize = (unsigned int)size;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 check_truncated_file(usize > remaining, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Read u1 from stream
a61af66fc99e Initial load
duke
parents:
diff changeset
79 u1 get_u1(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 u1 get_u1_fast() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return *_current++;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Read u2 from stream
a61af66fc99e Initial load
duke
parents:
diff changeset
85 u2 get_u2(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 u2 get_u2_fast() {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 u2 res = Bytes::get_Java_u2(_current);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _current += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Read u4 from stream
a61af66fc99e Initial load
duke
parents:
diff changeset
93 u4 get_u4(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 u4 get_u4_fast() {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 u4 res = Bytes::get_Java_u4(_current);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _current += 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Read u8 from stream
a61af66fc99e Initial load
duke
parents:
diff changeset
101 u8 get_u8(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 u8 get_u8_fast() {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 u8 res = Bytes::get_Java_u8(_current);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _current += 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Get direct pointer into stream at current position.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Returns NULL if length elements are not remaining. The caller is
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // responsible for calling skip below if buffer contents is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 u1* get_u1_buffer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return _current;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 u2* get_u2_buffer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return (u2*) _current;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Skip length u1 or u2 elements from stream
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void skip_u1(int length, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void skip_u1_fast(int length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _current += length;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 void skip_u2(int length, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void skip_u2_fast(int length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 _current += 2 * length;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Tells whether eos is reached
a61af66fc99e Initial load
duke
parents:
diff changeset
131 bool at_eos() const { return _current == _buffer_end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
133
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
134 #endif // SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP