src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java
Print this page
*** 463,476 ****
@Override
void consumeStack() {
// If this is either __FILE__, __DIR__, or __LINE__ then load the property initially as Object as we'd convert
// it anyway for replaceLocationPropertyPlaceholder.
if(identNode.isCompileTimePropertyName()) {
! method.dynamicGet(Type.OBJECT, identNode.getSymbol().getName(), flags, identNode.isFunction());
replaceCompileTimeProperty();
} else {
! dynamicGet(identNode.getSymbol().getName(), flags, identNode.isFunction());
}
}
}
private class LoadFastScopeVar extends LoadScopeVar {
--- 463,476 ----
@Override
void consumeStack() {
// If this is either __FILE__, __DIR__, or __LINE__ then load the property initially as Object as we'd convert
// it anyway for replaceLocationPropertyPlaceholder.
if(identNode.isCompileTimePropertyName()) {
! method.dynamicGet(Type.OBJECT, identNode.getSymbol().getName(), flags, identNode.isFunction(), false);
replaceCompileTimeProperty();
} else {
! dynamicGet(identNode.getSymbol().getName(), flags, identNode.isFunction(), false);
}
}
}
private class LoadFastScopeVar extends LoadScopeVar {
*** 484,494 ****
}
}
private MethodEmitter storeFastScopeVar(final Symbol symbol, final int flags) {
loadFastScopeProto(symbol, true);
! method.dynamicSet(symbol.getName(), flags | CALLSITE_FAST_SCOPE);
return method;
}
private int getScopeProtoDepth(final Block startingBlock, final Symbol symbol) {
//walk up the chain from starting block and when we bump into the current function boundary, add the external
--- 484,494 ----
}
}
private MethodEmitter storeFastScopeVar(final Symbol symbol, final int flags) {
loadFastScopeProto(symbol, true);
! method.dynamicSet(symbol.getName(), flags | CALLSITE_FAST_SCOPE, false);
return method;
}
private int getScopeProtoDepth(final Block startingBlock, final Symbol symbol) {
//walk up the chain from starting block and when we bump into the current function boundary, add the external
*** 737,747 ****
assert method.peekType().isObject();
}
@Override
void consumeStack() {
final int flags = getCallSiteFlags();
! dynamicGet(accessNode.getProperty(), flags, accessNode.isFunction());
}
}.emit(baseAlreadyOnStack ? 1 : 0);
return false;
}
--- 737,747 ----
assert method.peekType().isObject();
}
@Override
void consumeStack() {
final int flags = getCallSiteFlags();
! dynamicGet(accessNode.getProperty(), flags, accessNode.isFunction(), accessNode.isIndex());
}
}.emit(baseAlreadyOnStack ? 1 : 0);
return false;
}
*** 1441,1451 ****
loadExpressionAsObject(node.getBase());
method.dup();
// NOTE: not using a nested OptimisticOperation on this dynamicGet, as we expect to get back
// a callable object. Nobody in their right mind would optimistically type this call site.
assert !node.isOptimistic();
! method.dynamicGet(node.getType(), node.getProperty(), flags, true);
method.swap();
argCount = loadArgs(args);
}
@Override
void consumeStack() {
--- 1441,1451 ----
loadExpressionAsObject(node.getBase());
method.dup();
// NOTE: not using a nested OptimisticOperation on this dynamicGet, as we expect to get back
// a callable object. Nobody in their right mind would optimistically type this call site.
assert !node.isOptimistic();
! method.dynamicGet(node.getType(), node.getProperty(), flags, true, node.isIndex());
method.swap();
argCount = loadArgs(args);
}
@Override
void consumeStack() {
*** 3144,3154 ****
// block scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ)
final int flags = CALLSITE_SCOPE | getCallSiteFlags() | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
if (isFastScope(identSymbol)) {
storeFastScopeVar(identSymbol, flags);
} else {
! method.dynamicSet(identNode.getName(), flags);
}
} else {
final Type identType = identNode.getType();
if(identType == Type.UNDEFINED) {
// The symbol must not be slotted; the initializer is either itself undefined (explicit assignment of
--- 3144,3154 ----
// block scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ)
final int flags = CALLSITE_SCOPE | getCallSiteFlags() | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
if (isFastScope(identSymbol)) {
storeFastScopeVar(identSymbol, flags);
} else {
! method.dynamicSet(identNode.getName(), flags, false);
}
} else {
final Type identType = identNode.getType();
if(identType == Type.UNDEFINED) {
// The symbol must not be slotted; the initializer is either itself undefined (explicit assignment of
*** 4250,4260 ****
if (symbol.isScope()) {
final int flags = CALLSITE_SCOPE | getCallSiteFlags();
if (isFastScope(symbol)) {
storeFastScopeVar(symbol, flags);
} else {
! method.dynamicSet(node.getName(), flags);
}
} else {
final Type storeType = assignNode.getType();
if (symbol.hasSlotFor(storeType)) {
// Only emit a convert for a store known to be live; converts for dead stores can
--- 4250,4260 ----
if (symbol.isScope()) {
final int flags = CALLSITE_SCOPE | getCallSiteFlags();
if (isFastScope(symbol)) {
storeFastScopeVar(symbol, flags);
} else {
! method.dynamicSet(node.getName(), flags, false);
}
} else {
final Type storeType = assignNode.getType();
if (symbol.hasSlotFor(storeType)) {
// Only emit a convert for a store known to be live; converts for dead stores can
*** 4267,4277 ****
}
@Override
public boolean enterAccessNode(final AccessNode node) {
! method.dynamicSet(node.getProperty(), getCallSiteFlags());
return false;
}
@Override
public boolean enterIndexNode(final IndexNode node) {
--- 4267,4277 ----
}
@Override
public boolean enterAccessNode(final AccessNode node) {
! method.dynamicSet(node.getProperty(), getCallSiteFlags(), node.isIndex());
return false;
}
@Override
public boolean enterIndexNode(final IndexNode node) {
*** 4605,4619 ****
* @param name the name of the property being get
* @param flags call site flags
* @param isMethod whether we're preferrably retrieving a function
* @return the current method emitter
*/
! MethodEmitter dynamicGet(final String name, final int flags, final boolean isMethod) {
if(isOptimistic) {
! return method.dynamicGet(getOptimisticCoercedType(), name, getOptimisticFlags(flags), isMethod);
}
! return method.dynamicGet(resultBounds.within(expression.getType()), name, nonOptimisticFlags(flags), isMethod);
}
MethodEmitter dynamicGetIndex(final int flags, final boolean isMethod) {
if(isOptimistic) {
return method.dynamicGetIndex(getOptimisticCoercedType(), getOptimisticFlags(flags), isMethod);
--- 4605,4619 ----
* @param name the name of the property being get
* @param flags call site flags
* @param isMethod whether we're preferrably retrieving a function
* @return the current method emitter
*/
! MethodEmitter dynamicGet(final String name, final int flags, final boolean isMethod, final boolean isIndex) {
if(isOptimistic) {
! return method.dynamicGet(getOptimisticCoercedType(), name, getOptimisticFlags(flags), isMethod, isIndex);
}
! return method.dynamicGet(resultBounds.within(expression.getType()), name, nonOptimisticFlags(flags), isMethod, isIndex);
}
MethodEmitter dynamicGetIndex(final int flags, final boolean isMethod) {
if(isOptimistic) {
return method.dynamicGetIndex(getOptimisticCoercedType(), getOptimisticFlags(flags), isMethod);