aboutsummaryrefslogtreecommitdiff
path: root/buildtools/nasgen
diff options
context:
space:
mode:
authorhannesw <none@none>2013-06-26 15:40:52 +0200
committerhannesw <none@none>2013-06-26 15:40:52 +0200
commitff041500c6143ec2f121357e16d98ed6e3103999 (patch)
treed3a1c705a124cc791c4f8e5fb064aace6059264f /buildtools/nasgen
parentc3b0922835493e0669b2d840eece6494b699d26d (diff)
downloadnashorn-ff041500c6143ec2f121357e16d98ed6e3103999.tar.gz
8019157: Avoid calling ScriptObject.setProto() if possible
Reviewed-by: jlaskey, sundar
Diffstat (limited to 'buildtools/nasgen')
-rw-r--r--buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java12
-rw-r--r--buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java14
2 files changed, 15 insertions, 11 deletions
diff --git a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java
index 808f2658..bc6bb4b2 100644
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java
@@ -166,11 +166,11 @@ public class ClassGenerator {
mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC);
mi.loadClass(className);
mi.invokeStatic(MAP_TYPE, MAP_NEWMAP, MAP_NEWMAP_DESC);
- mi.storeLocal(0);
+ // stack: PropertyMap
}
static void emitStaticInitSuffix(final MethodGenerator mi, final String className) {
- mi.loadLocal(0);
+ // stack: PropertyMap
mi.putStatic(className, MAP_FIELD_NAME, MAP_DESC);
mi.returnVoid();
mi.computeMaxs();
@@ -278,7 +278,7 @@ public class ClassGenerator {
static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) {
final String propertyName = memInfo.getName();
- mi.loadLocal(0);
+ // stack: PropertyMap
mi.loadLiteral(propertyName);
// setup flags
mi.push(memInfo.getAttributes());
@@ -293,12 +293,12 @@ public class ClassGenerator {
mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo)));
}
mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC);
- mi.storeLocal(0);
+ // stack: PropertyMap
}
static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) {
final String propertyName = getter.getName();
- mi.loadLocal(0);
+ // stack: PropertyMap
mi.loadLiteral(propertyName);
// setup flags
mi.push(getter.getAttributes());
@@ -313,7 +313,7 @@ public class ClassGenerator {
setter.getJavaName(), setter.getJavaDesc()));
}
mi.invokeStatic(LOOKUP_TYPE, LOOKUP_NEWPROPERTY, LOOKUP_NEWPROPERTY_DESC);
- mi.storeLocal(0);
+ // stack: PropertyMap
}
static ScriptClassInfo getScriptClassInfo(final String fileName) throws IOException {
diff --git a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java
index d140585f..ffeb90be 100644
--- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java
+++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java
@@ -159,10 +159,14 @@ public class ScriptClassInstrumentor extends ClassVisitor {
public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {
if (isConstructor && opcode == INVOKESPECIAL &&
INIT.equals(name) && SCRIPTOBJECT_TYPE.equals(owner)) {
- super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(),
- MAP_FIELD_NAME, MAP_DESC);
- super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT,
- SCRIPTOBJECT_INIT_DESC);
+
+ // replace call to empty super-constructor with one passing PropertyMap argument
+ if (DEFAULT_INIT_DESC.equals(desc)) {
+ super.visitFieldInsn(GETSTATIC, scriptClassInfo.getJavaName(), MAP_FIELD_NAME, MAP_DESC);
+ super.visitMethodInsn(INVOKESPECIAL, SCRIPTOBJECT_TYPE, INIT, SCRIPTOBJECT_INIT_DESC);
+ } else {
+ super.visitMethodInsn(opcode, owner, name, desc);
+ }
if (memberCount > 0) {
// initialize @Property fields if needed
@@ -223,7 +227,7 @@ public class ScriptClassInstrumentor extends ClassVisitor {
ClassGenerator.addSetter(cv, className, memInfo);
}
}
- ClassGenerator.addMapField(this);
+ // omit addMapField() since instance classes already define a static PropertyMap field
}
void emitGettersSetters() {