aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattila <none@none>2013-04-23 16:48:57 +0200
committerattila <none@none>2013-04-23 16:48:57 +0200
commit3ce60d36d50b24543cac486adbe342498c81e085 (patch)
tree3b5a1b5e902e64bafcde35ee9cef4c1781db1e3d
parentc2aeeaed59b41fd2d72599fab23fd69be593de88 (diff)
downloadnashorn-3ce60d36d50b24543cac486adbe342498c81e085.tar.gz
8010731: Don't expose internal symbols to scripts
Reviewed-by: jlaskey, lagergren
-rw-r--r--src/jdk/nashorn/internal/codegen/CompilerConstants.java40
-rw-r--r--src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java8
2 files changed, 24 insertions, 24 deletions
diff --git a/src/jdk/nashorn/internal/codegen/CompilerConstants.java b/src/jdk/nashorn/internal/codegen/CompilerConstants.java
index 809a2453..dfc9198c 100644
--- a/src/jdk/nashorn/internal/codegen/CompilerConstants.java
+++ b/src/jdk/nashorn/internal/codegen/CompilerConstants.java
@@ -87,55 +87,55 @@ public enum CompilerConstants {
THIS("this"),
/** this debugger symbol */
- THIS_DEBUGGER("__this__"),
+ THIS_DEBUGGER(":this"),
/** scope name, type and slot */
- SCOPE("__scope__", ScriptObject.class, 2),
+ SCOPE(":scope", ScriptObject.class, 2),
/** the return value variable name were intermediate results are stored for scripts */
- RETURN("__return__"),
+ RETURN(":return"),
/** the callee value variable when necessary */
- CALLEE("__callee__", ScriptFunction.class),
+ CALLEE(":callee", ScriptFunction.class),
/** the varargs variable when necessary */
- VARARGS("__varargs__"),
+ VARARGS(":varargs"),
/** the arguments vector when necessary and the slot */
ARGUMENTS("arguments", Object.class, 2),
/** prefix for iterators for for (x in ...) */
- ITERATOR_PREFIX("$iter"),
+ ITERATOR_PREFIX(":iter"),
/** prefix for tag variable used for switch evaluation */
- SWITCH_TAG_PREFIX("$tag"),
+ SWITCH_TAG_PREFIX(":tag"),
/** prefix for all exceptions */
- EXCEPTION_PREFIX("$exception"),
+ EXCEPTION_PREFIX(":exception"),
/** prefix for quick slots generated in Store */
- QUICK_PREFIX("$quick"),
+ QUICK_PREFIX(":quick"),
/** prefix for temporary variables */
- TEMP_PREFIX("$temp"),
+ TEMP_PREFIX(":temp"),
/** prefix for literals */
- LITERAL_PREFIX("$lit"),
-
- /** prefix for map */
- MAP("$map", 1),
+ LITERAL_PREFIX(":lit"),
/** prefix for regexps */
- REGEX_PREFIX("$regex"),
+ REGEX_PREFIX(":regex"),
/** "this" used in non-static Java methods; always in slot 0 */
- JAVA_THIS("this", 0),
+ JAVA_THIS(null, 0),
+
+ /** Map parameter in scope object constructors; always in slot 1 */
+ INIT_MAP(null, 1),
- /** init scope */
- INIT_SCOPE("$scope", 2),
+ /** Parent scope parameter in scope object constructors; always in slot 2 */
+ INIT_SCOPE(null, 2),
- /** init arguments */
- INIT_ARGUMENTS("$arguments", 3),
+ /** Arguments parameter in scope object constructors; in slot 3 when present */
+ INIT_ARGUMENTS(null, 3),
/** prefix for all ScriptObject subclasses with fields, @see ObjectGenerator */
JS_OBJECT_PREFIX("JO"),
diff --git a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java
index b82e26a2..9292f980 100644
--- a/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java
+++ b/src/jdk/nashorn/internal/codegen/ObjectClassGenerator.java
@@ -28,10 +28,10 @@ package jdk.nashorn.internal.codegen;
import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE;
import static jdk.nashorn.internal.codegen.CompilerConstants.ALLOCATE;
import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_ARGUMENTS;
+import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_MAP;
import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_SCOPE;
import static jdk.nashorn.internal.codegen.CompilerConstants.JAVA_THIS;
import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
-import static jdk.nashorn.internal.codegen.CompilerConstants.MAP;
import static jdk.nashorn.internal.codegen.CompilerConstants.className;
import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
import static jdk.nashorn.internal.lookup.Lookup.MH;
@@ -387,7 +387,7 @@ public final class ObjectClassGenerator {
final MethodEmitter init = classEmitter.init(PropertyMap.class);
init.begin();
init.load(Type.OBJECT, JAVA_THIS.slot());
- init.load(Type.OBJECT, MAP.slot());
+ init.load(Type.OBJECT, INIT_MAP.slot());
init.invoke(constructorNoLookup(ScriptObject.class, PropertyMap.class));
return init;
@@ -402,7 +402,7 @@ public final class ObjectClassGenerator {
final MethodEmitter init = classEmitter.init(PropertyMap.class, ScriptObject.class);
init.begin();
init.load(Type.OBJECT, JAVA_THIS.slot());
- init.load(Type.OBJECT, MAP.slot());
+ init.load(Type.OBJECT, INIT_MAP.slot());
init.load(Type.OBJECT, INIT_SCOPE.slot());
init.invoke(constructorNoLookup(FunctionScope.class, PropertyMap.class, ScriptObject.class));
@@ -418,7 +418,7 @@ public final class ObjectClassGenerator {
final MethodEmitter init = classEmitter.init(PropertyMap.class, ScriptObject.class, Object.class);
init.begin();
init.load(Type.OBJECT, JAVA_THIS.slot());
- init.load(Type.OBJECT, MAP.slot());
+ init.load(Type.OBJECT, INIT_MAP.slot());
init.load(Type.OBJECT, INIT_SCOPE.slot());
init.load(Type.OBJECT, INIT_ARGUMENTS.slot());
init.invoke(constructorNoLookup(FunctionScope.class, PropertyMap.class, ScriptObject.class, Object.class));