annotate src/share/vm/adlc/filebuff.hpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents d336b3173277
children
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: 769
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 769
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: 769
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_ADLC_FILEBUFF_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_ADLC_FILEBUFF_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // FILEBUFF.HPP - Definitions for parser file buffering routines
229
3e82d72933d0 6718830: Hotspot fails to build with gcc 4.3
xlu
parents: 0
diff changeset
29 #include <iostream>
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
229
3e82d72933d0 6718830: Hotspot fails to build with gcc 4.3
xlu
parents: 0
diff changeset
31 using namespace std;
603
dbbe28fc66b5 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 488
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 1972
diff changeset
34
d336b3173277 8000592: Improve adlc usability
kvn
parents: 1972
diff changeset
35 class BufferedFile {
d336b3173277 8000592: Improve adlc usability
kvn
parents: 1972
diff changeset
36 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37 const char *_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 FILE *_fp;
6850
d336b3173277 8000592: Improve adlc usability
kvn
parents: 1972
diff changeset
39 inline BufferedFile() { _name = NULL; _fp = NULL; };
d336b3173277 8000592: Improve adlc usability
kvn
parents: 1972
diff changeset
40 inline ~BufferedFile() {};
d336b3173277 8000592: Improve adlc usability
kvn
parents: 1972
diff changeset
41 };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class ArchDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 //------------------------------FileBuff--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // This class defines a nicely behaved buffer of text. Entire file of text
605
98cb887364d3 6810672: Comment typos
twisti
parents: 603
diff changeset
47 // is read into buffer at creation, with sentinels at start and end.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 class FileBuff {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 friend class FileBuffRegion;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 long _bufferSize; // Size of text holding buffer.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 long _offset; // Expected filepointer offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 long _bufoff; // Start of buffer file offset
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 char *_buf; // The buffer itself.
605
98cb887364d3 6810672: Comment typos
twisti
parents: 603
diff changeset
56 char *_bigbuf; // The buffer plus sentinels; actual heap area
98cb887364d3 6810672: Comment typos
twisti
parents: 603
diff changeset
57 char *_bufmax; // A pointer to the buffer end sentinel
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 char *_bufeol; // A pointer to the last complete line end
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 int _err; // Error flag for file seek/read operations
a61af66fc99e Initial load
duke
parents:
diff changeset
61 long _filepos; // Current offset from start of file
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 229
diff changeset
62 int _linenum;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 ArchDesc& _AD; // Reference to Architecture Description
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Error reporting function
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void file_error(int flag, int linenum, const char *fmt, ...);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
70 const BufferedFile *_fp; // File to be buffered
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 FileBuff(BufferedFile *fp, ArchDesc& archDesc); // Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
73 ~FileBuff(); // Destructor
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // This returns a pointer to the start of the current line in the buffer,
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // and increments bufeol and filepos to point at the end of that line.
a61af66fc99e Initial load
duke
parents:
diff changeset
77 char *get_line(void);
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 229
diff changeset
78 int linenum() const { return _linenum; }
475
284d0af00d53 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 415
diff changeset
79 void set_linenum(int line) { _linenum = line; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // This converts a pointer into the buffer to a file offset. It only works
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // when the pointer is valid (i.e. just obtained from getline()).
769
116b019a3961 6839126: Type error found by newer windows compiler
ohair
parents: 628
diff changeset
83 long getoff(const char* s) { return _bufoff + (long)(s - _buf); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 };
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //------------------------------FileBuffRegion---------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // A buffer region is really a region of some file, specified as a linked list
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // of offsets and lengths. These regions can be merged; overlapping regions
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // will coalesce.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 class FileBuffRegion {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 public: // Workaround dev-studio friend/private bug
a61af66fc99e Initial load
duke
parents:
diff changeset
92 FileBuffRegion *_next; // Linked list of regions sorted by offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 FileBuff *_bfr; // The Buffer of the file
a61af66fc99e Initial load
duke
parents:
diff changeset
95 int _offset, _length; // The file area
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int _sol; // Start of line where the file area starts
a61af66fc99e Initial load
duke
parents:
diff changeset
97 int _line; // First line of region
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
100 FileBuffRegion(FileBuff*, int sol, int line, int offset, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 ~FileBuffRegion();
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 FileBuffRegion *copy(); // Deep copy
a61af66fc99e Initial load
duke
parents:
diff changeset
104 FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void print(ostream&);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 friend ostream& operator<< (ostream&, FileBuffRegion&);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
109
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
110 #endif // SHARE_VM_ADLC_FILEBUFF_HPP