1 /*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
168
169 assert methodHandle != null;
170 assert property != null;
171
172 final MethodHandle boundHandle;
173 if (find.isInheritedOrdinaryProperty()) {
174 boundHandle = ScriptObject.addProtoFilter(methodHandle, find.getProtoChainLength());
175 } else {
176 boundHandle = methodHandle;
177 }
178 return new SetMethod(boundHandle, property);
179 }
180
181 private SetMethod createGlobalPropertySetter() {
182 final ScriptObject global = Context.getGlobal();
183 return new SetMethod(MH.filterArguments(global.addSpill(type, getName()), 0, ScriptObject.GLOBALFILTER), null);
184 }
185
186 private SetMethod createNewPropertySetter(final SwitchPoint builtinSwitchPoint) {
187 final SetMethod sm = map.getFreeFieldSlot() > -1 ? createNewFieldSetter(builtinSwitchPoint) : createNewSpillPropertySetter(builtinSwitchPoint);
188 map.propertyAdded(sm.property, true);
189 return sm;
190 }
191
192 private SetMethod createNewSetter(final Property property, final SwitchPoint builtinSwitchPoint) {
193 property.setBuiltinSwitchPoint(builtinSwitchPoint);
194
195 final PropertyMap oldMap = getMap();
196 final PropertyMap newMap = getNewMap(property);
197 final boolean isStrict = NashornCallSiteDescriptor.isStrict(desc);
198 final String name = NashornCallSiteDescriptor.getOperand(desc);
199
200 //fast type specific setter
201 final MethodHandle fastSetter = property.getSetter(type, newMap); //0 sobj, 1 value, slot folded for spill property already
202
203 //slow setter, that calls ScriptObject.set with appropriate type and key name
204 MethodHandle slowSetter = ScriptObject.SET_SLOW[getAccessorTypeIndex(type)];
205 slowSetter = MH.insertArguments(slowSetter, 3, NashornCallSiteDescriptor.getFlags(desc));
206 slowSetter = MH.insertArguments(slowSetter, 1, name);
207 slowSetter = MH.asType(slowSetter, slowSetter.type().changeParameterType(0, Object.class));
208
|
1 /*
2 * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
168
169 assert methodHandle != null;
170 assert property != null;
171
172 final MethodHandle boundHandle;
173 if (find.isInheritedOrdinaryProperty()) {
174 boundHandle = ScriptObject.addProtoFilter(methodHandle, find.getProtoChainLength());
175 } else {
176 boundHandle = methodHandle;
177 }
178 return new SetMethod(boundHandle, property);
179 }
180
181 private SetMethod createGlobalPropertySetter() {
182 final ScriptObject global = Context.getGlobal();
183 return new SetMethod(MH.filterArguments(global.addSpill(type, getName()), 0, ScriptObject.GLOBALFILTER), null);
184 }
185
186 private SetMethod createNewPropertySetter(final SwitchPoint builtinSwitchPoint) {
187 final SetMethod sm = map.getFreeFieldSlot() > -1 ? createNewFieldSetter(builtinSwitchPoint) : createNewSpillPropertySetter(builtinSwitchPoint);
188 map.propertyChanged(sm.property);
189 return sm;
190 }
191
192 private SetMethod createNewSetter(final Property property, final SwitchPoint builtinSwitchPoint) {
193 property.setBuiltinSwitchPoint(builtinSwitchPoint);
194
195 final PropertyMap oldMap = getMap();
196 final PropertyMap newMap = getNewMap(property);
197 final boolean isStrict = NashornCallSiteDescriptor.isStrict(desc);
198 final String name = NashornCallSiteDescriptor.getOperand(desc);
199
200 //fast type specific setter
201 final MethodHandle fastSetter = property.getSetter(type, newMap); //0 sobj, 1 value, slot folded for spill property already
202
203 //slow setter, that calls ScriptObject.set with appropriate type and key name
204 MethodHandle slowSetter = ScriptObject.SET_SLOW[getAccessorTypeIndex(type)];
205 slowSetter = MH.insertArguments(slowSetter, 3, NashornCallSiteDescriptor.getFlags(desc));
206 slowSetter = MH.insertArguments(slowSetter, 1, name);
207 slowSetter = MH.asType(slowSetter, slowSetter.type().changeParameterType(0, Object.class));
208
|