src/jdk/nashorn/internal/codegen/SharedScopeCall.java

Print this page
rev 758 : 8021350: Share script classes between threads/globals within context
Reviewed-by: lagergren, sundar


 139 
 140         // Load correct scope by calling getProto() on the scope argument as often as specified
 141         // by the second argument.
 142         final Label parentLoopStart = new Label("parent_loop_start");
 143         final Label parentLoopDone  = new Label("parent_loop_done");
 144         method.load(Type.OBJECT, 0);
 145         method.label(parentLoopStart);
 146         method.load(Type.INT, 1);
 147         method.iinc(1, -1);
 148         method.ifle(parentLoopDone);
 149         method.invoke(ScriptObject.GET_PROTO);
 150         method._goto(parentLoopStart);
 151         method.label(parentLoopDone);
 152 
 153         method.dynamicGet(valueType, symbol.getName(), flags, isCall);
 154 
 155         // If this is a get we're done, otherwise call the value as function.
 156         if (isCall) {
 157             method.convert(Type.OBJECT);
 158             // ScriptFunction will see CALLSITE_SCOPE and will bind scope accordingly.
 159             method.loadNull();
 160             int slot = 2;
 161             for (final Type type : paramTypes) {
 162                 method.load(type, slot++);
 163                 if (type == Type.NUMBER || type == Type.LONG) {
 164                     slot++;
 165                 }
 166             }
 167             method.dynamicCall(returnType, 2 + paramTypes.length, flags);
 168         }
 169 
 170         method._return(returnType);
 171         method.end();
 172     }
 173 
 174     private String getStaticSignature() {
 175         if (staticSignature == null) {
 176             if (paramTypes == null) {
 177                 staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT);
 178             } else {
 179                 final Type[] params = new Type[paramTypes.length + 2];


 139 
 140         // Load correct scope by calling getProto() on the scope argument as often as specified
 141         // by the second argument.
 142         final Label parentLoopStart = new Label("parent_loop_start");
 143         final Label parentLoopDone  = new Label("parent_loop_done");
 144         method.load(Type.OBJECT, 0);
 145         method.label(parentLoopStart);
 146         method.load(Type.INT, 1);
 147         method.iinc(1, -1);
 148         method.ifle(parentLoopDone);
 149         method.invoke(ScriptObject.GET_PROTO);
 150         method._goto(parentLoopStart);
 151         method.label(parentLoopDone);
 152 
 153         method.dynamicGet(valueType, symbol.getName(), flags, isCall);
 154 
 155         // If this is a get we're done, otherwise call the value as function.
 156         if (isCall) {
 157             method.convert(Type.OBJECT);
 158             // ScriptFunction will see CALLSITE_SCOPE and will bind scope accordingly.
 159             method.loadUndefined(Type.OBJECT);
 160             int slot = 2;
 161             for (final Type type : paramTypes) {
 162                 method.load(type, slot++);
 163                 if (type == Type.NUMBER || type == Type.LONG) {
 164                     slot++;
 165                 }
 166             }
 167             method.dynamicCall(returnType, 2 + paramTypes.length, flags);
 168         }
 169 
 170         method._return(returnType);
 171         method.end();
 172     }
 173 
 174     private String getStaticSignature() {
 175         if (staticSignature == null) {
 176             if (paramTypes == null) {
 177                 staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT);
 178             } else {
 179                 final Type[] params = new Type[paramTypes.length + 2];