OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 | 1619 |
1620 Node* result = m.AllocateJSObjectFromMap(map, properties, elements); | 1620 Node* result = m.AllocateJSObjectFromMap(map, properties, elements); |
1621 | 1621 |
1622 m.Return(result); | 1622 m.Return(result); |
1623 } | 1623 } |
1624 | 1624 |
1625 Handle<Code> code = m.GenerateCode(); | 1625 Handle<Code> code = m.GenerateCode(); |
1626 FunctionTester ft(code, kNumParams); | 1626 FunctionTester ft(code, kNumParams); |
1627 | 1627 |
1628 Handle<Map> maps[] = { | 1628 Handle<Map> maps[] = { |
1629 isolate->object_with_null_prototype_map(), | 1629 isolate->slow_object_with_null_prototype_map(), |
1630 handle(isolate->object_function()->initial_map(), isolate), | 1630 handle(isolate->object_function()->initial_map(), isolate), |
1631 handle(isolate->array_function()->initial_map(), isolate), | 1631 handle(isolate->array_function()->initial_map(), isolate), |
1632 }; | 1632 }; |
1633 | 1633 |
1634 #define VERIFY(result, map_value, properties_value, elements_value) \ | 1634 #define VERIFY(result, map_value, properties_value, elements_value) \ |
1635 CHECK_EQ(result->map(), map_value); \ | 1635 CHECK_EQ(result->map(), map_value); \ |
1636 CHECK_EQ(result->properties(), properties_value); \ | 1636 CHECK_EQ(result->properties(), properties_value); \ |
1637 CHECK_EQ(result->elements(), elements_value); | 1637 CHECK_EQ(result->elements(), elements_value); |
1638 | 1638 |
1639 { | 1639 { |
(...skipping 14 matching lines...) Expand all Loading... |
1654 Handle<JSObject> object = Handle<JSObject>::cast( | 1654 Handle<JSObject> object = Handle<JSObject>::cast( |
1655 v8::Utils::OpenHandle(*CompileRun("var object = {a:1,b:2, 1:1, 2:2}; " | 1655 v8::Utils::OpenHandle(*CompileRun("var object = {a:1,b:2, 1:1, 2:2}; " |
1656 "object"))); | 1656 "object"))); |
1657 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, | 1657 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, |
1658 "Normalize"); | 1658 "Normalize"); |
1659 Handle<JSObject> result = Handle<JSObject>::cast( | 1659 Handle<JSObject> result = Handle<JSObject>::cast( |
1660 ft.Call(handle(object->map()), handle(object->properties()), | 1660 ft.Call(handle(object->map()), handle(object->properties()), |
1661 handle(object->elements())) | 1661 handle(object->elements())) |
1662 .ToHandleChecked()); | 1662 .ToHandleChecked()); |
1663 VERIFY(result, object->map(), object->properties(), object->elements()); | 1663 VERIFY(result, object->map(), object->properties(), object->elements()); |
| 1664 CHECK(!result->HasFastProperties()); |
1664 #ifdef VERIFY_HEAP | 1665 #ifdef VERIFY_HEAP |
1665 isolate->heap()->Verify(); | 1666 isolate->heap()->Verify(); |
1666 #endif | 1667 #endif |
1667 } | 1668 } |
1668 } | 1669 } |
| 1670 TEST(AllocateNameDictionary) { |
| 1671 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 1672 Factory* factory = isolate->factory(); |
| 1673 |
| 1674 const int kNumParams = 1; |
| 1675 CodeStubAssemblerTester m(isolate, kNumParams); |
| 1676 |
| 1677 { |
| 1678 Node* capacity = m.Parameter(0); |
| 1679 Node* result = m.AllocateNameDictionary(m.SmiUntag(capacity)); |
| 1680 m.Return(result); |
| 1681 } |
| 1682 |
| 1683 Handle<Code> code = m.GenerateCode(); |
| 1684 FunctionTester ft(code, kNumParams); |
| 1685 |
| 1686 { |
| 1687 Handle<Object> empty_fixed_array = factory->empty_fixed_array(); |
| 1688 for (int i = 2; i < 100; i *= 2) { |
| 1689 Handle<JSObject> result = Handle<JSObject>::cast( |
| 1690 ft.Call(handle(Smi::FromInt(i), isolate)).ToHandleChecked()); |
| 1691 Handle<NameDictionary> dict = NameDictionary::New( |
| 1692 isolate, i, NOT_TENURED, USE_CUSTOM_MINIMUM_CAPACITY); |
| 1693 // Both dictionaries should be memory equal. |
| 1694 int size = |
| 1695 FixedArrayBase::kHeaderSize + (dict->length() - 1) * kPointerSize; |
| 1696 CHECK_EQ(0, memcmp(*dict, *result, size)); |
| 1697 } |
| 1698 } |
| 1699 } |
1669 | 1700 |
1670 } // namespace internal | 1701 } // namespace internal |
1671 } // namespace v8 | 1702 } // namespace v8 |
OLD | NEW |