Skip to content

Commit 1146806

Browse files
RaisinTenRafaelGSS
authored andcommitted
bootstrap: stop delaying instantiation of maps in per-context scripts
The linked issue, https://bugs.chromium.org/p/v8/issues/detail?id=6593, is marked as "Fixed", so I think we can revert this now. This reverts commit 08a9c4a. Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42934 Refs: https://bugs.chromium.org/p/v8/issues/detail?id=9187 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent e058f47 commit 1146806

File tree

1 file changed

+37
-60
lines changed

1 file changed

+37
-60
lines changed

‎lib/internal/per_context/domexception.js‎

Lines changed: 37 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,18 @@ function throwInvalidThisError(Base, type){
3636
throwerr;
3737
}
3838

39-
letdisusedNamesSet;
40-
letinternalsMap;
41-
letnameToCodeMap;
42-
letisInitialized=false;
39+
constinternalsMap=newSafeWeakMap();
40+
constnameToCodeMap=newSafeMap();
4341

44-
// We need to instantiate the maps lazily because they render
45-
// the snapshot non-rehashable.
46-
// https://bugs.chromium.org/p/v8/issues/detail?id=6593
47-
functionensureInitialized(){
48-
if(isInitialized){
49-
return;
50-
}
51-
internalsMap=newSafeWeakMap();
52-
nameToCodeMap=newSafeMap();
53-
forEachCode((name,codeName,value)=>{
54-
nameToCodeMap.set(name,value);
55-
});
56-
57-
// These were removed from the error names table.
58-
// See https://github.com/heycam/webidl/pull/946.
59-
disusedNamesSet=newSafeSet()
60-
.add('DOMStringSizeError')
61-
.add('NoDataAllowedError')
62-
.add('ValidationError');
63-
64-
isInitialized=true;
65-
}
42+
// These were removed from the error names table.
43+
// See https://github.com/heycam/webidl/pull/946.
44+
constdisusedNamesSet=newSafeSet()
45+
.add('DOMStringSizeError')
46+
.add('NoDataAllowedError')
47+
.add('ValidationError');
6648

6749
classDOMException{
6850
constructor(message='',name='Error'){
69-
ensureInitialized();
7051
ErrorCaptureStackTrace(this);
7152
internalsMap.set(this,{
7253
message: `${message}`,
@@ -75,7 +56,6 @@ class DOMException{
7556
}
7657

7758
getname(){
78-
ensureInitialized();
7959
constinternals=internalsMap.get(this);
8060
if(internals===undefined){
8161
throwInvalidThisError(TypeError,'DOMException');
@@ -84,7 +64,6 @@ class DOMException{
8464
}
8565

8666
getmessage(){
87-
ensureInitialized();
8867
constinternals=internalsMap.get(this);
8968
if(internals===undefined){
9069
throwInvalidThisError(TypeError,'DOMException');
@@ -93,7 +72,6 @@ class DOMException{
9372
}
9473

9574
getcode(){
96-
ensureInitialized();
9775
constinternals=internalsMap.get(this);
9876
if(internals===undefined){
9977
throwInvalidThisError(TypeError,'DOMException');
@@ -116,40 +94,39 @@ ObjectDefineProperties(DOMException.prototype,{
11694
code: {enumerable: true,configurable: true}
11795
});
11896

119-
functionforEachCode(fn){
120-
fn('IndexSizeError','INDEX_SIZE_ERR',1);
121-
fn('DOMStringSizeError','DOMSTRING_SIZE_ERR',2);
122-
fn('HierarchyRequestError','HIERARCHY_REQUEST_ERR',3);
123-
fn('WrongDocumentError','WRONG_DOCUMENT_ERR',4);
124-
fn('InvalidCharacterError','INVALID_CHARACTER_ERR',5);
125-
fn('NoDataAllowedError','NO_DATA_ALLOWED_ERR',6);
126-
fn('NoModificationAllowedError','NO_MODIFICATION_ALLOWED_ERR',7);
127-
fn('NotFoundError','NOT_FOUND_ERR',8);
128-
fn('NotSupportedError','NOT_SUPPORTED_ERR',9);
129-
fn('InUseAttributeError','INUSE_ATTRIBUTE_ERR',10);
130-
fn('InvalidStateError','INVALID_STATE_ERR',11);
131-
fn('SyntaxError','SYNTAX_ERR',12);
132-
fn('InvalidModificationError','INVALID_MODIFICATION_ERR',13);
133-
fn('NamespaceError','NAMESPACE_ERR',14);
134-
fn('InvalidAccessError','INVALID_ACCESS_ERR',15);
135-
fn('ValidationError','VALIDATION_ERR',16);
136-
fn('TypeMismatchError','TYPE_MISMATCH_ERR',17);
137-
fn('SecurityError','SECURITY_ERR',18);
138-
fn('NetworkError','NETWORK_ERR',19);
139-
fn('AbortError','ABORT_ERR',20);
140-
fn('URLMismatchError','URL_MISMATCH_ERR',21);
141-
fn('QuotaExceededError','QUOTA_EXCEEDED_ERR',22);
142-
fn('TimeoutError','TIMEOUT_ERR',23);
143-
fn('InvalidNodeTypeError','INVALID_NODE_TYPE_ERR',24);
144-
fn('DataCloneError','DATA_CLONE_ERR',25);
97+
for(const{0: name,1: codeName,2: value}of[
98+
['IndexSizeError','INDEX_SIZE_ERR',1],
99+
['DOMStringSizeError','DOMSTRING_SIZE_ERR',2],
100+
['HierarchyRequestError','HIERARCHY_REQUEST_ERR',3],
101+
['WrongDocumentError','WRONG_DOCUMENT_ERR',4],
102+
['InvalidCharacterError','INVALID_CHARACTER_ERR',5],
103+
['NoDataAllowedError','NO_DATA_ALLOWED_ERR',6],
104+
['NoModificationAllowedError','NO_MODIFICATION_ALLOWED_ERR',7],
105+
['NotFoundError','NOT_FOUND_ERR',8],
106+
['NotSupportedError','NOT_SUPPORTED_ERR',9],
107+
['InUseAttributeError','INUSE_ATTRIBUTE_ERR',10],
108+
['InvalidStateError','INVALID_STATE_ERR',11],
109+
['SyntaxError','SYNTAX_ERR',12],
110+
['InvalidModificationError','INVALID_MODIFICATION_ERR',13],
111+
['NamespaceError','NAMESPACE_ERR',14],
112+
['InvalidAccessError','INVALID_ACCESS_ERR',15],
113+
['ValidationError','VALIDATION_ERR',16],
114+
['TypeMismatchError','TYPE_MISMATCH_ERR',17],
115+
['SecurityError','SECURITY_ERR',18],
116+
['NetworkError','NETWORK_ERR',19],
117+
['AbortError','ABORT_ERR',20],
118+
['URLMismatchError','URL_MISMATCH_ERR',21],
119+
['QuotaExceededError','QUOTA_EXCEEDED_ERR',22],
120+
['TimeoutError','TIMEOUT_ERR',23],
121+
['InvalidNodeTypeError','INVALID_NODE_TYPE_ERR',24],
122+
['DataCloneError','DATA_CLONE_ERR',25],
145123
// There are some more error names, but since they don't have codes assigned,
146124
// we don't need to care about them.
147-
}
148-
149-
forEachCode((name,codeName,value)=>{
125+
]){
150126
constdesc={enumerable: true, value };
151127
ObjectDefineProperty(DOMException,codeName,desc);
152128
ObjectDefineProperty(DOMException.prototype,codeName,desc);
153-
});
129+
nameToCodeMap.set(name,value);
130+
}
154131

155132
exports.DOMException=DOMException;

0 commit comments

Comments
(0)