159159import com .oracle .truffle .api .nodes .UnexpectedResultException ;
160160import com .oracle .truffle .api .object .DynamicObjectLibrary ;
161161import com .oracle .truffle .api .object .HiddenKey ;
162+ import com .oracle .truffle .api .object .Property ;
162163import com .oracle .truffle .api .source .Source ;
163164import com .oracle .truffle .api .source .SourceSection ;
164165import com .oracle .truffle .api .strings .TruffleString ;
255256import com .oracle .truffle .js .runtime .objects .JSObject ;
256257import com .oracle .truffle .js .runtime .objects .JSObjectUtil ;
257258import com .oracle .truffle .js .runtime .objects .JSOrdinaryObject ;
259+ import com .oracle .truffle .js .runtime .objects .JSProperty ;
258260import com .oracle .truffle .js .runtime .objects .Null ;
259261import com .oracle .truffle .js .runtime .objects .PromiseCapabilityRecord ;
260262import com .oracle .truffle .js .runtime .objects .PropertyDescriptor ;
@@ -1157,6 +1159,7 @@ public Object objectGetPropertyNames(Object object, boolean ownOnly,
11571159 JSDynamicObject dynamicObject = (JSDynamicObject ) object ;
11581160 do {
11591161 JSClass jsclass = JSObject .getJSClass (dynamicObject );
1162+ boolean ordinaryGetOwnProperty = jsclass .usesOrdinaryGetOwnProperty ();
11601163 Iterable <Object > ownKeys = jsclass .ownPropertyKeys (dynamicObject );
11611164 for (Object key : ownKeys ) {
11621165 Object keyToStore = key ;
@@ -1179,10 +1182,18 @@ public Object objectGetPropertyNames(Object object, boolean ownOnly,
11791182 continue ;
11801183 }
11811184 }
1182- PropertyDescriptor desc = jsclass .getOwnProperty (dynamicObject , key );
1183- if ((enumerableOnly && (desc == null || !desc .getEnumerable ())) || (configurableOnly && (desc == null || !desc .getConfigurable ())) ||
1184- (writableOnly && (desc == null || !desc .getWritable ()))) {
1185- continue ;
1185+ if (ordinaryGetOwnProperty ) {
1186+ Property prop = dynamicObject .getShape ().getProperty (key );
1187+ if ((enumerableOnly && (prop == null || !JSProperty .isEnumerable (prop ))) || (configurableOnly && (prop == null || !JSProperty .isConfigurable (prop ))) ||
1188+ (writableOnly && (prop == null || !JSProperty .isWritable (prop )))) {
1189+ continue ;
1190+ }
1191+ } else {
1192+ PropertyDescriptor desc = jsclass .getOwnProperty (dynamicObject , key );
1193+ if ((enumerableOnly && (desc == null || !desc .getEnumerable ())) || (configurableOnly && (desc == null || !desc .getConfigurable ())) ||
1194+ (writableOnly && (desc == null || !desc .getWritable ()))) {
1195+ continue ;
1196+ }
11861197 }
11871198 keys .add (keyToStore );
11881199 }
0 commit comments