Java Code Examples for jdk.internal.dynalink.linker.LinkRequest#isCallSiteUnstable()
The following examples show how to use
jdk.internal.dynalink.linker.LinkRequest#isCallSiteUnstable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptObject.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 2
Source File: WithObject.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 3
Source File: ScriptObject.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 4
Source File: WithObject.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 5
Source File: ScriptObject.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 6
Source File: WithObject.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 7
Source File: ScriptObject.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 8
Source File: WithObject.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 9
Source File: ScriptObject.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 10
Source File: WithObject.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 11
Source File: ScriptObject.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable()) { return findMegaMorphicSetMethod(desc, name); } final boolean scope = isScope(); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, scope, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (!scope && find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, "property.not.writable", false); } // Otherwise, forget the found property find = null; } if (find != null) { if(!find.getProperty().isWritable()) { // Existing, non-writable property return createEmptySetMethod(desc, "property.not.writable", true); } } else { if (PROTO_PROPERTY_NAME.equals(name)) { return new GuardedInvocation(SETPROTOCHECK, NashornGuards.getScriptObjectGuard()); } else if (! isExtensible()) { return createEmptySetMethod(desc, "object.non.extensible", false); } } return new SetMethodCreator(this, find, desc).createGuardedInvocation(); }
Example 12
Source File: ScriptObject.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable()) { return findMegaMorphicSetMethod(desc, name); } final boolean scope = isScope(); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, scope, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (!scope && find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, "property.not.writable", false); } // Otherwise, forget the found property find = null; } if (find != null) { if(!find.getProperty().isWritable()) { // Existing, non-writable property return createEmptySetMethod(desc, "property.not.writable", true); } } else { if (PROTO_PROPERTY_NAME.equals(name)) { return new GuardedInvocation(SETPROTOCHECK, NashornGuards.getScriptObjectGuard()); } else if (! isExtensible()) { return createEmptySetMethod(desc, "object.non.extensible", false); } } return new SetMethodCreator(this, find, desc).createGuardedInvocation(); }
Example 13
Source File: ScriptObject.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if (request.isCallSiteUnstable() || hasWithScope()) { return findMegaMorphicSetMethod(desc, name); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } // Otherwise, forget the found property unless this is a scope callsite and the owner is a scope object as well. if (!NashornCallSiteDescriptor.isScope(desc) || !find.getOwner().isScope()) { find = null; } } if (find != null) { if (!find.getProperty().isWritable() && !NashornCallSiteDescriptor.isDeclaration(desc)) { if (NashornCallSiteDescriptor.isScope(desc) && find.getProperty().isLexicalBinding()) { throw typeError("assign.constant", name); // Overwriting ES6 const should throw also in non-strict mode. } // Existing, non-writable property return createEmptySetMethod(desc, explicitInstanceOfCheck, "property.not.writable", true); } } else { if (!isExtensible()) { return createEmptySetMethod(desc, explicitInstanceOfCheck, "object.non.extensible", false); } } final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); final GlobalConstants globalConstants = getGlobalConstants(); if (globalConstants != null) { final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); if (cinv != null) { return cinv; } } return inv; }
Example 14
Source File: WithObject.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
@Override public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { if (request.isCallSiteUnstable()) { // Fall back to megamorphic invocation which performs a complete lookup each time without further relinking. return super.lookup(desc, request); } // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of // necessity have a Nashorn descriptor - it is safe to cast. final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; FindProperty find = null; GuardedInvocation link = null; ScriptObject self; final boolean isNamedOperation; final String name; if (desc.getNameTokenCount() > 2) { isNamedOperation = true; name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); } else { isNamedOperation = false; name = null; } self = expression; if (isNamedOperation) { find = self.findProperty(name, true); } if (find != null) { link = self.lookup(desc, request); if (link != null) { return fixExpressionCallSite(ndesc, link); } } final ScriptObject scope = getProto(); if (isNamedOperation) { find = scope.findProperty(name, true); } if (find != null) { return fixScopeCallSite(scope.lookup(desc, request), name, find.getOwner()); } // the property is not found - now check for // __noSuchProperty__ and __noSuchMethod__ in expression if (self != null) { final String fallBack; final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0); switch (operator) { case "callMethod": throw new AssertionError(); // Nashorn never emits callMethod case "getMethod": fallBack = NO_SUCH_METHOD_NAME; break; case "getProp": case "getElem": fallBack = NO_SUCH_PROPERTY_NAME; break; default: fallBack = null; break; } if (fallBack != null) { find = self.findProperty(fallBack, true); if (find != null) { switch (operator) { case "getMethod": link = self.noSuchMethod(desc, request); break; case "getProp": case "getElem": link = self.noSuchProperty(desc, request); break; default: break; } } } if (link != null) { return fixExpressionCallSite(ndesc, link); } } // still not found, may be scope can handle with it's own // __noSuchProperty__, __noSuchMethod__ etc. link = scope.lookup(desc, request); if (link != null) { return fixScopeCallSite(link, name, null); } return null; }
Example 15
Source File: ScriptObject.java From nashorn with GNU General Public License v2.0 | 4 votes |
/** * Find the appropriate SET method for an invoke dynamic call. * * @param desc the call site descriptor * @param request the link request * * @return GuardedInvocation to be invoked at call site. */ protected GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) { final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); if(request.isCallSiteUnstable()) { return findMegaMorphicSetMethod(desc, name); } final boolean scope = isScope(); /* * If doing property set on a scope object, we should stop proto search on the first * non-scope object. Without this, for example, when assigning "toString" on global scope, * we'll end up assigning it on it's proto - which is Object.prototype.toString !! * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ FindProperty find = findProperty(name, true, scope, this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (!scope && find != null && find.isInherited() && !(find.getProperty() instanceof UserAccessorProperty)) { // We should still check if inherited data property is not writable if (isExtensible() && !find.getProperty().isWritable()) { return createEmptySetMethod(desc, "property.not.writable", false); } // Otherwise, forget the found property find = null; } if (find != null) { if(!find.getProperty().isWritable()) { // Existing, non-writable property return createEmptySetMethod(desc, "property.not.writable", true); } } else { if (PROTO_PROPERTY_NAME.equals(name)) { return new GuardedInvocation(SETPROTOCHECK, NashornGuards.getScriptObjectGuard()); } else if (! isExtensible()) { return createEmptySetMethod(desc, "object.non.extensible", false); } } return new SetMethodCreator(this, find, desc).createGuardedInvocation(); }