author | hannesw |
Mon, 15 Feb 2016 17:02:32 +0100 | |
changeset 36023 | 528cc67f1289 |
parent 34455 | cc9f05d3caf0 |
child 39793 | 55220fbb0992 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.nashorn.internal.runtime.linker; |
|
27 |
||
16277 | 28 |
import static jdk.nashorn.internal.lookup.Lookup.MH; |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
29 |
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
30 |
|
16147 | 31 |
import java.lang.invoke.MethodHandle; |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
32 |
import java.lang.invoke.MethodHandles; |
16147 | 33 |
import java.lang.invoke.MethodType; |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
34 |
import java.lang.invoke.SwitchPoint; |
34455
cc9f05d3caf0
8144473: Nashorn code assumes NashornCallSiteDescriptor always
sundar
parents:
34447
diff
changeset
|
35 |
import jdk.dynalink.CallSiteDescriptor; |
34447
ec4c069f9436
8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents:
33343
diff
changeset
|
36 |
import jdk.dynalink.linker.GuardedInvocation; |
ec4c069f9436
8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents:
33343
diff
changeset
|
37 |
import jdk.dynalink.linker.LinkRequest; |
ec4c069f9436
8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents:
33343
diff
changeset
|
38 |
import jdk.dynalink.linker.support.Guards; |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
39 |
import jdk.nashorn.internal.runtime.Context; |
23372
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
40 |
import jdk.nashorn.internal.runtime.FindProperty; |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
41 |
import jdk.nashorn.internal.runtime.GlobalConstants; |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
42 |
import jdk.nashorn.internal.runtime.JSType; |
16147 | 43 |
import jdk.nashorn.internal.runtime.ScriptObject; |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
44 |
import jdk.nashorn.internal.runtime.ScriptRuntime; |
16147 | 45 |
|
46 |
/** |
|
47 |
* Implements lookup of methods to link for dynamic operations on JavaScript primitive values (booleans, strings, and |
|
48 |
* numbers). This class is only public so it can be accessed by classes in the {@code jdk.nashorn.internal.objects} |
|
49 |
* package. |
|
50 |
*/ |
|
19105
a01ba9d17eab
8021571: @fork tests should use VM options passed from project.properties
sundar
parents:
16534
diff
changeset
|
51 |
public final class PrimitiveLookup { |
16147 | 52 |
|
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
53 |
/** Method handle to link setters on primitive base. See ES5 8.7.2. */ |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
54 |
private static final MethodHandle PRIMITIVE_SETTER = findOwnMH("primitiveSetter", |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
55 |
MH.type(void.class, ScriptObject.class, Object.class, Object.class, boolean.class, Object.class)); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
56 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
57 |
|
16147 | 58 |
private PrimitiveLookup() { |
59 |
} |
|
60 |
||
61 |
/** |
|
62 |
* Returns a guarded invocation representing the linkage for a dynamic operation on a primitive Java value. |
|
16195
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16186
diff
changeset
|
63 |
* @param request the link request for the dynamic call site. |
16147 | 64 |
* @param receiverClass the class of the receiver value (e.g., {@link java.lang.Boolean}, {@link java.lang.String} etc.) |
65 |
* @param wrappedReceiver a transient JavaScript native wrapper object created as the object proxy for the primitive |
|
66 |
* value; see ECMAScript 5.1, section 8.7.1 for discussion of using {@code [[Get]]} on a property reference with a |
|
67 |
* primitive base value. This instance will be used to delegate actual lookup. |
|
68 |
* @param wrapFilter A method handle that takes a primitive value of type specified in the {@code receiverClass} and |
|
69 |
* creates a transient native wrapper of the same type as {@code wrappedReceiver} for subsequent invocations of the |
|
70 |
* method - it will be combined into the returned invocation as an argument filter on the receiver. |
|
71 |
* @return a guarded invocation representing the operation at the call site when performed on a JavaScript primitive |
|
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
23372
diff
changeset
|
72 |
* @param protoFilter A method handle that walks up the proto chain of this receiver object |
16147 | 73 |
* type {@code receiverClass}. |
74 |
*/ |
|
16195
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16186
diff
changeset
|
75 |
public static GuardedInvocation lookupPrimitive(final LinkRequest request, final Class<?> receiverClass, |
23372
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
76 |
final ScriptObject wrappedReceiver, final MethodHandle wrapFilter, |
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
77 |
final MethodHandle protoFilter) { |
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
78 |
return lookupPrimitive(request, Guards.getInstanceOfGuard(receiverClass), wrappedReceiver, wrapFilter, protoFilter); |
16147 | 79 |
} |
80 |
||
81 |
/** |
|
82 |
* Returns a guarded invocation representing the linkage for a dynamic operation on a primitive Java value. |
|
16195
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16186
diff
changeset
|
83 |
* @param request the link request for the dynamic call site. |
16147 | 84 |
* @param guard an explicit guard that will be used for the returned guarded invocation. |
85 |
* @param wrappedReceiver a transient JavaScript native wrapper object created as the object proxy for the primitive |
|
86 |
* value; see ECMAScript 5.1, section 8.7.1 for discussion of using {@code [[Get]]} on a property reference with a |
|
87 |
* primitive base value. This instance will be used to delegate actual lookup. |
|
88 |
* @param wrapFilter A method handle that takes a primitive value of type guarded by the {@code guard} and |
|
89 |
* creates a transient native wrapper of the same type as {@code wrappedReceiver} for subsequent invocations of the |
|
90 |
* method - it will be combined into the returned invocation as an argument filter on the receiver. |
|
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
23372
diff
changeset
|
91 |
* @param protoFilter A method handle that walks up the proto chain of this receiver object |
16147 | 92 |
* @return a guarded invocation representing the operation at the call site when performed on a JavaScript primitive |
93 |
* type (that is implied by both {@code guard} and {@code wrappedReceiver}). |
|
94 |
*/ |
|
16195
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16186
diff
changeset
|
95 |
public static GuardedInvocation lookupPrimitive(final LinkRequest request, final MethodHandle guard, |
23372
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
96 |
final ScriptObject wrappedReceiver, final MethodHandle wrapFilter, |
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
97 |
final MethodHandle protoFilter) { |
34455
cc9f05d3caf0
8144473: Nashorn code assumes NashornCallSiteDescriptor always
sundar
parents:
34447
diff
changeset
|
98 |
final CallSiteDescriptor desc = request.getCallSiteDescriptor(); |
cc9f05d3caf0
8144473: Nashorn code assumes NashornCallSiteDescriptor always
sundar
parents:
34447
diff
changeset
|
99 |
final String name = NashornCallSiteDescriptor.getOperand(desc); |
33343
23abd10384a5
8139931: Introduce Operation objects in Dynalink instead of string encoding
attila
parents:
33337
diff
changeset
|
100 |
final FindProperty find = name != null ? wrappedReceiver.findProperty(name, true) : null; |
16147 | 101 |
|
34455
cc9f05d3caf0
8144473: Nashorn code assumes NashornCallSiteDescriptor always
sundar
parents:
34447
diff
changeset
|
102 |
switch (NashornCallSiteDescriptor.getFirstStandardOperation(desc)) { |
33343
23abd10384a5
8139931: Introduce Operation objects in Dynalink instead of string encoding
attila
parents:
33337
diff
changeset
|
103 |
case GET_PROPERTY: |
23abd10384a5
8139931: Introduce Operation objects in Dynalink instead of string encoding
attila
parents:
33337
diff
changeset
|
104 |
case GET_ELEMENT: |
23abd10384a5
8139931: Introduce Operation objects in Dynalink instead of string encoding
attila
parents:
33337
diff
changeset
|
105 |
case GET_METHOD: |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
106 |
//checks whether the property name is hard-coded in the call-site (i.e. a getProp vs a getElem, or setProp vs setElem) |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
107 |
//if it is we can make assumptions on the property: that if it is not defined on primitive wrapper itself it never will be. |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
108 |
//so in that case we can skip creation of primitive wrapper and start our search with the prototype. |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
109 |
if (name != null) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
110 |
if (find == null) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
111 |
// Give up early, give chance to BeanLinker and NashornBottomLinker to deal with it. |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
112 |
return null; |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
113 |
} |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
114 |
|
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
115 |
final SwitchPoint sp = find.getProperty().getBuiltinSwitchPoint(); //can use this instead of proto filter |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
116 |
if (sp instanceof Context.BuiltinSwitchPoint && !sp.hasBeenInvalidated()) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
117 |
return new GuardedInvocation(GlobalConstants.staticConstantGetter(find.getObjectValue()), guard, sp, null); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
118 |
} |
23372
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
119 |
|
36023 | 120 |
if (find.isInherited() && !(find.getProperty().isAccessorProperty())) { |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
121 |
// If property is found in the prototype object bind the method handle directly to |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
122 |
// the proto filter instead of going through wrapper instantiation below. |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
123 |
final ScriptObject proto = wrappedReceiver.getProto(); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
124 |
final GuardedInvocation link = proto.lookup(desc, request); |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
125 |
|
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
126 |
if (link != null) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
127 |
final MethodHandle invocation = link.getInvocation(); //this contains the builtin switchpoint |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
128 |
final MethodHandle adaptedInvocation = MH.asType(invocation, invocation.type().changeParameterType(0, Object.class)); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
129 |
final MethodHandle method = MH.filterArguments(adaptedInvocation, 0, protoFilter); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
130 |
final MethodHandle protoGuard = MH.filterArguments(link.getGuard(), 0, protoFilter); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
131 |
return new GuardedInvocation(method, NashornGuards.combineGuards(guard, protoGuard)); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
132 |
} |
23372
09707b3e5fb0
8021350: Share script classes between threads/globals within context
hannesw
parents:
19105
diff
changeset
|
133 |
} |
16147 | 134 |
} |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
135 |
break; |
33343
23abd10384a5
8139931: Introduce Operation objects in Dynalink instead of string encoding
attila
parents:
33337
diff
changeset
|
136 |
case SET_PROPERTY: |
23abd10384a5
8139931: Introduce Operation objects in Dynalink instead of string encoding
attila
parents:
33337
diff
changeset
|
137 |
case SET_ELEMENT: |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
138 |
return getPrimitiveSetter(name, guard, wrapFilter, NashornCallSiteDescriptor.isStrict(desc)); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
139 |
default: |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
140 |
break; |
16147 | 141 |
} |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
142 |
|
16195
3f6c0ab2597a
8006766: Array-like access to characters of a string is slow
hannesw
parents:
16186
diff
changeset
|
143 |
final GuardedInvocation link = wrappedReceiver.lookup(desc, request); |
16147 | 144 |
if (link != null) { |
145 |
MethodHandle method = link.getInvocation(); |
|
16186
91bd9d2aa2f5
8006570: This-value for non-strict functions should be converted to object
hannesw
parents:
16151
diff
changeset
|
146 |
final Class<?> receiverType = method.type().parameterType(0); |
16207
ed4aec2d599c
8007060: Primitive wrap filter throws ClassCastException in test262parallel
hannesw
parents:
16195
diff
changeset
|
147 |
if (receiverType != Object.class) { |
16147 | 148 |
final MethodType wrapType = wrapFilter.type(); |
16186
91bd9d2aa2f5
8006570: This-value for non-strict functions should be converted to object
hannesw
parents:
16151
diff
changeset
|
149 |
assert receiverType.isAssignableFrom(wrapType.returnType()); |
91bd9d2aa2f5
8006570: This-value for non-strict functions should be converted to object
hannesw
parents:
16151
diff
changeset
|
150 |
method = MH.filterArguments(method, 0, MH.asType(wrapFilter, wrapType.changeReturnType(receiverType))); |
16147 | 151 |
} |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
152 |
|
24738
be2026c9717c
8039746: Transform applies to calls wherever possible, for ScriptFunctions and JSObjects.
lagergren
parents:
24731
diff
changeset
|
153 |
return new GuardedInvocation(method, guard, link.getSwitchPoints(), null); |
16147 | 154 |
} |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26508
diff
changeset
|
155 |
|
16147 | 156 |
return null; |
157 |
} |
|
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
158 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
159 |
private static GuardedInvocation getPrimitiveSetter(final String name, final MethodHandle guard, |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
160 |
final MethodHandle wrapFilter, final boolean isStrict) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
161 |
MethodHandle filter = MH.asType(wrapFilter, wrapFilter.type().changeReturnType(ScriptObject.class)); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
162 |
final MethodHandle target; |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
163 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
164 |
if (name == null) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
165 |
filter = MH.dropArguments(filter, 1, Object.class, Object.class); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
166 |
target = MH.insertArguments(PRIMITIVE_SETTER, 3, isStrict); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
167 |
} else { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
168 |
filter = MH.dropArguments(filter, 1, Object.class); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
169 |
target = MH.insertArguments(PRIMITIVE_SETTER, 2, name, isStrict); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
170 |
} |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
171 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
172 |
return new GuardedInvocation(MH.foldArguments(target, filter), guard); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
173 |
} |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
174 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
175 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
176 |
@SuppressWarnings("unused") |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
177 |
private static void primitiveSetter(final ScriptObject wrappedSelf, final Object self, final Object key, |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
178 |
final boolean strict, final Object value) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
179 |
// See ES5.1 8.7.2 PutValue (V, W) |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
180 |
final String name = JSType.toString(key); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
181 |
final FindProperty find = wrappedSelf.findProperty(name, true); |
36023 | 182 |
if (find == null || !find.getProperty().isAccessorProperty() || !find.getProperty().hasNativeSetter()) { |
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
183 |
if (strict) { |
36023 | 184 |
if (find == null || !find.getProperty().isAccessorProperty()) { |
185 |
throw typeError("property.not.writable", name, ScriptRuntime.safeToString(self)); |
|
186 |
} else { |
|
187 |
throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self)); |
|
188 |
} |
|
28127
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
189 |
} |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
190 |
return; |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
191 |
} |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
192 |
// property found and is a UserAccessorProperty |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
193 |
find.setValue(value, strict); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
194 |
} |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
195 |
|
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
196 |
private static MethodHandle findOwnMH(final String name, final MethodType type) { |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
197 |
return MH.findStatic(MethodHandles.lookup(), PrimitiveLookup.class, name, type); |
08a5e0d3248d
8066226: Fuzzing bug: parameter counts differ in TypeConverterFactory
hannesw
parents:
26768
diff
changeset
|
198 |
} |
16147 | 199 |
} |