aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/codegen/ObjectCreator.java
diff options
context:
space:
mode:
authorhannesw <none@none>2013-07-05 14:36:54 +0200
committerhannesw <none@none>2013-07-05 14:36:54 +0200
commit3e6b14405217bed1b38b25efbce8b2e015fd0b66 (patch)
tree0b0c324cd89ec0731448329cc38a8d50b41ac466 /src/jdk/nashorn/internal/codegen/ObjectCreator.java
parent48f4f1edffddc0bd3368942fa77f75286cc286e7 (diff)
8017084: Use spill properties for large object literals
Reviewed-by: lagergren, sundar
Diffstat (limited to 'src/jdk/nashorn/internal/codegen/ObjectCreator.java')
-rw-r--r--src/jdk/nashorn/internal/codegen/ObjectCreator.java74
1 files changed, 13 insertions, 61 deletions
diff --git a/src/jdk/nashorn/internal/codegen/ObjectCreator.java b/src/jdk/nashorn/internal/codegen/ObjectCreator.java
index b0e5a773..2a8ebba7 100644
--- a/src/jdk/nashorn/internal/codegen/ObjectCreator.java
+++ b/src/jdk/nashorn/internal/codegen/ObjectCreator.java
@@ -25,10 +25,10 @@
package jdk.nashorn.internal.codegen;
+import static jdk.nashorn.internal.codegen.CompilerConstants.SCOPE;
+
import java.util.List;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.FIELD_PADDING;
import jdk.nashorn.internal.ir.Symbol;
-import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.PropertyMap;
/**
@@ -36,9 +36,6 @@ import jdk.nashorn.internal.runtime.PropertyMap;
*/
public abstract class ObjectCreator {
- /** Compile unit for this ObjectCreator, see CompileUnit */
- //protected final CompileUnit compileUnit;
-
/** List of keys to initiate in this ObjectCreator */
protected final List<String> keys;
@@ -50,12 +47,7 @@ public abstract class ObjectCreator {
private final boolean isScope;
private final boolean hasArguments;
- private int fieldCount;
- private int paddedFieldCount;
- private int paramCount;
- private String fieldObjectClassName;
- private Class<?> fieldObjectClass;
- private PropertyMap propertyMap;
+ protected PropertyMap propertyMap;
/**
* Constructor
@@ -72,41 +64,6 @@ public abstract class ObjectCreator {
this.symbols = symbols;
this.isScope = isScope;
this.hasArguments = hasArguments;
-
- countFields();
- findClass();
- }
-
- /**
- * Tally the number of fields and parameters.
- */
- private void countFields() {
- for (final Symbol symbol : this.symbols) {
- if (symbol != null) {
- if (hasArguments() && symbol.isParam()) {
- symbol.setFieldIndex(paramCount++);
- } else {
- symbol.setFieldIndex(fieldCount++);
- }
- }
- }
-
- paddedFieldCount = fieldCount + FIELD_PADDING;
- }
-
- /**
- * Locate (or indirectly create) the object container class.
- */
- private void findClass() {
- fieldObjectClassName = isScope() ?
- ObjectClassGenerator.getClassName(fieldCount, paramCount) :
- ObjectClassGenerator.getClassName(paddedFieldCount);
-
- try {
- this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName));
- } catch (final ClassNotFoundException e) {
- throw new AssertionError("Nashorn has encountered an internal error. Structure can not be created.");
- }
}
/**
@@ -116,6 +73,12 @@ public abstract class ObjectCreator {
protected abstract void makeObject(final MethodEmitter method);
/**
+ * Construct the property map appropriate for the object.
+ * @return the newly created property map
+ */
+ protected abstract PropertyMap makeMap();
+
+ /**
* Create a new MapCreator
* @param clazz type of MapCreator
* @return map creator instantiated by type
@@ -125,12 +88,11 @@ public abstract class ObjectCreator {
}
/**
- * Construct the property map appropriate for the object.
- * @return the newly created property map
+ * Loads the scope on the stack through the passed method emitter.
+ * @param method the method emitter to use
*/
- protected PropertyMap makeMap() {
- propertyMap = newMapCreator(fieldObjectClass).makeMap(hasArguments(), fieldCount, paddedFieldCount);
- return propertyMap;
+ protected void loadScope(final MethodEmitter method) {
+ method.loadCompilerConstant(SCOPE);
}
/**
@@ -144,16 +106,6 @@ public abstract class ObjectCreator {
}
/**
- * Get the class name for the object class,
- * e.g. {@code com.nashorn.oracle.scripts.JO2P0}
- *
- * @return script class name
- */
- String getClassName() {
- return fieldObjectClassName;
- }
-
- /**
* Is this a scope object
* @return true if scope
*/