|
57 | 57 | import java.util.SplittableRandom; |
58 | 58 | import java.util.WeakHashMap; |
59 | 59 |
|
| 60 | +import com.oracle.truffle.js.runtime.objects.Null; |
60 | 61 | import org.graalvm.collections.Pair; |
61 | 62 | import org.graalvm.home.HomeFinder; |
62 | 63 | import org.graalvm.options.OptionValues; |
@@ -274,6 +275,15 @@ public class JSRealm { |
274 | 275 | private final JSFunctionObject callSiteConstructor; |
275 | 276 | private final JSDynamicObject callSitePrototype; |
276 | 277 |
|
| 278 | + private final JSDynamicObject foreignArrayPrototype; |
| 279 | + private final JSDynamicObject foreignDatePrototype; |
| 280 | + private final JSDynamicObject foreignMapPrototype; |
| 281 | + private final JSDynamicObject foreignStringPrototype; |
| 282 | + private final JSDynamicObject foreignNumberPrototype; |
| 283 | + private final JSDynamicObject foreignBooleanPrototype; |
| 284 | + private final JSDynamicObject foreignFunctionPrototype; |
| 285 | + private final JSDynamicObject foreignObjectPrototype; |
| 286 | + |
277 | 287 | private final Shape initialRegExpPrototypeShape; |
278 | 288 | private final JSObjectFactory.RealmData objectFactories; |
279 | 289 |
|
@@ -974,6 +984,18 @@ protected JSRealm(JSContext context, TruffleLanguage.Env env, JSRealm parentReal |
974 | 984 | this.temporalZonedDateTimeConstructor = null; |
975 | 985 | this.temporalZonedDateTimePrototype = null; |
976 | 986 | } |
| 987 | + |
| 988 | + // always create, regardless of context.isOptionForeignObjectPrototype() |
| 989 | + // we use them in some scenarios even when option is turned off |
| 990 | + this.foreignArrayPrototype = JSOrdinary.createInit(this, this.arrayPrototype); |
| 991 | + this.foreignDatePrototype = JSOrdinary.createInit(this, this.datePrototype); |
| 992 | + // mapPrototype can be null in ES5 mode |
| 993 | + this.foreignMapPrototype = JSOrdinary.createInit(this, this.mapPrototype == null ? Null.instance : this.mapPrototype); |
| 994 | + this.foreignStringPrototype = JSOrdinary.createInit(this, this.stringPrototype); |
| 995 | + this.foreignNumberPrototype = JSOrdinary.createInit(this, this.numberPrototype); |
| 996 | + this.foreignBooleanPrototype = JSOrdinary.createInit(this, this.booleanPrototype); |
| 997 | + this.foreignFunctionPrototype = JSOrdinary.createInit(this, this.functionPrototype); |
| 998 | + this.foreignObjectPrototype = JSOrdinary.createInit(this, this.objectPrototype); |
977 | 999 | } |
978 | 1000 |
|
979 | 1001 | private void initializeTypedArrayConstructors() { |
@@ -1492,6 +1514,38 @@ public JSDynamicObject getTemporalZonedDateTimePrototype() { |
1492 | 1514 | return temporalZonedDateTimePrototype; |
1493 | 1515 | } |
1494 | 1516 |
|
| 1517 | + public final JSDynamicObject getForeignArrayPrototype() { |
| 1518 | + return foreignArrayPrototype; |
| 1519 | + } |
| 1520 | + |
| 1521 | + public final JSDynamicObject getForeignDatePrototype() { |
| 1522 | + return foreignDatePrototype; |
| 1523 | + } |
| 1524 | + |
| 1525 | + public JSDynamicObject getForeignMapPrototype() { |
| 1526 | + return foreignMapPrototype; |
| 1527 | + } |
| 1528 | + |
| 1529 | + public JSDynamicObject getForeignStringPrototype() { |
| 1530 | + return foreignStringPrototype; |
| 1531 | + } |
| 1532 | + |
| 1533 | + public JSDynamicObject getForeignNumberPrototype() { |
| 1534 | + return foreignNumberPrototype; |
| 1535 | + } |
| 1536 | + |
| 1537 | + public JSDynamicObject getForeignBooleanPrototype() { |
| 1538 | + return foreignBooleanPrototype; |
| 1539 | + } |
| 1540 | + |
| 1541 | + public JSDynamicObject getForeignFunctionPrototype() { |
| 1542 | + return foreignFunctionPrototype; |
| 1543 | + } |
| 1544 | + |
| 1545 | + public JSDynamicObject getForeignObjectPrototype() { |
| 1546 | + return foreignObjectPrototype; |
| 1547 | + } |
| 1548 | + |
1495 | 1549 | public final Map<Object, JSDynamicObject> getTemplateRegistry() { |
1496 | 1550 | if (templateRegistry == null) { |
1497 | 1551 | createTemplateRegistry(); |
|
0 commit comments