|
45 | 45 | import static com.oracle.truffle.js.runtime.util.DefinePropertyUtil.notExtensibleMessage; |
46 | 46 | import static com.oracle.truffle.js.runtime.util.DefinePropertyUtil.reject; |
47 | 47 |
|
48 | | -import java.util.AbstractMap; |
49 | 48 | import java.util.ArrayList; |
50 | 49 | import java.util.Collections; |
51 | 50 | import java.util.List; |
52 | | -import java.util.Map; |
53 | 51 |
|
54 | 52 | import org.graalvm.collections.EconomicMap; |
55 | | -import org.graalvm.collections.MapCursor; |
56 | 53 |
|
57 | 54 | import com.oracle.truffle.api.CompilerAsserts; |
58 | 55 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
|
81 | 78 | import com.oracle.truffle.js.runtime.objects.JSShape; |
82 | 79 | import com.oracle.truffle.js.runtime.objects.Null; |
83 | 80 | import com.oracle.truffle.js.runtime.objects.PropertyDescriptor; |
84 | | -import com.oracle.truffle.js.runtime.objects.PropertyProxy; |
85 | 81 | import com.oracle.truffle.js.runtime.objects.Undefined; |
86 | 82 | import com.oracle.truffle.js.runtime.util.DefinePropertyUtil; |
87 | 83 |
|
@@ -469,63 +465,6 @@ private static PropertyDescriptor toPropertyDescriptor(Property p, Object value) |
469 | 465 | return desc; |
470 | 466 | } |
471 | 467 |
|
472 | | - private static void makeOrdinaryObject(JSDynamicObject obj, String reason) { |
473 | | - CompilerAsserts.neverPartOfCompilation(); |
474 | | - if (JSConfig.TraceDictionaryObject) { |
475 | | - System.out.printf("transitioning from dictionary object to ordinary object: %s\n", reason); |
476 | | - } |
477 | | - |
478 | | - EconomicMap<Object, PropertyDescriptor> hashMap = getHashMap(obj); |
479 | | - Shape oldShape = obj.getShape(); |
480 | | - JSContext context = JSObject.getJSContext(obj); |
481 | | - Shape newRootShape = makeEmptyShapeForNewType(context, oldShape, JSOrdinary.INSTANCE, obj); |
482 | | - |
483 | | - DynamicObjectLibrary lib = DynamicObjectLibrary.getUncached(); |
484 | | - |
485 | | - List<Property> allProperties = oldShape.getPropertyListInternal(true); |
486 | | - List<Map.Entry<Property, Object>> archive = new ArrayList<>(allProperties.size()); |
487 | | - for (Property prop : allProperties) { |
488 | | - Object key = prop.getKey(); |
489 | | - Object value = Properties.getOrDefault(lib, obj, key, null); |
490 | | - if (HASHMAP_PROPERTY_NAME.equals(key)) { |
491 | | - continue; |
492 | | - } |
493 | | - archive.add(new AbstractMap.SimpleImmutableEntry<>(prop, value)); |
494 | | - } |
495 | | - |
496 | | - lib.resetShape(obj, newRootShape); |
497 | | - |
498 | | - for (int i = 0; i < archive.size(); i++) { |
499 | | - Map.Entry<Property, Object> e = archive.get(i); |
500 | | - Property p = e.getKey(); |
501 | | - Object key = p.getKey(); |
502 | | - if (!newRootShape.hasProperty(key)) { |
503 | | - Object value = e.getValue(); |
504 | | - if (p.getLocation().isConstant()) { |
505 | | - Properties.putConstant(lib, obj, key, value, p.getFlags()); |
506 | | - } else { |
507 | | - Properties.putWithFlags(lib, obj, key, value, p.getFlags()); |
508 | | - } |
509 | | - } |
510 | | - } |
511 | | - |
512 | | - MapCursor<Object, PropertyDescriptor> cursor = hashMap.getEntries(); |
513 | | - while (cursor.advance()) { |
514 | | - Object key = cursor.getKey(); |
515 | | - assert JSRuntime.isPropertyKey(key); |
516 | | - PropertyDescriptor desc = cursor.getValue(); |
517 | | - if (desc.isDataDescriptor()) { |
518 | | - Object value = desc.getValue(); |
519 | | - assert !(value instanceof Accessor || value instanceof PropertyProxy); |
520 | | - JSObjectUtil.defineDataProperty(obj, key, value, desc.getFlags()); |
521 | | - } else { |
522 | | - JSObjectUtil.defineAccessorProperty(obj, key, new Accessor(desc.getGet(), desc.getSet()), desc.getFlags()); |
523 | | - } |
524 | | - } |
525 | | - |
526 | | - assert JSOrdinary.isJSOrdinaryObject(obj) && obj.getShape().getProperty(HASHMAP_PROPERTY_NAME) == null; |
527 | | - } |
528 | | - |
529 | 468 | public static Shape makeDictionaryShape(JSContext context, JSDynamicObject prototype) { |
530 | 469 | assert prototype != Null.instance; |
531 | 470 | return JSObjectUtil.getProtoChildShape(prototype, JSDictionary.INSTANCE, context); |
|
0 commit comments