@@ -27,19 +27,6 @@ namespace test_elements_kind { |
27 | 27 |
|
28 | 28 | namespace { |
29 | 29 |
|
30 | | -Handle<String> MakeString(const char* str) { |
31 | | - Isolate* isolate = CcTest::i_isolate(); |
32 | | - Factory* factory = isolate->factory(); |
33 | | - return factory->InternalizeUtf8String(str); |
34 | | -} |
35 | | - |
36 | | - |
37 | | -Handle<String> MakeName(const char* str, int suffix) { |
38 | | - EmbeddedVector<char, 128> buffer; |
39 | | - SNPrintF(buffer, "%s%d", str, suffix); |
40 | | - return MakeString(buffer.begin()); |
41 | | -} |
42 | | - |
43 | 30 | template <typename T, typename M> |
44 | 31 | bool EQUALS(Isolate* isolate, Handle<T> left, Handle<M> right) { |
45 | 32 | if (*left == *right) return true; |
@@ -127,7 +114,7 @@ TEST(JSObjectAddingProperties) { |
127 | 114 |
|
128 | 115 | // for the default constructor function no in-object properties are reserved |
129 | 116 | // hence adding a single property will initialize the property-array |
130 | | - Handle<String> name = MakeName("property", 0); |
| 117 | + Handle<String> name = CcTest::MakeName("property", 0); |
131 | 118 | JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) |
132 | 119 | .Check(); |
133 | 120 | CHECK_NE(object->map(), *previous_map); |
@@ -162,7 +149,7 @@ TEST(JSObjectInObjectAddingProperties) { |
162 | 149 | // we have reserved space for in-object properties, hence adding up to |
163 | 150 | // |nof_inobject_properties| will not create a property store |
164 | 151 | for (int i = 0; i < nof_inobject_properties; i++) { |
165 | | - Handle<String> name = MakeName("property", i); |
| 152 | + Handle<String> name = CcTest::MakeName("property", i); |
166 | 153 | JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) |
167 | 154 | .Check(); |
168 | 155 | } |
@@ -174,7 +161,7 @@ TEST(JSObjectInObjectAddingProperties) { |
174 | 161 | // adding one more property will not fit in the in-object properties, thus |
175 | 162 | // creating a property store |
176 | 163 | int index = nof_inobject_properties + 1; |
177 | | - Handle<String> name = MakeName("property", index); |
| 164 | + Handle<String> name = CcTest::MakeName("property", index); |
178 | 165 | JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) |
179 | 166 | .Check(); |
180 | 167 | CHECK_NE(object->map(), *previous_map); |
@@ -205,7 +192,7 @@ TEST(JSObjectAddingElements) { |
205 | 192 | CHECK(EQUALS(isolate, object->elements(), empty_fixed_array)); |
206 | 193 |
|
207 | 194 | // Adding an indexed element initializes the elements array |
208 | | - name = MakeString("0"); |
| 195 | + name = CcTest::MakeString("0"); |
209 | 196 | JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) |
210 | 197 | .Check(); |
211 | 198 | // no change in elements_kind => no map transition |
@@ -217,7 +204,7 @@ TEST(JSObjectAddingElements) { |
217 | 204 | // Adding more consecutive elements without a change in the backing store |
218 | 205 | int non_dict_backing_store_limit = 100; |
219 | 206 | for (int i = 1; i < non_dict_backing_store_limit; i++) { |
220 | | - name = MakeName("", i); |
| 207 | + name = CcTest::MakeName("", i); |
221 | 208 | JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) |
222 | 209 | .Check(); |
223 | 210 | } |
@@ -229,7 +216,7 @@ TEST(JSObjectAddingElements) { |
229 | 216 |
|
230 | 217 | // Adding an element at an very large index causes a change to |
231 | 218 | // DICTIONARY_ELEMENTS |
232 | | - name = MakeString("100000000"); |
| 219 | + name = CcTest::MakeString("100000000"); |
233 | 220 | JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE) |
234 | 221 | .Check(); |
235 | 222 | // change in elements_kind => map transition |
@@ -260,7 +247,7 @@ TEST(JSArrayAddingProperties) { |
260 | 247 |
|
261 | 248 | // for the default constructor function no in-object properties are reserved |
262 | 249 | // hence adding a single property will initialize the property-array |
263 | | - Handle<String> name = MakeName("property", 0); |
| 250 | + Handle<String> name = CcTest::MakeName("property", 0); |
264 | 251 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE) |
265 | 252 | .Check(); |
266 | 253 | // No change in elements_kind but added property => new map |
@@ -292,7 +279,7 @@ TEST(JSArrayAddingElements) { |
292 | 279 | CHECK_EQ(0, Smi::ToInt(array->length())); |
293 | 280 |
|
294 | 281 | // Adding an indexed element initializes the elements array |
295 | | - name = MakeString("0"); |
| 282 | + name = CcTest::MakeString("0"); |
296 | 283 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE) |
297 | 284 | .Check(); |
298 | 285 | // no change in elements_kind => no map transition |
@@ -305,7 +292,7 @@ TEST(JSArrayAddingElements) { |
305 | 292 | // Adding more consecutive elements without a change in the backing store |
306 | 293 | int non_dict_backing_store_limit = 100; |
307 | 294 | for (int i = 1; i < non_dict_backing_store_limit; i++) { |
308 | | - name = MakeName("", i); |
| 295 | + name = CcTest::MakeName("", i); |
309 | 296 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE) |
310 | 297 | .Check(); |
311 | 298 | } |
@@ -319,7 +306,7 @@ TEST(JSArrayAddingElements) { |
319 | 306 | // Adding an element at an very large index causes a change to |
320 | 307 | // DICTIONARY_ELEMENTS |
321 | 308 | int index = 100000000; |
322 | | - name = MakeName("", index); |
| 309 | + name = CcTest::MakeName("", index); |
323 | 310 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE) |
324 | 311 | .Check(); |
325 | 312 | // change in elements_kind => map transition |
@@ -340,7 +327,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { |
340 | 327 |
|
341 | 328 | Handle<String> name; |
342 | 329 | Handle<Object> value_smi(Smi::FromInt(42), isolate); |
343 | | - Handle<Object> value_string(MakeString("value")); |
| 330 | + Handle<Object> value_string(CcTest::MakeString("value")); |
344 | 331 | Handle<Object> value_double = factory->NewNumber(3.1415); |
345 | 332 |
|
346 | 333 | Handle<JSArray> array = |
@@ -350,7 +337,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { |
350 | 337 | CHECK_EQ(0, Smi::ToInt(array->length())); |
351 | 338 |
|
352 | 339 | // `array[0] = smi_value` doesn't change the elements_kind |
353 | | - name = MakeString("0"); |
| 340 | + name = CcTest::MakeString("0"); |
354 | 341 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
355 | 342 | NONE) |
356 | 343 | .Check(); |
@@ -360,19 +347,19 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { |
360 | 347 | CHECK_EQ(1, Smi::ToInt(array->length())); |
361 | 348 |
|
362 | 349 | // `delete array[0]` does not alter length, but changes the elments_kind |
363 | | - name = MakeString("0"); |
| 350 | + name = CcTest::MakeString("0"); |
364 | 351 | CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false)); |
365 | 352 | CHECK_NE(array->map(), *previous_map); |
366 | 353 | CHECK_EQ(HOLEY_SMI_ELEMENTS, array->map().elements_kind()); |
367 | 354 | CHECK_EQ(1, Smi::ToInt(array->length())); |
368 | 355 | previous_map = handle(array->map(), isolate); |
369 | 356 |
|
370 | 357 | // add a couple of elements again |
371 | | - name = MakeString("0"); |
| 358 | + name = CcTest::MakeString("0"); |
372 | 359 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
373 | 360 | NONE) |
374 | 361 | .Check(); |
375 | | - name = MakeString("1"); |
| 362 | + name = CcTest::MakeString("1"); |
376 | 363 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
377 | 364 | NONE) |
378 | 365 | .Check(); |
@@ -381,7 +368,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { |
381 | 368 | CHECK_EQ(2, Smi::ToInt(array->length())); |
382 | 369 |
|
383 | 370 | // Adding a string to the array changes from FAST_HOLEY_SMI to FAST_HOLEY |
384 | | - name = MakeString("0"); |
| 371 | + name = CcTest::MakeString("0"); |
385 | 372 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_string, |
386 | 373 | NONE) |
387 | 374 | .Check(); |
@@ -391,14 +378,14 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) { |
391 | 378 | previous_map = handle(array->map(), isolate); |
392 | 379 |
|
393 | 380 | // We don't transition back to FAST_SMI even if we remove the string |
394 | | - name = MakeString("0"); |
| 381 | + name = CcTest::MakeString("0"); |
395 | 382 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
396 | 383 | NONE) |
397 | 384 | .Check(); |
398 | 385 | CHECK_EQ(array->map(), *previous_map); |
399 | 386 |
|
400 | 387 | // Adding a double doesn't change the map either |
401 | | - name = MakeString("0"); |
| 388 | + name = CcTest::MakeString("0"); |
402 | 389 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double, |
403 | 390 | NONE) |
404 | 391 | .Check(); |
@@ -414,7 +401,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) { |
414 | 401 |
|
415 | 402 | Handle<String> name; |
416 | 403 | Handle<Object> value_smi(Smi::FromInt(42), isolate); |
417 | | - Handle<Object> value_string(MakeString("value")); |
| 404 | + Handle<Object> value_string(CcTest::MakeString("value")); |
418 | 405 |
|
419 | 406 | Handle<JSArray> array = |
420 | 407 | factory->NewJSArray(ElementsKind::PACKED_ELEMENTS, 0, 0); |
@@ -423,7 +410,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) { |
423 | 410 | CHECK_EQ(0, Smi::ToInt(array->length())); |
424 | 411 |
|
425 | 412 | // `array[0] = smi_value` doesn't change the elements_kind |
426 | | - name = MakeString("0"); |
| 413 | + name = CcTest::MakeString("0"); |
427 | 414 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
428 | 415 | NONE) |
429 | 416 | .Check(); |
@@ -433,19 +420,19 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) { |
433 | 420 | CHECK_EQ(1, Smi::ToInt(array->length())); |
434 | 421 |
|
435 | 422 | // `delete array[0]` does not alter length, but changes the elments_kind |
436 | | - name = MakeString("0"); |
| 423 | + name = CcTest::MakeString("0"); |
437 | 424 | CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false)); |
438 | 425 | CHECK_NE(array->map(), *previous_map); |
439 | 426 | CHECK_EQ(HOLEY_ELEMENTS, array->map().elements_kind()); |
440 | 427 | CHECK_EQ(1, Smi::ToInt(array->length())); |
441 | 428 | previous_map = handle(array->map(), isolate); |
442 | 429 |
|
443 | 430 | // add a couple of elements, elements_kind stays HOLEY |
444 | | - name = MakeString("0"); |
| 431 | + name = CcTest::MakeString("0"); |
445 | 432 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_string, |
446 | 433 | NONE) |
447 | 434 | .Check(); |
448 | | - name = MakeString("1"); |
| 435 | + name = CcTest::MakeString("1"); |
449 | 436 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
450 | 437 | NONE) |
451 | 438 | .Check(); |
@@ -463,15 +450,15 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { |
463 | 450 |
|
464 | 451 | Handle<String> name; |
465 | 452 | Handle<Object> value_smi(Smi::FromInt(42), isolate); |
466 | | - Handle<Object> value_string(MakeString("value")); |
| 453 | + Handle<Object> value_string(CcTest::MakeString("value")); |
467 | 454 | Handle<Object> value_double = factory->NewNumber(3.1415); |
468 | 455 |
|
469 | 456 | Handle<JSArray> array = |
470 | 457 | factory->NewJSArray(ElementsKind::PACKED_SMI_ELEMENTS, 0, 0); |
471 | 458 | Handle<Map> previous_map(array->map(), isolate); |
472 | 459 |
|
473 | 460 | // `array[0] = value_double` changes |elements_kind| to PACKED_DOUBLE_ELEMENTS |
474 | | - name = MakeString("0"); |
| 461 | + name = CcTest::MakeString("0"); |
475 | 462 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double, |
476 | 463 | NONE) |
477 | 464 | .Check(); |
@@ -481,7 +468,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { |
481 | 468 | previous_map = handle(array->map(), isolate); |
482 | 469 |
|
483 | 470 | // `array[1] = value_smi` doesn't alter the |elements_kind| |
484 | | - name = MakeString("1"); |
| 471 | + name = CcTest::MakeString("1"); |
485 | 472 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi, |
486 | 473 | NONE) |
487 | 474 | .Check(); |
@@ -490,15 +477,15 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { |
490 | 477 | CHECK_EQ(2, Smi::ToInt(array->length())); |
491 | 478 |
|
492 | 479 | // `delete array[0]` does not alter length, but changes the elments_kind |
493 | | - name = MakeString("0"); |
| 480 | + name = CcTest::MakeString("0"); |
494 | 481 | CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false)); |
495 | 482 | CHECK_NE(array->map(), *previous_map); |
496 | 483 | CHECK_EQ(HOLEY_DOUBLE_ELEMENTS, array->map().elements_kind()); |
497 | 484 | CHECK_EQ(2, Smi::ToInt(array->length())); |
498 | 485 | previous_map = handle(array->map(), isolate); |
499 | 486 |
|
500 | 487 | // filling the hole `array[0] = value_smi` again doesn't transition back |
501 | | - name = MakeString("0"); |
| 488 | + name = CcTest::MakeString("0"); |
502 | 489 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double, |
503 | 490 | NONE) |
504 | 491 | .Check(); |
@@ -507,7 +494,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { |
507 | 494 | CHECK_EQ(2, Smi::ToInt(array->length())); |
508 | 495 |
|
509 | 496 | // Adding a string to the array changes to elements_kind PACKED_ELEMENTS |
510 | | - name = MakeString("1"); |
| 497 | + name = CcTest::MakeString("1"); |
511 | 498 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_string, |
512 | 499 | NONE) |
513 | 500 | .Check(); |
@@ -517,7 +504,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) { |
517 | 504 | previous_map = handle(array->map(), isolate); |
518 | 505 |
|
519 | 506 | // Adding a double doesn't change the map |
520 | | - name = MakeString("0"); |
| 507 | + name = CcTest::MakeString("0"); |
521 | 508 | JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double, |
522 | 509 | NONE) |
523 | 510 | .Check(); |
|