116 } |
116 } |
117 |
117 |
118 private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception { |
118 private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception { |
119 final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); |
119 final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); |
120 final int c = desc.getNameTokenCount(); |
120 final int c = desc.getNameTokenCount(); |
|
121 GuardedInvocation inv; |
|
122 try { |
|
123 inv = nashornBeansLinker.getGuardedInvocation(request, linkerServices); |
|
124 } catch (Throwable th) { |
|
125 inv = null; |
|
126 } |
121 |
127 |
122 switch (operator) { |
128 switch (operator) { |
123 case "getProp": |
129 case "getProp": |
124 case "getElem": |
130 case "getElem": |
125 case "getMethod": |
131 case "getMethod": |
126 if (c > 2) { |
132 return c > 2? findGetMethod(desc, inv) : findGetIndexMethod(inv); |
127 return findGetMethod(desc); |
|
128 } |
|
129 // For indexed get, we want GuardedInvocation from beans linker and pass it. |
|
130 // BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access. |
|
131 return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices)); |
|
132 case "setProp": |
133 case "setProp": |
133 case "setElem": |
134 case "setElem": |
134 return c > 2 ? findSetMethod(desc) : findSetIndexMethod(); |
135 return c > 2? findSetMethod(desc, inv) : findSetIndexMethod(); |
135 case "call": |
136 case "call": |
136 return findCallMethod(desc); |
137 return findCallMethod(desc); |
137 default: |
138 default: |
138 return null; |
139 return null; |
139 } |
140 } |
140 } |
141 } |
141 |
142 |
142 private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc) { |
143 private static GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) { |
|
144 if (inv != null) { |
|
145 return inv; |
|
146 } |
143 final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); |
147 final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); |
144 final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name); |
148 final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name); |
145 return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); |
149 return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); |
146 } |
150 } |
147 |
151 |
148 private static GuardedInvocation findGetIndexMethod(final GuardedInvocation inv) { |
152 private static GuardedInvocation findGetIndexMethod(final GuardedInvocation inv) { |
149 final MethodHandle getter = MH.insertArguments(JSOBJECTLINKER_GET, 0, inv.getInvocation()); |
153 final MethodHandle getter = MH.insertArguments(JSOBJECTLINKER_GET, 0, inv.getInvocation()); |
150 return inv.replaceMethods(getter, inv.getGuard()); |
154 return inv.replaceMethods(getter, inv.getGuard()); |
151 } |
155 } |
152 |
156 |
153 private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc) { |
157 private static GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final GuardedInvocation inv) { |
|
158 if (inv != null) { |
|
159 return inv; |
|
160 } |
154 final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, desc.getNameToken(2)); |
161 final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, desc.getNameToken(2)); |
155 return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); |
162 return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); |
156 } |
163 } |
157 |
164 |
158 private static GuardedInvocation findSetIndexMethod() { |
165 private static GuardedInvocation findSetIndexMethod() { |