Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | d6cd0d55d0b5 |
children | 1d1603768966 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
87 readVMStructs(); | 87 readVMStructs(); |
88 readVMIntConstants(); | 88 readVMIntConstants(); |
89 readVMLongConstants(); | 89 readVMLongConstants(); |
90 } | 90 } |
91 | 91 |
92 public Type lookupType(String cTypeName, boolean throwException) { | |
93 Type fieldType = super.lookupType(cTypeName, false); | |
94 if (fieldType == null && cTypeName.startsWith("const ")) { | |
95 fieldType = (BasicType)lookupType(cTypeName.substring(6), false); | |
96 } | |
97 if (fieldType == null && cTypeName.endsWith(" const")) { | |
98 fieldType = (BasicType)lookupType(cTypeName.substring(0, cTypeName.length() - 6), false); | |
99 } | |
100 if (fieldType == null) { | |
101 if (cTypeName.startsWith("GrowableArray<") && cTypeName.endsWith(">*")) { | |
102 String ttype = cTypeName.substring("GrowableArray<".length(), | |
103 cTypeName.length() - 2); | |
104 Type templateType = lookupType(ttype, false); | |
105 if (templateType == null && typeNameIsPointerType(ttype)) { | |
106 templateType = recursiveCreateBasicPointerType(ttype); | |
107 } | |
108 if (templateType == null) { | |
109 lookupOrFail(ttype); | |
110 } | |
111 fieldType = recursiveCreateBasicPointerType(cTypeName); | |
112 } | |
113 } | |
114 if (fieldType == null && typeNameIsPointerType(cTypeName)) { | |
115 fieldType = recursiveCreateBasicPointerType(cTypeName); | |
116 } | |
117 if (fieldType == null && throwException) { | |
118 super.lookupType(cTypeName, true); | |
119 } | |
120 return fieldType; | |
121 } | |
122 | |
92 private void readVMTypes() { | 123 private void readVMTypes() { |
93 // Get the variables we need in order to traverse the VMTypeEntry[] | 124 // Get the variables we need in order to traverse the VMTypeEntry[] |
94 long typeEntryTypeNameOffset; | 125 long typeEntryTypeNameOffset; |
95 long typeEntrySuperclassNameOffset; | 126 long typeEntrySuperclassNameOffset; |
96 long typeEntryIsOopTypeOffset; | 127 long typeEntryIsOopTypeOffset; |
248 | 279 |
249 // The containing Type must already be in the database -- no exceptions | 280 // The containing Type must already be in the database -- no exceptions |
250 BasicType containingType = lookupOrFail(typeName); | 281 BasicType containingType = lookupOrFail(typeName); |
251 | 282 |
252 // The field's Type must already be in the database -- no exceptions | 283 // The field's Type must already be in the database -- no exceptions |
253 BasicType fieldType = lookupOrFail(typeString); | 284 BasicType fieldType = (BasicType)lookupType(typeString); |
254 | 285 |
255 // Create field by type | 286 // Create field by type |
256 createField(containingType, fieldName, fieldType, | 287 createField(containingType, fieldName, fieldType, |
257 isStatic, offset, staticFieldAddr); | 288 isStatic, offset, staticFieldAddr); |
258 } | 289 } |
440 /** Recursively creates a PointerType from the string representation | 471 /** Recursively creates a PointerType from the string representation |
441 of the type's name. Note that this currently needs some | 472 of the type's name. Note that this currently needs some |
442 workarounds due to incomplete information in the VMStructs | 473 workarounds due to incomplete information in the VMStructs |
443 database. */ | 474 database. */ |
444 private BasicPointerType recursiveCreateBasicPointerType(String typeName) { | 475 private BasicPointerType recursiveCreateBasicPointerType(String typeName) { |
476 BasicPointerType result = (BasicPointerType)super.lookupType(typeName, false); | |
477 if (result != null) { | |
478 return result; | |
479 } | |
445 String targetTypeName = typeName.substring(0, typeName.lastIndexOf('*')).trim(); | 480 String targetTypeName = typeName.substring(0, typeName.lastIndexOf('*')).trim(); |
446 Type targetType = null; | 481 Type targetType = null; |
447 if (typeNameIsPointerType(targetTypeName)) { | 482 if (typeNameIsPointerType(targetTypeName)) { |
448 targetType = recursiveCreateBasicPointerType(targetTypeName); | 483 targetType = lookupType(targetTypeName, false); |
484 if (targetType == null) { | |
485 targetType = recursiveCreateBasicPointerType(targetTypeName); | |
486 } | |
449 } else { | 487 } else { |
450 targetType = lookupType(targetTypeName, false); | 488 targetType = lookupType(targetTypeName, false); |
451 if (targetType == null) { | 489 if (targetType == null) { |
452 // Workaround for missing C integer types in database. | 490 // Workaround for missing C integer types in database. |
453 // Also looks like we can't throw an exception for other | 491 // Also looks like we can't throw an exception for other |
464 targetType = basicTargetType; | 502 targetType = basicTargetType; |
465 } else if (targetTypeName.equals("u_char")) { | 503 } else if (targetTypeName.equals("u_char")) { |
466 BasicType basicTargetType = createBasicType(targetTypeName, false, true, true); | 504 BasicType basicTargetType = createBasicType(targetTypeName, false, true, true); |
467 basicTargetType.setSize(1); | 505 basicTargetType.setSize(1); |
468 targetType = basicTargetType; | 506 targetType = basicTargetType; |
507 } else if (targetTypeName.startsWith("GrowableArray<")) { | |
508 BasicType basicTargetType = createBasicType(targetTypeName, false, false, false); | |
509 | |
510 // transfer fields from GenericGrowableArray to template instance | |
511 BasicType generic = lookupOrFail("GenericGrowableArray"); | |
512 basicTargetType.setSize(generic.getSize()); | |
513 Iterator fields = generic.getFields(); | |
514 while (fields.hasNext()) { | |
515 Field f = (Field)fields.next(); | |
516 basicTargetType.addField(internalCreateField(basicTargetType, f.getName(), | |
517 f.getType(), f.isStatic(), | |
518 f.getOffset(), null)); | |
519 } | |
520 targetType = basicTargetType; | |
469 } else { | 521 } else { |
470 if (DEBUG) { | 522 if (DEBUG) { |
471 System.err.println("WARNING: missing target type \"" + targetTypeName + "\" for pointer type \"" + typeName + "\""); | 523 System.err.println("WARNING: missing target type \"" + targetTypeName + "\" for pointer type \"" + typeName + "\""); |
472 } | 524 } |
473 targetType = createBasicType(targetTypeName, false, false, false); | 525 targetType = createBasicType(targetTypeName, false, false, false); |
474 } | 526 } |
475 } | 527 } |
476 } | 528 } |
477 return new BasicPointerType(this, typeName, targetType); | 529 result = new BasicPointerType(this, typeName, targetType); |
530 result.setSize(UNINITIALIZED_SIZE); | |
531 addType(result); | |
532 return result; | |
478 } | 533 } |
479 | 534 |
480 private boolean typeNameIsPointerType(String typeName) { | 535 private boolean typeNameIsPointerType(String typeName) { |
481 int i = typeName.length() - 1; | 536 int i = typeName.length() - 1; |
482 while (i >= 0 && Character.isWhitespace(typeName.charAt(i))) { | 537 while (i >= 0 && Character.isWhitespace(typeName.charAt(i))) { |