OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
11 #include "src/execution.h" | 11 #include "src/execution.h" |
12 #include "src/factory.h" | 12 #include "src/factory.h" |
13 #include "src/global-handles.h" | 13 #include "src/global-handles.h" |
14 #include "src/ic/ic.h" | 14 #include "src/ic/ic.h" |
15 #include "src/macro-assembler.h" | 15 #include "src/macro-assembler.h" |
16 #include "test/cctest/cctest.h" | 16 #include "test/cctest/cctest.h" |
17 | 17 |
18 using namespace v8::base; | 18 using namespace v8::base; |
19 using namespace v8::internal; | 19 using namespace v8::internal; |
20 | 20 |
21 #if (V8_DOUBLE_FIELDS_UNBOXING) | 21 #if (V8_DOUBLE_FIELDS_UNBOXING) |
22 | 22 |
23 | 23 |
24 // | 24 // |
25 // Helper functions. | 25 // Helper functions. |
26 // | 26 // |
27 | 27 |
| 28 |
| 29 static void InitializeVerifiedMapDescriptors( |
| 30 Map* map, DescriptorArray* descriptors, |
| 31 LayoutDescriptor* layout_descriptor) { |
| 32 map->InitializeDescriptors(descriptors, layout_descriptor); |
| 33 #ifdef VERIFY_HEAP |
| 34 if (FLAG_verify_heap) { |
| 35 DCHECK(layout_descriptor->IsConsistentWithMap(map)); |
| 36 } |
| 37 #endif |
| 38 } |
| 39 |
| 40 |
28 static Handle<String> MakeString(const char* str) { | 41 static Handle<String> MakeString(const char* str) { |
29 Isolate* isolate = CcTest::i_isolate(); | 42 Isolate* isolate = CcTest::i_isolate(); |
30 Factory* factory = isolate->factory(); | 43 Factory* factory = isolate->factory(); |
31 return factory->InternalizeUtf8String(str); | 44 return factory->InternalizeUtf8String(str); |
32 } | 45 } |
33 | 46 |
34 | 47 |
35 static Handle<String> MakeName(const char* str, int suffix) { | 48 static Handle<String> MakeName(const char* str, int suffix) { |
36 EmbeddedVector<char, 128> buffer; | 49 EmbeddedVector<char, 128> buffer; |
37 SNPrintF(buffer, "%s%d", str, suffix); | 50 SNPrintF(buffer, "%s%d", str, suffix); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 162 |
150 { | 163 { |
151 Handle<DescriptorArray> descriptors = | 164 Handle<DescriptorArray> descriptors = |
152 CreateDescriptorArray(isolate, props, kPropsCount); | 165 CreateDescriptorArray(isolate, props, kPropsCount); |
153 | 166 |
154 Handle<Map> map = Map::Create(isolate, kPropsCount); | 167 Handle<Map> map = Map::Create(isolate, kPropsCount); |
155 | 168 |
156 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 169 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
157 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 170 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
158 CHECK_EQ(kSmiValueSize, layout_descriptor->capacity()); | 171 CHECK_EQ(kSmiValueSize, layout_descriptor->capacity()); |
159 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 172 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
160 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
161 } | 173 } |
162 | 174 |
163 props[0] = PROP_DOUBLE; | 175 props[0] = PROP_DOUBLE; |
164 props[kPropsCount - 1] = PROP_DOUBLE; | 176 props[kPropsCount - 1] = PROP_DOUBLE; |
165 | 177 |
166 Handle<DescriptorArray> descriptors = | 178 Handle<DescriptorArray> descriptors = |
167 CreateDescriptorArray(isolate, props, kPropsCount); | 179 CreateDescriptorArray(isolate, props, kPropsCount); |
168 | 180 |
169 { | 181 { |
170 int inobject_properties = kPropsCount - 1; | 182 int inobject_properties = kPropsCount - 1; |
171 Handle<Map> map = Map::Create(isolate, inobject_properties); | 183 Handle<Map> map = Map::Create(isolate, inobject_properties); |
172 | 184 |
173 // Should be fast as the only double property is the first one. | 185 // Should be fast as the only double property is the first one. |
174 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 186 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
175 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 187 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
176 CHECK(!layout_descriptor->IsSlowLayout()); | 188 CHECK(!layout_descriptor->IsSlowLayout()); |
177 CHECK(!layout_descriptor->IsFastPointerLayout()); | 189 CHECK(!layout_descriptor->IsFastPointerLayout()); |
178 | 190 |
179 CHECK_EQ(false, layout_descriptor->IsTagged(0)); | 191 CHECK_EQ(false, layout_descriptor->IsTagged(0)); |
180 for (int i = 1; i < kPropsCount; i++) { | 192 for (int i = 1; i < kPropsCount; i++) { |
181 CHECK_EQ(true, layout_descriptor->IsTagged(i)); | 193 CHECK_EQ(true, layout_descriptor->IsTagged(i)); |
182 } | 194 } |
183 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 195 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
184 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
185 } | 196 } |
186 | 197 |
187 { | 198 { |
188 int inobject_properties = kPropsCount; | 199 int inobject_properties = kPropsCount; |
189 Handle<Map> map = Map::Create(isolate, inobject_properties); | 200 Handle<Map> map = Map::Create(isolate, inobject_properties); |
190 | 201 |
191 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 202 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
192 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 203 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
193 CHECK(layout_descriptor->IsSlowLayout()); | 204 CHECK(layout_descriptor->IsSlowLayout()); |
194 CHECK(!layout_descriptor->IsFastPointerLayout()); | 205 CHECK(!layout_descriptor->IsFastPointerLayout()); |
195 CHECK(layout_descriptor->capacity() > kSmiValueSize); | 206 CHECK(layout_descriptor->capacity() > kSmiValueSize); |
196 | 207 |
197 CHECK_EQ(false, layout_descriptor->IsTagged(0)); | 208 CHECK_EQ(false, layout_descriptor->IsTagged(0)); |
198 CHECK_EQ(false, layout_descriptor->IsTagged(kPropsCount - 1)); | 209 CHECK_EQ(false, layout_descriptor->IsTagged(kPropsCount - 1)); |
199 for (int i = 1; i < kPropsCount - 1; i++) { | 210 for (int i = 1; i < kPropsCount - 1; i++) { |
200 CHECK_EQ(true, layout_descriptor->IsTagged(i)); | 211 CHECK_EQ(true, layout_descriptor->IsTagged(i)); |
201 } | 212 } |
202 | 213 |
203 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 214 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
204 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
205 | 215 |
206 // Here we have truly slow layout descriptor, so play with the bits. | 216 // Here we have truly slow layout descriptor, so play with the bits. |
207 CHECK_EQ(true, layout_descriptor->IsTagged(-1)); | 217 CHECK_EQ(true, layout_descriptor->IsTagged(-1)); |
208 CHECK_EQ(true, layout_descriptor->IsTagged(-12347)); | 218 CHECK_EQ(true, layout_descriptor->IsTagged(-12347)); |
209 CHECK_EQ(true, layout_descriptor->IsTagged(15635)); | 219 CHECK_EQ(true, layout_descriptor->IsTagged(15635)); |
210 | 220 |
211 LayoutDescriptor* layout_desc = *layout_descriptor; | 221 LayoutDescriptor* layout_desc = *layout_descriptor; |
212 // Play with the bits but leave it in consistent state with map at the end. | 222 // Play with the bits but leave it in consistent state with map at the end. |
213 for (int i = 1; i < kPropsCount - 1; i++) { | 223 for (int i = 1; i < kPropsCount - 1; i++) { |
214 layout_desc = layout_desc->SetTaggedForTesting(i, false); | 224 layout_desc = layout_desc->SetTaggedForTesting(i, false); |
215 CHECK_EQ(false, layout_desc->IsTagged(i)); | 225 CHECK_EQ(false, layout_desc->IsTagged(i)); |
216 layout_desc = layout_desc->SetTaggedForTesting(i, true); | 226 layout_desc = layout_desc->SetTaggedForTesting(i, true); |
217 CHECK_EQ(true, layout_desc->IsTagged(i)); | 227 CHECK_EQ(true, layout_desc->IsTagged(i)); |
218 } | 228 } |
219 CHECK(layout_desc->IsSlowLayout()); | 229 CHECK(layout_desc->IsSlowLayout()); |
220 CHECK(!layout_desc->IsFastPointerLayout()); | 230 CHECK(!layout_desc->IsFastPointerLayout()); |
221 | 231 #ifdef VERIFY_HEAP |
222 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | 232 if (FLAG_verify_heap) { |
| 233 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); |
| 234 } |
| 235 #endif |
223 } | 236 } |
224 } | 237 } |
225 | 238 |
226 | 239 |
227 static void TestLayoutDescriptorQueries(int layout_descriptor_length, | 240 static void TestLayoutDescriptorQueries(int layout_descriptor_length, |
228 int* bit_flip_positions, | 241 int* bit_flip_positions, |
229 int max_sequence_length) { | 242 int max_sequence_length) { |
230 Handle<LayoutDescriptor> layout_descriptor = LayoutDescriptor::NewForTesting( | 243 Handle<LayoutDescriptor> layout_descriptor = LayoutDescriptor::NewForTesting( |
231 CcTest::i_isolate(), layout_descriptor_length); | 244 CcTest::i_isolate(), layout_descriptor_length); |
232 layout_descriptor_length = layout_descriptor->capacity(); | 245 layout_descriptor_length = layout_descriptor->capacity(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 }; | 487 }; |
475 const int kPropsCount = arraysize(props); | 488 const int kPropsCount = arraysize(props); |
476 | 489 |
477 Handle<DescriptorArray> descriptors = | 490 Handle<DescriptorArray> descriptors = |
478 CreateDescriptorArray(isolate, props, kPropsCount); | 491 CreateDescriptorArray(isolate, props, kPropsCount); |
479 | 492 |
480 { | 493 { |
481 Handle<Map> map = Map::Create(isolate, 0); | 494 Handle<Map> map = Map::Create(isolate, 0); |
482 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 495 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
483 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 496 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
484 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 497 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
485 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
486 } | 498 } |
487 | 499 |
488 { | 500 { |
489 Handle<Map> map = Map::Create(isolate, 1); | 501 Handle<Map> map = Map::Create(isolate, 1); |
490 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 502 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
491 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 503 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
492 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 504 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
493 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
494 } | 505 } |
495 | 506 |
496 { | 507 { |
497 Handle<Map> map = Map::Create(isolate, 2); | 508 Handle<Map> map = Map::Create(isolate, 2); |
498 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 509 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
499 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 510 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
500 CHECK(!layout_descriptor->IsSlowLayout()); | 511 CHECK(!layout_descriptor->IsSlowLayout()); |
501 CHECK_EQ(true, layout_descriptor->IsTagged(0)); | 512 CHECK_EQ(true, layout_descriptor->IsTagged(0)); |
502 CHECK_EQ(false, layout_descriptor->IsTagged(1)); | 513 CHECK_EQ(false, layout_descriptor->IsTagged(1)); |
503 CHECK_EQ(true, layout_descriptor->IsTagged(2)); | 514 CHECK_EQ(true, layout_descriptor->IsTagged(2)); |
504 CHECK_EQ(true, layout_descriptor->IsTagged(125)); | 515 CHECK_EQ(true, layout_descriptor->IsTagged(125)); |
505 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 516 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
506 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
507 } | 517 } |
508 } | 518 } |
509 | 519 |
510 | 520 |
511 TEST(LayoutDescriptorCreateNewSlow) { | 521 TEST(LayoutDescriptorCreateNewSlow) { |
512 CcTest::InitializeVM(); | 522 CcTest::InitializeVM(); |
513 Isolate* isolate = CcTest::i_isolate(); | 523 Isolate* isolate = CcTest::i_isolate(); |
514 v8::HandleScope scope(CcTest::isolate()); | 524 v8::HandleScope scope(CcTest::isolate()); |
515 | 525 |
516 Handle<LayoutDescriptor> layout_descriptor; | 526 Handle<LayoutDescriptor> layout_descriptor; |
517 const int kPropsCount = kSmiValueSize * 3; | 527 const int kPropsCount = kSmiValueSize * 3; |
518 TestPropertyKind props[kPropsCount]; | 528 TestPropertyKind props[kPropsCount]; |
519 for (int i = 0; i < kPropsCount; i++) { | 529 for (int i = 0; i < kPropsCount; i++) { |
520 props[i] = static_cast<TestPropertyKind>(i % PROP_KIND_NUMBER); | 530 props[i] = static_cast<TestPropertyKind>(i % PROP_KIND_NUMBER); |
521 } | 531 } |
522 | 532 |
523 Handle<DescriptorArray> descriptors = | 533 Handle<DescriptorArray> descriptors = |
524 CreateDescriptorArray(isolate, props, kPropsCount); | 534 CreateDescriptorArray(isolate, props, kPropsCount); |
525 | 535 |
526 { | 536 { |
527 Handle<Map> map = Map::Create(isolate, 0); | 537 Handle<Map> map = Map::Create(isolate, 0); |
528 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 538 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
529 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 539 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
530 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 540 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
531 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
532 } | 541 } |
533 | 542 |
534 { | 543 { |
535 Handle<Map> map = Map::Create(isolate, 1); | 544 Handle<Map> map = Map::Create(isolate, 1); |
536 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 545 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
537 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 546 CHECK_EQ(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
538 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 547 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
539 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
540 } | 548 } |
541 | 549 |
542 { | 550 { |
543 Handle<Map> map = Map::Create(isolate, 2); | 551 Handle<Map> map = Map::Create(isolate, 2); |
544 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 552 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
545 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 553 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
546 CHECK(!layout_descriptor->IsSlowLayout()); | 554 CHECK(!layout_descriptor->IsSlowLayout()); |
547 CHECK_EQ(true, layout_descriptor->IsTagged(0)); | 555 CHECK_EQ(true, layout_descriptor->IsTagged(0)); |
548 CHECK_EQ(false, layout_descriptor->IsTagged(1)); | 556 CHECK_EQ(false, layout_descriptor->IsTagged(1)); |
549 CHECK_EQ(true, layout_descriptor->IsTagged(2)); | 557 CHECK_EQ(true, layout_descriptor->IsTagged(2)); |
550 CHECK_EQ(true, layout_descriptor->IsTagged(125)); | 558 CHECK_EQ(true, layout_descriptor->IsTagged(125)); |
551 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 559 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
552 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
553 } | 560 } |
554 | 561 |
555 { | 562 { |
556 int inobject_properties = kPropsCount / 2; | 563 int inobject_properties = kPropsCount / 2; |
557 Handle<Map> map = Map::Create(isolate, inobject_properties); | 564 Handle<Map> map = Map::Create(isolate, inobject_properties); |
558 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); | 565 layout_descriptor = LayoutDescriptor::New(map, descriptors, kPropsCount); |
559 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); | 566 CHECK_NE(LayoutDescriptor::FastPointerLayout(), *layout_descriptor); |
560 CHECK(layout_descriptor->IsSlowLayout()); | 567 CHECK(layout_descriptor->IsSlowLayout()); |
561 for (int i = 0; i < inobject_properties; i++) { | 568 for (int i = 0; i < inobject_properties; i++) { |
562 // PROP_DOUBLE has index 1 among DATA properties. | 569 // PROP_DOUBLE has index 1 among DATA properties. |
563 const bool tagged = (i % (PROP_KIND_NUMBER - 1)) != 1; | 570 const bool tagged = (i % (PROP_KIND_NUMBER - 1)) != 1; |
564 CHECK_EQ(tagged, layout_descriptor->IsTagged(i)); | 571 CHECK_EQ(tagged, layout_descriptor->IsTagged(i)); |
565 } | 572 } |
566 // Every property after inobject_properties must be tagged. | 573 // Every property after inobject_properties must be tagged. |
567 for (int i = inobject_properties; i < kPropsCount; i++) { | 574 for (int i = inobject_properties; i < kPropsCount; i++) { |
568 CHECK_EQ(true, layout_descriptor->IsTagged(i)); | 575 CHECK_EQ(true, layout_descriptor->IsTagged(i)); |
569 } | 576 } |
570 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 577 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
571 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
572 | 578 |
573 // Now test LayoutDescriptor::cast_gc_safe(). | 579 // Now test LayoutDescriptor::cast_gc_safe(). |
574 Handle<LayoutDescriptor> layout_descriptor_copy = | 580 Handle<LayoutDescriptor> layout_descriptor_copy = |
575 LayoutDescriptor::New(map, descriptors, kPropsCount); | 581 LayoutDescriptor::New(map, descriptors, kPropsCount); |
576 | 582 |
577 LayoutDescriptor* layout_desc = *layout_descriptor; | 583 LayoutDescriptor* layout_desc = *layout_descriptor; |
578 CHECK_EQ(layout_desc, LayoutDescriptor::cast(layout_desc)); | 584 CHECK_EQ(layout_desc, LayoutDescriptor::cast(layout_desc)); |
579 CHECK_EQ(layout_desc, LayoutDescriptor::cast_gc_safe(layout_desc)); | 585 CHECK_EQ(layout_desc, LayoutDescriptor::cast_gc_safe(layout_desc)); |
580 CHECK(layout_descriptor->IsFixedTypedArrayBase()); | 586 CHECK(layout_descriptor->IsFixedTypedArrayBase()); |
581 // Now make it look like a forwarding pointer to layout_descriptor_copy. | 587 // Now make it look like a forwarding pointer to layout_descriptor_copy. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 bool is_inobject = field_index < map->inobject_properties(); | 639 bool is_inobject = field_index < map->inobject_properties(); |
634 for (int bit = 0; bit < field_width_in_words; bit++) { | 640 for (int bit = 0; bit < field_width_in_words; bit++) { |
635 CHECK_EQ(is_inobject && (kind == PROP_DOUBLE), | 641 CHECK_EQ(is_inobject && (kind == PROP_DOUBLE), |
636 !layout_descriptor->IsTagged(field_index + bit)); | 642 !layout_descriptor->IsTagged(field_index + bit)); |
637 } | 643 } |
638 CHECK(layout_descriptor->IsTagged(next_field_offset)); | 644 CHECK(layout_descriptor->IsTagged(next_field_offset)); |
639 } | 645 } |
640 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 646 map->InitializeDescriptors(*descriptors, *layout_descriptor); |
641 } | 647 } |
642 Handle<LayoutDescriptor> layout_descriptor(map->layout_descriptor(), isolate); | 648 Handle<LayoutDescriptor> layout_descriptor(map->layout_descriptor(), isolate); |
643 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | 649 #ifdef VERIFY_HEAP |
| 650 if (FLAG_verify_heap) { |
| 651 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); |
| 652 } |
| 653 #endif |
644 return layout_descriptor; | 654 return layout_descriptor; |
645 } | 655 } |
646 | 656 |
647 | 657 |
648 TEST(LayoutDescriptorAppend) { | 658 TEST(LayoutDescriptorAppend) { |
649 CcTest::InitializeVM(); | 659 CcTest::InitializeVM(); |
650 Isolate* isolate = CcTest::i_isolate(); | 660 Isolate* isolate = CcTest::i_isolate(); |
651 v8::HandleScope scope(CcTest::isolate()); | 661 v8::HandleScope scope(CcTest::isolate()); |
652 | 662 |
653 Handle<LayoutDescriptor> layout_descriptor; | 663 Handle<LayoutDescriptor> layout_descriptor; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 int field_width_in_words = details.field_width_in_words(); | 770 int field_width_in_words = details.field_width_in_words(); |
761 | 771 |
762 bool is_inobject = field_index < map->inobject_properties(); | 772 bool is_inobject = field_index < map->inobject_properties(); |
763 for (int bit = 0; bit < field_width_in_words; bit++) { | 773 for (int bit = 0; bit < field_width_in_words; bit++) { |
764 CHECK_EQ(is_inobject && details.representation().IsDouble(), | 774 CHECK_EQ(is_inobject && details.representation().IsDouble(), |
765 !layout_desc->IsTagged(field_index + bit)); | 775 !layout_desc->IsTagged(field_index + bit)); |
766 } | 776 } |
767 CHECK(layout_desc->IsTagged(field_index + field_width_in_words)); | 777 CHECK(layout_desc->IsTagged(field_index + field_width_in_words)); |
768 } | 778 } |
769 } | 779 } |
770 DCHECK(map->layout_descriptor()->IsConsistentWithMap(*map)); | 780 #ifdef VERIFY_HEAP |
| 781 if (FLAG_verify_heap) { |
| 782 DCHECK(map->layout_descriptor()->IsConsistentWithMap(*map)); |
| 783 } |
| 784 #endif |
771 } | 785 } |
772 | 786 |
773 Handle<LayoutDescriptor> layout_descriptor(map->GetLayoutDescriptor(), | 787 Handle<LayoutDescriptor> layout_descriptor(map->GetLayoutDescriptor(), |
774 isolate); | 788 isolate); |
775 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | 789 #ifdef VERIFY_HEAP |
| 790 if (FLAG_verify_heap) { |
| 791 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); |
| 792 } |
| 793 #endif |
776 return layout_descriptor; | 794 return layout_descriptor; |
777 } | 795 } |
778 | 796 |
779 | 797 |
780 TEST(LayoutDescriptorAppendIfFastOrUseFull) { | 798 TEST(LayoutDescriptorAppendIfFastOrUseFull) { |
781 CcTest::InitializeVM(); | 799 CcTest::InitializeVM(); |
782 Isolate* isolate = CcTest::i_isolate(); | 800 Isolate* isolate = CcTest::i_isolate(); |
783 v8::HandleScope scope(CcTest::isolate()); | 801 v8::HandleScope scope(CcTest::isolate()); |
784 | 802 |
785 Handle<LayoutDescriptor> layout_descriptor; | 803 Handle<LayoutDescriptor> layout_descriptor; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 988 |
971 | 989 |
972 static void TestLayoutDescriptorHelper(Isolate* isolate, | 990 static void TestLayoutDescriptorHelper(Isolate* isolate, |
973 int inobject_properties, | 991 int inobject_properties, |
974 Handle<DescriptorArray> descriptors, | 992 Handle<DescriptorArray> descriptors, |
975 int number_of_descriptors) { | 993 int number_of_descriptors) { |
976 Handle<Map> map = Map::Create(isolate, inobject_properties); | 994 Handle<Map> map = Map::Create(isolate, inobject_properties); |
977 | 995 |
978 Handle<LayoutDescriptor> layout_descriptor = LayoutDescriptor::New( | 996 Handle<LayoutDescriptor> layout_descriptor = LayoutDescriptor::New( |
979 map, descriptors, descriptors->number_of_descriptors()); | 997 map, descriptors, descriptors->number_of_descriptors()); |
980 map->InitializeDescriptors(*descriptors, *layout_descriptor); | 998 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
981 DCHECK(layout_descriptor->IsConsistentWithMap(*map)); | |
982 | 999 |
983 LayoutDescriptorHelper helper(*map); | 1000 LayoutDescriptorHelper helper(*map); |
984 bool all_fields_tagged = true; | 1001 bool all_fields_tagged = true; |
985 | 1002 |
986 int instance_size = map->instance_size(); | 1003 int instance_size = map->instance_size(); |
987 | 1004 |
988 int end_offset = instance_size * 2; | 1005 int end_offset = instance_size * 2; |
989 int first_non_tagged_field_offset = end_offset; | 1006 int first_non_tagged_field_offset = end_offset; |
990 for (int i = 0; i < number_of_descriptors; i++) { | 1007 for (int i = 0; i < number_of_descriptors; i++) { |
991 PropertyDetails details = descriptors->GetDetails(i); | 1008 PropertyDetails details = descriptors->GetDetails(i); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 Handle<String> name = MakeName("prop", i); | 1144 Handle<String> name = MakeName("prop", i); |
1128 map = Map::CopyWithField(map, name, any_type, NONE, Representation::Smi(), | 1145 map = Map::CopyWithField(map, name, any_type, NONE, Representation::Smi(), |
1129 INSERT_TRANSITION).ToHandleChecked(); | 1146 INSERT_TRANSITION).ToHandleChecked(); |
1130 } | 1147 } |
1131 split_map = Map::CopyWithField(map, MakeString("dbl"), any_type, NONE, | 1148 split_map = Map::CopyWithField(map, MakeString("dbl"), any_type, NONE, |
1132 Representation::Double(), | 1149 Representation::Double(), |
1133 INSERT_TRANSITION).ToHandleChecked(); | 1150 INSERT_TRANSITION).ToHandleChecked(); |
1134 } | 1151 } |
1135 Handle<LayoutDescriptor> split_layout_descriptor( | 1152 Handle<LayoutDescriptor> split_layout_descriptor( |
1136 split_map->layout_descriptor(), isolate); | 1153 split_map->layout_descriptor(), isolate); |
1137 DCHECK(split_layout_descriptor->IsConsistentWithMap(*split_map)); | 1154 #ifdef VERIFY_HEAP |
| 1155 if (FLAG_verify_heap) { |
| 1156 DCHECK(split_layout_descriptor->IsConsistentWithMap(*split_map)); |
| 1157 } |
| 1158 #endif |
1138 CHECK(split_layout_descriptor->IsSlowLayout()); | 1159 CHECK(split_layout_descriptor->IsSlowLayout()); |
1139 CHECK(split_map->owns_descriptors()); | 1160 CHECK(split_map->owns_descriptors()); |
1140 | 1161 |
1141 Handle<Map> map1 = Map::CopyWithField(split_map, MakeString("foo"), any_type, | 1162 Handle<Map> map1 = Map::CopyWithField(split_map, MakeString("foo"), any_type, |
1142 NONE, Representation::Double(), | 1163 NONE, Representation::Double(), |
1143 INSERT_TRANSITION).ToHandleChecked(); | 1164 INSERT_TRANSITION).ToHandleChecked(); |
1144 CHECK(!split_map->owns_descriptors()); | 1165 CHECK(!split_map->owns_descriptors()); |
1145 CHECK_EQ(*split_layout_descriptor, split_map->layout_descriptor()); | 1166 CHECK_EQ(*split_layout_descriptor, split_map->layout_descriptor()); |
1146 | 1167 |
1147 // Layout descriptors should be shared with |split_map|. | 1168 // Layout descriptors should be shared with |split_map|. |
1148 CHECK(map1->owns_descriptors()); | 1169 CHECK(map1->owns_descriptors()); |
1149 CHECK_EQ(*split_layout_descriptor, map1->layout_descriptor()); | 1170 CHECK_EQ(*split_layout_descriptor, map1->layout_descriptor()); |
1150 DCHECK(map1->layout_descriptor()->IsConsistentWithMap(*map1)); | 1171 #ifdef VERIFY_HEAP |
| 1172 if (FLAG_verify_heap) { |
| 1173 DCHECK(map1->layout_descriptor()->IsConsistentWithMap(*map1)); |
| 1174 } |
| 1175 #endif |
1151 | 1176 |
1152 Handle<Map> map2 = Map::CopyWithField(split_map, MakeString("bar"), any_type, | 1177 Handle<Map> map2 = Map::CopyWithField(split_map, MakeString("bar"), any_type, |
1153 NONE, Representation::Tagged(), | 1178 NONE, Representation::Tagged(), |
1154 INSERT_TRANSITION).ToHandleChecked(); | 1179 INSERT_TRANSITION).ToHandleChecked(); |
1155 | 1180 |
1156 // Layout descriptors should not be shared with |split_map|. | 1181 // Layout descriptors should not be shared with |split_map|. |
1157 CHECK(map2->owns_descriptors()); | 1182 CHECK(map2->owns_descriptors()); |
1158 CHECK_NE(*split_layout_descriptor, map2->layout_descriptor()); | 1183 CHECK_NE(*split_layout_descriptor, map2->layout_descriptor()); |
1159 DCHECK(map2->layout_descriptor()->IsConsistentWithMap(*map2)); | 1184 #ifdef VERIFY_HEAP |
| 1185 if (FLAG_verify_heap) { |
| 1186 DCHECK(map2->layout_descriptor()->IsConsistentWithMap(*map2)); |
| 1187 } |
| 1188 #endif |
1160 } | 1189 } |
1161 | 1190 |
1162 | 1191 |
1163 TEST(StoreBufferScanOnScavenge) { | 1192 TEST(StoreBufferScanOnScavenge) { |
1164 CcTest::InitializeVM(); | 1193 CcTest::InitializeVM(); |
1165 Isolate* isolate = CcTest::i_isolate(); | 1194 Isolate* isolate = CcTest::i_isolate(); |
1166 Factory* factory = isolate->factory(); | 1195 Factory* factory = isolate->factory(); |
1167 v8::HandleScope scope(CcTest::isolate()); | 1196 v8::HandleScope scope(CcTest::isolate()); |
1168 | 1197 |
1169 CompileRun( | 1198 CompileRun( |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 Handle<JSObject> clone(JSObject::cast(clone_obj)); | 1331 Handle<JSObject> clone(JSObject::cast(clone_obj)); |
1303 CHECK(heap->old_pointer_space()->Contains(clone->address())); | 1332 CHECK(heap->old_pointer_space()->Contains(clone->address())); |
1304 | 1333 |
1305 CcTest::heap()->CollectGarbage(NEW_SPACE, "boom"); | 1334 CcTest::heap()->CollectGarbage(NEW_SPACE, "boom"); |
1306 | 1335 |
1307 // The value in cloned object should not be corrupted by GC. | 1336 // The value in cloned object should not be corrupted by GC. |
1308 CHECK_EQ(boom_value, clone->RawFastDoublePropertyAt(index)); | 1337 CHECK_EQ(boom_value, clone->RawFastDoublePropertyAt(index)); |
1309 } | 1338 } |
1310 | 1339 |
1311 #endif | 1340 #endif |
OLD | NEW |