Mercurial > hg > truffle
annotate src/share/vm/adlc/filebuff.hpp @ 1293:51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
Summary: A modified MethodHandlesTest revealed two bugs on x86_64.
Reviewed-by: never, jrose
author | twisti |
---|---|
date | Mon, 08 Mar 2010 04:46:30 -0800 |
parents | 116b019a3961 |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
488
diff
changeset
|
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // FILEBUFF.HPP - Definitions for parser file buffering routines | |
229 | 26 #include <iostream> |
0 | 27 |
229 | 28 using namespace std; |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
488
diff
changeset
|
29 |
0 | 30 // STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES |
31 typedef struct { | |
32 const char *_name; | |
33 FILE *_fp; | |
34 } BufferedFile; | |
35 | |
36 class ArchDesc; | |
37 | |
38 //------------------------------FileBuff-------------------------------------- | |
39 // This class defines a nicely behaved buffer of text. Entire file of text | |
605 | 40 // is read into buffer at creation, with sentinels at start and end. |
0 | 41 class FileBuff { |
42 friend class FileBuffRegion; | |
43 private: | |
44 long _bufferSize; // Size of text holding buffer. | |
45 long _offset; // Expected filepointer offset. | |
46 long _bufoff; // Start of buffer file offset | |
47 | |
48 char *_buf; // The buffer itself. | |
605 | 49 char *_bigbuf; // The buffer plus sentinels; actual heap area |
50 char *_bufmax; // A pointer to the buffer end sentinel | |
0 | 51 char *_bufeol; // A pointer to the last complete line end |
52 | |
53 int _err; // Error flag for file seek/read operations | |
54 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
|
55 int _linenum; |
0 | 56 |
57 ArchDesc& _AD; // Reference to Architecture Description | |
58 | |
59 // Error reporting function | |
60 void file_error(int flag, int linenum, const char *fmt, ...); | |
61 | |
62 public: | |
63 const BufferedFile *_fp; // File to be buffered | |
64 | |
65 FileBuff(BufferedFile *fp, ArchDesc& archDesc); // Constructor | |
66 ~FileBuff(); // Destructor | |
67 | |
68 // This returns a pointer to the start of the current line in the buffer, | |
69 // and increments bufeol and filepos to point at the end of that line. | |
70 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
|
71 int linenum() const { return _linenum; } |
475
284d0af00d53
6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents:
415
diff
changeset
|
72 void set_linenum(int line) { _linenum = line; } |
0 | 73 |
74 // This converts a pointer into the buffer to a file offset. It only works | |
75 // when the pointer is valid (i.e. just obtained from getline()). | |
769 | 76 long getoff(const char* s) { return _bufoff + (long)(s - _buf); } |
0 | 77 }; |
78 | |
79 //------------------------------FileBuffRegion--------------------------------- | |
80 // A buffer region is really a region of some file, specified as a linked list | |
81 // of offsets and lengths. These regions can be merged; overlapping regions | |
82 // will coalesce. | |
83 class FileBuffRegion { | |
84 public: // Workaround dev-studio friend/private bug | |
85 FileBuffRegion *_next; // Linked list of regions sorted by offset. | |
86 private: | |
87 FileBuff *_bfr; // The Buffer of the file | |
88 int _offset, _length; // The file area | |
89 int _sol; // Start of line where the file area starts | |
90 int _line; // First line of region | |
91 | |
92 public: | |
93 FileBuffRegion(FileBuff*, int sol, int line, int offset, int len); | |
94 ~FileBuffRegion(); | |
95 | |
96 FileBuffRegion *copy(); // Deep copy | |
97 FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input | |
98 | |
99 void print(ostream&); | |
100 friend ostream& operator<< (ostream&, FileBuffRegion&); | |
101 }; |