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

changeset 1006
e94bfa3c6c6c
parent 991
b7a2db4de254
child 1007
39ba6d257e4c
equal deleted inserted replaced
1005:2cad9bf911a4 1006:e94bfa3c6c6c
1048 addOwnProperty(newUserAccessors(key, oldProperty != null ? oldProperty.getFlags() : 0, getter, setter)); 1048 addOwnProperty(newUserAccessors(key, oldProperty != null ? oldProperty.getFlags() : 0, getter, setter));
1049 } 1049 }
1050 } 1050 }
1051 1051
1052 private static int getIntValue(final FindProperty find, final int programPoint) { 1052 private static int getIntValue(final FindProperty find, final int programPoint) {
1053 final MethodHandle getter = find.getGetter(int.class, programPoint); 1053 final MethodHandle getter = find.getGetter(int.class, programPoint, null);
1054 if (getter != null) { 1054 if (getter != null) {
1055 try { 1055 try {
1056 return (int)getter.invokeExact((Object)find.getGetterReceiver()); 1056 return (int)getter.invokeExact((Object)find.getGetterReceiver());
1057 } catch (final Error|RuntimeException e) { 1057 } catch (final Error|RuntimeException e) {
1058 throw e; 1058 throw e;
1063 1063
1064 return UNDEFINED_INT; 1064 return UNDEFINED_INT;
1065 } 1065 }
1066 1066
1067 private static long getLongValue(final FindProperty find, final int programPoint) { 1067 private static long getLongValue(final FindProperty find, final int programPoint) {
1068 final MethodHandle getter = find.getGetter(long.class, programPoint); 1068 final MethodHandle getter = find.getGetter(long.class, programPoint, null);
1069 if (getter != null) { 1069 if (getter != null) {
1070 try { 1070 try {
1071 return (long)getter.invokeExact((Object)find.getGetterReceiver()); 1071 return (long)getter.invokeExact((Object)find.getGetterReceiver());
1072 } catch (final Error|RuntimeException e) { 1072 } catch (final Error|RuntimeException e) {
1073 throw e; 1073 throw e;
1078 1078
1079 return UNDEFINED_LONG; 1079 return UNDEFINED_LONG;
1080 } 1080 }
1081 1081
1082 private static double getDoubleValue(final FindProperty find, final int programPoint) { 1082 private static double getDoubleValue(final FindProperty find, final int programPoint) {
1083 final MethodHandle getter = find.getGetter(double.class, programPoint); 1083 final MethodHandle getter = find.getGetter(double.class, programPoint, null);
1084 if (getter != null) { 1084 if (getter != null) {
1085 try { 1085 try {
1086 return (double)getter.invokeExact((Object)find.getGetterReceiver()); 1086 return (double)getter.invokeExact((Object)find.getGetterReceiver());
1087 } catch (final Error|RuntimeException e) { 1087 } catch (final Error|RuntimeException e) {
1088 throw e; 1088 throw e;
1981 1981
1982 final int programPoint = NashornCallSiteDescriptor.isOptimistic(desc) ? 1982 final int programPoint = NashornCallSiteDescriptor.isOptimistic(desc) ?
1983 NashornCallSiteDescriptor.getProgramPoint(desc) : 1983 NashornCallSiteDescriptor.getProgramPoint(desc) :
1984 UnwarrantedOptimismException.INVALID_PROGRAM_POINT; 1984 UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
1985 1985
1986 mh = find.getGetter(returnType, programPoint); 1986 mh = find.getGetter(returnType, programPoint, request);
1987 // Get the appropriate guard for this callsite and property. 1987 // Get the appropriate guard for this callsite and property.
1988 final MethodHandle guard = NashornGuards.getGuard(this, property, desc, explicitInstanceOfCheck); 1988 final MethodHandle guard = NashornGuards.getGuard(this, property, desc, explicitInstanceOfCheck);
1989 final ScriptObject owner = find.getOwner(); 1989 final ScriptObject owner = find.getOwner();
1990 final Class<ClassCastException> exception = explicitInstanceOfCheck ? null : ClassCastException.class; 1990 final Class<ClassCastException> exception = explicitInstanceOfCheck ? null : ClassCastException.class;
1991 1991
1993 1993
1994 if (mh == null) { 1994 if (mh == null) {
1995 mh = Lookup.emptyGetter(returnType); 1995 mh = Lookup.emptyGetter(returnType);
1996 protoSwitchPoint = getProtoSwitchPoint(name, owner); 1996 protoSwitchPoint = getProtoSwitchPoint(name, owner);
1997 } else if (!find.isSelf()) { 1997 } else if (!find.isSelf()) {
1998 assert mh.type().returnType().equals(returnType) : "returntype mismatch for getter " + mh.type().returnType() + " != " + returnType; 1998 assert mh.type().returnType().equals(returnType) :
1999 if (!property.hasGetterFunction(owner)) { 1999 "return type mismatch for getter " + mh.type().returnType() + " != " + returnType;
2000 if (!(property instanceof UserAccessorProperty)) {
2000 // Add a filter that replaces the self object with the prototype owning the property. 2001 // Add a filter that replaces the self object with the prototype owning the property.
2001 mh = addProtoFilter(mh, find.getProtoChainLength()); 2002 mh = addProtoFilter(mh, find.getProtoChainLength());
2002 } 2003 }
2003 protoSwitchPoint = getProtoSwitchPoint(name, owner); 2004 protoSwitchPoint = getProtoSwitchPoint(name, owner);
2004 } else { 2005 } else {
2165 if (!isExtensible()) { 2166 if (!isExtensible()) {
2166 return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); 2167 return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false);
2167 } 2168 }
2168 } 2169 }
2169 2170
2170 final GuardedInvocation inv = new SetMethodCreator(this, find, desc, explicitInstanceOfCheck).createGuardedInvocation(); 2171 final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation();
2171 2172
2172 final GuardedInvocation cinv = Global.getConstants().findSetMethod(find, this, inv, desc, request); 2173 final GuardedInvocation cinv = Global.getConstants().findSetMethod(find, this, inv, desc, request);
2173 if (cinv != null) { 2174 if (cinv != null) {
2174 return cinv; 2175 return cinv;
2175 } 2176 }
2318 return new GuardedInvocation( 2319 return new GuardedInvocation(
2319 mh, 2320 mh,
2320 find.isSelf()? 2321 find.isSelf()?
2321 getKnownFunctionPropertyGuardSelf( 2322 getKnownFunctionPropertyGuardSelf(
2322 getMap(), 2323 getMap(),
2323 find.getGetter(Object.class, INVALID_PROGRAM_POINT), 2324 find.getGetter(Object.class, INVALID_PROGRAM_POINT, request),
2324 func) 2325 func)
2325 : 2326 :
2326 //TODO this always does a scriptobject check 2327 //TODO this always does a scriptobject check
2327 getKnownFunctionPropertyGuardProto( 2328 getKnownFunctionPropertyGuardProto(
2328 getMap(), 2329 getMap(),
2329 find.getGetter(Object.class, INVALID_PROGRAM_POINT), 2330 find.getGetter(Object.class, INVALID_PROGRAM_POINT, request),
2330 find.getProtoChainLength(), 2331 find.getProtoChainLength(),
2331 func), 2332 func),
2332 getProtoSwitchPoint(NO_SUCH_PROPERTY_NAME, find.getOwner()), 2333 getProtoSwitchPoint(NO_SUCH_PROPERTY_NAME, find.getOwner()),
2333 //TODO this doesn't need a ClassCastException as guard always checks script object 2334 //TODO this doesn't need a ClassCastException as guard always checks script object
2334 null); 2335 null);

mercurial