Skip to content

Commit bda1514

Browse files
committed
deps: V8: cherry-pick be91c6c50818
Original commit message: [compiler][cleanup] Move Make(String|Name) helper methods to cctest.h Several tests were using them and we can dedup code. Change-Id: I4ef5ae5772856d1f36e965b6b62ff5895b4e04fb Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2215173 Reviewed-by: Maya Lekova <[email protected]> Commit-Queue: Santiago Aboy Solanes <[email protected]> Cr-Commit-Position: refs/heads/master@{#67974} Refs: v8/v8@be91c6c PR-URL: #38275 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
1 parent 16a005c commit bda1514

7 files changed

+102
-138
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.58',
39+
'v8_embedder_string': '-node.59',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/test/cctest/cctest.cc

+12
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ void CcTest::PreciseCollectAllGarbage(i::Isolate* isolate) {
150150
i::GarbageCollectionReason::kTesting);
151151
}
152152

153+
i::Handle<i::String> CcTest::MakeString(const char* str) {
154+
i::Isolate* isolate = CcTest::i_isolate();
155+
i::Factory* factory = isolate->factory();
156+
return factory->InternalizeUtf8String(str);
157+
}
158+
159+
i::Handle<i::String> CcTest::MakeName(const char* str, int suffix) {
160+
i::EmbeddedVector<char, 128> buffer;
161+
SNPrintF(buffer, "%s%d", str, suffix);
162+
return CcTest::MakeString(buffer.begin());
163+
}
164+
153165
v8::base::RandomNumberGenerator* CcTest::random_number_generator() {
154166
return InitIsolateOnce()->random_number_generator();
155167
}

deps/v8/test/cctest/cctest.h

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class CcTest {
141141
static void CollectAllAvailableGarbage(i::Isolate* isolate = nullptr);
142142
static void PreciseCollectAllGarbage(i::Isolate* isolate = nullptr);
143143

144+
static i::Handle<i::String> MakeString(const char* str);
145+
static i::Handle<i::String> MakeName(const char* str, int suffix);
146+
144147
static v8::base::RandomNumberGenerator* random_number_generator();
145148

146149
static v8::Local<v8::Object> global();

deps/v8/test/cctest/test-code-stub-assembler.cc

+5-17
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ template <class T>
4242
using TVariable = TypedCodeAssemblerVariable<T>;
4343
using PromiseResolvingFunctions = TorqueStructPromiseResolvingFunctions;
4444

45-
Handle<String> MakeString(const char* str) {
46-
Isolate* isolate = CcTest::i_isolate();
47-
Factory* factory = isolate->factory();
48-
return factory->InternalizeUtf8String(str);
49-
}
50-
51-
Handle<String> MakeName(const char* str, int suffix) {
52-
EmbeddedVector<char, 128> buffer;
53-
SNPrintF(buffer, "%s%d", str, suffix);
54-
return MakeString(buffer.begin());
55-
}
56-
5745
intptr_t sum10(intptr_t a0, intptr_t a1, intptr_t a2, intptr_t a3, intptr_t a4,
5846
intptr_t a5, intptr_t a6, intptr_t a7, intptr_t a8,
5947
intptr_t a9) {
@@ -1091,7 +1079,7 @@ TEST(TransitionLookup) {
10911079
name = factory->NewSymbol();
10921080
} else {
10931081
int random_key = rand_gen.NextInt(Smi::kMaxValue);
1094-
name = MakeName("p", random_key);
1082+
name = CcTest::MakeName("p", random_key);
10951083
}
10961084
keys[i] = name;
10971085

@@ -3646,8 +3634,8 @@ TEST(TestCallBuiltinInlineTrampoline) {
36463634
options.use_pc_relative_calls_and_jumps = false;
36473635
options.isolate_independent_code = false;
36483636
FunctionTester ft(asm_tester.GenerateCode(options), kNumParams);
3649-
MaybeHandle<Object> result = ft.Call(MakeString("abcdef"));
3650-
CHECK(String::Equals(isolate, MakeString("abcdefabcdef"),
3637+
MaybeHandle<Object> result = ft.Call(CcTest::MakeString("abcdef"));
3638+
CHECK(String::Equals(isolate, CcTest::MakeString("abcdefabcdef"),
36513639
Handle<String>::cast(result.ToHandleChecked())));
36523640
}
36533641

@@ -3672,8 +3660,8 @@ DISABLED_TEST(TestCallBuiltinIndirectLoad) {
36723660
options.use_pc_relative_calls_and_jumps = false;
36733661
options.isolate_independent_code = true;
36743662
FunctionTester ft(asm_tester.GenerateCode(options), kNumParams);
3675-
MaybeHandle<Object> result = ft.Call(MakeString("abcdef"));
3676-
CHECK(String::Equals(isolate, MakeString("abcdefabcdef"),
3663+
MaybeHandle<Object> result = ft.Call(CcTest::MakeString("abcdef"));
3664+
CHECK(String::Equals(isolate, CcTest::MakeString("abcdefabcdef"),
36773665
Handle<String>::cast(result.ToHandleChecked())));
36783666
}
36793667

deps/v8/test/cctest/test-elements-kind.cc

+30-43
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ namespace test_elements_kind {
2727

2828
namespace {
2929

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-
4330
template <typename T, typename M>
4431
bool EQUALS(Isolate* isolate, Handle<T> left, Handle<M> right) {
4532
if (*left == *right) return true;
@@ -127,7 +114,7 @@ TEST(JSObjectAddingProperties) {
127114

128115
// for the default constructor function no in-object properties are reserved
129116
// 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);
131118
JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE)
132119
.Check();
133120
CHECK_NE(object->map(), *previous_map);
@@ -162,7 +149,7 @@ TEST(JSObjectInObjectAddingProperties) {
162149
// we have reserved space for in-object properties, hence adding up to
163150
// |nof_inobject_properties| will not create a property store
164151
for (int i = 0; i < nof_inobject_properties; i++) {
165-
Handle<String> name = MakeName("property", i);
152+
Handle<String> name = CcTest::MakeName("property", i);
166153
JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE)
167154
.Check();
168155
}
@@ -174,7 +161,7 @@ TEST(JSObjectInObjectAddingProperties) {
174161
// adding one more property will not fit in the in-object properties, thus
175162
// creating a property store
176163
int index = nof_inobject_properties + 1;
177-
Handle<String> name = MakeName("property", index);
164+
Handle<String> name = CcTest::MakeName("property", index);
178165
JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE)
179166
.Check();
180167
CHECK_NE(object->map(), *previous_map);
@@ -205,7 +192,7 @@ TEST(JSObjectAddingElements) {
205192
CHECK(EQUALS(isolate, object->elements(), empty_fixed_array));
206193

207194
// Adding an indexed element initializes the elements array
208-
name = MakeString("0");
195+
name = CcTest::MakeString("0");
209196
JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE)
210197
.Check();
211198
// no change in elements_kind => no map transition
@@ -217,7 +204,7 @@ TEST(JSObjectAddingElements) {
217204
// Adding more consecutive elements without a change in the backing store
218205
int non_dict_backing_store_limit = 100;
219206
for (int i = 1; i < non_dict_backing_store_limit; i++) {
220-
name = MakeName("", i);
207+
name = CcTest::MakeName("", i);
221208
JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE)
222209
.Check();
223210
}
@@ -229,7 +216,7 @@ TEST(JSObjectAddingElements) {
229216

230217
// Adding an element at an very large index causes a change to
231218
// DICTIONARY_ELEMENTS
232-
name = MakeString("100000000");
219+
name = CcTest::MakeString("100000000");
233220
JSObject::DefinePropertyOrElementIgnoreAttributes(object, name, value, NONE)
234221
.Check();
235222
// change in elements_kind => map transition
@@ -260,7 +247,7 @@ TEST(JSArrayAddingProperties) {
260247

261248
// for the default constructor function no in-object properties are reserved
262249
// 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);
264251
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE)
265252
.Check();
266253
// No change in elements_kind but added property => new map
@@ -292,7 +279,7 @@ TEST(JSArrayAddingElements) {
292279
CHECK_EQ(0, Smi::ToInt(array->length()));
293280

294281
// Adding an indexed element initializes the elements array
295-
name = MakeString("0");
282+
name = CcTest::MakeString("0");
296283
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE)
297284
.Check();
298285
// no change in elements_kind => no map transition
@@ -305,7 +292,7 @@ TEST(JSArrayAddingElements) {
305292
// Adding more consecutive elements without a change in the backing store
306293
int non_dict_backing_store_limit = 100;
307294
for (int i = 1; i < non_dict_backing_store_limit; i++) {
308-
name = MakeName("", i);
295+
name = CcTest::MakeName("", i);
309296
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE)
310297
.Check();
311298
}
@@ -319,7 +306,7 @@ TEST(JSArrayAddingElements) {
319306
// Adding an element at an very large index causes a change to
320307
// DICTIONARY_ELEMENTS
321308
int index = 100000000;
322-
name = MakeName("", index);
309+
name = CcTest::MakeName("", index);
323310
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value, NONE)
324311
.Check();
325312
// change in elements_kind => map transition
@@ -340,7 +327,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
340327

341328
Handle<String> name;
342329
Handle<Object> value_smi(Smi::FromInt(42), isolate);
343-
Handle<Object> value_string(MakeString("value"));
330+
Handle<Object> value_string(CcTest::MakeString("value"));
344331
Handle<Object> value_double = factory->NewNumber(3.1415);
345332

346333
Handle<JSArray> array =
@@ -350,7 +337,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
350337
CHECK_EQ(0, Smi::ToInt(array->length()));
351338

352339
// `array[0] = smi_value` doesn't change the elements_kind
353-
name = MakeString("0");
340+
name = CcTest::MakeString("0");
354341
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
355342
NONE)
356343
.Check();
@@ -360,19 +347,19 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
360347
CHECK_EQ(1, Smi::ToInt(array->length()));
361348

362349
// `delete array[0]` does not alter length, but changes the elments_kind
363-
name = MakeString("0");
350+
name = CcTest::MakeString("0");
364351
CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false));
365352
CHECK_NE(array->map(), *previous_map);
366353
CHECK_EQ(HOLEY_SMI_ELEMENTS, array->map().elements_kind());
367354
CHECK_EQ(1, Smi::ToInt(array->length()));
368355
previous_map = handle(array->map(), isolate);
369356

370357
// add a couple of elements again
371-
name = MakeString("0");
358+
name = CcTest::MakeString("0");
372359
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
373360
NONE)
374361
.Check();
375-
name = MakeString("1");
362+
name = CcTest::MakeString("1");
376363
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
377364
NONE)
378365
.Check();
@@ -381,7 +368,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
381368
CHECK_EQ(2, Smi::ToInt(array->length()));
382369

383370
// Adding a string to the array changes from FAST_HOLEY_SMI to FAST_HOLEY
384-
name = MakeString("0");
371+
name = CcTest::MakeString("0");
385372
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_string,
386373
NONE)
387374
.Check();
@@ -391,14 +378,14 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
391378
previous_map = handle(array->map(), isolate);
392379

393380
// We don't transition back to FAST_SMI even if we remove the string
394-
name = MakeString("0");
381+
name = CcTest::MakeString("0");
395382
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
396383
NONE)
397384
.Check();
398385
CHECK_EQ(array->map(), *previous_map);
399386

400387
// Adding a double doesn't change the map either
401-
name = MakeString("0");
388+
name = CcTest::MakeString("0");
402389
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double,
403390
NONE)
404391
.Check();
@@ -414,7 +401,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) {
414401

415402
Handle<String> name;
416403
Handle<Object> value_smi(Smi::FromInt(42), isolate);
417-
Handle<Object> value_string(MakeString("value"));
404+
Handle<Object> value_string(CcTest::MakeString("value"));
418405

419406
Handle<JSArray> array =
420407
factory->NewJSArray(ElementsKind::PACKED_ELEMENTS, 0, 0);
@@ -423,7 +410,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) {
423410
CHECK_EQ(0, Smi::ToInt(array->length()));
424411

425412
// `array[0] = smi_value` doesn't change the elements_kind
426-
name = MakeString("0");
413+
name = CcTest::MakeString("0");
427414
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
428415
NONE)
429416
.Check();
@@ -433,19 +420,19 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) {
433420
CHECK_EQ(1, Smi::ToInt(array->length()));
434421

435422
// `delete array[0]` does not alter length, but changes the elments_kind
436-
name = MakeString("0");
423+
name = CcTest::MakeString("0");
437424
CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false));
438425
CHECK_NE(array->map(), *previous_map);
439426
CHECK_EQ(HOLEY_ELEMENTS, array->map().elements_kind());
440427
CHECK_EQ(1, Smi::ToInt(array->length()));
441428
previous_map = handle(array->map(), isolate);
442429

443430
// add a couple of elements, elements_kind stays HOLEY
444-
name = MakeString("0");
431+
name = CcTest::MakeString("0");
445432
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_string,
446433
NONE)
447434
.Check();
448-
name = MakeString("1");
435+
name = CcTest::MakeString("1");
449436
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
450437
NONE)
451438
.Check();
@@ -463,15 +450,15 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
463450

464451
Handle<String> name;
465452
Handle<Object> value_smi(Smi::FromInt(42), isolate);
466-
Handle<Object> value_string(MakeString("value"));
453+
Handle<Object> value_string(CcTest::MakeString("value"));
467454
Handle<Object> value_double = factory->NewNumber(3.1415);
468455

469456
Handle<JSArray> array =
470457
factory->NewJSArray(ElementsKind::PACKED_SMI_ELEMENTS, 0, 0);
471458
Handle<Map> previous_map(array->map(), isolate);
472459

473460
// `array[0] = value_double` changes |elements_kind| to PACKED_DOUBLE_ELEMENTS
474-
name = MakeString("0");
461+
name = CcTest::MakeString("0");
475462
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double,
476463
NONE)
477464
.Check();
@@ -481,7 +468,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
481468
previous_map = handle(array->map(), isolate);
482469

483470
// `array[1] = value_smi` doesn't alter the |elements_kind|
484-
name = MakeString("1");
471+
name = CcTest::MakeString("1");
485472
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_smi,
486473
NONE)
487474
.Check();
@@ -490,15 +477,15 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
490477
CHECK_EQ(2, Smi::ToInt(array->length()));
491478

492479
// `delete array[0]` does not alter length, but changes the elments_kind
493-
name = MakeString("0");
480+
name = CcTest::MakeString("0");
494481
CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false));
495482
CHECK_NE(array->map(), *previous_map);
496483
CHECK_EQ(HOLEY_DOUBLE_ELEMENTS, array->map().elements_kind());
497484
CHECK_EQ(2, Smi::ToInt(array->length()));
498485
previous_map = handle(array->map(), isolate);
499486

500487
// filling the hole `array[0] = value_smi` again doesn't transition back
501-
name = MakeString("0");
488+
name = CcTest::MakeString("0");
502489
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double,
503490
NONE)
504491
.Check();
@@ -507,7 +494,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
507494
CHECK_EQ(2, Smi::ToInt(array->length()));
508495

509496
// Adding a string to the array changes to elements_kind PACKED_ELEMENTS
510-
name = MakeString("1");
497+
name = CcTest::MakeString("1");
511498
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_string,
512499
NONE)
513500
.Check();
@@ -517,7 +504,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
517504
previous_map = handle(array->map(), isolate);
518505

519506
// Adding a double doesn't change the map
520-
name = MakeString("0");
507+
name = CcTest::MakeString("0");
521508
JSObject::DefinePropertyOrElementIgnoreAttributes(array, name, value_double,
522509
NONE)
523510
.Check();

0 commit comments

Comments
 (0)