aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jdk/nashorn/internal/codegen/CodeGenerator.java5
-rw-r--r--src/jdk/nashorn/internal/objects/Global.java7
-rw-r--r--src/jdk/nashorn/internal/runtime/ScriptObject.java16
3 files changed, 17 insertions, 11 deletions
diff --git a/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/src/jdk/nashorn/internal/codegen/CodeGenerator.java
index 9cf0adb9..882846c6 100644
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java
+++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java
@@ -1451,7 +1451,10 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
if (value == null) {
hasGettersSetters = true;
- } else if (key.equals(ScriptObject.PROTO_PROPERTY_NAME)) {
+ } else if (propertyNode.getKey() instanceof IdentNode &&
+ key.equals(ScriptObject.PROTO_PROPERTY_NAME)) {
+ // ES6 draft compliant __proto__ inside object literal
+ // Identifier key and name is __proto__
protoNode = value;
continue;
}
diff --git a/src/jdk/nashorn/internal/objects/Global.java b/src/jdk/nashorn/internal/objects/Global.java
index 9e40dbeb..00019382 100644
--- a/src/jdk/nashorn/internal/objects/Global.java
+++ b/src/jdk/nashorn/internal/objects/Global.java
@@ -1906,6 +1906,13 @@ public final class Global extends ScriptObject implements Scope {
// Object.getPrototypeOf(Function.prototype) === Object.prototype
anon.setInitialProto(ObjectPrototype);
+ // ES6 draft compliant __proto__ property of Object.prototype
+ // accessors on Object.prototype for "__proto__"
+ final ScriptFunction getProto = ScriptFunctionImpl.makeFunction("getProto", ScriptObject.GETPROTO);
+ final ScriptFunction setProto = ScriptFunctionImpl.makeFunction("setProto", ScriptObject.SETPROTOCHECK);
+ ObjectPrototype.addOwnProperty("__proto__", Attribute.NOT_ENUMERABLE, getProto, setProto);
+
+
// Function valued properties of Function.prototype were not properly
// initialized. Because, these were created before global.function and
// global.object were not initialized.
diff --git a/src/jdk/nashorn/internal/runtime/ScriptObject.java b/src/jdk/nashorn/internal/runtime/ScriptObject.java
index 1519024a..d4556d89 100644
--- a/src/jdk/nashorn/internal/runtime/ScriptObject.java
+++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java
@@ -91,7 +91,7 @@ import jdk.nashorn.internal.runtime.linker.NashornGuards;
*/
public abstract class ScriptObject implements PropertyAccess {
- /** __proto__ special property name */
+ /** __proto__ special property name inside object literals. ES6 draft. */
public static final String PROTO_PROPERTY_NAME = "__proto__";
/** Search fall back routine name for "no such method" */
@@ -130,8 +130,10 @@ public abstract class ScriptObject implements PropertyAccess {
/** Indexed array data. */
private ArrayData arrayData;
- static final MethodHandle GETPROTO = findOwnMH("getProto", ScriptObject.class);
- static final MethodHandle SETPROTOCHECK = findOwnMH("setProtoCheck", void.class, Object.class);
+ /** Method handle to retrive prototype of this object */
+ public static final MethodHandle GETPROTO = findOwnMH("getProto", ScriptObject.class);
+ /** Method handle to set prototype of this object */
+ public static final MethodHandle SETPROTOCHECK = findOwnMH("setProtoCheck", void.class, Object.class);
static final MethodHandle MEGAMORPHIC_GET = findOwnMH("megamorphicGet", Object.class, String.class, boolean.class, boolean.class);
static final MethodHandle GLOBALFILTER = findOwnMH("globalFilter", Object.class, Object.class);
@@ -1732,10 +1734,6 @@ public abstract class ScriptObject implements PropertyAccess {
MethodHandle methodHandle;
if (find == null) {
- if (PROTO_PROPERTY_NAME.equals(name)) {
- return new GuardedInvocation(GETPROTO, NashornGuards.getScriptObjectGuard());
- }
-
if ("getProp".equals(operator)) {
return noSuchProperty(desc, request);
} else if ("getMethod".equals(operator)) {
@@ -1890,9 +1888,7 @@ public abstract class ScriptObject implements PropertyAccess {
return createEmptySetMethod(desc, "property.not.writable", true);
}
} else {
- if (PROTO_PROPERTY_NAME.equals(name)) {
- return new GuardedInvocation(SETPROTOCHECK, NashornGuards.getScriptObjectGuard());
- } else if (! isExtensible()) {
+ if (! isExtensible()) {
return createEmptySetMethod(desc, "object.non.extensible", false);
}
}