Commit 7f44397 1 parent f7d527c commit 7f44397 Copy full SHA for 7f44397
File tree 5 files changed +36
-4
lines changed
5 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 85
85
"postpack" : " git clean -f '*.d.ts*' '*.tsbuildinfo'"
86
86
},
87
87
"dependencies" : {
88
- "@endo/env-options" : " workspace:^"
88
+ "@endo/env-options" : " workspace:^" ,
89
+ "@endo/no-trapping-shim" : " ^0.1.0"
89
90
},
90
91
"devDependencies" : {
91
92
"@endo/compartment-mapper" : " workspace:^" ,
Original file line number Diff line number Diff line change 14
14
/* global globalThis */
15
15
/* eslint-disable no-restricted-globals */
16
16
17
+ import '@endo/no-trapping-shim/shim.js' ;
18
+
17
19
// We cannot use globalThis as the local name since it would capture the
18
20
// lexical name.
19
21
const universalThis = globalThis ;
@@ -75,6 +77,11 @@ export const {
75
77
setPrototypeOf,
76
78
values,
77
79
fromEntries,
80
+ // https://github.com/endojs/endo/pull/2673
81
+ // @ts -expect-error TS does not yet have this on ObjectConstructor.
82
+ isNoTrapping,
83
+ // @ts -expect-error TS does not yet have this on ObjectConstructor.
84
+ suppressTrapping,
78
85
} = Object ;
79
86
80
87
export const {
@@ -125,6 +132,11 @@ export const {
125
132
ownKeys,
126
133
preventExtensions : reflectPreventExtensions ,
127
134
set : reflectSet ,
135
+ // https://github.com/endojs/endo/pull/2673
136
+ // @ts -expect-error TS does not yet have this on typeof Reflect.
137
+ isNoTrapping : reflectIsNoTrapping ,
138
+ // @ts -expect-error TS does not yet have this on typeof Reflect.
139
+ suppressTrapping : reflectSuppressTrapping ,
128
140
} = Reflect ;
129
141
130
142
export const { isArray, prototype : arrayPrototype } = Array ;
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ import {
30
30
apply ,
31
31
arrayForEach ,
32
32
defineProperty ,
33
- freeze ,
34
33
getOwnPropertyDescriptor ,
35
34
getOwnPropertyDescriptors ,
36
35
getPrototypeOf ,
@@ -49,6 +48,8 @@ import {
49
48
FERAL_STACK_GETTER ,
50
49
FERAL_STACK_SETTER ,
51
50
isError ,
51
+ isFrozen ,
52
+ suppressTrapping ,
52
53
} from './commons.js' ;
53
54
import { assert } from './error/assert.js' ;
54
55
@@ -182,8 +183,17 @@ export const makeHardener = () => {
182
183
// Also throws if the object is an ArrayBuffer or any TypedArray.
183
184
if ( isTypedArray ( obj ) ) {
184
185
freezeTypedArray ( obj ) ;
186
+ if ( isFrozen ( obj ) ) {
187
+ // After `freezeTypedArray`, the typed array might actually be
188
+ // frozen if
189
+ // - it has no indexed properties
190
+ // - it is backed by an Immutable ArrayBuffer as proposed.
191
+ // In either case, this makes it a candidate to be made
192
+ // non-trapping.
193
+ suppressTrapping ( obj ) ;
194
+ }
185
195
} else {
186
- freeze ( obj ) ;
196
+ suppressTrapping ( obj ) ;
187
197
}
188
198
189
199
// we rely upon certain commitments of Object.freeze and proxies here
Original file line number Diff line number Diff line change @@ -488,6 +488,9 @@ export const permitted = {
488
488
groupBy : fn ,
489
489
// Seen on QuickJS
490
490
__getClass : false ,
491
+ // https://github.com/endojs/endo/pull/2673
492
+ isNoTrapping : fn ,
493
+ suppressTrapping : fn ,
491
494
} ,
492
495
493
496
'%ObjectPrototype%' : {
@@ -1624,12 +1627,17 @@ export const permitted = {
1624
1627
set : fn ,
1625
1628
setPrototypeOf : fn ,
1626
1629
'@@toStringTag' : 'string' ,
1630
+ // https://github.com/endojs/endo/pull/2673
1631
+ isNoTrapping : fn ,
1632
+ suppressTrapping : fn ,
1627
1633
} ,
1628
1634
1629
1635
Proxy : {
1630
1636
// Properties of the Proxy Constructor
1631
1637
'[[Proto]]' : '%FunctionPrototype%' ,
1632
1638
revocable : fn ,
1639
+ // https://github.com/endojs/endo/pull/2673
1640
+ prototype : 'undefined' ,
1633
1641
} ,
1634
1642
1635
1643
// Appendix B
Original file line number Diff line number Diff line change @@ -702,7 +702,7 @@ __metadata:
702
702
languageName : unknown
703
703
linkType : soft
704
704
705
- " @endo/no-trapping-shim@workspace:packages/no-trapping-shim " :
705
+ " @endo/no-trapping-shim@npm:^0.1.0, @endo/no-trapping-shim@ workspace:packages/no-trapping-shim " :
706
706
version : 0.0.0-use.local
707
707
resolution : " @endo/no-trapping-shim@workspace:packages/no-trapping-shim"
708
708
dependencies :
@@ -8960,6 +8960,7 @@ __metadata:
8960
8960
" @endo/compartment-mapper " : " workspace:^"
8961
8961
" @endo/env-options " : " workspace:^"
8962
8962
" @endo/module-source " : " workspace:^"
8963
+ " @endo/no-trapping-shim " : " npm:^0.1.0"
8963
8964
" @endo/test262-runner " : " workspace:^"
8964
8965
ava : " npm:^6.1.3"
8965
8966
babel-eslint : " npm:^10.1.0"
You can’t perform that action at this time.
0 commit comments