@@ -139,49 +139,42 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
139
139
{
140
140
break ;
141
141
}
142
- ecma_number_t num = ecma_string_to_number (property_name_p );
143
- bool is_same ;
144
- if (num <= 0 )
145
- {
146
- is_same = true;
147
- }
148
- else
149
- {
150
- ecma_string_t * num_to_str = ecma_new_ecma_string_from_number (num );
151
- is_same = ecma_compare_ecma_strings (property_name_p , num_to_str );
152
- ecma_deref_ecma_string (num_to_str );
153
- }
154
142
155
- if (is_same )
143
+ uint32_t index = ecma_string_get_array_index (property_name_p );
144
+
145
+ if (index == ECMA_STRING_NOT_ARRAY_INDEX )
156
146
{
157
- ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
158
- ecma_value_t value = ecma_get_typedarray_element (& info , num );
147
+ JERRY_ASSERT (index == UINT32_MAX );
159
148
160
- if (ECMA_IS_VALUE_ERROR ( value ))
149
+ if (! ecma_typedarray_is_element_index ( property_name_p ))
161
150
{
162
- property_ref_p -> virtual_value = value ;
163
- return ECMA_PROPERTY_TYPE_NOT_FOUND ;
151
+ break ;
164
152
}
153
+ }
165
154
166
- if (!ecma_is_value_undefined (value ))
167
- {
168
- if (options & ECMA_PROPERTY_GET_VALUE )
169
- {
170
- property_ref_p -> virtual_value = value ;
171
- }
172
- else
173
- {
174
- ecma_fast_free_value (value );
175
- }
155
+ ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
156
+ ecma_value_t value = ecma_get_typedarray_element (& info , index );
176
157
177
- return ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_PROPERTY_VIRTUAL ;
178
- }
179
- else
180
- {
181
- return ECMA_PROPERTY_TYPE_NOT_FOUND ;
182
- }
158
+ if (ECMA_IS_VALUE_ERROR (value ))
159
+ {
160
+ return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_THROW ;
183
161
}
184
- break ;
162
+
163
+ if (JERRY_UNLIKELY (ecma_is_value_undefined (value )))
164
+ {
165
+ return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP ;
166
+ }
167
+
168
+ if (options & ECMA_PROPERTY_GET_VALUE )
169
+ {
170
+ property_ref_p -> virtual_value = value ;
171
+ }
172
+ else
173
+ {
174
+ ecma_fast_free_value (value );
175
+ }
176
+
177
+ return ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_PROPERTY_VIRTUAL ;
185
178
}
186
179
#endif /* JERRY_BUILTIN_TYPEDARRAY */
187
180
#if JERRY_MODULE_SYSTEM
@@ -457,48 +450,25 @@ ecma_op_object_has_property (ecma_object_t *object_p, /**< the object */
457
450
}
458
451
#endif /* JERRY_BUILTIN_PROXY */
459
452
460
- #if JERRY_BUILTIN_TYPEDARRAY
461
- if (ecma_object_is_typedarray (object_p ) && !ecma_prop_name_is_symbol (property_name_p ))
453
+ /* 2 - 3. */
454
+ ecma_property_t property = ecma_op_object_get_own_property (object_p ,
455
+ property_name_p ,
456
+ NULL ,
457
+ ECMA_PROPERTY_GET_NO_OPTIONS );
458
+
459
+ if (property != ECMA_PROPERTY_TYPE_NOT_FOUND )
462
460
{
463
- ecma_number_t num = ecma_string_to_number (property_name_p );
464
- bool is_same ;
465
- if (num <= 0 )
466
- {
467
- is_same = true;
468
- }
469
- else
461
+ #if JERRY_BUILTIN_TYPEDARRAY
462
+ if (JERRY_UNLIKELY (property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_THROW ))
470
463
{
471
- ecma_string_t * num_to_str = ecma_new_ecma_string_from_number (num );
472
- is_same = ecma_compare_ecma_strings (property_name_p , num_to_str );
473
- ecma_deref_ecma_string (num_to_str );
464
+ return ECMA_VALUE_ERROR ;
474
465
}
475
-
476
- if (is_same )
477
- {
478
- ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
479
-
480
- if (ecma_arraybuffer_is_detached (info .array_buffer_p ))
481
- {
482
- return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached ));
483
- }
484
-
485
- if (!ecma_op_is_integer (num )
486
- || num >= info .length
487
- || num < 0
488
- || (ecma_number_is_negative (num ) && ecma_number_is_zero (num )))
489
- {
490
- return ECMA_VALUE_FALSE ;
491
- }
492
-
493
- return ECMA_VALUE_TRUE ;
494
- }
495
- }
496
466
#endif /* JERRY_BUILTIN_TYPEDARRAY */
497
467
498
- /* 2 - 3. */
499
- if ( ecma_op_ordinary_object_has_own_property ( object_p , property_name_p ))
500
- {
501
- return ECMA_VALUE_TRUE ;
468
+ JERRY_ASSERT ( property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP
469
+ || ECMA_PROPERTY_IS_FOUND ( property ));
470
+
471
+ return ecma_make_boolean_value ( property != ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP ) ;
502
472
}
503
473
504
474
jmem_cpointer_t proto_cp = ecma_op_ordinary_object_get_prototype_of (object_p );
@@ -604,26 +574,20 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
604
574
break ;
605
575
}
606
576
607
- ecma_number_t num = ecma_string_to_number (property_name_p );
608
- bool is_same ;
609
- if (num <= 0 )
610
- {
611
- is_same = true;
612
- }
613
- else
614
- {
615
- ecma_string_t * num_to_str = ecma_new_ecma_string_from_number (num );
616
- is_same = ecma_compare_ecma_strings (property_name_p , num_to_str );
617
- ecma_deref_ecma_string (num_to_str );
618
- }
577
+ uint32_t index = ecma_string_get_array_index (property_name_p );
619
578
620
- if (is_same )
579
+ if (index == ECMA_STRING_NOT_ARRAY_INDEX )
621
580
{
622
- ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
623
- return ecma_get_typedarray_element (& info , num );
581
+ JERRY_ASSERT (index == UINT32_MAX );
582
+
583
+ if (!ecma_typedarray_is_element_index (property_name_p ))
584
+ {
585
+ break ;
586
+ }
624
587
}
625
588
626
- break ;
589
+ ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
590
+ return ecma_get_typedarray_element (& info , index );
627
591
}
628
592
#endif /* JERRY_BUILTIN_TYPEDARRAY */
629
593
#if JERRY_MODULE_SYSTEM
@@ -1447,25 +1411,20 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
1447
1411
break ;
1448
1412
}
1449
1413
1450
- ecma_number_t num = ecma_string_to_number (property_name_p );
1451
- bool is_same ;
1452
- if (num <= 0 )
1453
- {
1454
- is_same = true;
1455
- }
1456
- else
1457
- {
1458
- ecma_string_t * num_to_str = ecma_new_ecma_string_from_number (num );
1459
- is_same = ecma_compare_ecma_strings (property_name_p , num_to_str );
1460
- ecma_deref_ecma_string (num_to_str );
1461
- }
1414
+ uint32_t index = ecma_string_get_array_index (property_name_p );
1462
1415
1463
- if (is_same )
1416
+ if (index == ECMA_STRING_NOT_ARRAY_INDEX )
1464
1417
{
1465
- ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
1466
- return ecma_set_typedarray_element (& info , value , num );
1418
+ JERRY_ASSERT (index == UINT32_MAX );
1419
+
1420
+ if (!ecma_typedarray_is_element_index (property_name_p ))
1421
+ {
1422
+ break ;
1423
+ }
1467
1424
}
1468
- break ;
1425
+
1426
+ ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p );
1427
+ return ecma_set_typedarray_element (& info , value , index );
1469
1428
}
1470
1429
#endif /* JERRY_BUILTIN_TYPEDARRAY */
1471
1430
#if JERRY_MODULE_SYSTEM
@@ -1668,8 +1627,7 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
1668
1627
& property_ref ,
1669
1628
ECMA_PROPERTY_GET_NO_OPTIONS );
1670
1629
1671
- if (inherited_property != ECMA_PROPERTY_TYPE_NOT_FOUND
1672
- && inherited_property != ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP )
1630
+ if (ECMA_PROPERTY_IS_FOUND (inherited_property ))
1673
1631
{
1674
1632
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (inherited_property ));
1675
1633
@@ -1683,6 +1641,9 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
1683
1641
create_new_property = ecma_is_property_writable (inherited_property );
1684
1642
break ;
1685
1643
}
1644
+
1645
+ JERRY_ASSERT (inherited_property == ECMA_PROPERTY_TYPE_NOT_FOUND
1646
+ || inherited_property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP );
1686
1647
}
1687
1648
1688
1649
#if JERRY_BUILTIN_PROXY
@@ -1962,13 +1923,18 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
1962
1923
& property_ref ,
1963
1924
ECMA_PROPERTY_GET_VALUE );
1964
1925
1965
- if (ECMA_IS_VALUE_ERROR ( property_ref . virtual_value ))
1926
+ if (! ECMA_PROPERTY_IS_FOUND ( property ))
1966
1927
{
1967
- return property_ref .virtual_value ;
1968
- }
1928
+ #if JERRY_BUILTIN_TYPEDARRAY
1929
+ if (JERRY_UNLIKELY (property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_THROW ))
1930
+ {
1931
+ return ECMA_VALUE_ERROR ;
1932
+ }
1933
+ #endif /* JERRY_BUILTIN_TYPEDARRAY */
1934
+
1935
+ JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND
1936
+ || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP );
1969
1937
1970
- if (property == ECMA_PROPERTY_TYPE_NOT_FOUND || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP )
1971
- {
1972
1938
return ECMA_VALUE_FALSE ;
1973
1939
}
1974
1940
@@ -3488,7 +3454,7 @@ ecma_op_ordinary_object_prevent_extensions (ecma_object_t *object_p) /**< object
3488
3454
* @return true - if property is found
3489
3455
* false - otherwise
3490
3456
*/
3491
- extern inline bool JERRY_ATTR_ALWAYS_INLINE
3457
+ extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
3492
3458
ecma_op_ordinary_object_has_own_property (ecma_object_t * object_p , /**< the object */
3493
3459
ecma_string_t * property_name_p ) /**< property name */
3494
3460
{
@@ -3499,7 +3465,18 @@ ecma_op_ordinary_object_has_own_property (ecma_object_t *object_p, /**< the obje
3499
3465
NULL ,
3500
3466
ECMA_PROPERTY_GET_NO_OPTIONS );
3501
3467
3502
- return property != ECMA_PROPERTY_TYPE_NOT_FOUND && property != ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP ;
3468
+ #if JERRY_BUILTIN_TYPEDARRAY
3469
+ if (JERRY_UNLIKELY (property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_THROW ))
3470
+ {
3471
+ return ECMA_VALUE_ERROR ;
3472
+ }
3473
+ #endif /* JERRY_BUILTIN_TYPEDARRAY */
3474
+
3475
+ JERRY_ASSERT (ECMA_PROPERTY_IS_FOUND (property )
3476
+ || property == ECMA_PROPERTY_TYPE_NOT_FOUND
3477
+ || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP );
3478
+
3479
+ return ecma_make_boolean_value (ECMA_PROPERTY_IS_FOUND (property ));
3503
3480
} /* ecma_op_ordinary_object_has_own_property */
3504
3481
3505
3482
#if JERRY_BUILTIN_WEAKREF || JERRY_BUILTIN_CONTAINER
0 commit comments