src/jdk/nashorn/internal/runtime/SetMethodCreator.java

Print this page




 131     }
 132 
 133     private SetMethod createExistingPropertySetter() {
 134         final Property property = find.getProperty();
 135         final Class<?> type = desc.getMethodType().parameterType(1);
 136         final MethodHandle methodHandle = find.getSetter(type, NashornCallSiteDescriptor.isStrict(desc));
 137 
 138         assert methodHandle != null;
 139         assert property     != null;
 140 
 141         final MethodHandle boundHandle;
 142         if (!property.hasSetterFunction(find.getOwner()) && find.isInherited()) {
 143             boundHandle = ScriptObject.addProtoFilter(methodHandle, find.getProtoChainLength());
 144         } else {
 145             boundHandle = methodHandle;
 146         }
 147         return new SetMethod(boundHandle, property);
 148     }
 149 
 150     private SetMethod createGlobalPropertySetter() {
 151         final ScriptObject global = Context.getGlobalTrusted();
 152         return new SetMethod(MH.filterArguments(global.addSpill(getName()), 0, ScriptObject.GLOBALFILTER), null);
 153     }
 154 
 155     private SetMethod createNewPropertySetter() {
 156         final SetMethod sm = map.getFieldCount() < map.getFieldMaximum() ? createNewFieldSetter() : createNewSpillPropertySetter();
 157         final PropertyListeners listeners = map.getListeners();
 158         if (listeners != null) {
 159             listeners.propertyAdded(sm.property);
 160         }
 161         return sm;
 162     }
 163 
 164     private SetMethod createNewFieldSetter() {
 165         final PropertyMap oldMap = getMap();
 166         final Property property = new AccessorProperty(getName(), 0, sobj.getClass(), oldMap.getFieldCount());
 167         final PropertyMap newMap = oldMap.addProperty(property);
 168         MethodHandle setter = MH.insertArguments(ScriptObject.SETFIELD, 0, desc, oldMap, newMap, property.getSetter(Object.class, newMap));
 169 
 170         return new SetMethod(MH.asType(setter, Lookup.SET_OBJECT_TYPE), property);
 171     }




 131     }
 132 
 133     private SetMethod createExistingPropertySetter() {
 134         final Property property = find.getProperty();
 135         final Class<?> type = desc.getMethodType().parameterType(1);
 136         final MethodHandle methodHandle = find.getSetter(type, NashornCallSiteDescriptor.isStrict(desc));
 137 
 138         assert methodHandle != null;
 139         assert property     != null;
 140 
 141         final MethodHandle boundHandle;
 142         if (!property.hasSetterFunction(find.getOwner()) && find.isInherited()) {
 143             boundHandle = ScriptObject.addProtoFilter(methodHandle, find.getProtoChainLength());
 144         } else {
 145             boundHandle = methodHandle;
 146         }
 147         return new SetMethod(boundHandle, property);
 148     }
 149 
 150     private SetMethod createGlobalPropertySetter() {
 151         final ScriptObject global = Context.getGlobal();
 152         return new SetMethod(MH.filterArguments(global.addSpill(getName()), 0, ScriptObject.GLOBALFILTER), null);
 153     }
 154 
 155     private SetMethod createNewPropertySetter() {
 156         final SetMethod sm = map.getFieldCount() < map.getFieldMaximum() ? createNewFieldSetter() : createNewSpillPropertySetter();
 157         final PropertyListeners listeners = map.getListeners();
 158         if (listeners != null) {
 159             listeners.propertyAdded(sm.property);
 160         }
 161         return sm;
 162     }
 163 
 164     private SetMethod createNewFieldSetter() {
 165         final PropertyMap oldMap = getMap();
 166         final Property property = new AccessorProperty(getName(), 0, sobj.getClass(), oldMap.getFieldCount());
 167         final PropertyMap newMap = oldMap.addProperty(property);
 168         MethodHandle setter = MH.insertArguments(ScriptObject.SETFIELD, 0, desc, oldMap, newMap, property.getSetter(Object.class, newMap));
 169 
 170         return new SetMethod(MH.asType(setter, Lookup.SET_OBJECT_TYPE), property);
 171     }